mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 22:57:44 +00:00
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.
This commit is contained in:
parent
306b9dfb51
commit
772718b8d8
2 changed files with 10 additions and 0 deletions
|
@ -44,11 +44,16 @@ void Element::set_attribute(const String& name, const String& value)
|
||||||
attribute->set_value(value);
|
attribute->set_value(value);
|
||||||
else
|
else
|
||||||
m_attributes.empend(name, value);
|
m_attributes.empend(name, value);
|
||||||
|
|
||||||
|
parse_attribute(name, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Element::set_attributes(Vector<Attribute>&& attributes)
|
void Element::set_attributes(Vector<Attribute>&& attributes)
|
||||||
{
|
{
|
||||||
m_attributes = move(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
|
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();
|
ASSERT_NOT_REACHED();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Element::parse_attribute(const String&, const String&)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
|
@ -43,6 +43,7 @@ public:
|
||||||
bool has_class(const StringView&) const;
|
bool has_class(const StringView&) const;
|
||||||
|
|
||||||
virtual void apply_presentational_hints(StyleProperties&) const {}
|
virtual void apply_presentational_hints(StyleProperties&) const {}
|
||||||
|
virtual void parse_attribute(const String& name, const String& value);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RefPtr<LayoutNode> create_layout_node(const StyleResolver&, const StyleProperties* parent_properties) const override;
|
RefPtr<LayoutNode> create_layout_node(const StyleResolver&, const StyleProperties* parent_properties) const override;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue