mirror of
https://github.com/zebrajr/ladybird.git
synced 2025-12-06 00:19:53 +01:00
LibWeb/DOM: Add custom-property helpers to AbstractElement
This commit is contained in:
parent
97ad1ea7e0
commit
cd4ea67706
|
|
@ -75,6 +75,35 @@ GC::Ptr<CSS::ComputedProperties const> AbstractElement::computed_properties() co
|
|||
return m_element->computed_properties();
|
||||
}
|
||||
|
||||
HashMap<FlyString, CSS::StyleProperty> const& AbstractElement::custom_properties() const
|
||||
{
|
||||
return m_element->custom_properties(m_pseudo_element);
|
||||
}
|
||||
|
||||
void AbstractElement::set_custom_properties(HashMap<FlyString, CSS::StyleProperty>&& custom_properties)
|
||||
{
|
||||
m_element->set_custom_properties(m_pseudo_element, move(custom_properties));
|
||||
}
|
||||
|
||||
RefPtr<CSS::CSSStyleValue const> AbstractElement::get_custom_property(FlyString const& name) const
|
||||
{
|
||||
// FIXME: We should be producing computed values for custom properties, just like regular properties.
|
||||
if (m_pseudo_element.has_value()) {
|
||||
auto const& custom_properties = m_element->custom_properties(*m_pseudo_element);
|
||||
if (auto it = custom_properties.find(name); it != custom_properties.end()) {
|
||||
return it->value.value;
|
||||
}
|
||||
}
|
||||
|
||||
for (auto const* current_element = m_element.ptr(); current_element; current_element = current_element->parent_or_shadow_host_element()) {
|
||||
auto const& custom_properties = current_element->custom_properties({});
|
||||
if (auto it = custom_properties.find(name); it != custom_properties.end()) {
|
||||
return it->value.value;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool AbstractElement::has_non_empty_counters_set() const
|
||||
{
|
||||
if (m_pseudo_element.has_value())
|
||||
|
|
|
|||
|
|
@ -31,6 +31,10 @@ public:
|
|||
|
||||
GC::Ptr<CSS::ComputedProperties const> computed_properties() const;
|
||||
|
||||
void set_custom_properties(HashMap<FlyString, CSS::StyleProperty>&& custom_properties);
|
||||
[[nodiscard]] HashMap<FlyString, CSS::StyleProperty> const& custom_properties() const;
|
||||
RefPtr<CSS::CSSStyleValue const> get_custom_property(FlyString const& name) const;
|
||||
|
||||
bool has_non_empty_counters_set() const;
|
||||
Optional<CSS::CountersSet const&> counters_set() const;
|
||||
CSS::CountersSet& ensure_counters_set();
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user