1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 13:48:12 +00:00

LibHTML: Move layout root from HtmlView to Document

The layout root is now kept alive via Document::m_layout_root.
This will allow us to do more layout-related things inside the inner
layer of LibHTML without reaching out to the HtmlView.

I'd like to keep HtmlView at a slightly higher level, to prevent it
from getting too complex.

This patch also fixes accidental disconnection of the layout tree from
the DOM after doing a layout tree rebuild. ~LayoutNode() now only
unsets the DOM node's layout_node() if it's itself.
This commit is contained in:
Andreas Kling 2019-10-13 12:34:25 +02:00
parent 48ef1d1bd1
commit 49ac0c2e24
6 changed files with 51 additions and 20 deletions

View file

@ -14,6 +14,7 @@ class Frame;
class HTMLBodyElement;
class HTMLHtmlElement;
class HTMLHeadElement;
class LayoutDocument;
class LayoutNode;
class StyleResolver;
class StyleSheet;
@ -64,11 +65,15 @@ public:
Color visited_link_color() const { return m_visited_link_color; }
void set_visited_link_color(Color);
void layout();
void invalidate_layout();
Function<void()> on_invalidate_layout;
virtual bool is_child_allowed(const Node&) const override;
const LayoutDocument* layout_node() const;
private:
virtual RefPtr<LayoutNode> create_layout_node(const StyleResolver&, const StyleProperties* parent_style) const override;
@ -78,6 +83,8 @@ private:
WeakPtr<Frame> m_frame;
URL m_url;
RefPtr<LayoutDocument> m_layout_root;
Color m_link_color { Color::Blue };
Color m_active_link_color { Color::Red };
Color m_visited_link_color { Color::Magenta };