diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-10-06 10:09:55 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-10-06 10:09:55 +0200 |
commit | 772718b8d8d543082bc29d326b874573aa12e351 (patch) | |
tree | 81254ad278f47586bd436c9a6c2b2652cb02392d | |
parent | 306b9dfb51b4fbdecad2ae29fb954327d50cf0a5 (diff) | |
download | serenity-772718b8d8d543082bc29d326b874573aa12e351.zip |
LibHTML: Add a per-attribute callback for Elements to parse attributes
Elements now have a virtual parse_attribute(name, value) callback that
gets invoked for each one of its attributes.
-rw-r--r-- | Libraries/LibHTML/DOM/Element.cpp | 9 | ||||
-rw-r--r-- | Libraries/LibHTML/DOM/Element.h | 1 |
2 files changed, 10 insertions, 0 deletions
diff --git a/Libraries/LibHTML/DOM/Element.cpp b/Libraries/LibHTML/DOM/Element.cpp index c60319c075..2662562f4d 100644 --- a/Libraries/LibHTML/DOM/Element.cpp +++ b/Libraries/LibHTML/DOM/Element.cpp @@ -44,11 +44,16 @@ void Element::set_attribute(const String& name, const String& value) attribute->set_value(value); else m_attributes.empend(name, value); + + parse_attribute(name, value); } void Element::set_attributes(Vector<Attribute>&& attributes) { m_attributes = move(attributes); + + for (auto& attribute : m_attributes) + parse_attribute(attribute.name(), attribute.value()); } bool Element::has_class(const StringView& class_name) const @@ -80,3 +85,7 @@ RefPtr<LayoutNode> Element::create_layout_node(const StyleResolver& resolver, co ASSERT_NOT_REACHED(); } + +void Element::parse_attribute(const String&, const String&) +{ +} diff --git a/Libraries/LibHTML/DOM/Element.h b/Libraries/LibHTML/DOM/Element.h index a45f09ba4b..d6641e5496 100644 --- a/Libraries/LibHTML/DOM/Element.h +++ b/Libraries/LibHTML/DOM/Element.h @@ -43,6 +43,7 @@ public: bool has_class(const StringView&) const; virtual void apply_presentational_hints(StyleProperties&) const {} + virtual void parse_attribute(const String& name, const String& value); private: RefPtr<LayoutNode> create_layout_node(const StyleResolver&, const StyleProperties* parent_properties) const override; |