mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-10 10:09:14 +00:00
LibWeb: Store pseudo-element layout nodes as NodeWithStyle
We were already guaranteed to return a NodeWithStyle from `create_layout_node_for_display_type()`, so make use of that knowledge.
This commit is contained in:
parent
7758875cfd
commit
521cd161a8
Notes:
github-actions[bot]
2024-08-07 14:16:00 +00:00
Author: https://github.com/AtkinsSJ
Commit: 521cd161a8
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/994
2 changed files with 7 additions and 7 deletions
|
@ -395,7 +395,7 @@ JS::GCPtr<Layout::Node> Element::create_layout_node(NonnullRefPtr<CSS::StyleProp
|
||||||
return create_layout_node_for_display_type(document(), display, move(style), this);
|
return create_layout_node_for_display_type(document(), display, move(style), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
JS::GCPtr<Layout::Node> Element::create_layout_node_for_display_type(DOM::Document& document, CSS::Display const& display, NonnullRefPtr<CSS::StyleProperties> style, Element* element)
|
JS::GCPtr<Layout::NodeWithStyle> Element::create_layout_node_for_display_type(DOM::Document& document, CSS::Display const& display, NonnullRefPtr<CSS::StyleProperties> style, Element* element)
|
||||||
{
|
{
|
||||||
if (display.is_table_inside() || display.is_table_row_group() || display.is_table_header_group() || display.is_table_footer_group() || display.is_table_row())
|
if (display.is_table_inside() || display.is_table_row_group() || display.is_table_header_group() || display.is_table_footer_group() || display.is_table_row())
|
||||||
return document.heap().allocate_without_realm<Layout::Box>(document, element, move(style));
|
return document.heap().allocate_without_realm<Layout::Box>(document, element, move(style));
|
||||||
|
@ -1125,7 +1125,7 @@ void Element::children_changed()
|
||||||
set_needs_style_update(true);
|
set_needs_style_update(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Element::set_pseudo_element_node(Badge<Layout::TreeBuilder>, CSS::Selector::PseudoElement::Type pseudo_element, JS::GCPtr<Layout::Node> pseudo_element_node)
|
void Element::set_pseudo_element_node(Badge<Layout::TreeBuilder>, CSS::Selector::PseudoElement::Type pseudo_element, JS::GCPtr<Layout::NodeWithStyle> pseudo_element_node)
|
||||||
{
|
{
|
||||||
auto existing_pseudo_element = get_pseudo_element(pseudo_element);
|
auto existing_pseudo_element = get_pseudo_element(pseudo_element);
|
||||||
if (!existing_pseudo_element.has_value() && !pseudo_element_node)
|
if (!existing_pseudo_element.has_value() && !pseudo_element_node)
|
||||||
|
@ -1134,7 +1134,7 @@ void Element::set_pseudo_element_node(Badge<Layout::TreeBuilder>, CSS::Selector:
|
||||||
ensure_pseudo_element(pseudo_element).layout_node = move(pseudo_element_node);
|
ensure_pseudo_element(pseudo_element).layout_node = move(pseudo_element_node);
|
||||||
}
|
}
|
||||||
|
|
||||||
JS::GCPtr<Layout::Node> Element::get_pseudo_element_node(CSS::Selector::PseudoElement::Type pseudo_element) const
|
JS::GCPtr<Layout::NodeWithStyle> Element::get_pseudo_element_node(CSS::Selector::PseudoElement::Type pseudo_element) const
|
||||||
{
|
{
|
||||||
if (auto element_data = get_pseudo_element(pseudo_element); element_data.has_value())
|
if (auto element_data = get_pseudo_element(pseudo_element); element_data.has_value())
|
||||||
return element_data->layout_node;
|
return element_data->layout_node;
|
||||||
|
|
|
@ -241,10 +241,10 @@ public:
|
||||||
virtual void did_receive_focus() { }
|
virtual void did_receive_focus() { }
|
||||||
virtual void did_lose_focus() { }
|
virtual void did_lose_focus() { }
|
||||||
|
|
||||||
static JS::GCPtr<Layout::Node> create_layout_node_for_display_type(DOM::Document&, CSS::Display const&, NonnullRefPtr<CSS::StyleProperties>, Element*);
|
static JS::GCPtr<Layout::NodeWithStyle> create_layout_node_for_display_type(DOM::Document&, CSS::Display const&, NonnullRefPtr<CSS::StyleProperties>, Element*);
|
||||||
|
|
||||||
void set_pseudo_element_node(Badge<Layout::TreeBuilder>, CSS::Selector::PseudoElement::Type, JS::GCPtr<Layout::Node>);
|
void set_pseudo_element_node(Badge<Layout::TreeBuilder>, CSS::Selector::PseudoElement::Type, JS::GCPtr<Layout::NodeWithStyle>);
|
||||||
JS::GCPtr<Layout::Node> get_pseudo_element_node(CSS::Selector::PseudoElement::Type) const;
|
JS::GCPtr<Layout::NodeWithStyle> get_pseudo_element_node(CSS::Selector::PseudoElement::Type) const;
|
||||||
void clear_pseudo_element_nodes(Badge<Layout::TreeBuilder>);
|
void clear_pseudo_element_nodes(Badge<Layout::TreeBuilder>);
|
||||||
void serialize_pseudo_elements_as_json(JsonArraySerializer<StringBuilder>& children_array) const;
|
void serialize_pseudo_elements_as_json(JsonArraySerializer<StringBuilder>& children_array) const;
|
||||||
|
|
||||||
|
@ -453,7 +453,7 @@ private:
|
||||||
HashMap<FlyString, CSS::StyleProperty> m_custom_properties;
|
HashMap<FlyString, CSS::StyleProperty> m_custom_properties;
|
||||||
|
|
||||||
struct PseudoElement {
|
struct PseudoElement {
|
||||||
JS::GCPtr<Layout::Node> layout_node;
|
JS::GCPtr<Layout::NodeWithStyle> layout_node;
|
||||||
RefPtr<CSS::StyleProperties> computed_css_values;
|
RefPtr<CSS::StyleProperties> computed_css_values;
|
||||||
HashMap<FlyString, CSS::StyleProperty> custom_properties;
|
HashMap<FlyString, CSS::StyleProperty> custom_properties;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue