mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 04:27:45 +00:00
LibWeb: Compute element style in Layout::TreeBuilder
Instead of making each Layout::Node compute style for itself, we now compute it in TreeBuilder before even calling create_layout_node(). For non-element DOM nodes, we create the style and layout tree node in TreeBuilder. This allows us to move create_layout_node() from DOM::Node to DOM::Element.
This commit is contained in:
parent
3451673ac8
commit
7e1bf4d300
31 changed files with 48 additions and 91 deletions
|
@ -16,11 +16,8 @@ SVGGElement::SVGGElement(DOM::Document& document, QualifiedName qualified_name)
|
|||
{
|
||||
}
|
||||
|
||||
RefPtr<Layout::Node> SVGGElement::create_layout_node()
|
||||
RefPtr<Layout::Node> SVGGElement::create_layout_node(NonnullRefPtr<CSS::StyleProperties> style)
|
||||
{
|
||||
auto style = document().style_computer().compute_style(*this);
|
||||
if (style->display().is_none())
|
||||
return nullptr;
|
||||
return adopt_ref(*new Layout::SVGGraphicsBox(document(), *this, move(style)));
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ public:
|
|||
SVGGElement(DOM::Document&, QualifiedName);
|
||||
virtual ~SVGGElement() override = default;
|
||||
|
||||
virtual RefPtr<Layout::Node> create_layout_node() override;
|
||||
virtual RefPtr<Layout::Node> create_layout_node(NonnullRefPtr<CSS::StyleProperties>) override;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -443,11 +443,8 @@ SVGPathElement::SVGPathElement(DOM::Document& document, QualifiedName qualified_
|
|||
{
|
||||
}
|
||||
|
||||
RefPtr<Layout::Node> SVGPathElement::create_layout_node()
|
||||
RefPtr<Layout::Node> SVGPathElement::create_layout_node(NonnullRefPtr<CSS::StyleProperties> style)
|
||||
{
|
||||
auto style = document().style_computer().compute_style(*this);
|
||||
if (style->display().is_none())
|
||||
return nullptr;
|
||||
return adopt_ref(*new Layout::SVGPathBox(document(), *this, move(style)));
|
||||
}
|
||||
|
||||
|
|
|
@ -89,7 +89,7 @@ public:
|
|||
SVGPathElement(DOM::Document&, QualifiedName);
|
||||
virtual ~SVGPathElement() override = default;
|
||||
|
||||
virtual RefPtr<Layout::Node> create_layout_node() override;
|
||||
virtual RefPtr<Layout::Node> create_layout_node(NonnullRefPtr<CSS::StyleProperties>) override;
|
||||
|
||||
virtual void parse_attribute(const FlyString& name, const String& value) override;
|
||||
|
||||
|
|
|
@ -19,11 +19,8 @@ SVGSVGElement::SVGSVGElement(DOM::Document& document, QualifiedName qualified_na
|
|||
{
|
||||
}
|
||||
|
||||
RefPtr<Layout::Node> SVGSVGElement::create_layout_node()
|
||||
RefPtr<Layout::Node> SVGSVGElement::create_layout_node(NonnullRefPtr<CSS::StyleProperties> style)
|
||||
{
|
||||
auto style = document().style_computer().compute_style(*this);
|
||||
if (style->display().is_none())
|
||||
return nullptr;
|
||||
return adopt_ref(*new Layout::SVGSVGBox(document(), *this, move(style)));
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ public:
|
|||
|
||||
SVGSVGElement(DOM::Document&, QualifiedName);
|
||||
|
||||
virtual RefPtr<Layout::Node> create_layout_node() override;
|
||||
virtual RefPtr<Layout::Node> create_layout_node(NonnullRefPtr<CSS::StyleProperties>) override;
|
||||
|
||||
unsigned width() const;
|
||||
unsigned height() const;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue