LibWeb: Return AbstractElement from element_to_inherit_style_from

No functional changes.
This commit is contained in:
Callum Law 2025-08-21 16:38:17 +12:00 committed by Jelle Raaijmakers
commit a2c9ab9c9a
Notes: github-actions[bot] 2025-08-22 07:50:15 +00:00
3 changed files with 11 additions and 5 deletions

View file

@ -3119,9 +3119,10 @@ NonnullRefPtr<StyleValue const> StyleComputer::compute_value_of_custom_property(
// Unset is the same as inherit for inherited properties, and by default all custom properties are inherited. // Unset is the same as inherit for inherited properties, and by default all custom properties are inherited.
// FIXME: Support non-inherited registered custom properties. // FIXME: Support non-inherited registered custom properties.
if (value->is_inherit() || value->is_unset()) { if (value->is_inherit() || value->is_unset()) {
if (!abstract_element.element_to_inherit_style_from()) auto element_to_inherit_style_from = abstract_element.element_to_inherit_style_from();
if (!element_to_inherit_style_from.has_value())
return document.custom_property_initial_value(name); return document.custom_property_initial_value(name);
auto inherited_value = DOM::AbstractElement { const_cast<DOM::Element&>(*abstract_element.element_to_inherit_style_from()) }.get_custom_property(name); auto inherited_value = element_to_inherit_style_from->get_custom_property(name);
if (!inherited_value) if (!inherited_value)
return document.custom_property_initial_value(name); return document.custom_property_initial_value(name);
return inherited_value.release_nonnull(); return inherited_value.release_nonnull();

View file

@ -40,9 +40,14 @@ GC::Ptr<Element const> AbstractElement::parent_element() const
return m_element->parent_element(); return m_element->parent_element();
} }
GC::Ptr<Element const> AbstractElement::element_to_inherit_style_from() const Optional<AbstractElement> AbstractElement::element_to_inherit_style_from() const
{ {
return m_element->element_to_inherit_style_from(m_pseudo_element); GC::Ptr<Element const> element = m_element->element_to_inherit_style_from(m_pseudo_element);
if (!element)
return OptionalNone {};
return AbstractElement { const_cast<DOM::Element&>(*element) };
} }
Optional<AbstractElement> AbstractElement::walk_layout_tree(WalkMethod walk_method) Optional<AbstractElement> AbstractElement::walk_layout_tree(WalkMethod walk_method)

View file

@ -27,7 +27,7 @@ public:
GC::Ptr<Layout::NodeWithStyle const> layout_node() const { return const_cast<AbstractElement*>(this)->layout_node(); } GC::Ptr<Layout::NodeWithStyle const> layout_node() const { return const_cast<AbstractElement*>(this)->layout_node(); }
GC::Ptr<Element const> parent_element() const; GC::Ptr<Element const> parent_element() const;
GC::Ptr<Element const> element_to_inherit_style_from() const; Optional<AbstractElement> element_to_inherit_style_from() const;
Optional<AbstractElement> previous_in_tree_order() { return walk_layout_tree(WalkMethod::Previous); } Optional<AbstractElement> previous_in_tree_order() { return walk_layout_tree(WalkMethod::Previous); }
Optional<AbstractElement> previous_sibling_in_tree_order() { return walk_layout_tree(WalkMethod::PreviousSibling); } Optional<AbstractElement> previous_sibling_in_tree_order() { return walk_layout_tree(WalkMethod::PreviousSibling); }
bool is_before(AbstractElement const&) const; bool is_before(AbstractElement const&) const;