From dc9179bb1b73d372e5952dacbd77aacb37358f76 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 14 Nov 2024 00:05:38 +0100 Subject: [PATCH] LibWeb: Keep track of the order in which option elements are selected This allows us to locate the most-recently-selected when running the selectedness update algorithm. --- .../LibWeb/Bindings/OptionConstructor.cpp | 2 +- Libraries/LibWeb/HTML/HTMLOptGroupElement.cpp | 21 +++++++++ Libraries/LibWeb/HTML/HTMLOptGroupElement.h | 2 + Libraries/LibWeb/HTML/HTMLOptionElement.cpp | 44 +++++++++++++++++-- Libraries/LibWeb/HTML/HTMLOptionElement.h | 6 +++ Libraries/LibWeb/HTML/HTMLSelectElement.cpp | 32 ++++++++++---- Libraries/LibWeb/HTML/HTMLSelectElement.h | 4 +- .../optgroup-removal.window.txt | 4 +- .../inserted-or-removed.txt | 11 +++-- .../select-ask-for-reset.txt | 8 ++-- 10 files changed, 107 insertions(+), 27 deletions(-) diff --git a/Libraries/LibWeb/Bindings/OptionConstructor.cpp b/Libraries/LibWeb/Bindings/OptionConstructor.cpp index 3d5482f884f..601f1f4475f 100644 --- a/Libraries/LibWeb/Bindings/OptionConstructor.cpp +++ b/Libraries/LibWeb/Bindings/OptionConstructor.cpp @@ -77,7 +77,7 @@ JS::ThrowCompletionOr> OptionConstructor::construct } // 6. If selected is true, then set option's selectedness to true; otherwise set its selectedness to false (even if defaultSelected is true). - option_element->m_selected = vm.argument(3).to_boolean(); + option_element->set_selected_internal(vm.argument(3).to_boolean()); // 7. Return option. return option_element; diff --git a/Libraries/LibWeb/HTML/HTMLOptGroupElement.cpp b/Libraries/LibWeb/HTML/HTMLOptGroupElement.cpp index 64b568c51fd..18677ba557b 100644 --- a/Libraries/LibWeb/HTML/HTMLOptGroupElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLOptGroupElement.cpp @@ -7,6 +7,7 @@ #include #include #include +#include namespace Web::HTML { @@ -25,4 +26,24 @@ void HTMLOptGroupElement::initialize(JS::Realm& realm) WEB_SET_PROTOTYPE_FOR_INTERFACE(HTMLOptGroupElement); } +void HTMLOptGroupElement::inserted() +{ + Base::inserted(); + + // AD-HOC: We update the selectedness of our needs to be updated when is removed \ No newline at end of file +Result Test Name MessagePass