mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 21:57:35 +00:00
LibWeb: Make the paint tree GC-allocated
This simplifies the ownership model between DOM/layout/paint nodes immensely by deferring to the garbage collector for figuring out what's live and what's not.
This commit is contained in:
parent
35ba13802d
commit
4d401bf796
64 changed files with 148 additions and 108 deletions
|
@ -41,7 +41,7 @@ Painting::PaintableWithLines const* BlockContainer::paint_box() const
|
|||
return static_cast<Painting::PaintableWithLines const*>(Box::paint_box());
|
||||
}
|
||||
|
||||
RefPtr<Painting::Paintable> BlockContainer::create_paintable() const
|
||||
JS::GCPtr<Painting::Paintable> BlockContainer::create_paintable() const
|
||||
{
|
||||
return Painting::PaintableWithLines::create(*this);
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ public:
|
|||
|
||||
Painting::PaintableWithLines const* paint_box() const;
|
||||
|
||||
virtual RefPtr<Painting::Paintable> create_paintable() const override;
|
||||
virtual JS::GCPtr<Painting::Paintable> create_paintable() const override;
|
||||
|
||||
private:
|
||||
virtual bool is_block_container() const final { return true; }
|
||||
|
|
|
@ -40,7 +40,7 @@ bool Box::is_body() const
|
|||
return dom_node() && dom_node() == document().body();
|
||||
}
|
||||
|
||||
RefPtr<Painting::Paintable> Box::create_paintable() const
|
||||
JS::GCPtr<Painting::Paintable> Box::create_paintable() const
|
||||
{
|
||||
return Painting::PaintableBox::create(*this);
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ public:
|
|||
|
||||
virtual void did_set_rect() { }
|
||||
|
||||
virtual RefPtr<Painting::Paintable> create_paintable() const override;
|
||||
virtual JS::GCPtr<Painting::Paintable> create_paintable() const override;
|
||||
|
||||
protected:
|
||||
Box(DOM::Document&, DOM::Node*, NonnullRefPtr<CSS::StyleProperties>);
|
||||
|
|
|
@ -30,7 +30,7 @@ void ButtonBox::prepare_for_replaced_layout()
|
|||
}
|
||||
}
|
||||
|
||||
RefPtr<Painting::Paintable> ButtonBox::create_paintable() const
|
||||
JS::GCPtr<Painting::Paintable> ButtonBox::create_paintable() const
|
||||
{
|
||||
return Painting::ButtonPaintable::create(*this);
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ public:
|
|||
virtual void prepare_for_replaced_layout() override;
|
||||
|
||||
private:
|
||||
virtual RefPtr<Painting::Paintable> create_paintable() const override;
|
||||
virtual JS::GCPtr<Painting::Paintable> create_paintable() const override;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ void CanvasBox::prepare_for_replaced_layout()
|
|||
set_intrinsic_height(dom_node().height());
|
||||
}
|
||||
|
||||
RefPtr<Painting::Paintable> CanvasBox::create_paintable() const
|
||||
JS::GCPtr<Painting::Paintable> CanvasBox::create_paintable() const
|
||||
{
|
||||
return Painting::CanvasPaintable::create(*this);
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ public:
|
|||
|
||||
const HTML::HTMLCanvasElement& dom_node() const { return static_cast<const HTML::HTMLCanvasElement&>(ReplacedBox::dom_node()); }
|
||||
|
||||
virtual RefPtr<Painting::Paintable> create_paintable() const override;
|
||||
virtual JS::GCPtr<Painting::Paintable> create_paintable() const override;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ CheckBox::CheckBox(DOM::Document& document, HTML::HTMLInputElement& element, Non
|
|||
|
||||
CheckBox::~CheckBox() = default;
|
||||
|
||||
RefPtr<Painting::Paintable> CheckBox::create_paintable() const
|
||||
JS::GCPtr<Painting::Paintable> CheckBox::create_paintable() const
|
||||
{
|
||||
return Painting::CheckBoxPaintable::create(*this);
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ public:
|
|||
virtual ~CheckBox() override;
|
||||
|
||||
private:
|
||||
virtual RefPtr<Painting::Paintable> create_paintable() const override;
|
||||
virtual JS::GCPtr<Painting::Paintable> create_paintable() const override;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ void FrameBox::did_set_rect()
|
|||
dom_node().nested_browsing_context()->set_size(paint_box()->content_size());
|
||||
}
|
||||
|
||||
RefPtr<Painting::Paintable> FrameBox::create_paintable() const
|
||||
JS::GCPtr<Painting::Paintable> FrameBox::create_paintable() const
|
||||
{
|
||||
return Painting::NestedBrowsingContextPaintable::create(*this);
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ public:
|
|||
const HTML::HTMLIFrameElement& dom_node() const { return verify_cast<HTML::HTMLIFrameElement>(ReplacedBox::dom_node()); }
|
||||
HTML::HTMLIFrameElement& dom_node() { return verify_cast<HTML::HTMLIFrameElement>(ReplacedBox::dom_node()); }
|
||||
|
||||
virtual RefPtr<Painting::Paintable> create_paintable() const override;
|
||||
virtual JS::GCPtr<Painting::Paintable> create_paintable() const override;
|
||||
|
||||
private:
|
||||
virtual void did_set_rect() override;
|
||||
|
|
|
@ -97,7 +97,7 @@ void ImageBox::browsing_context_did_set_viewport_rect(CSSPixelRect const& viewpo
|
|||
m_image_loader.set_visible_in_viewport(paint_box() && viewport_rect.intersects(paint_box()->absolute_rect()));
|
||||
}
|
||||
|
||||
RefPtr<Painting::Paintable> ImageBox::create_paintable() const
|
||||
JS::GCPtr<Painting::Paintable> ImageBox::create_paintable() const
|
||||
{
|
||||
return Painting::ImagePaintable::create(*this);
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ public:
|
|||
|
||||
bool renders_as_alt_text() const;
|
||||
|
||||
virtual RefPtr<Painting::Paintable> create_paintable() const override;
|
||||
virtual JS::GCPtr<Painting::Paintable> create_paintable() const override;
|
||||
|
||||
auto const& image_loader() const { return m_image_loader; }
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ InlineNode::InlineNode(DOM::Document& document, DOM::Element* element, NonnullRe
|
|||
|
||||
InlineNode::~InlineNode() = default;
|
||||
|
||||
RefPtr<Painting::Paintable> InlineNode::create_paintable() const
|
||||
JS::GCPtr<Painting::Paintable> InlineNode::create_paintable() const
|
||||
{
|
||||
return Painting::InlinePaintable::create(*this);
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ public:
|
|||
InlineNode(DOM::Document&, DOM::Element*, NonnullRefPtr<CSS::StyleProperties>);
|
||||
virtual ~InlineNode() override;
|
||||
|
||||
virtual RefPtr<Painting::Paintable> create_paintable() const override;
|
||||
virtual JS::GCPtr<Painting::Paintable> create_paintable() const override;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ ListItemMarkerBox::ListItemMarkerBox(DOM::Document& document, CSS::ListStyleType
|
|||
|
||||
ListItemMarkerBox::~ListItemMarkerBox() = default;
|
||||
|
||||
RefPtr<Painting::Paintable> ListItemMarkerBox::create_paintable() const
|
||||
JS::GCPtr<Painting::Paintable> ListItemMarkerBox::create_paintable() const
|
||||
{
|
||||
return Painting::MarkerPaintable::create(*this);
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ public:
|
|||
|
||||
DeprecatedString const& text() const { return m_text; }
|
||||
|
||||
virtual RefPtr<Painting::Paintable> create_paintable() const override;
|
||||
virtual JS::GCPtr<Painting::Paintable> create_paintable() const override;
|
||||
|
||||
CSS::ListStyleType list_style_type() const { return m_list_style_type; }
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@ void Node::visit_edges(Cell::Visitor& visitor)
|
|||
{
|
||||
Base::visit_edges(visitor);
|
||||
visitor.visit(m_dom_node);
|
||||
visitor.visit(m_paintable);
|
||||
visitor.visit(m_browsing_context);
|
||||
TreeNode::visit_edges(visitor);
|
||||
}
|
||||
|
@ -679,12 +680,12 @@ void NodeWithStyle::reset_table_box_computed_values_used_by_wrapper_to_init_valu
|
|||
mutable_computed_values.set_margin({ CSS::Length::make_px(0), CSS::Length::make_px(0), CSS::Length::make_px(0), CSS::Length::make_px(0) });
|
||||
}
|
||||
|
||||
void Node::set_paintable(RefPtr<Painting::Paintable> paintable)
|
||||
void Node::set_paintable(JS::GCPtr<Painting::Paintable> paintable)
|
||||
{
|
||||
m_paintable = move(paintable);
|
||||
}
|
||||
|
||||
RefPtr<Painting::Paintable> Node::create_paintable() const
|
||||
JS::GCPtr<Painting::Paintable> Node::create_paintable() const
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
@ -51,9 +51,9 @@ public:
|
|||
|
||||
Painting::Paintable* paintable() { return m_paintable; }
|
||||
Painting::Paintable const* paintable() const { return m_paintable; }
|
||||
void set_paintable(RefPtr<Painting::Paintable>);
|
||||
void set_paintable(JS::GCPtr<Painting::Paintable>);
|
||||
|
||||
virtual RefPtr<Painting::Paintable> create_paintable() const;
|
||||
virtual JS::GCPtr<Painting::Paintable> create_paintable() const;
|
||||
|
||||
DOM::Document& document();
|
||||
DOM::Document const& document() const;
|
||||
|
@ -150,7 +150,7 @@ private:
|
|||
friend class NodeWithStyle;
|
||||
|
||||
JS::NonnullGCPtr<DOM::Node> m_dom_node;
|
||||
RefPtr<Painting::Paintable> m_paintable;
|
||||
JS::GCPtr<Painting::Paintable> m_paintable;
|
||||
|
||||
JS::NonnullGCPtr<HTML::BrowsingContext> m_browsing_context;
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ Progress::Progress(DOM::Document& document, HTML::HTMLProgressElement& element,
|
|||
|
||||
Progress::~Progress() = default;
|
||||
|
||||
RefPtr<Painting::Paintable> Progress::create_paintable() const
|
||||
JS::GCPtr<Painting::Paintable> Progress::create_paintable() const
|
||||
{
|
||||
return Painting::ProgressPaintable::create(*this);
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ public:
|
|||
const HTML::HTMLProgressElement& dom_node() const { return static_cast<const HTML::HTMLProgressElement&>(LabelableNode::dom_node()); }
|
||||
HTML::HTMLProgressElement& dom_node() { return static_cast<HTML::HTMLProgressElement&>(LabelableNode::dom_node()); }
|
||||
|
||||
virtual RefPtr<Painting::Paintable> create_paintable() const override;
|
||||
virtual JS::GCPtr<Painting::Paintable> create_paintable() const override;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ RadioButton::RadioButton(DOM::Document& document, HTML::HTMLInputElement& elemen
|
|||
|
||||
RadioButton::~RadioButton() = default;
|
||||
|
||||
RefPtr<Painting::Paintable> RadioButton::create_paintable() const
|
||||
JS::GCPtr<Painting::Paintable> RadioButton::create_paintable() const
|
||||
{
|
||||
return Painting::RadioButtonPaintable::create(*this);
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ public:
|
|||
virtual ~RadioButton() override;
|
||||
|
||||
private:
|
||||
virtual RefPtr<Painting::Paintable> create_paintable() const override;
|
||||
virtual JS::GCPtr<Painting::Paintable> create_paintable() const override;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ CSSPixelPoint SVGGeometryBox::viewbox_origin() const
|
|||
return { svg_box->view_box().value().min_x, svg_box->view_box().value().min_y };
|
||||
}
|
||||
|
||||
RefPtr<Painting::Paintable> SVGGeometryBox::create_paintable() const
|
||||
JS::GCPtr<Painting::Paintable> SVGGeometryBox::create_paintable() const
|
||||
{
|
||||
return Painting::SVGGeometryPaintable::create(*this);
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ public:
|
|||
float viewbox_scaling() const;
|
||||
CSSPixelPoint viewbox_origin() const;
|
||||
|
||||
virtual RefPtr<Painting::Paintable> create_paintable() const override;
|
||||
virtual JS::GCPtr<Painting::Paintable> create_paintable() const override;
|
||||
|
||||
private:
|
||||
virtual bool is_svg_geometry_box() const final { return true; }
|
||||
|
|
|
@ -17,7 +17,7 @@ SVGSVGBox::SVGSVGBox(DOM::Document& document, SVG::SVGSVGElement& element, Nonnu
|
|||
{
|
||||
}
|
||||
|
||||
RefPtr<Painting::Paintable> SVGSVGBox::create_paintable() const
|
||||
JS::GCPtr<Painting::Paintable> SVGSVGBox::create_paintable() const
|
||||
{
|
||||
return Painting::SVGSVGPaintable::create(*this);
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ public:
|
|||
|
||||
virtual bool can_have_children() const override { return true; }
|
||||
|
||||
virtual RefPtr<Painting::Paintable> create_paintable() const override;
|
||||
virtual JS::GCPtr<Painting::Paintable> create_paintable() const override;
|
||||
|
||||
virtual void prepare_for_replaced_layout() override;
|
||||
};
|
||||
|
|
|
@ -188,7 +188,7 @@ Optional<TextNode::Chunk> TextNode::ChunkIterator::try_commit_chunk(Utf8View::It
|
|||
return {};
|
||||
}
|
||||
|
||||
RefPtr<Painting::Paintable> TextNode::create_paintable() const
|
||||
JS::GCPtr<Painting::Paintable> TextNode::create_paintable() const
|
||||
{
|
||||
return Painting::TextPaintable::create(*this);
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ public:
|
|||
|
||||
void compute_text_for_rendering(bool collapse);
|
||||
|
||||
virtual RefPtr<Painting::Paintable> create_paintable() const override;
|
||||
virtual JS::GCPtr<Painting::Paintable> create_paintable() const override;
|
||||
|
||||
private:
|
||||
virtual bool is_text_node() const final { return true; }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue