LibWeb: Invalidate style when HTMLDialogElement modal state changes

This fixes Layout/input/dialog-open-modal.html which began flaking
super hard after the preceding commits that reduced style invalidation
for focus-related pseudo class selectors.
This commit is contained in:
Andreas Kling 2025-04-17 15:40:48 +02:00 committed by Andreas Kling
parent 8d51c41a42
commit 832b0a0ace
Notes: github-actions[bot] 2025-04-17 17:46:52 +00:00
2 changed files with 11 additions and 2 deletions

View file

@ -223,7 +223,7 @@ WebIDL::ExceptionOr<void> HTMLDialogElement::show_a_modal_dialog(HTMLDialogEleme
TRY(subject.set_attribute(AttributeNames::open, {}));
// 12. Set is modal of subject to true.
subject.m_is_modal = true;
subject.set_is_modal(true);
// FIXME: 13. Assert: subject's node document's open dialogs list does not contain subject.
// FIXME: 14. Add subject to subject's node document's open dialogs list.
@ -338,7 +338,7 @@ void HTMLDialogElement::close_the_dialog(Optional<String> result)
// FIXME: 7. Let wasModal be the value of subject's is modal flag.
// 8. Set the is modal flag of subject to false.
m_is_modal = false;
set_is_modal(false);
// FIXME: 9. Remove subject from subject's node document's open dialogs list.
@ -435,4 +435,12 @@ void HTMLDialogElement::run_dialog_focusing_steps()
// FIXME: 10. Set topDocument's autofocus processed flag to true.
}
void HTMLDialogElement::set_is_modal(bool is_modal)
{
if (m_is_modal == is_modal)
return;
m_is_modal = is_modal;
invalidate_style(DOM::StyleInvalidationReason::NodeRemove);
}
}

View file

@ -37,6 +37,7 @@ public:
virtual Optional<ARIA::Role> default_role() const override { return ARIA::Role::dialog; }
bool is_modal() const { return m_is_modal; }
void set_is_modal(bool);
private:
HTMLDialogElement(DOM::Document&, DOM::QualifiedName);