From d4f8b598cb69717d40b5667d1270e8ab0f4351de Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Thu, 14 Nov 2024 08:14:16 -0500 Subject: [PATCH] LibWeb: Consolidate the attribute change handlers We currently have 2 virtual methods to inform DOM::Element subclasses when an attribute has changed, one of which is spec-compliant. This patch removes the non-compliant variant. --- Libraries/LibWeb/DOM/Element.cpp | 122 +++++++++--------- Libraries/LibWeb/DOM/Element.h | 7 +- Libraries/LibWeb/HTML/FormAssociatedElement.h | 54 ++++---- Libraries/LibWeb/HTML/HTMLAnchorElement.cpp | 5 +- Libraries/LibWeb/HTML/HTMLAnchorElement.h | 2 +- Libraries/LibWeb/HTML/HTMLAreaElement.cpp | 5 +- Libraries/LibWeb/HTML/HTMLAreaElement.h | 2 +- Libraries/LibWeb/HTML/HTMLBaseElement.cpp | 4 +- Libraries/LibWeb/HTML/HTMLBaseElement.h | 2 +- Libraries/LibWeb/HTML/HTMLBodyElement.cpp | 5 +- Libraries/LibWeb/HTML/HTMLBodyElement.h | 2 +- Libraries/LibWeb/HTML/HTMLDetailsElement.cpp | 4 +- Libraries/LibWeb/HTML/HTMLDetailsElement.h | 2 +- Libraries/LibWeb/HTML/HTMLElement.cpp | 11 +- Libraries/LibWeb/HTML/HTMLElement.h | 3 +- Libraries/LibWeb/HTML/HTMLFormElement.cpp | 5 +- Libraries/LibWeb/HTML/HTMLFormElement.h | 2 +- Libraries/LibWeb/HTML/HTMLFrameElement.cpp | 4 +- Libraries/LibWeb/HTML/HTMLFrameElement.h | 2 +- Libraries/LibWeb/HTML/HTMLFrameSetElement.cpp | 4 +- Libraries/LibWeb/HTML/HTMLFrameSetElement.h | 2 +- Libraries/LibWeb/HTML/HTMLIFrameElement.cpp | 4 +- Libraries/LibWeb/HTML/HTMLIFrameElement.h | 2 +- Libraries/LibWeb/HTML/HTMLLinkElement.cpp | 4 +- Libraries/LibWeb/HTML/HTMLLinkElement.h | 2 +- Libraries/LibWeb/HTML/HTMLMediaElement.cpp | 4 +- Libraries/LibWeb/HTML/HTMLMediaElement.h | 2 +- Libraries/LibWeb/HTML/HTMLOptionElement.cpp | 4 +- Libraries/LibWeb/HTML/HTMLOptionElement.h | 2 +- Libraries/LibWeb/HTML/HTMLOrSVGElement.cpp | 2 +- Libraries/LibWeb/HTML/HTMLOrSVGElement.h | 2 +- Libraries/LibWeb/HTML/HTMLScriptElement.cpp | 4 +- Libraries/LibWeb/HTML/HTMLScriptElement.h | 2 +- Libraries/LibWeb/HTML/HTMLSlotElement.cpp | 4 +- Libraries/LibWeb/HTML/HTMLSlotElement.h | 2 +- Libraries/LibWeb/HTML/HTMLTableElement.cpp | 5 +- Libraries/LibWeb/HTML/HTMLTableElement.h | 2 +- Libraries/LibWeb/HTML/HTMLTrackElement.cpp | 4 +- Libraries/LibWeb/HTML/HTMLTrackElement.h | 2 +- Libraries/LibWeb/HTML/HTMLVideoElement.cpp | 4 +- Libraries/LibWeb/HTML/HTMLVideoElement.h | 2 +- Libraries/LibWeb/MathML/MathMLElement.cpp | 6 +- Libraries/LibWeb/MathML/MathMLElement.h | 2 +- Libraries/LibWeb/SVG/SVGAElement.cpp | 5 +- Libraries/LibWeb/SVG/SVGAElement.h | 2 +- Libraries/LibWeb/SVG/SVGClipPathElement.cpp | 5 +- Libraries/LibWeb/SVG/SVGClipPathElement.h | 2 +- Libraries/LibWeb/SVG/SVGElement.cpp | 11 +- Libraries/LibWeb/SVG/SVGElement.h | 3 +- Libraries/LibWeb/SVG/SVGEllipseElement.cpp | 4 +- Libraries/LibWeb/SVG/SVGEllipseElement.h | 2 +- Libraries/LibWeb/SVG/SVGGradientElement.cpp | 5 +- Libraries/LibWeb/SVG/SVGGradientElement.h | 2 +- Libraries/LibWeb/SVG/SVGGraphicsElement.cpp | 5 +- Libraries/LibWeb/SVG/SVGGraphicsElement.h | 2 +- Libraries/LibWeb/SVG/SVGImageElement.cpp | 5 +- Libraries/LibWeb/SVG/SVGImageElement.h | 2 +- Libraries/LibWeb/SVG/SVGLineElement.cpp | 4 +- Libraries/LibWeb/SVG/SVGLineElement.h | 2 +- .../LibWeb/SVG/SVGLinearGradientElement.cpp | 4 +- .../LibWeb/SVG/SVGLinearGradientElement.h | 2 +- Libraries/LibWeb/SVG/SVGMaskElement.cpp | 5 +- Libraries/LibWeb/SVG/SVGMaskElement.h | 2 +- Libraries/LibWeb/SVG/SVGPathElement.cpp | 4 +- Libraries/LibWeb/SVG/SVGPathElement.h | 2 +- Libraries/LibWeb/SVG/SVGPolygonElement.cpp | 4 +- Libraries/LibWeb/SVG/SVGPolygonElement.h | 2 +- Libraries/LibWeb/SVG/SVGPolylineElement.cpp | 4 +- Libraries/LibWeb/SVG/SVGPolylineElement.h | 2 +- .../LibWeb/SVG/SVGRadialGradientElement.cpp | 4 +- .../LibWeb/SVG/SVGRadialGradientElement.h | 2 +- Libraries/LibWeb/SVG/SVGRectElement.cpp | 4 +- Libraries/LibWeb/SVG/SVGRectElement.h | 2 +- Libraries/LibWeb/SVG/SVGSVGElement.cpp | 4 +- Libraries/LibWeb/SVG/SVGSVGElement.h | 2 +- Libraries/LibWeb/SVG/SVGStopElement.cpp | 5 +- Libraries/LibWeb/SVG/SVGStopElement.h | 2 +- Libraries/LibWeb/SVG/SVGSymbolElement.cpp | 5 +- Libraries/LibWeb/SVG/SVGSymbolElement.h | 2 +- .../LibWeb/SVG/SVGTextPositioningElement.cpp | 4 +- .../LibWeb/SVG/SVGTextPositioningElement.h | 2 +- Libraries/LibWeb/SVG/SVGUseElement.cpp | 4 +- Libraries/LibWeb/SVG/SVGUseElement.h | 2 +- 83 files changed, 224 insertions(+), 228 deletions(-) diff --git a/Libraries/LibWeb/DOM/Element.cpp b/Libraries/LibWeb/DOM/Element.cpp index eaa290563e1..d0a0ba7af1c 100644 --- a/Libraries/LibWeb/DOM/Element.cpp +++ b/Libraries/LibWeb/DOM/Element.cpp @@ -444,10 +444,7 @@ JS::GCPtr Element::create_layout_node_for_display_type(DO void Element::run_attribute_change_steps(FlyString const& local_name, Optional const& old_value, Optional const& value, Optional const& namespace_) { - attribute_change_steps(local_name, old_value, value, namespace_); - - // AD-HOC: Run our own internal attribute change handler. - attribute_changed(local_name, old_value, value); + attribute_changed(local_name, old_value, value, namespace_); if (old_value != value) { invalidate_style_after_attribute_change(local_name); @@ -455,63 +452,6 @@ void Element::run_attribute_change_steps(FlyString const& local_name, Optional const&, Optional const& value) -{ - auto value_or_empty = value.value_or(String {}); - - if (name == HTML::AttributeNames::id) { - if (value_or_empty.is_empty()) - m_id = {}; - else - m_id = value_or_empty; - - document().element_id_changed({}, *this); - } else if (name == HTML::AttributeNames::name) { - if (value_or_empty.is_empty()) - m_name = {}; - else - m_name = value_or_empty; - - document().element_name_changed({}, *this); - } else if (name == HTML::AttributeNames::class_) { - if (value_or_empty.is_empty()) { - m_classes.clear(); - } else { - auto new_classes = value_or_empty.bytes_as_string_view().split_view_if(Infra::is_ascii_whitespace); - m_classes.clear(); - m_classes.ensure_capacity(new_classes.size()); - for (auto& new_class : new_classes) { - m_classes.unchecked_append(FlyString::from_utf8(new_class).release_value_but_fixme_should_propagate_errors()); - } - } - if (m_class_list) - m_class_list->associated_attribute_changed(value_or_empty); - } else if (name == HTML::AttributeNames::style) { - if (!value.has_value()) { - if (m_inline_style) { - m_inline_style = nullptr; - set_needs_style_update(true); - } - } else { - // https://drafts.csswg.org/cssom/#ref-for-cssstyledeclaration-updating-flag - if (m_inline_style && m_inline_style->is_updating()) - return; - m_inline_style = parse_css_style_attribute(CSS::Parser::ParsingContext(document()), *value, *this); - set_needs_style_update(true); - } - } else if (name == HTML::AttributeNames::dir) { - // https://html.spec.whatwg.org/multipage/dom.html#attr-dir - if (value_or_empty.equals_ignoring_ascii_case("ltr"sv)) - m_dir = Dir::Ltr; - else if (value_or_empty.equals_ignoring_ascii_case("rtl"sv)) - m_dir = Dir::Rtl; - else if (value_or_empty.equals_ignoring_ascii_case("auto"sv)) - m_dir = Dir::Auto; - else - m_dir = {}; - } -} - static CSS::RequiredInvalidationAfterStyleChange compute_required_invalidation(CSS::StyleProperties const& old_style, CSS::StyleProperties const& new_style) { CSS::RequiredInvalidationAfterStyleChange invalidation; @@ -2727,9 +2667,10 @@ Element::Directionality Element::parent_directionality() const return Directionality::Ltr; } -// https://dom.spec.whatwg.org/#ref-for-concept-element-attributes-change-extâ‘  -void Element::attribute_change_steps(FlyString const& local_name, Optional const& old_value, Optional const& value, Optional const& namespace_) +// https://dom.spec.whatwg.org/#concept-element-attributes-change-ext +void Element::attribute_changed(FlyString const& local_name, Optional const& old_value, Optional const& value, Optional const& namespace_) { + // https://dom.spec.whatwg.org/#ref-for-concept-element-attributes-change-extâ‘  // 1. If localName is slot and namespace is null, then: if (local_name == HTML::AttributeNames::slot && !namespace_.has_value()) { // 1. If value is oldValue, then return. @@ -2757,6 +2698,61 @@ void Element::attribute_change_steps(FlyString const& local_name, Optionalassociated_attribute_changed(value_or_empty); + } else if (local_name == HTML::AttributeNames::style) { + if (!value.has_value()) { + if (m_inline_style) { + m_inline_style = nullptr; + set_needs_style_update(true); + } + } else { + // https://drafts.csswg.org/cssom/#ref-for-cssstyledeclaration-updating-flag + if (m_inline_style && m_inline_style->is_updating()) + return; + m_inline_style = parse_css_style_attribute(CSS::Parser::ParsingContext(document()), *value, *this); + set_needs_style_update(true); + } + } else if (local_name == HTML::AttributeNames::dir) { + // https://html.spec.whatwg.org/multipage/dom.html#attr-dir + if (value_or_empty.equals_ignoring_ascii_case("ltr"sv)) + m_dir = Dir::Ltr; + else if (value_or_empty.equals_ignoring_ascii_case("rtl"sv)) + m_dir = Dir::Rtl; + else if (value_or_empty.equals_ignoring_ascii_case("auto"sv)) + m_dir = Dir::Auto; + else + m_dir = {}; } } diff --git a/Libraries/LibWeb/DOM/Element.h b/Libraries/LibWeb/DOM/Element.h index fb9f5332e0e..33e7e0dcd6a 100644 --- a/Libraries/LibWeb/DOM/Element.h +++ b/Libraries/LibWeb/DOM/Element.h @@ -173,11 +173,7 @@ public: virtual void apply_presentational_hints(CSS::StyleProperties&) const { } - // https://dom.spec.whatwg.org/#concept-element-attributes-change-ext - virtual void attribute_change_steps(FlyString const& local_name, Optional const& old_value, Optional const& value, Optional const& namespace_); - void run_attribute_change_steps(FlyString const& local_name, Optional const& old_value, Optional const& value, Optional const& namespace_); - virtual void attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value); CSS::RequiredInvalidationAfterStyleChange recompute_style(); @@ -430,6 +426,9 @@ protected: virtual void children_changed() override; virtual i32 default_tab_index_value() const; + // https://dom.spec.whatwg.org/#concept-element-attributes-change-ext + virtual void attribute_changed(FlyString const& local_name, Optional const& old_value, Optional const& value, Optional const& namespace_); + virtual void computed_css_values_changed() { } virtual void visit_edges(Cell::Visitor&) override; diff --git a/Libraries/LibWeb/HTML/FormAssociatedElement.h b/Libraries/LibWeb/HTML/FormAssociatedElement.h index 3eae2d17396..bdba181e071 100644 --- a/Libraries/LibWeb/HTML/FormAssociatedElement.h +++ b/Libraries/LibWeb/HTML/FormAssociatedElement.h @@ -23,33 +23,33 @@ namespace Web::HTML { // HTMLElement::inserted() -> Use form_associated_element_was_inserted() // HTMLElement::removed_from() -> Use form_associated_element_was_removed() // -#define FORM_ASSOCIATED_ELEMENT(ElementBaseClass, ElementClass) \ -private: \ - virtual HTMLElement& form_associated_element_to_html_element() override \ - { \ - static_assert(IsBaseOf); \ - return *this; \ - } \ - \ - virtual void inserted() override \ - { \ - ElementBaseClass::inserted(); \ - form_node_was_inserted(); \ - form_associated_element_was_inserted(); \ - } \ - \ - virtual void removed_from(DOM::Node* node) override \ - { \ - ElementBaseClass::removed_from(node); \ - form_node_was_removed(); \ - form_associated_element_was_removed(node); \ - } \ - \ - virtual void attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value) override \ - { \ - ElementBaseClass::attribute_changed(name, old_value, value); \ - form_node_attribute_changed(name, value); \ - form_associated_element_attribute_changed(name, value); \ +#define FORM_ASSOCIATED_ELEMENT(ElementBaseClass, ElementClass) \ +private: \ + virtual HTMLElement& form_associated_element_to_html_element() override \ + { \ + static_assert(IsBaseOf); \ + return *this; \ + } \ + \ + virtual void inserted() override \ + { \ + ElementBaseClass::inserted(); \ + form_node_was_inserted(); \ + form_associated_element_was_inserted(); \ + } \ + \ + virtual void removed_from(DOM::Node* node) override \ + { \ + ElementBaseClass::removed_from(node); \ + form_node_was_removed(); \ + form_associated_element_was_removed(node); \ + } \ + \ + virtual void attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value, Optional const& namespace_) override \ + { \ + ElementBaseClass::attribute_changed(name, old_value, value, namespace_); \ + form_node_attribute_changed(name, value); \ + form_associated_element_attribute_changed(name, value); \ } // https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#selection-direction diff --git a/Libraries/LibWeb/HTML/HTMLAnchorElement.cpp b/Libraries/LibWeb/HTML/HTMLAnchorElement.cpp index 67218848d61..fff4f7e0313 100644 --- a/Libraries/LibWeb/HTML/HTMLAnchorElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLAnchorElement.cpp @@ -40,9 +40,10 @@ void HTMLAnchorElement::visit_edges(Cell::Visitor& visitor) visitor.visit(m_rel_list); } -void HTMLAnchorElement::attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value) +void HTMLAnchorElement::attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value, Optional const& namespace_) { - HTMLElement::attribute_changed(name, old_value, value); + Base::attribute_changed(name, old_value, value, namespace_); + if (name == HTML::AttributeNames::href) { set_the_url(); } else if (name == HTML::AttributeNames::rel) { diff --git a/Libraries/LibWeb/HTML/HTMLAnchorElement.h b/Libraries/LibWeb/HTML/HTMLAnchorElement.h index 4dfe9c9943f..4735a8c86ff 100644 --- a/Libraries/LibWeb/HTML/HTMLAnchorElement.h +++ b/Libraries/LibWeb/HTML/HTMLAnchorElement.h @@ -46,7 +46,7 @@ private: virtual bool has_download_preference() const; // ^DOM::Element - virtual void attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value) override; + virtual void attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value, Optional const& namespace_) override; virtual i32 default_tab_index_value() const override; // ^HTML::HTMLHyperlinkElementUtils diff --git a/Libraries/LibWeb/HTML/HTMLAreaElement.cpp b/Libraries/LibWeb/HTML/HTMLAreaElement.cpp index 028dba9ffa5..4da0ae4343c 100644 --- a/Libraries/LibWeb/HTML/HTMLAreaElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLAreaElement.cpp @@ -33,9 +33,10 @@ void HTMLAreaElement::visit_edges(Cell::Visitor& visitor) visitor.visit(m_rel_list); } -void HTMLAreaElement::attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value) +void HTMLAreaElement::attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value, Optional const& namespace_) { - HTMLElement::attribute_changed(name, old_value, value); + Base::attribute_changed(name, old_value, value, namespace_); + if (name == HTML::AttributeNames::href) { set_the_url(); } else if (name == HTML::AttributeNames::rel) { diff --git a/Libraries/LibWeb/HTML/HTMLAreaElement.h b/Libraries/LibWeb/HTML/HTMLAreaElement.h index 3ae0dc3d77b..c06423f3dc3 100644 --- a/Libraries/LibWeb/HTML/HTMLAreaElement.h +++ b/Libraries/LibWeb/HTML/HTMLAreaElement.h @@ -29,7 +29,7 @@ private: virtual void visit_edges(Cell::Visitor&) override; // ^DOM::Element - virtual void attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value) override; + virtual void attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value, Optional const& namespace_) override; virtual i32 default_tab_index_value() const override; // ^HTML::HTMLHyperlinkElementUtils diff --git a/Libraries/LibWeb/HTML/HTMLBaseElement.cpp b/Libraries/LibWeb/HTML/HTMLBaseElement.cpp index 0484d270f68..9ad150120c4 100644 --- a/Libraries/LibWeb/HTML/HTMLBaseElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLBaseElement.cpp @@ -46,9 +46,9 @@ void HTMLBaseElement::removed_from(Node* parent) document().update_base_element({}); } -void HTMLBaseElement::attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value) +void HTMLBaseElement::attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value, Optional const& namespace_) { - HTMLElement::attribute_changed(name, old_value, value); + Base::attribute_changed(name, old_value, value, namespace_); // The frozen base URL must be immediately set for an element whenever any of the following situations occur: // - The base element is the first base element in tree order with an href content attribute in its Document, and its href content attribute is changed. diff --git a/Libraries/LibWeb/HTML/HTMLBaseElement.h b/Libraries/LibWeb/HTML/HTMLBaseElement.h index 3dec1001418..d30bb926a7f 100644 --- a/Libraries/LibWeb/HTML/HTMLBaseElement.h +++ b/Libraries/LibWeb/HTML/HTMLBaseElement.h @@ -24,7 +24,7 @@ public: virtual void inserted() override; virtual void removed_from(Node*) override; - virtual void attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value) override; + virtual void attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value, Optional const& namespace_) override; private: HTMLBaseElement(DOM::Document&, DOM::QualifiedName); diff --git a/Libraries/LibWeb/HTML/HTMLBodyElement.cpp b/Libraries/LibWeb/HTML/HTMLBodyElement.cpp index 2f7b6b73fa0..d3aa37d705b 100644 --- a/Libraries/LibWeb/HTML/HTMLBodyElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLBodyElement.cpp @@ -59,9 +59,10 @@ void HTMLBodyElement::apply_presentational_hints(CSS::StyleProperties& style) co }); } -void HTMLBodyElement::attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value) +void HTMLBodyElement::attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value, Optional const& namespace_) { - HTMLElement::attribute_changed(name, old_value, value); + Base::attribute_changed(name, old_value, value, namespace_); + if (name.equals_ignoring_ascii_case("link"sv)) { // https://html.spec.whatwg.org/multipage/rendering.html#the-page:rules-for-parsing-a-legacy-colour-value-3 auto color = parse_legacy_color_value(value.value_or(String {})); diff --git a/Libraries/LibWeb/HTML/HTMLBodyElement.h b/Libraries/LibWeb/HTML/HTMLBodyElement.h index 22095bf3e4d..6938d898913 100644 --- a/Libraries/LibWeb/HTML/HTMLBodyElement.h +++ b/Libraries/LibWeb/HTML/HTMLBodyElement.h @@ -21,7 +21,7 @@ class HTMLBodyElement final public: virtual ~HTMLBodyElement() override; - virtual void attribute_changed(FlyString const&, Optional const& old_value, Optional const&) override; + virtual void attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value, Optional const& namespace_) override; virtual void apply_presentational_hints(CSS::StyleProperties&) const override; // https://www.w3.org/TR/html-aria/#el-body diff --git a/Libraries/LibWeb/HTML/HTMLDetailsElement.cpp b/Libraries/LibWeb/HTML/HTMLDetailsElement.cpp index d150a262d4b..d21a15bfeb8 100644 --- a/Libraries/LibWeb/HTML/HTMLDetailsElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLDetailsElement.cpp @@ -53,9 +53,9 @@ void HTMLDetailsElement::removed_from(DOM::Node*) set_shadow_root(nullptr); } -void HTMLDetailsElement::attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value) +void HTMLDetailsElement::attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value, Optional const& namespace_) { - Base::attribute_changed(name, old_value, value); + Base::attribute_changed(name, old_value, value, namespace_); // https://html.spec.whatwg.org/multipage/interactive-elements.html#details-notification-task-steps if (name == HTML::AttributeNames::open) { diff --git a/Libraries/LibWeb/HTML/HTMLDetailsElement.h b/Libraries/LibWeb/HTML/HTMLDetailsElement.h index b98feb8cef1..4803f5b3244 100644 --- a/Libraries/LibWeb/HTML/HTMLDetailsElement.h +++ b/Libraries/LibWeb/HTML/HTMLDetailsElement.h @@ -34,7 +34,7 @@ private: virtual void inserted() override; virtual void removed_from(DOM::Node*) override; virtual void children_changed() override; - virtual void attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value) override; + virtual void attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value, Optional const& namespace_) override; void queue_a_details_toggle_event_task(String old_state, String new_state); diff --git a/Libraries/LibWeb/HTML/HTMLElement.cpp b/Libraries/LibWeb/HTML/HTMLElement.cpp index c07f8c9f38a..affdc0668b5 100644 --- a/Libraries/LibWeb/HTML/HTMLElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLElement.cpp @@ -595,9 +595,10 @@ bool HTMLElement::cannot_navigate() const return !is(this) && !is_connected(); } -void HTMLElement::attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value) +void HTMLElement::attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value, Optional const& namespace_) { - Element::attribute_changed(name, old_value, value); + Base::attribute_changed(name, old_value, value, namespace_); + HTMLOrSVGElement::attribute_changed(name, old_value, value, namespace_); if (name == HTML::AttributeNames::contenteditable) { if (!value.has_value()) { @@ -627,12 +628,6 @@ void HTMLElement::attribute_changed(FlyString const& name, Optional cons #undef __ENUMERATE } -void HTMLElement::attribute_change_steps(FlyString const& local_name, Optional const& old_value, Optional const& value, Optional const& namespace_) -{ - Base::attribute_change_steps(local_name, old_value, value, namespace_); - HTMLOrSVGElement::attribute_change_steps(local_name, old_value, value, namespace_); -} - WebIDL::ExceptionOr HTMLElement::cloned(Web::DOM::Node& copy, bool clone_children) { TRY(Base::cloned(copy, clone_children)); diff --git a/Libraries/LibWeb/HTML/HTMLElement.h b/Libraries/LibWeb/HTML/HTMLElement.h index 1f46a9f9c5c..763ba078ffa 100644 --- a/Libraries/LibWeb/HTML/HTMLElement.h +++ b/Libraries/LibWeb/HTML/HTMLElement.h @@ -81,8 +81,7 @@ protected: virtual void initialize(JS::Realm&) override; - virtual void attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value) override; - virtual void attribute_change_steps(FlyString const&, Optional const&, Optional const&, Optional const&) override; + virtual void attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value, Optional const& namespace_) override; virtual WebIDL::ExceptionOr cloned(DOM::Node&, bool) override; virtual void inserted() override; diff --git a/Libraries/LibWeb/HTML/HTMLFormElement.cpp b/Libraries/LibWeb/HTML/HTMLFormElement.cpp index 71c7d7e4747..cea33b2d894 100644 --- a/Libraries/LibWeb/HTML/HTMLFormElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLFormElement.cpp @@ -602,9 +602,10 @@ WebIDL::ExceptionOr HTMLFormElement::set_action(String const& value) return set_attribute(AttributeNames::action, value); } -void HTMLFormElement::attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value) +void HTMLFormElement::attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value, Optional const& namespace_) { - HTMLElement::attribute_changed(name, old_value, value); + Base::attribute_changed(name, old_value, value, namespace_); + if (name == HTML::AttributeNames::rel) { if (m_rel_list) m_rel_list->associated_attribute_changed(value.value_or(String {})); diff --git a/Libraries/LibWeb/HTML/HTMLFormElement.h b/Libraries/LibWeb/HTML/HTMLFormElement.h index 098f852884e..554ca5f179b 100644 --- a/Libraries/LibWeb/HTML/HTMLFormElement.h +++ b/Libraries/LibWeb/HTML/HTMLFormElement.h @@ -108,7 +108,7 @@ private: virtual JS::Value named_item_value(FlyString const& name) const override; virtual Vector supported_property_names() const override; - virtual void attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value) override; + virtual void attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value, Optional const& namespace_) override; ErrorOr pick_an_encoding() const; diff --git a/Libraries/LibWeb/HTML/HTMLFrameElement.cpp b/Libraries/LibWeb/HTML/HTMLFrameElement.cpp index e5694a6b1f4..0b76e1ea43a 100644 --- a/Libraries/LibWeb/HTML/HTMLFrameElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLFrameElement.cpp @@ -65,9 +65,9 @@ void HTMLFrameElement::removed_from(DOM::Node* node) } // https://html.spec.whatwg.org/multipage/obsolete.html#frames:frame-3 -void HTMLFrameElement::attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value) +void HTMLFrameElement::attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value, Optional const& namespace_) { - Base::attribute_changed(name, old_value, value); + Base::attribute_changed(name, old_value, value, namespace_); // Whenever a frame element with a non-null content navigable has its src attribute set, changed, or removed, the // user agent must process the frame attributes. diff --git a/Libraries/LibWeb/HTML/HTMLFrameElement.h b/Libraries/LibWeb/HTML/HTMLFrameElement.h index f8da486203d..42be1fd2289 100644 --- a/Libraries/LibWeb/HTML/HTMLFrameElement.h +++ b/Libraries/LibWeb/HTML/HTMLFrameElement.h @@ -26,7 +26,7 @@ private: // ^DOM::Element virtual void inserted() override; virtual void removed_from(Node*) override; - virtual void attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value) override; + virtual void attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value, Optional const& namespace_) override; virtual i32 default_tab_index_value() const override; virtual void adjust_computed_style(CSS::StyleProperties&) override; diff --git a/Libraries/LibWeb/HTML/HTMLFrameSetElement.cpp b/Libraries/LibWeb/HTML/HTMLFrameSetElement.cpp index 8f788c86a4b..1d4b0c7591f 100644 --- a/Libraries/LibWeb/HTML/HTMLFrameSetElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLFrameSetElement.cpp @@ -34,9 +34,9 @@ void HTMLFrameSetElement::initialize(JS::Realm& realm) WEB_SET_PROTOTYPE_FOR_INTERFACE(HTMLFrameSetElement); } -void HTMLFrameSetElement::attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value) +void HTMLFrameSetElement::attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value, Optional const& namespace_) { - HTMLElement::attribute_changed(name, old_value, value); + Base::attribute_changed(name, old_value, value, namespace_); #undef __ENUMERATE #define __ENUMERATE(attribute_name, event_name) \ diff --git a/Libraries/LibWeb/HTML/HTMLFrameSetElement.h b/Libraries/LibWeb/HTML/HTMLFrameSetElement.h index 3faa188c404..da2f4cfdefa 100644 --- a/Libraries/LibWeb/HTML/HTMLFrameSetElement.h +++ b/Libraries/LibWeb/HTML/HTMLFrameSetElement.h @@ -27,7 +27,7 @@ private: virtual void adjust_computed_style(CSS::StyleProperties&) override; virtual void initialize(JS::Realm&) override; - virtual void attribute_changed(FlyString const&, Optional const& old_value, Optional const&) override; + virtual void attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value, Optional const& namespace_) override; // ^HTML::GlobalEventHandlers virtual JS::GCPtr global_event_handlers_to_event_target(FlyString const& event_name) override; diff --git a/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp b/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp index 36cb20d2239..6a700ed4255 100644 --- a/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp @@ -45,9 +45,9 @@ void HTMLIFrameElement::adjust_computed_style(CSS::StyleProperties& style) style.set_property(CSS::PropertyID::Display, CSS::DisplayStyleValue::create(CSS::Display::from_short(CSS::Display::Short::None))); } -void HTMLIFrameElement::attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value) +void HTMLIFrameElement::attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value, Optional const& namespace_) { - HTMLElement::attribute_changed(name, old_value, value); + Base::attribute_changed(name, old_value, value, namespace_); // https://html.spec.whatwg.org/multipage/iframe-embed-object.html#the-iframe-element:process-the-iframe-attributes-2 // https://html.spec.whatwg.org/multipage/iframe-embed-object.html#the-iframe-element:process-the-iframe-attributes-3 diff --git a/Libraries/LibWeb/HTML/HTMLIFrameElement.h b/Libraries/LibWeb/HTML/HTMLIFrameElement.h index 35ae1f4a2be..caceb6c9724 100644 --- a/Libraries/LibWeb/HTML/HTMLIFrameElement.h +++ b/Libraries/LibWeb/HTML/HTMLIFrameElement.h @@ -41,7 +41,7 @@ private: // ^DOM::Element virtual void inserted() override; virtual void removed_from(Node*) override; - virtual void attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value) override; + virtual void attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value, Optional const& namespace_) override; virtual i32 default_tab_index_value() const override; // https://html.spec.whatwg.org/multipage/iframe-embed-object.html#the-iframe-element:dimension-attributes diff --git a/Libraries/LibWeb/HTML/HTMLLinkElement.cpp b/Libraries/LibWeb/HTML/HTMLLinkElement.cpp index 6f6e0d1130b..cc94852eb85 100644 --- a/Libraries/LibWeb/HTML/HTMLLinkElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLLinkElement.cpp @@ -129,9 +129,9 @@ bool HTMLLinkElement::has_loaded_icon() const return m_relationship & Relationship::Icon && resource() && resource()->is_loaded() && resource()->has_encoded_data(); } -void HTMLLinkElement::attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value) +void HTMLLinkElement::attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value, Optional const& namespace_) { - HTMLElement::attribute_changed(name, old_value, value); + Base::attribute_changed(name, old_value, value, namespace_); // 4.6.7 Link types - https://html.spec.whatwg.org/multipage/links.html#linkTypes if (name == HTML::AttributeNames::rel) { diff --git a/Libraries/LibWeb/HTML/HTMLLinkElement.h b/Libraries/LibWeb/HTML/HTMLLinkElement.h index d890ff88f5c..c25e63b2843 100644 --- a/Libraries/LibWeb/HTML/HTMLLinkElement.h +++ b/Libraries/LibWeb/HTML/HTMLLinkElement.h @@ -47,7 +47,7 @@ private: HTMLLinkElement(DOM::Document&, DOM::QualifiedName); virtual void initialize(JS::Realm&) override; - virtual void attribute_changed(FlyString const&, Optional const& old_value, Optional const&) override; + virtual void attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value, Optional const& namespace_) override; // ^ResourceClient virtual void resource_did_fail() override; diff --git a/Libraries/LibWeb/HTML/HTMLMediaElement.cpp b/Libraries/LibWeb/HTML/HTMLMediaElement.cpp index 537760747ee..3aa8f162925 100644 --- a/Libraries/LibWeb/HTML/HTMLMediaElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLMediaElement.cpp @@ -98,9 +98,9 @@ void HTMLMediaElement::visit_edges(Cell::Visitor& visitor) visitor.visit(m_pending_play_promises); } -void HTMLMediaElement::attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value) +void HTMLMediaElement::attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value, Optional const& namespace_) { - Base::attribute_changed(name, old_value, value); + Base::attribute_changed(name, old_value, value, namespace_); if (name == HTML::AttributeNames::src) { load_element().release_value_but_fixme_should_propagate_errors(); diff --git a/Libraries/LibWeb/HTML/HTMLMediaElement.h b/Libraries/LibWeb/HTML/HTMLMediaElement.h index c4921974e35..2e4719e1723 100644 --- a/Libraries/LibWeb/HTML/HTMLMediaElement.h +++ b/Libraries/LibWeb/HTML/HTMLMediaElement.h @@ -140,7 +140,7 @@ protected: virtual void finalize() override; virtual void visit_edges(Cell::Visitor&) override; - virtual void attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value) override; + virtual void attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value, Optional const& namespace_) override; virtual void removed_from(DOM::Node*) override; virtual void children_changed() override; diff --git a/Libraries/LibWeb/HTML/HTMLOptionElement.cpp b/Libraries/LibWeb/HTML/HTMLOptionElement.cpp index 94020b54f4c..778e9a660b6 100644 --- a/Libraries/LibWeb/HTML/HTMLOptionElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLOptionElement.cpp @@ -34,9 +34,9 @@ void HTMLOptionElement::initialize(JS::Realm& realm) WEB_SET_PROTOTYPE_FOR_INTERFACE(HTMLOptionElement); } -void HTMLOptionElement::attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value) +void HTMLOptionElement::attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value, Optional const& namespace_) { - HTMLElement::attribute_changed(name, old_value, value); + Base::attribute_changed(name, old_value, value, namespace_); if (name == HTML::AttributeNames::selected) { if (!value.has_value()) { diff --git a/Libraries/LibWeb/HTML/HTMLOptionElement.h b/Libraries/LibWeb/HTML/HTMLOptionElement.h index 27a594c43e4..3481458ee20 100644 --- a/Libraries/LibWeb/HTML/HTMLOptionElement.h +++ b/Libraries/LibWeb/HTML/HTMLOptionElement.h @@ -44,7 +44,7 @@ private: virtual void initialize(JS::Realm&) override; - void attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value) override; + virtual void attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value, Optional const& namespace_) override; void ask_for_a_reset(); diff --git a/Libraries/LibWeb/HTML/HTMLOrSVGElement.cpp b/Libraries/LibWeb/HTML/HTMLOrSVGElement.cpp index 80f0d7a9eff..7122376953d 100644 --- a/Libraries/LibWeb/HTML/HTMLOrSVGElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLOrSVGElement.cpp @@ -58,7 +58,7 @@ void HTMLOrSVGElement::blur() // https://html.spec.whatwg.org/#dom-noncedelement-nonce template -void HTMLOrSVGElement::attribute_change_steps(FlyString const& local_name, Optional const&, Optional const& value, Optional const& namespace_) +void HTMLOrSVGElement::attribute_changed(FlyString const& local_name, Optional const&, Optional const& value, Optional const& namespace_) { // 1. If element does not include HTMLOrSVGElement, then return. // 2. If localName is not nonce or namespace is not null, then return. diff --git a/Libraries/LibWeb/HTML/HTMLOrSVGElement.h b/Libraries/LibWeb/HTML/HTMLOrSVGElement.h index da3495fbc15..fe6bd3288c9 100644 --- a/Libraries/LibWeb/HTML/HTMLOrSVGElement.h +++ b/Libraries/LibWeb/HTML/HTMLOrSVGElement.h @@ -25,7 +25,7 @@ public: void blur(); protected: - void attribute_change_steps(FlyString const&, Optional const&, Optional const&, Optional const&); + void attribute_changed(FlyString const&, Optional const&, Optional const&, Optional const&); WebIDL::ExceptionOr cloned(DOM::Node&, bool); void inserted(); void visit_edges(JS::Cell::Visitor&); diff --git a/Libraries/LibWeb/HTML/HTMLScriptElement.cpp b/Libraries/LibWeb/HTML/HTMLScriptElement.cpp index 585ea2ab812..15b76022d92 100644 --- a/Libraries/LibWeb/HTML/HTMLScriptElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLScriptElement.cpp @@ -50,9 +50,9 @@ void HTMLScriptElement::visit_edges(Cell::Visitor& visitor) visitor.visit(m_preparation_time_document); } -void HTMLScriptElement::attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value) +void HTMLScriptElement::attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value, Optional const& namespace_) { - Base::attribute_changed(name, old_value, value); + Base::attribute_changed(name, old_value, value, namespace_); if (name == HTML::AttributeNames::crossorigin) { m_crossorigin = cors_setting_attribute_from_keyword(value); diff --git a/Libraries/LibWeb/HTML/HTMLScriptElement.h b/Libraries/LibWeb/HTML/HTMLScriptElement.h index 3f6162b5c0d..bdb419cc3ad 100644 --- a/Libraries/LibWeb/HTML/HTMLScriptElement.h +++ b/Libraries/LibWeb/HTML/HTMLScriptElement.h @@ -70,7 +70,7 @@ private: virtual void initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; - virtual void attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value) override; + virtual void attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value, Optional const& namespace_) override; // https://html.spec.whatwg.org/multipage/scripting.html#prepare-the-script-element void prepare_script(); diff --git a/Libraries/LibWeb/HTML/HTMLSlotElement.cpp b/Libraries/LibWeb/HTML/HTMLSlotElement.cpp index e3a7d5b0885..021b49524c3 100644 --- a/Libraries/LibWeb/HTML/HTMLSlotElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLSlotElement.cpp @@ -117,9 +117,9 @@ void HTMLSlotElement::assign(Vector nodes) } // https://dom.spec.whatwg.org/#ref-for-concept-element-attributes-change-ext -void HTMLSlotElement::attribute_change_steps(FlyString const& local_name, Optional const& old_value, Optional const& value, Optional const& namespace_) +void HTMLSlotElement::attribute_changed(FlyString const& local_name, Optional const& old_value, Optional const& value, Optional const& namespace_) { - Base::attribute_change_steps(local_name, old_value, value, namespace_); + Base::attribute_changed(local_name, old_value, value, namespace_); // 1. If element is a slot, localName is name, and namespace is null, then: if (local_name == AttributeNames::name && !namespace_.has_value()) { diff --git a/Libraries/LibWeb/HTML/HTMLSlotElement.h b/Libraries/LibWeb/HTML/HTMLSlotElement.h index 3b579264048..01370a3eac4 100644 --- a/Libraries/LibWeb/HTML/HTMLSlotElement.h +++ b/Libraries/LibWeb/HTML/HTMLSlotElement.h @@ -45,7 +45,7 @@ private: virtual void initialize(JS::Realm&) override; virtual void visit_edges(JS::Cell::Visitor&) override; - virtual void attribute_change_steps(FlyString const& local_name, Optional const& old_value, Optional const& value, Optional const& namespace_) override; + virtual void attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value, Optional const& namespace_) override; // https://html.spec.whatwg.org/multipage/scripting.html#manually-assigned-nodes Vector m_manually_assigned_nodes; diff --git a/Libraries/LibWeb/HTML/HTMLTableElement.cpp b/Libraries/LibWeb/HTML/HTMLTableElement.cpp index 9d85c069e76..7edb3636e5c 100644 --- a/Libraries/LibWeb/HTML/HTMLTableElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLTableElement.cpp @@ -108,9 +108,10 @@ void HTMLTableElement::apply_presentational_hints(CSS::StyleProperties& style) c }); } -void HTMLTableElement::attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value) +void HTMLTableElement::attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value, Optional const& namespace_) { - Base::attribute_changed(name, old_value, value); + Base::attribute_changed(name, old_value, value, namespace_); + if (name == HTML::AttributeNames::cellpadding) { if (value.has_value()) m_padding = max(0, parse_integer(value.value()).value_or(0)); diff --git a/Libraries/LibWeb/HTML/HTMLTableElement.h b/Libraries/LibWeb/HTML/HTMLTableElement.h index 73a070184ac..3cf064375c4 100644 --- a/Libraries/LibWeb/HTML/HTMLTableElement.h +++ b/Libraries/LibWeb/HTML/HTMLTableElement.h @@ -59,7 +59,7 @@ private: virtual void visit_edges(Cell::Visitor&) override; virtual void apply_presentational_hints(CSS::StyleProperties&) const override; - virtual void attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value) override; + virtual void attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value, Optional const& namespace_) override; JS::GCPtr mutable m_rows; JS::GCPtr mutable m_t_bodies; diff --git a/Libraries/LibWeb/HTML/HTMLTrackElement.cpp b/Libraries/LibWeb/HTML/HTMLTrackElement.cpp index fef19156005..99682937212 100644 --- a/Libraries/LibWeb/HTML/HTMLTrackElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLTrackElement.cpp @@ -35,9 +35,9 @@ void HTMLTrackElement::visit_edges(Cell::Visitor& visitor) visitor.visit(m_track); } -void HTMLTrackElement::attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value) +void HTMLTrackElement::attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value, Optional const& namespace_) { - HTMLElement::attribute_changed(name, old_value, value); + Base::attribute_changed(name, old_value, value, namespace_); // https://html.spec.whatwg.org/multipage/media.html#sourcing-out-of-band-text-tracks // As the kind, label, and srclang attributes are set, changed, or removed, the text track must update accordingly, as per the definitions above. diff --git a/Libraries/LibWeb/HTML/HTMLTrackElement.h b/Libraries/LibWeb/HTML/HTMLTrackElement.h index 67e482127e0..1710a472d67 100644 --- a/Libraries/LibWeb/HTML/HTMLTrackElement.h +++ b/Libraries/LibWeb/HTML/HTMLTrackElement.h @@ -30,7 +30,7 @@ private: virtual void visit_edges(Cell::Visitor&) override; // ^DOM::Element - virtual void attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value) override; + virtual void attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value, Optional const& namespace_) override; JS::GCPtr m_track; }; diff --git a/Libraries/LibWeb/HTML/HTMLVideoElement.cpp b/Libraries/LibWeb/HTML/HTMLVideoElement.cpp index 5beeed6780e..de480344941 100644 --- a/Libraries/LibWeb/HTML/HTMLVideoElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLVideoElement.cpp @@ -54,9 +54,9 @@ void HTMLVideoElement::visit_edges(Cell::Visitor& visitor) visitor.visit(m_fetch_controller); } -void HTMLVideoElement::attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value) +void HTMLVideoElement::attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value, Optional const& namespace_) { - Base::attribute_changed(name, old_value, value); + Base::attribute_changed(name, old_value, value, namespace_); if (name == HTML::AttributeNames::poster) { determine_element_poster_frame(value).release_value_but_fixme_should_propagate_errors(); diff --git a/Libraries/LibWeb/HTML/HTMLVideoElement.h b/Libraries/LibWeb/HTML/HTMLVideoElement.h index b84e8aeb02b..f0b67b658bc 100644 --- a/Libraries/LibWeb/HTML/HTMLVideoElement.h +++ b/Libraries/LibWeb/HTML/HTMLVideoElement.h @@ -55,7 +55,7 @@ private: virtual void finalize() override; virtual void visit_edges(Cell::Visitor&) override; - virtual void attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value) override; + virtual void attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value, Optional const& namespace_) override; // https://html.spec.whatwg.org/multipage/media.html#the-video-element:dimension-attributes virtual bool supports_dimension_attributes() const override { return true; } diff --git a/Libraries/LibWeb/MathML/MathMLElement.cpp b/Libraries/LibWeb/MathML/MathMLElement.cpp index e5294616cc1..677007d1c34 100644 --- a/Libraries/LibWeb/MathML/MathMLElement.cpp +++ b/Libraries/LibWeb/MathML/MathMLElement.cpp @@ -20,10 +20,10 @@ MathMLElement::MathMLElement(DOM::Document& document, DOM::QualifiedName qualifi { } -void MathMLElement::attribute_change_steps(FlyString const& local_name, Optional const& old_value, Optional const& value, Optional const& namespace_) +void MathMLElement::attribute_changed(FlyString const& local_name, Optional const& old_value, Optional const& value, Optional const& namespace_) { - Base::attribute_change_steps(local_name, old_value, value, namespace_); - HTMLOrSVGElement::attribute_change_steps(local_name, old_value, value, namespace_); + Base::attribute_changed(local_name, old_value, value, namespace_); + HTMLOrSVGElement::attribute_changed(local_name, old_value, value, namespace_); } WebIDL::ExceptionOr MathMLElement::cloned(DOM::Node& node, bool clone_children) diff --git a/Libraries/LibWeb/MathML/MathMLElement.h b/Libraries/LibWeb/MathML/MathMLElement.h index 5fc98f761d8..48f57c6bff8 100644 --- a/Libraries/LibWeb/MathML/MathMLElement.h +++ b/Libraries/LibWeb/MathML/MathMLElement.h @@ -24,7 +24,7 @@ public: virtual Optional default_role() const override; protected: - virtual void attribute_change_steps(FlyString const&, Optional const&, Optional const&, Optional const&) override; + virtual void attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value, Optional const& namespace_) override; virtual WebIDL::ExceptionOr cloned(DOM::Node&, bool) override; virtual void inserted() override; virtual JS::GCPtr global_event_handlers_to_event_target(FlyString const&) override { return *this; } diff --git a/Libraries/LibWeb/SVG/SVGAElement.cpp b/Libraries/LibWeb/SVG/SVGAElement.cpp index b53f4893b90..9afd2437545 100644 --- a/Libraries/LibWeb/SVG/SVGAElement.cpp +++ b/Libraries/LibWeb/SVG/SVGAElement.cpp @@ -34,9 +34,10 @@ void SVGAElement::visit_edges(Cell::Visitor& visitor) visitor.visit(m_rel_list); } -void SVGAElement::attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value) +void SVGAElement::attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value, Optional const& namespace_) { - Base::attribute_changed(name, old_value, value); + Base::attribute_changed(name, old_value, value, namespace_); + if (name == SVG::AttributeNames::href) { invalidate_style(DOM::StyleInvalidationReason::HTMLHyperlinkElementHrefChange); } diff --git a/Libraries/LibWeb/SVG/SVGAElement.h b/Libraries/LibWeb/SVG/SVGAElement.h index 18d5b197741..c0ea3160934 100644 --- a/Libraries/LibWeb/SVG/SVGAElement.h +++ b/Libraries/LibWeb/SVG/SVGAElement.h @@ -32,7 +32,7 @@ private: virtual void visit_edges(Cell::Visitor&) override; // ^DOM::Element - virtual void attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value) override; + virtual void attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value, Optional const& namespace_) override; virtual i32 default_tab_index_value() const override; JS::GCPtr m_rel_list; diff --git a/Libraries/LibWeb/SVG/SVGClipPathElement.cpp b/Libraries/LibWeb/SVG/SVGClipPathElement.cpp index 76fc4546d7e..532c0e21092 100644 --- a/Libraries/LibWeb/SVG/SVGClipPathElement.cpp +++ b/Libraries/LibWeb/SVG/SVGClipPathElement.cpp @@ -28,9 +28,10 @@ void SVGClipPathElement::initialize(JS::Realm& realm) WEB_SET_PROTOTYPE_FOR_INTERFACE(SVGClipPathElement); } -void SVGClipPathElement::attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value) +void SVGClipPathElement::attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value, Optional const& namespace_) { - SVGElement::attribute_changed(name, old_value, value); + Base::attribute_changed(name, old_value, value, namespace_); + if (name == AttributeNames::clipPathUnits) m_clip_path_units = AttributeParser::parse_units(value.value_or(String {})); } diff --git a/Libraries/LibWeb/SVG/SVGClipPathElement.h b/Libraries/LibWeb/SVG/SVGClipPathElement.h index c64b664d7cd..e56faf087fa 100644 --- a/Libraries/LibWeb/SVG/SVGClipPathElement.h +++ b/Libraries/LibWeb/SVG/SVGClipPathElement.h @@ -33,7 +33,7 @@ public: return PreserveAspectRatio { PreserveAspectRatio::Align::None, {} }; } - virtual void attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value) override; + virtual void attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value, Optional const& namespace_) override; ClipPathUnits clip_path_units() const { diff --git a/Libraries/LibWeb/SVG/SVGElement.cpp b/Libraries/LibWeb/SVG/SVGElement.cpp index 4c2a997a4ee..ee395b3bfa8 100644 --- a/Libraries/LibWeb/SVG/SVGElement.cpp +++ b/Libraries/LibWeb/SVG/SVGElement.cpp @@ -35,19 +35,14 @@ void SVGElement::visit_edges(Cell::Visitor& visitor) visitor.visit(m_class_name_animated_string); } -void SVGElement::attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value) +void SVGElement::attribute_changed(FlyString const& local_name, Optional const& old_value, Optional const& value, Optional const& namespace_) { - Base::attribute_changed(name, old_value, value); + Base::attribute_changed(local_name, old_value, value, namespace_); + HTMLOrSVGElement::attribute_changed(local_name, old_value, value, namespace_); update_use_elements_that_reference_this(); } -void SVGElement::attribute_change_steps(FlyString const& local_name, Optional const& old_value, Optional const& value, Optional const& namespace_) -{ - Base::attribute_change_steps(local_name, old_value, value, namespace_); - HTMLOrSVGElement::attribute_change_steps(local_name, old_value, value, namespace_); -} - WebIDL::ExceptionOr SVGElement::cloned(DOM::Node& copy, bool clone_children) { TRY(Base::cloned(copy, clone_children)); diff --git a/Libraries/LibWeb/SVG/SVGElement.h b/Libraries/LibWeb/SVG/SVGElement.h index 62791676dc7..952e71b99c4 100644 --- a/Libraries/LibWeb/SVG/SVGElement.h +++ b/Libraries/LibWeb/SVG/SVGElement.h @@ -31,8 +31,7 @@ protected: virtual void initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; - virtual void attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value) override; - virtual void attribute_change_steps(FlyString const&, Optional const&, Optional const&, Optional const&) override; + virtual void attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value, Optional const& namespace_) override; virtual WebIDL::ExceptionOr cloned(DOM::Node&, bool) override; virtual void children_changed() override; virtual void inserted() override; diff --git a/Libraries/LibWeb/SVG/SVGEllipseElement.cpp b/Libraries/LibWeb/SVG/SVGEllipseElement.cpp index 20e23f92b6d..4d07d7858b8 100644 --- a/Libraries/LibWeb/SVG/SVGEllipseElement.cpp +++ b/Libraries/LibWeb/SVG/SVGEllipseElement.cpp @@ -26,9 +26,9 @@ void SVGEllipseElement::initialize(JS::Realm& realm) WEB_SET_PROTOTYPE_FOR_INTERFACE(SVGEllipseElement); } -void SVGEllipseElement::attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value) +void SVGEllipseElement::attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value, Optional const& namespace_) { - SVGGeometryElement::attribute_changed(name, old_value, value); + Base::attribute_changed(name, old_value, value, namespace_); if (name == SVG::AttributeNames::cx) { m_center_x = AttributeParser::parse_coordinate(value.value_or(String {})); diff --git a/Libraries/LibWeb/SVG/SVGEllipseElement.h b/Libraries/LibWeb/SVG/SVGEllipseElement.h index 60adb01cdb0..54e3cfe7e09 100644 --- a/Libraries/LibWeb/SVG/SVGEllipseElement.h +++ b/Libraries/LibWeb/SVG/SVGEllipseElement.h @@ -18,7 +18,7 @@ class SVGEllipseElement final : public SVGGeometryElement { public: virtual ~SVGEllipseElement() override = default; - virtual void attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value) override; + virtual void attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value, Optional const& namespace_) override; virtual Gfx::Path get_path(CSSPixelSize viewport_size) override; diff --git a/Libraries/LibWeb/SVG/SVGGradientElement.cpp b/Libraries/LibWeb/SVG/SVGGradientElement.cpp index f3bd4904c0a..6ab5fd7668c 100644 --- a/Libraries/LibWeb/SVG/SVGGradientElement.cpp +++ b/Libraries/LibWeb/SVG/SVGGradientElement.cpp @@ -19,9 +19,10 @@ SVGGradientElement::SVGGradientElement(DOM::Document& document, DOM::QualifiedNa { } -void SVGGradientElement::attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value) +void SVGGradientElement::attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value, Optional const& namespace_) { - SVGElement::attribute_changed(name, old_value, value); + Base::attribute_changed(name, old_value, value, namespace_); + if (name == AttributeNames::gradientUnits) { m_gradient_units = AttributeParser::parse_units(value.value_or(String {})); } else if (name == AttributeNames::spreadMethod) { diff --git a/Libraries/LibWeb/SVG/SVGGradientElement.h b/Libraries/LibWeb/SVG/SVGGradientElement.h index 8365179e7b7..46e44197bca 100644 --- a/Libraries/LibWeb/SVG/SVGGradientElement.h +++ b/Libraries/LibWeb/SVG/SVGGradientElement.h @@ -43,7 +43,7 @@ class SVGGradientElement public: virtual ~SVGGradientElement() override = default; - virtual void attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value) override; + virtual void attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value, Optional const& namespace_) override; virtual Optional to_gfx_paint_style(SVGPaintContext const&) const = 0; diff --git a/Libraries/LibWeb/SVG/SVGGraphicsElement.cpp b/Libraries/LibWeb/SVG/SVGGraphicsElement.cpp index ae847c93a56..1464dd7ad2e 100644 --- a/Libraries/LibWeb/SVG/SVGGraphicsElement.cpp +++ b/Libraries/LibWeb/SVG/SVGGraphicsElement.cpp @@ -37,9 +37,10 @@ void SVGGraphicsElement::initialize(JS::Realm& realm) WEB_SET_PROTOTYPE_FOR_INTERFACE(SVGGraphicsElement); } -void SVGGraphicsElement::attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value) +void SVGGraphicsElement::attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value, Optional const& namespace_) { - SVGElement::attribute_changed(name, old_value, value); + Base::attribute_changed(name, old_value, value, namespace_); + if (name == "transform"sv) { auto transform_list = AttributeParser::parse_transform(value.value_or(String {})); if (transform_list.has_value()) diff --git a/Libraries/LibWeb/SVG/SVGGraphicsElement.h b/Libraries/LibWeb/SVG/SVGGraphicsElement.h index 664a418b39b..5436e117625 100644 --- a/Libraries/LibWeb/SVG/SVGGraphicsElement.h +++ b/Libraries/LibWeb/SVG/SVGGraphicsElement.h @@ -32,7 +32,7 @@ class SVGGraphicsElement : public SVGElement { public: virtual void apply_presentational_hints(CSS::StyleProperties&) const override; - virtual void attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value) override; + virtual void attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value, Optional const& namespace_) override; Optional fill_color() const; Optional stroke_color() const; diff --git a/Libraries/LibWeb/SVG/SVGImageElement.cpp b/Libraries/LibWeb/SVG/SVGImageElement.cpp index a2e5e3f4982..632917f57d6 100644 --- a/Libraries/LibWeb/SVG/SVGImageElement.cpp +++ b/Libraries/LibWeb/SVG/SVGImageElement.cpp @@ -42,9 +42,10 @@ void SVGImageElement::visit_edges(Cell::Visitor& visitor) visitor.visit(m_resource_request); } -void SVGImageElement::attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value) +void SVGImageElement::attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value, Optional const& namespace_) { - SVGGraphicsElement::attribute_changed(name, old_value, value); + Base::attribute_changed(name, old_value, value, namespace_); + if (name == SVG::AttributeNames::x) { auto parsed_value = AttributeParser::parse_coordinate(value.value_or(String {})); MUST(x()->base_val()->set_value(parsed_value.value_or(0))); diff --git a/Libraries/LibWeb/SVG/SVGImageElement.h b/Libraries/LibWeb/SVG/SVGImageElement.h index 9e427a27925..a079335c7a5 100644 --- a/Libraries/LibWeb/SVG/SVGImageElement.h +++ b/Libraries/LibWeb/SVG/SVGImageElement.h @@ -20,7 +20,7 @@ class SVGImageElement WEB_PLATFORM_OBJECT(SVGImageElement, SVGGraphicsElement); public: - virtual void attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value) override; + virtual void attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value, Optional const& namespace_) override; JS::NonnullGCPtr x(); JS::NonnullGCPtr y(); diff --git a/Libraries/LibWeb/SVG/SVGLineElement.cpp b/Libraries/LibWeb/SVG/SVGLineElement.cpp index 60573a3f530..3b89c411c8f 100644 --- a/Libraries/LibWeb/SVG/SVGLineElement.cpp +++ b/Libraries/LibWeb/SVG/SVGLineElement.cpp @@ -26,9 +26,9 @@ void SVGLineElement::initialize(JS::Realm& realm) WEB_SET_PROTOTYPE_FOR_INTERFACE(SVGLineElement); } -void SVGLineElement::attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value) +void SVGLineElement::attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value, Optional const& namespace_) { - SVGGeometryElement::attribute_changed(name, old_value, value); + Base::attribute_changed(name, old_value, value, namespace_); if (name == SVG::AttributeNames::x1) { m_x1 = AttributeParser::parse_number_percentage(value.value_or(String {})); diff --git a/Libraries/LibWeb/SVG/SVGLineElement.h b/Libraries/LibWeb/SVG/SVGLineElement.h index e8119159c53..56ab7c217e6 100644 --- a/Libraries/LibWeb/SVG/SVGLineElement.h +++ b/Libraries/LibWeb/SVG/SVGLineElement.h @@ -18,7 +18,7 @@ class SVGLineElement final : public SVGGeometryElement { public: virtual ~SVGLineElement() override = default; - virtual void attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value) override; + virtual void attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value, Optional const& namespace_) override; virtual Gfx::Path get_path(CSSPixelSize viewport_size) override; diff --git a/Libraries/LibWeb/SVG/SVGLinearGradientElement.cpp b/Libraries/LibWeb/SVG/SVGLinearGradientElement.cpp index 7389059e33f..2ffb11188e9 100644 --- a/Libraries/LibWeb/SVG/SVGLinearGradientElement.cpp +++ b/Libraries/LibWeb/SVG/SVGLinearGradientElement.cpp @@ -28,9 +28,9 @@ void SVGLinearGradientElement::initialize(JS::Realm& realm) WEB_SET_PROTOTYPE_FOR_INTERFACE(SVGLinearGradientElement); } -void SVGLinearGradientElement::attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value) +void SVGLinearGradientElement::attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value, Optional const& namespace_) { - SVGGradientElement::attribute_changed(name, old_value, value); + Base::attribute_changed(name, old_value, value, namespace_); // FIXME: Should allow for ` | ` for x1, x2, y1, y2 if (name == SVG::AttributeNames::x1) { diff --git a/Libraries/LibWeb/SVG/SVGLinearGradientElement.h b/Libraries/LibWeb/SVG/SVGLinearGradientElement.h index eabf7cee6d3..dfd84949329 100644 --- a/Libraries/LibWeb/SVG/SVGLinearGradientElement.h +++ b/Libraries/LibWeb/SVG/SVGLinearGradientElement.h @@ -19,7 +19,7 @@ class SVGLinearGradientElement : public SVGGradientElement { public: virtual ~SVGLinearGradientElement() override = default; - virtual void attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value) override; + virtual void attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value, Optional const& namespace_) override; virtual Optional to_gfx_paint_style(SVGPaintContext const&) const override; diff --git a/Libraries/LibWeb/SVG/SVGMaskElement.cpp b/Libraries/LibWeb/SVG/SVGMaskElement.cpp index f6f8cd0f97d..644d987255e 100644 --- a/Libraries/LibWeb/SVG/SVGMaskElement.cpp +++ b/Libraries/LibWeb/SVG/SVGMaskElement.cpp @@ -33,9 +33,10 @@ JS::GCPtr SVGMaskElement::create_layout_node(CSS::StyleProperties) return nullptr; } -void SVGMaskElement::attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value) +void SVGMaskElement::attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value, Optional const& namespace_) { - SVGGraphicsElement::attribute_changed(name, old_value, value); + Base::attribute_changed(name, old_value, value, namespace_); + if (name == AttributeNames::maskUnits) { m_mask_units = AttributeParser::parse_units(value.value_or(String {})); } else if (name == AttributeNames::maskContentUnits) { diff --git a/Libraries/LibWeb/SVG/SVGMaskElement.h b/Libraries/LibWeb/SVG/SVGMaskElement.h index 2e66c821873..5d5df12ce7f 100644 --- a/Libraries/LibWeb/SVG/SVGMaskElement.h +++ b/Libraries/LibWeb/SVG/SVGMaskElement.h @@ -36,7 +36,7 @@ public: return PreserveAspectRatio { PreserveAspectRatio::Align::None, {} }; } - virtual void attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value) override; + virtual void attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value, Optional const& namespace_) override; virtual JS::GCPtr create_layout_node(CSS::StyleProperties) override; diff --git a/Libraries/LibWeb/SVG/SVGPathElement.cpp b/Libraries/LibWeb/SVG/SVGPathElement.cpp index 62511d76385..ca1ae579e56 100644 --- a/Libraries/LibWeb/SVG/SVGPathElement.cpp +++ b/Libraries/LibWeb/SVG/SVGPathElement.cpp @@ -97,9 +97,9 @@ void SVGPathElement::initialize(JS::Realm& realm) WEB_SET_PROTOTYPE_FOR_INTERFACE(SVGPathElement); } -void SVGPathElement::attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value) +void SVGPathElement::attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value, Optional const& namespace_) { - SVGGeometryElement::attribute_changed(name, old_value, value); + Base::attribute_changed(name, old_value, value, namespace_); if (name == "d") m_instructions = AttributeParser::parse_path_data(value.value_or(String {})); diff --git a/Libraries/LibWeb/SVG/SVGPathElement.h b/Libraries/LibWeb/SVG/SVGPathElement.h index 73024b8910f..ceb4108e10f 100644 --- a/Libraries/LibWeb/SVG/SVGPathElement.h +++ b/Libraries/LibWeb/SVG/SVGPathElement.h @@ -20,7 +20,7 @@ class SVGPathElement final : public SVGGeometryElement { public: virtual ~SVGPathElement() override = default; - virtual void attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value) override; + virtual void attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value, Optional const& namespace_) override; virtual Gfx::Path get_path(CSSPixelSize viewport_size) override; diff --git a/Libraries/LibWeb/SVG/SVGPolygonElement.cpp b/Libraries/LibWeb/SVG/SVGPolygonElement.cpp index d2345184bcb..c2e05310a95 100644 --- a/Libraries/LibWeb/SVG/SVGPolygonElement.cpp +++ b/Libraries/LibWeb/SVG/SVGPolygonElement.cpp @@ -26,9 +26,9 @@ void SVGPolygonElement::initialize(JS::Realm& realm) WEB_SET_PROTOTYPE_FOR_INTERFACE(SVGPolygonElement); } -void SVGPolygonElement::attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value) +void SVGPolygonElement::attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value, Optional const& namespace_) { - SVGGeometryElement::attribute_changed(name, old_value, value); + Base::attribute_changed(name, old_value, value, namespace_); if (name == SVG::AttributeNames::points) m_points = AttributeParser::parse_points(value.value_or(String {})); diff --git a/Libraries/LibWeb/SVG/SVGPolygonElement.h b/Libraries/LibWeb/SVG/SVGPolygonElement.h index 33844082469..92fff8144db 100644 --- a/Libraries/LibWeb/SVG/SVGPolygonElement.h +++ b/Libraries/LibWeb/SVG/SVGPolygonElement.h @@ -17,7 +17,7 @@ class SVGPolygonElement final : public SVGGeometryElement { public: virtual ~SVGPolygonElement() override = default; - virtual void attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value) override; + virtual void attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value, Optional const& namespace_) override; virtual Gfx::Path get_path(CSSPixelSize viewport_size) override; diff --git a/Libraries/LibWeb/SVG/SVGPolylineElement.cpp b/Libraries/LibWeb/SVG/SVGPolylineElement.cpp index 773248aae4c..c8ab2a5e8ea 100644 --- a/Libraries/LibWeb/SVG/SVGPolylineElement.cpp +++ b/Libraries/LibWeb/SVG/SVGPolylineElement.cpp @@ -26,9 +26,9 @@ void SVGPolylineElement::initialize(JS::Realm& realm) WEB_SET_PROTOTYPE_FOR_INTERFACE(SVGPolylineElement); } -void SVGPolylineElement::attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value) +void SVGPolylineElement::attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value, Optional const& namespace_) { - SVGGeometryElement::attribute_changed(name, old_value, value); + Base::attribute_changed(name, old_value, value, namespace_); if (name == SVG::AttributeNames::points) m_points = AttributeParser::parse_points(value.value_or(String {})); diff --git a/Libraries/LibWeb/SVG/SVGPolylineElement.h b/Libraries/LibWeb/SVG/SVGPolylineElement.h index 8bdd610a6d1..8ffd01d0fe9 100644 --- a/Libraries/LibWeb/SVG/SVGPolylineElement.h +++ b/Libraries/LibWeb/SVG/SVGPolylineElement.h @@ -17,7 +17,7 @@ class SVGPolylineElement final : public SVGGeometryElement { public: virtual ~SVGPolylineElement() override = default; - virtual void attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value) override; + virtual void attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value, Optional const& namespace_) override; virtual Gfx::Path get_path(CSSPixelSize viewport_size) override; diff --git a/Libraries/LibWeb/SVG/SVGRadialGradientElement.cpp b/Libraries/LibWeb/SVG/SVGRadialGradientElement.cpp index a365bb86531..fbe7f9bc0c0 100644 --- a/Libraries/LibWeb/SVG/SVGRadialGradientElement.cpp +++ b/Libraries/LibWeb/SVG/SVGRadialGradientElement.cpp @@ -25,9 +25,9 @@ void SVGRadialGradientElement::initialize(JS::Realm& realm) WEB_SET_PROTOTYPE_FOR_INTERFACE(SVGRadialGradientElement); } -void SVGRadialGradientElement::attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value) +void SVGRadialGradientElement::attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value, Optional const& namespace_) { - SVGGradientElement::attribute_changed(name, old_value, value); + Base::attribute_changed(name, old_value, value, namespace_); // FIXME: These are or in the spec, but all examples seem to allow percentages // and unitless values. diff --git a/Libraries/LibWeb/SVG/SVGRadialGradientElement.h b/Libraries/LibWeb/SVG/SVGRadialGradientElement.h index 8d48cbe42ef..b712a13ff35 100644 --- a/Libraries/LibWeb/SVG/SVGRadialGradientElement.h +++ b/Libraries/LibWeb/SVG/SVGRadialGradientElement.h @@ -19,7 +19,7 @@ class SVGRadialGradientElement : public SVGGradientElement { public: virtual ~SVGRadialGradientElement() override = default; - virtual void attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value) override; + virtual void attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value, Optional const& namespace_) override; virtual Optional to_gfx_paint_style(SVGPaintContext const&) const override; diff --git a/Libraries/LibWeb/SVG/SVGRectElement.cpp b/Libraries/LibWeb/SVG/SVGRectElement.cpp index 686d0c23e04..9cddb40aed9 100644 --- a/Libraries/LibWeb/SVG/SVGRectElement.cpp +++ b/Libraries/LibWeb/SVG/SVGRectElement.cpp @@ -28,9 +28,9 @@ void SVGRectElement::initialize(JS::Realm& realm) WEB_SET_PROTOTYPE_FOR_INTERFACE(SVGRectElement); } -void SVGRectElement::attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value) +void SVGRectElement::attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value, Optional const& namespace_) { - SVGGeometryElement::attribute_changed(name, old_value, value); + Base::attribute_changed(name, old_value, value, namespace_); if (name == SVG::AttributeNames::x) { m_x = AttributeParser::parse_coordinate(value.value_or(String {})); diff --git a/Libraries/LibWeb/SVG/SVGRectElement.h b/Libraries/LibWeb/SVG/SVGRectElement.h index 9f67ff46b6b..8befef1908a 100644 --- a/Libraries/LibWeb/SVG/SVGRectElement.h +++ b/Libraries/LibWeb/SVG/SVGRectElement.h @@ -18,7 +18,7 @@ class SVGRectElement final : public SVGGeometryElement { public: virtual ~SVGRectElement() override = default; - virtual void attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value) override; + virtual void attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value, Optional const& namespace_) override; virtual Gfx::Path get_path(CSSPixelSize viewport_size) override; diff --git a/Libraries/LibWeb/SVG/SVGSVGElement.cpp b/Libraries/LibWeb/SVG/SVGSVGElement.cpp index 873395a502a..62c2eab47be 100644 --- a/Libraries/LibWeb/SVG/SVGSVGElement.cpp +++ b/Libraries/LibWeb/SVG/SVGSVGElement.cpp @@ -101,9 +101,9 @@ void SVGSVGElement::apply_presentational_hints(CSS::StyleProperties& style) cons style.set_property(CSS::PropertyID::Height, height.release_nonnull()); } -void SVGSVGElement::attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value) +void SVGSVGElement::attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value, Optional const& namespace_) { - SVGGraphicsElement::attribute_changed(name, old_value, value); + Base::attribute_changed(name, old_value, value, namespace_); if (name.equals_ignoring_ascii_case(SVG::AttributeNames::viewBox)) { if (!value.has_value()) { diff --git a/Libraries/LibWeb/SVG/SVGSVGElement.h b/Libraries/LibWeb/SVG/SVGSVGElement.h index d2a22ce6752..0db8ab863de 100644 --- a/Libraries/LibWeb/SVG/SVGSVGElement.h +++ b/Libraries/LibWeb/SVG/SVGSVGElement.h @@ -91,7 +91,7 @@ private: virtual bool is_svg_svg_element() const override { return true; } - virtual void attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value) override; + virtual void attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value, Optional const& namespace_) override; void update_fallback_view_box_for_svg_as_image(); diff --git a/Libraries/LibWeb/SVG/SVGStopElement.cpp b/Libraries/LibWeb/SVG/SVGStopElement.cpp index 9835ee00fd5..595076f691a 100644 --- a/Libraries/LibWeb/SVG/SVGStopElement.cpp +++ b/Libraries/LibWeb/SVG/SVGStopElement.cpp @@ -21,9 +21,10 @@ SVGStopElement::SVGStopElement(DOM::Document& document, DOM::QualifiedName quali { } -void SVGStopElement::attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value) +void SVGStopElement::attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value, Optional const& namespace_) { - SVGElement::attribute_changed(name, old_value, value); + Base::attribute_changed(name, old_value, value, namespace_); + if (name == SVG::AttributeNames::offset) { m_offset = AttributeParser::parse_number_percentage(value.value_or(String {})); } diff --git a/Libraries/LibWeb/SVG/SVGStopElement.h b/Libraries/LibWeb/SVG/SVGStopElement.h index b7a1d4cafc8..9dd3418b56b 100644 --- a/Libraries/LibWeb/SVG/SVGStopElement.h +++ b/Libraries/LibWeb/SVG/SVGStopElement.h @@ -21,7 +21,7 @@ class SVGStopElement final : public SVGElement { public: virtual ~SVGStopElement() override = default; - virtual void attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value) override; + virtual void attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value, Optional const& namespace_) override; JS::NonnullGCPtr offset() const; diff --git a/Libraries/LibWeb/SVG/SVGSymbolElement.cpp b/Libraries/LibWeb/SVG/SVGSymbolElement.cpp index 54246d9d3a6..fefc3be7663 100644 --- a/Libraries/LibWeb/SVG/SVGSymbolElement.cpp +++ b/Libraries/LibWeb/SVG/SVGSymbolElement.cpp @@ -50,9 +50,10 @@ void SVGSymbolElement::apply_presentational_hints(CSS::StyleProperties& style) c } } -void SVGSymbolElement::attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value) +void SVGSymbolElement::attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value, Optional const& namespace_) { - Base::attribute_changed(name, old_value, value); + Base::attribute_changed(name, old_value, value, namespace_); + if (name.equals_ignoring_ascii_case(SVG::AttributeNames::viewBox)) { m_view_box = try_parse_view_box(value.value_or(String {})); m_view_box_for_bindings->set_nulled(!m_view_box.has_value()); diff --git a/Libraries/LibWeb/SVG/SVGSymbolElement.h b/Libraries/LibWeb/SVG/SVGSymbolElement.h index ce3122326ea..e416753c346 100644 --- a/Libraries/LibWeb/SVG/SVGSymbolElement.h +++ b/Libraries/LibWeb/SVG/SVGSymbolElement.h @@ -40,7 +40,7 @@ private: bool is_direct_child_of_use_shadow_tree() const; - virtual void attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value) override; + virtual void attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value, Optional const& namespace_) override; Optional m_view_box; diff --git a/Libraries/LibWeb/SVG/SVGTextPositioningElement.cpp b/Libraries/LibWeb/SVG/SVGTextPositioningElement.cpp index 5a54070b723..9bb2a703ce3 100644 --- a/Libraries/LibWeb/SVG/SVGTextPositioningElement.cpp +++ b/Libraries/LibWeb/SVG/SVGTextPositioningElement.cpp @@ -29,9 +29,9 @@ void SVGTextPositioningElement::initialize(JS::Realm& realm) WEB_SET_PROTOTYPE_FOR_INTERFACE(SVGTextPositioningElement); } -void SVGTextPositioningElement::attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value) +void SVGTextPositioningElement::attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value, Optional const& namespace_) { - SVGGraphicsElement::attribute_changed(name, old_value, value); + Base::attribute_changed(name, old_value, value, namespace_); if (name == SVG::AttributeNames::x) { m_x = AttributeParser::parse_number_percentage(value.value_or(String {})); diff --git a/Libraries/LibWeb/SVG/SVGTextPositioningElement.h b/Libraries/LibWeb/SVG/SVGTextPositioningElement.h index c944fe0cae2..549865e4571 100644 --- a/Libraries/LibWeb/SVG/SVGTextPositioningElement.h +++ b/Libraries/LibWeb/SVG/SVGTextPositioningElement.h @@ -16,7 +16,7 @@ class SVGTextPositioningElement : public SVGTextContentElement { WEB_PLATFORM_OBJECT(SVGTextPositioningElement, SVGTextContentElement); public: - virtual void attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value) override; + virtual void attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value, Optional const& namespace_) override; Gfx::FloatPoint get_offset(CSSPixelSize const& viewport_size) const; diff --git a/Libraries/LibWeb/SVG/SVGUseElement.cpp b/Libraries/LibWeb/SVG/SVGUseElement.cpp index 379e4e9f2cb..85f331e0df5 100644 --- a/Libraries/LibWeb/SVG/SVGUseElement.cpp +++ b/Libraries/LibWeb/SVG/SVGUseElement.cpp @@ -55,9 +55,9 @@ void SVGUseElement::visit_edges(Cell::Visitor& visitor) visitor.visit(m_resource_request); } -void SVGUseElement::attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value) +void SVGUseElement::attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value, Optional const& namespace_) { - Base::attribute_changed(name, old_value, value); + Base::attribute_changed(name, old_value, value, namespace_); // https://svgwg.org/svg2-draft/struct.html#UseLayout if (name == SVG::AttributeNames::x) { diff --git a/Libraries/LibWeb/SVG/SVGUseElement.h b/Libraries/LibWeb/SVG/SVGUseElement.h index 407826f86f0..7ec7efc223e 100644 --- a/Libraries/LibWeb/SVG/SVGUseElement.h +++ b/Libraries/LibWeb/SVG/SVGUseElement.h @@ -24,7 +24,7 @@ class SVGUseElement final public: virtual ~SVGUseElement() override = default; - virtual void attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value) override; + virtual void attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value, Optional const& namespace_) override; virtual void inserted() override;