mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 13:27:34 +00:00
LibWeb: Make DOM::Node::create_layout_node() not need parent's style
The StyleResolver can find the specified CSS values for the parent element via the DOM. Forcing everyone to locate specified values for their parent was completely unnecessary.
This commit is contained in:
parent
d9b2650dcc
commit
29a4da30b7
28 changed files with 40 additions and 39 deletions
|
@ -408,7 +408,7 @@ void Document::update_style()
|
|||
update_layout();
|
||||
}
|
||||
|
||||
RefPtr<Layout::Node> Document::create_layout_node(const CSS::StyleProperties*)
|
||||
RefPtr<Layout::Node> Document::create_layout_node()
|
||||
{
|
||||
return adopt(*new Layout::InitialContainingBlockBox(*this, CSS::StyleProperties::create()));
|
||||
}
|
||||
|
|
|
@ -223,7 +223,7 @@ public:
|
|||
private:
|
||||
explicit Document(const URL&);
|
||||
|
||||
virtual RefPtr<Layout::Node> create_layout_node(const CSS::StyleProperties* parent_style) override;
|
||||
virtual RefPtr<Layout::Node> create_layout_node() override;
|
||||
|
||||
void tear_down_layout_tree();
|
||||
|
||||
|
|
|
@ -111,9 +111,9 @@ bool Element::has_class(const FlyString& class_name) const
|
|||
return false;
|
||||
}
|
||||
|
||||
RefPtr<Layout::Node> Element::create_layout_node(const CSS::StyleProperties* parent_style)
|
||||
RefPtr<Layout::Node> Element::create_layout_node()
|
||||
{
|
||||
auto style = document().style_resolver().resolve_style(*this, parent_style);
|
||||
auto style = document().style_resolver().resolve_style(*this);
|
||||
const_cast<Element&>(*this).m_specified_css_values = style;
|
||||
auto display = style->display();
|
||||
|
||||
|
@ -199,8 +199,7 @@ void Element::recompute_style()
|
|||
set_needs_style_update(false);
|
||||
ASSERT(parent());
|
||||
auto old_specified_css_values = m_specified_css_values;
|
||||
auto* parent_specified_css_values = parent()->is_element() ? downcast<Element>(*parent()).specified_css_values() : nullptr;
|
||||
auto new_specified_css_values = document().style_resolver().resolve_style(*this, parent_specified_css_values);
|
||||
auto new_specified_css_values = document().style_resolver().resolve_style(*this);
|
||||
m_specified_css_values = new_specified_css_values;
|
||||
if (!layout_node()) {
|
||||
if (new_specified_css_values->display() == CSS::Display::None)
|
||||
|
|
|
@ -99,7 +99,7 @@ public:
|
|||
virtual bool is_focusable() const { return false; }
|
||||
|
||||
protected:
|
||||
RefPtr<Layout::Node> create_layout_node(const CSS::StyleProperties* parent_style) override;
|
||||
RefPtr<Layout::Node> create_layout_node() override;
|
||||
|
||||
private:
|
||||
Attribute* find_attribute(const FlyString& name);
|
||||
|
|
|
@ -105,7 +105,7 @@ void Node::set_text_content(const String& content)
|
|||
document().invalidate_layout();
|
||||
}
|
||||
|
||||
RefPtr<Layout::Node> Node::create_layout_node(const CSS::StyleProperties*)
|
||||
RefPtr<Layout::Node> Node::create_layout_node()
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ public:
|
|||
RefPtr<Node> insert_before(NonnullRefPtr<Node> node, RefPtr<Node> child, bool notify = true);
|
||||
void remove_all_children();
|
||||
|
||||
virtual RefPtr<Layout::Node> create_layout_node(const CSS::StyleProperties* parent_style);
|
||||
virtual RefPtr<Layout::Node> create_layout_node();
|
||||
|
||||
virtual FlyString node_name() const = 0;
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ Text::~Text()
|
|||
{
|
||||
}
|
||||
|
||||
RefPtr<Layout::Node> Text::create_layout_node(const CSS::StyleProperties*)
|
||||
RefPtr<Layout::Node> Text::create_layout_node()
|
||||
{
|
||||
return adopt(*new Layout::TextNode(document(), *this));
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ public:
|
|||
virtual FlyString node_name() const override { return "#text"; }
|
||||
|
||||
private:
|
||||
virtual RefPtr<Layout::Node> create_layout_node(const CSS::StyleProperties* parent_style) override;
|
||||
virtual RefPtr<Layout::Node> create_layout_node() override;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue