Ver Fonte

LibWeb: Make Paintable ref-counted

This will allow us to use a protective NonnullRefPtr to keep paintables
alive while running arbitrary JavaScript in response to events.
Andreas Kling há 3 anos atrás
pai
commit
ed84fbce47
58 ficheiros alterados com 94 adições e 75 exclusões
  1. 1 1
      Userland/Libraries/LibWeb/Layout/BlockContainer.cpp
  2. 1 1
      Userland/Libraries/LibWeb/Layout/BlockContainer.h
  3. 1 1
      Userland/Libraries/LibWeb/Layout/Box.cpp
  4. 1 1
      Userland/Libraries/LibWeb/Layout/Box.h
  5. 1 1
      Userland/Libraries/LibWeb/Layout/ButtonBox.cpp
  6. 1 1
      Userland/Libraries/LibWeb/Layout/ButtonBox.h
  7. 1 1
      Userland/Libraries/LibWeb/Layout/CanvasBox.cpp
  8. 1 1
      Userland/Libraries/LibWeb/Layout/CanvasBox.h
  9. 1 1
      Userland/Libraries/LibWeb/Layout/CheckBox.cpp
  10. 1 1
      Userland/Libraries/LibWeb/Layout/CheckBox.h
  11. 1 1
      Userland/Libraries/LibWeb/Layout/FrameBox.cpp
  12. 1 1
      Userland/Libraries/LibWeb/Layout/FrameBox.h
  13. 1 1
      Userland/Libraries/LibWeb/Layout/ImageBox.cpp
  14. 1 1
      Userland/Libraries/LibWeb/Layout/ImageBox.h
  15. 1 1
      Userland/Libraries/LibWeb/Layout/InlineNode.cpp
  16. 1 1
      Userland/Libraries/LibWeb/Layout/InlineNode.h
  17. 1 1
      Userland/Libraries/LibWeb/Layout/ListItemMarkerBox.cpp
  18. 1 1
      Userland/Libraries/LibWeb/Layout/ListItemMarkerBox.h
  19. 2 2
      Userland/Libraries/LibWeb/Layout/Node.cpp
  20. 4 3
      Userland/Libraries/LibWeb/Layout/Node.h
  21. 1 1
      Userland/Libraries/LibWeb/Layout/Progress.cpp
  22. 1 1
      Userland/Libraries/LibWeb/Layout/Progress.h
  23. 1 1
      Userland/Libraries/LibWeb/Layout/RadioButton.cpp
  24. 1 1
      Userland/Libraries/LibWeb/Layout/RadioButton.h
  25. 6 1
      Userland/Libraries/LibWeb/Layout/SVGGeometryBox.cpp
  26. 2 0
      Userland/Libraries/LibWeb/Layout/SVGGeometryBox.h
  27. 6 1
      Userland/Libraries/LibWeb/Layout/SVGSVGBox.cpp
  28. 2 0
      Userland/Libraries/LibWeb/Layout/SVGSVGBox.h
  29. 1 1
      Userland/Libraries/LibWeb/Layout/TextNode.cpp
  30. 1 1
      Userland/Libraries/LibWeb/Layout/TextNode.h
  31. 2 2
      Userland/Libraries/LibWeb/Painting/ButtonPaintable.cpp
  32. 1 1
      Userland/Libraries/LibWeb/Painting/ButtonPaintable.h
  33. 2 2
      Userland/Libraries/LibWeb/Painting/CanvasPaintable.cpp
  34. 1 1
      Userland/Libraries/LibWeb/Painting/CanvasPaintable.h
  35. 2 2
      Userland/Libraries/LibWeb/Painting/CheckBoxPaintable.cpp
  36. 1 1
      Userland/Libraries/LibWeb/Painting/CheckBoxPaintable.h
  37. 2 2
      Userland/Libraries/LibWeb/Painting/ImagePaintable.cpp
  38. 1 1
      Userland/Libraries/LibWeb/Painting/ImagePaintable.h
  39. 2 2
      Userland/Libraries/LibWeb/Painting/InlinePaintable.cpp
  40. 1 1
      Userland/Libraries/LibWeb/Painting/InlinePaintable.h
  41. 2 2
      Userland/Libraries/LibWeb/Painting/MarkerPaintable.cpp
  42. 1 1
      Userland/Libraries/LibWeb/Painting/MarkerPaintable.h
  43. 2 2
      Userland/Libraries/LibWeb/Painting/NestedBrowsingContextPaintable.cpp
  44. 1 1
      Userland/Libraries/LibWeb/Painting/NestedBrowsingContextPaintable.h
  45. 2 2
      Userland/Libraries/LibWeb/Painting/Paintable.cpp
  46. 4 4
      Userland/Libraries/LibWeb/Painting/Paintable.h
  47. 2 2
      Userland/Libraries/LibWeb/Painting/ProgressPaintable.cpp
  48. 1 1
      Userland/Libraries/LibWeb/Painting/ProgressPaintable.h
  49. 2 2
      Userland/Libraries/LibWeb/Painting/RadioButtonPaintable.cpp
  50. 1 1
      Userland/Libraries/LibWeb/Painting/RadioButtonPaintable.h
  51. 2 2
      Userland/Libraries/LibWeb/Painting/SVGGeometryPaintable.cpp
  52. 1 1
      Userland/Libraries/LibWeb/Painting/SVGGeometryPaintable.h
  53. 0 2
      Userland/Libraries/LibWeb/Painting/SVGGraphicsPaintable.h
  54. 0 2
      Userland/Libraries/LibWeb/Painting/SVGPaintable.h
  55. 5 0
      Userland/Libraries/LibWeb/Painting/SVGSVGPaintable.cpp
  56. 1 1
      Userland/Libraries/LibWeb/Painting/SVGSVGPaintable.h
  57. 5 2
      Userland/Libraries/LibWeb/Painting/TextPaintable.cpp
  58. 1 1
      Userland/Libraries/LibWeb/Painting/TextPaintable.h

+ 1 - 1
Userland/Libraries/LibWeb/Layout/BlockContainer.cpp

@@ -85,7 +85,7 @@ Painting::PaintableWithLines const* BlockContainer::paint_box() const
     return static_cast<Painting::PaintableWithLines const*>(Box::paint_box());
 }
 
-OwnPtr<Painting::Paintable> BlockContainer::create_paintable() const
+RefPtr<Painting::Paintable> BlockContainer::create_paintable() const
 {
     return Painting::PaintableWithLines::create(*this);
 }

+ 1 - 1
Userland/Libraries/LibWeb/Layout/BlockContainer.h

@@ -31,7 +31,7 @@ public:
 
     Painting::PaintableWithLines const* paint_box() const;
 
-    virtual OwnPtr<Painting::Paintable> create_paintable() const override;
+    virtual RefPtr<Painting::Paintable> create_paintable() const override;
 
 private:
     virtual bool is_block_container() const final { return true; }

+ 1 - 1
Userland/Libraries/LibWeb/Layout/Box.cpp

@@ -86,7 +86,7 @@ bool Box::is_body() const
     return dom_node() && dom_node() == document().body();
 }
 
-OwnPtr<Painting::Paintable> Box::create_paintable() const
+RefPtr<Painting::Paintable> Box::create_paintable() const
 {
     return Painting::PaintableBox::create(*this);
 }

+ 1 - 1
Userland/Libraries/LibWeb/Layout/Box.h

@@ -41,7 +41,7 @@ public:
 
     virtual void did_set_rect() { }
 
-    virtual OwnPtr<Painting::Paintable> create_paintable() const override;
+    virtual RefPtr<Painting::Paintable> create_paintable() const override;
 
 protected:
     Box(DOM::Document&, DOM::Node*, NonnullRefPtr<CSS::StyleProperties>);

+ 1 - 1
Userland/Libraries/LibWeb/Layout/ButtonBox.cpp

@@ -106,7 +106,7 @@ void ButtonBox::handle_associated_label_mousemove(Badge<Label>, bool is_inside_n
     set_needs_display();
 }
 
-OwnPtr<Painting::Paintable> ButtonBox::create_paintable() const
+RefPtr<Painting::Paintable> ButtonBox::create_paintable() const
 {
     return Painting::ButtonPaintable::create(*this);
 }

+ 1 - 1
Userland/Libraries/LibWeb/Layout/ButtonBox.h

@@ -23,7 +23,7 @@ public:
 
     bool being_pressed() const { return m_being_pressed; }
 
-    virtual OwnPtr<Painting::Paintable> create_paintable() const override;
+    virtual RefPtr<Painting::Paintable> create_paintable() const override;
 
 private:
     virtual bool wants_mouse_events() const override { return true; }

+ 1 - 1
Userland/Libraries/LibWeb/Layout/CanvasBox.cpp

@@ -25,7 +25,7 @@ void CanvasBox::prepare_for_replaced_layout()
     set_intrinsic_height(dom_node().height());
 }
 
-OwnPtr<Painting::Paintable> CanvasBox::create_paintable() const
+RefPtr<Painting::Paintable> CanvasBox::create_paintable() const
 {
     return Painting::CanvasPaintable::create(*this);
 }

+ 1 - 1
Userland/Libraries/LibWeb/Layout/CanvasBox.h

@@ -20,7 +20,7 @@ public:
 
     const HTML::HTMLCanvasElement& dom_node() const { return static_cast<const HTML::HTMLCanvasElement&>(ReplacedBox::dom_node()); }
 
-    virtual OwnPtr<Painting::Paintable> create_paintable() const override;
+    virtual RefPtr<Painting::Paintable> create_paintable() const override;
 };
 
 }

+ 1 - 1
Userland/Libraries/LibWeb/Layout/CheckBox.cpp

@@ -108,7 +108,7 @@ void CheckBox::handle_associated_label_mousemove(Badge<Label>, bool is_inside_no
     set_needs_display();
 }
 
-OwnPtr<Painting::Paintable> CheckBox::create_paintable() const
+RefPtr<Painting::Paintable> CheckBox::create_paintable() const
 {
     return Painting::CheckBoxPaintable::create(*this);
 }

+ 1 - 1
Userland/Libraries/LibWeb/Layout/CheckBox.h

@@ -21,7 +21,7 @@ public:
 
     bool being_pressed() const { return m_being_pressed; }
 
-    virtual OwnPtr<Painting::Paintable> create_paintable() const override;
+    virtual RefPtr<Painting::Paintable> create_paintable() const override;
 
 private:
     virtual bool wants_mouse_events() const override { return true; }

+ 1 - 1
Userland/Libraries/LibWeb/Layout/FrameBox.cpp

@@ -40,7 +40,7 @@ void FrameBox::did_set_rect()
     dom_node().nested_browsing_context()->set_size(paint_box()->content_size().to_type<int>());
 }
 
-OwnPtr<Painting::Paintable> FrameBox::create_paintable() const
+RefPtr<Painting::Paintable> FrameBox::create_paintable() const
 {
     return Painting::NestedBrowsingContextPaintable::create(*this);
 }

+ 1 - 1
Userland/Libraries/LibWeb/Layout/FrameBox.h

@@ -21,7 +21,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 OwnPtr<Painting::Paintable> create_paintable() const override;
+    virtual RefPtr<Painting::Paintable> create_paintable() const override;
 
 private:
     virtual void did_set_rect() override;

+ 1 - 1
Userland/Libraries/LibWeb/Layout/ImageBox.cpp

@@ -84,7 +84,7 @@ void ImageBox::browsing_context_did_set_viewport_rect(Gfx::IntRect const& viewpo
     m_image_loader.set_visible_in_viewport(viewport_rect.to_type<float>().intersects(paint_box()->absolute_rect()));
 }
 
-OwnPtr<Painting::Paintable> ImageBox::create_paintable() const
+RefPtr<Painting::Paintable> ImageBox::create_paintable() const
 {
     return Painting::ImagePaintable::create(*this);
 }

+ 1 - 1
Userland/Libraries/LibWeb/Layout/ImageBox.h

@@ -25,7 +25,7 @@ public:
 
     bool renders_as_alt_text() const;
 
-    virtual OwnPtr<Painting::Paintable> create_paintable() const override;
+    virtual RefPtr<Painting::Paintable> create_paintable() const override;
 
     auto const& image_loader() const { return m_image_loader; }
 

+ 1 - 1
Userland/Libraries/LibWeb/Layout/InlineNode.cpp

@@ -25,7 +25,7 @@ InlineNode::~InlineNode()
 {
 }
 
-OwnPtr<Painting::Paintable> InlineNode::create_paintable() const
+RefPtr<Painting::Paintable> InlineNode::create_paintable() const
 {
     return Painting::InlinePaintable::create(*this);
 }

+ 1 - 1
Userland/Libraries/LibWeb/Layout/InlineNode.h

@@ -15,7 +15,7 @@ public:
     InlineNode(DOM::Document&, DOM::Element*, NonnullRefPtr<CSS::StyleProperties>);
     virtual ~InlineNode() override;
 
-    virtual OwnPtr<Painting::Paintable> create_paintable() const override;
+    virtual RefPtr<Painting::Paintable> create_paintable() const override;
 };
 
 }

+ 1 - 1
Userland/Libraries/LibWeb/Layout/ListItemMarkerBox.cpp

@@ -60,7 +60,7 @@ Gfx::Bitmap const* ListItemMarkerBox::list_style_image_bitmap() const
     return list_style_image() ? list_style_image()->bitmap() : nullptr;
 }
 
-OwnPtr<Painting::Paintable> ListItemMarkerBox::create_paintable() const
+RefPtr<Painting::Paintable> ListItemMarkerBox::create_paintable() const
 {
     return Painting::MarkerPaintable::create(*this);
 }

+ 1 - 1
Userland/Libraries/LibWeb/Layout/ListItemMarkerBox.h

@@ -19,7 +19,7 @@ public:
     Gfx::Bitmap const* list_style_image_bitmap() const;
     String const& text() const { return m_text; }
 
-    virtual OwnPtr<Painting::Paintable> create_paintable() const override;
+    virtual RefPtr<Painting::Paintable> create_paintable() const override;
 
     CSS::ListStyleType list_style_type() const { return m_list_style_type; }
 

+ 2 - 2
Userland/Libraries/LibWeb/Layout/Node.cpp

@@ -584,12 +584,12 @@ NonnullRefPtr<NodeWithStyle> NodeWithStyle::create_anonymous_wrapper() const
     return wrapper;
 }
 
-void Node::set_paintable(OwnPtr<Painting::Paintable> paintable)
+void Node::set_paintable(RefPtr<Painting::Paintable> paintable)
 {
     m_paintable = move(paintable);
 }
 
-OwnPtr<Painting::Paintable> Node::create_paintable() const
+RefPtr<Painting::Paintable> Node::create_paintable() const
 {
     return nullptr;
 }

+ 4 - 3
Userland/Libraries/LibWeb/Layout/Node.h

@@ -54,10 +54,11 @@ public:
     const DOM::Node* dom_node() const { return m_dom_node; }
     DOM::Node* dom_node() { return m_dom_node; }
 
+    Painting::Paintable* paintable() { return m_paintable; }
     Painting::Paintable const* paintable() const { return m_paintable; }
-    void set_paintable(OwnPtr<Painting::Paintable>);
+    void set_paintable(RefPtr<Painting::Paintable>);
 
-    virtual OwnPtr<Painting::Paintable> create_paintable() const;
+    virtual RefPtr<Painting::Paintable> create_paintable() const;
 
     DOM::Document& document() { return m_document; }
     const DOM::Document& document() const { return m_document; }
@@ -224,7 +225,7 @@ private:
 
     NonnullRefPtr<DOM::Document> m_document;
     RefPtr<DOM::Node> m_dom_node;
-    OwnPtr<Painting::Paintable> m_paintable;
+    RefPtr<Painting::Paintable> m_paintable;
 
     bool m_inline { false };
     bool m_has_style { false };

+ 1 - 1
Userland/Libraries/LibWeb/Layout/Progress.cpp

@@ -21,7 +21,7 @@ Progress::~Progress()
 {
 }
 
-OwnPtr<Painting::Paintable> Progress::create_paintable() const
+RefPtr<Painting::Paintable> Progress::create_paintable() const
 {
     return Painting::ProgressPaintable::create(*this);
 }

+ 1 - 1
Userland/Libraries/LibWeb/Layout/Progress.h

@@ -19,7 +19,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 OwnPtr<Painting::Paintable> create_paintable() const override;
+    virtual RefPtr<Painting::Paintable> create_paintable() const override;
 };
 
 }

+ 1 - 1
Userland/Libraries/LibWeb/Layout/RadioButton.cpp

@@ -114,7 +114,7 @@ void RadioButton::set_checked_within_group()
     });
 }
 
-OwnPtr<Painting::Paintable> RadioButton::create_paintable() const
+RefPtr<Painting::Paintable> RadioButton::create_paintable() const
 {
     return Painting::RadioButtonPaintable::create(*this);
 }

+ 1 - 1
Userland/Libraries/LibWeb/Layout/RadioButton.h

@@ -19,7 +19,7 @@ public:
     const HTML::HTMLInputElement& dom_node() const { return static_cast<const HTML::HTMLInputElement&>(LabelableNode::dom_node()); }
     HTML::HTMLInputElement& dom_node() { return static_cast<HTML::HTMLInputElement&>(LabelableNode::dom_node()); }
 
-    virtual OwnPtr<Painting::Paintable> create_paintable() const override;
+    virtual RefPtr<Painting::Paintable> create_paintable() const override;
 
     bool being_pressed() const { return m_being_pressed; }
 

+ 6 - 1
Userland/Libraries/LibWeb/Layout/SVGGeometryBox.cpp

@@ -8,7 +8,7 @@
 #include <LibGfx/AntiAliasingPainter.h>
 #include <LibGfx/Painter.h>
 #include <LibWeb/Layout/SVGGeometryBox.h>
-#include <LibWeb/Painting/Paintable.h>
+#include <LibWeb/Painting/SVGGeometryPaintable.h>
 #include <LibWeb/SVG/SVGPathElement.h>
 #include <LibWeb/SVG/SVGSVGElement.h>
 
@@ -47,4 +47,9 @@ Gfx::FloatPoint 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
+{
+    return Painting::SVGGeometryPaintable::create(*this);
+}
+
 }

+ 2 - 0
Userland/Libraries/LibWeb/Layout/SVGGeometryBox.h

@@ -22,6 +22,8 @@ public:
     float viewbox_scaling() const;
     Gfx::FloatPoint viewbox_origin() const;
 
+    virtual RefPtr<Painting::Paintable> create_paintable() const override;
+
 private:
     virtual bool is_svg_geometry_box() const final { return true; }
 };

+ 6 - 1
Userland/Libraries/LibWeb/Layout/SVGSVGBox.cpp

@@ -5,7 +5,7 @@
  */
 
 #include <LibWeb/Layout/SVGSVGBox.h>
-#include <LibWeb/Painting/Paintable.h>
+#include <LibWeb/Painting/SVGSVGPaintable.h>
 
 namespace Web::Layout {
 
@@ -14,4 +14,9 @@ SVGSVGBox::SVGSVGBox(DOM::Document& document, SVG::SVGSVGElement& element, Nonnu
 {
 }
 
+RefPtr<Painting::Paintable> SVGSVGBox::create_paintable() const
+{
+    return Painting::SVGSVGPaintable::create(*this);
+}
+
 }

+ 2 - 0
Userland/Libraries/LibWeb/Layout/SVGSVGBox.h

@@ -19,6 +19,8 @@ public:
     SVG::SVGSVGElement& dom_node() { return verify_cast<SVG::SVGSVGElement>(SVGGraphicsBox::dom_node()); }
 
     virtual bool can_have_children() const override { return true; }
+
+    virtual RefPtr<Painting::Paintable> create_paintable() const override;
 };
 
 }

+ 1 - 1
Userland/Libraries/LibWeb/Layout/TextNode.cpp

@@ -367,7 +367,7 @@ Optional<TextNode::Chunk> TextNode::ChunkIterator::try_commit_chunk(Utf8View::It
     return {};
 }
 
-OwnPtr<Painting::Paintable> TextNode::create_paintable() const
+RefPtr<Painting::Paintable> TextNode::create_paintable() const
 {
     return Painting::TextPaintable::create(*this);
 }

+ 1 - 1
Userland/Libraries/LibWeb/Layout/TextNode.h

@@ -52,7 +52,7 @@ public:
 
     void compute_text_for_rendering(bool collapse, bool previous_is_empty_or_ends_in_whitespace);
 
-    virtual OwnPtr<Painting::Paintable> create_paintable() const override;
+    virtual RefPtr<Painting::Paintable> create_paintable() const override;
 
 private:
     virtual bool is_text_node() const final { return true; }

+ 2 - 2
Userland/Libraries/LibWeb/Painting/ButtonPaintable.cpp

@@ -10,9 +10,9 @@
 
 namespace Web::Painting {
 
-NonnullOwnPtr<ButtonPaintable> ButtonPaintable::create(Layout::ButtonBox const& layout_box)
+NonnullRefPtr<ButtonPaintable> ButtonPaintable::create(Layout::ButtonBox const& layout_box)
 {
-    return adopt_own(*new ButtonPaintable(layout_box));
+    return adopt_ref(*new ButtonPaintable(layout_box));
 }
 
 ButtonPaintable::ButtonPaintable(Layout::ButtonBox const& layout_box)

+ 1 - 1
Userland/Libraries/LibWeb/Painting/ButtonPaintable.h

@@ -13,7 +13,7 @@ namespace Web::Painting {
 
 class ButtonPaintable final : public PaintableBox {
 public:
-    static NonnullOwnPtr<ButtonPaintable> create(Layout::ButtonBox const&);
+    static NonnullRefPtr<ButtonPaintable> create(Layout::ButtonBox const&);
 
     virtual void paint(PaintContext&, PaintPhase) const override;
 

+ 2 - 2
Userland/Libraries/LibWeb/Painting/CanvasPaintable.cpp

@@ -8,9 +8,9 @@
 
 namespace Web::Painting {
 
-NonnullOwnPtr<CanvasPaintable> CanvasPaintable::create(Layout::CanvasBox const& layout_box)
+NonnullRefPtr<CanvasPaintable> CanvasPaintable::create(Layout::CanvasBox const& layout_box)
 {
-    return adopt_own(*new CanvasPaintable(layout_box));
+    return adopt_ref(*new CanvasPaintable(layout_box));
 }
 
 CanvasPaintable::CanvasPaintable(Layout::CanvasBox const& layout_box)

+ 1 - 1
Userland/Libraries/LibWeb/Painting/CanvasPaintable.h

@@ -13,7 +13,7 @@ namespace Web::Painting {
 
 class CanvasPaintable final : public PaintableBox {
 public:
-    static NonnullOwnPtr<CanvasPaintable> create(Layout::CanvasBox const&);
+    static NonnullRefPtr<CanvasPaintable> create(Layout::CanvasBox const&);
 
     virtual void paint(PaintContext&, PaintPhase) const override;
 

+ 2 - 2
Userland/Libraries/LibWeb/Painting/CheckBoxPaintable.cpp

@@ -11,9 +11,9 @@
 
 namespace Web::Painting {
 
-NonnullOwnPtr<CheckBoxPaintable> CheckBoxPaintable::create(Layout::CheckBox const& layout_box)
+NonnullRefPtr<CheckBoxPaintable> CheckBoxPaintable::create(Layout::CheckBox const& layout_box)
 {
-    return adopt_own(*new CheckBoxPaintable(layout_box));
+    return adopt_ref(*new CheckBoxPaintable(layout_box));
 }
 
 CheckBoxPaintable::CheckBoxPaintable(Layout::CheckBox const& layout_box)

+ 1 - 1
Userland/Libraries/LibWeb/Painting/CheckBoxPaintable.h

@@ -13,7 +13,7 @@ namespace Web::Painting {
 
 class CheckBoxPaintable final : public PaintableBox {
 public:
-    static NonnullOwnPtr<CheckBoxPaintable> create(Layout::CheckBox const&);
+    static NonnullRefPtr<CheckBoxPaintable> create(Layout::CheckBox const&);
 
     virtual void paint(PaintContext&, PaintPhase) const override;
 

+ 2 - 2
Userland/Libraries/LibWeb/Painting/ImagePaintable.cpp

@@ -11,9 +11,9 @@
 
 namespace Web::Painting {
 
-NonnullOwnPtr<ImagePaintable> ImagePaintable::create(Layout::ImageBox const& layout_box)
+NonnullRefPtr<ImagePaintable> ImagePaintable::create(Layout::ImageBox const& layout_box)
 {
-    return adopt_own(*new ImagePaintable(layout_box));
+    return adopt_ref(*new ImagePaintable(layout_box));
 }
 
 ImagePaintable::ImagePaintable(Layout::ImageBox const& layout_box)

+ 1 - 1
Userland/Libraries/LibWeb/Painting/ImagePaintable.h

@@ -13,7 +13,7 @@ namespace Web::Painting {
 
 class ImagePaintable final : public PaintableBox {
 public:
-    static NonnullOwnPtr<ImagePaintable> create(Layout::ImageBox const&);
+    static NonnullRefPtr<ImagePaintable> create(Layout::ImageBox const&);
 
     virtual void paint(PaintContext&, PaintPhase) const override;
 

+ 2 - 2
Userland/Libraries/LibWeb/Painting/InlinePaintable.cpp

@@ -14,9 +14,9 @@
 
 namespace Web::Painting {
 
-NonnullOwnPtr<InlinePaintable> InlinePaintable::create(Layout::InlineNode const& layout_node)
+NonnullRefPtr<InlinePaintable> InlinePaintable::create(Layout::InlineNode const& layout_node)
 {
-    return adopt_own(*new InlinePaintable(layout_node));
+    return adopt_ref(*new InlinePaintable(layout_node));
 }
 
 InlinePaintable::InlinePaintable(Layout::InlineNode const& layout_node)

+ 1 - 1
Userland/Libraries/LibWeb/Painting/InlinePaintable.h

@@ -13,7 +13,7 @@ namespace Web::Painting {
 
 class InlinePaintable final : public Paintable {
 public:
-    static NonnullOwnPtr<InlinePaintable> create(Layout::InlineNode const&);
+    static NonnullRefPtr<InlinePaintable> create(Layout::InlineNode const&);
 
     virtual void paint(PaintContext&, PaintPhase) const override;
 

+ 2 - 2
Userland/Libraries/LibWeb/Painting/MarkerPaintable.cpp

@@ -10,9 +10,9 @@
 
 namespace Web::Painting {
 
-NonnullOwnPtr<MarkerPaintable> MarkerPaintable::create(Layout::ListItemMarkerBox const& layout_box)
+NonnullRefPtr<MarkerPaintable> MarkerPaintable::create(Layout::ListItemMarkerBox const& layout_box)
 {
-    return adopt_own(*new MarkerPaintable(layout_box));
+    return adopt_ref(*new MarkerPaintable(layout_box));
 }
 
 MarkerPaintable::MarkerPaintable(Layout::ListItemMarkerBox const& layout_box)

+ 1 - 1
Userland/Libraries/LibWeb/Painting/MarkerPaintable.h

@@ -13,7 +13,7 @@ namespace Web::Painting {
 
 class MarkerPaintable final : public PaintableBox {
 public:
-    static NonnullOwnPtr<MarkerPaintable> create(Layout::ListItemMarkerBox const&);
+    static NonnullRefPtr<MarkerPaintable> create(Layout::ListItemMarkerBox const&);
 
     virtual void paint(PaintContext&, PaintPhase) const override;
 

+ 2 - 2
Userland/Libraries/LibWeb/Painting/NestedBrowsingContextPaintable.cpp

@@ -12,9 +12,9 @@
 
 namespace Web::Painting {
 
-NonnullOwnPtr<NestedBrowsingContextPaintable> NestedBrowsingContextPaintable::create(Layout::FrameBox const& layout_box)
+NonnullRefPtr<NestedBrowsingContextPaintable> NestedBrowsingContextPaintable::create(Layout::FrameBox const& layout_box)
 {
-    return adopt_own(*new NestedBrowsingContextPaintable(layout_box));
+    return adopt_ref(*new NestedBrowsingContextPaintable(layout_box));
 }
 
 NestedBrowsingContextPaintable::NestedBrowsingContextPaintable(Layout::FrameBox const& layout_box)

+ 1 - 1
Userland/Libraries/LibWeb/Painting/NestedBrowsingContextPaintable.h

@@ -13,7 +13,7 @@ namespace Web::Painting {
 
 class NestedBrowsingContextPaintable final : public PaintableBox {
 public:
-    static NonnullOwnPtr<NestedBrowsingContextPaintable> create(Layout::FrameBox const&);
+    static NonnullRefPtr<NestedBrowsingContextPaintable> create(Layout::FrameBox const&);
 
     virtual void paint(PaintContext&, PaintPhase) const override;
 

+ 2 - 2
Userland/Libraries/LibWeb/Painting/Paintable.cpp

@@ -13,9 +13,9 @@
 
 namespace Web::Painting {
 
-NonnullOwnPtr<PaintableBox> PaintableBox::create(Layout::Box const& layout_box)
+NonnullRefPtr<PaintableBox> PaintableBox::create(Layout::Box const& layout_box)
 {
-    return adopt_own(*new PaintableBox(layout_box));
+    return adopt_ref(*new PaintableBox(layout_box));
 }
 
 PaintableBox::PaintableBox(Layout::Box const& layout_box)

+ 4 - 4
Userland/Libraries/LibWeb/Painting/Paintable.h

@@ -14,7 +14,7 @@
 
 namespace Web::Painting {
 
-class Paintable {
+class Paintable : public RefCounted<Paintable> {
     AK_MAKE_NONMOVABLE(Paintable);
     AK_MAKE_NONCOPYABLE(Paintable);
 
@@ -40,7 +40,7 @@ private:
 
 class PaintableBox : public Paintable {
 public:
-    static NonnullOwnPtr<PaintableBox> create(Layout::Box const&);
+    static NonnullRefPtr<PaintableBox> create(Layout::Box const&);
     virtual ~PaintableBox();
 
     virtual void paint(PaintContext&, PaintPhase) const override;
@@ -154,9 +154,9 @@ private:
 
 class PaintableWithLines : public PaintableBox {
 public:
-    static NonnullOwnPtr<PaintableWithLines> create(Layout::BlockContainer const& block_container)
+    static NonnullRefPtr<PaintableWithLines> create(Layout::BlockContainer const& block_container)
     {
-        return adopt_own(*new PaintableWithLines(block_container));
+        return adopt_ref(*new PaintableWithLines(block_container));
     }
     virtual ~PaintableWithLines() override;
 

+ 2 - 2
Userland/Libraries/LibWeb/Painting/ProgressPaintable.cpp

@@ -9,9 +9,9 @@
 
 namespace Web::Painting {
 
-NonnullOwnPtr<ProgressPaintable> ProgressPaintable::create(Layout::Progress const& layout_box)
+NonnullRefPtr<ProgressPaintable> ProgressPaintable::create(Layout::Progress const& layout_box)
 {
-    return adopt_own(*new ProgressPaintable(layout_box));
+    return adopt_ref(*new ProgressPaintable(layout_box));
 }
 
 ProgressPaintable::ProgressPaintable(Layout::Progress const& layout_box)

+ 1 - 1
Userland/Libraries/LibWeb/Painting/ProgressPaintable.h

@@ -13,7 +13,7 @@ namespace Web::Painting {
 
 class ProgressPaintable final : public PaintableBox {
 public:
-    static NonnullOwnPtr<ProgressPaintable> create(Layout::Progress const&);
+    static NonnullRefPtr<ProgressPaintable> create(Layout::Progress const&);
 
     virtual void paint(PaintContext&, PaintPhase) const override;
 

+ 2 - 2
Userland/Libraries/LibWeb/Painting/RadioButtonPaintable.cpp

@@ -11,9 +11,9 @@
 
 namespace Web::Painting {
 
-NonnullOwnPtr<RadioButtonPaintable> RadioButtonPaintable::create(Layout::RadioButton const& layout_box)
+NonnullRefPtr<RadioButtonPaintable> RadioButtonPaintable::create(Layout::RadioButton const& layout_box)
 {
-    return adopt_own(*new RadioButtonPaintable(layout_box));
+    return adopt_ref(*new RadioButtonPaintable(layout_box));
 }
 
 RadioButtonPaintable::RadioButtonPaintable(Layout::RadioButton const& layout_box)

+ 1 - 1
Userland/Libraries/LibWeb/Painting/RadioButtonPaintable.h

@@ -13,7 +13,7 @@ namespace Web::Painting {
 
 class RadioButtonPaintable final : public PaintableBox {
 public:
-    static NonnullOwnPtr<RadioButtonPaintable> create(Layout::RadioButton const&);
+    static NonnullRefPtr<RadioButtonPaintable> create(Layout::RadioButton const&);
 
     virtual void paint(PaintContext&, PaintPhase) const override;
 

+ 2 - 2
Userland/Libraries/LibWeb/Painting/SVGGeometryPaintable.cpp

@@ -11,9 +11,9 @@
 
 namespace Web::Painting {
 
-NonnullOwnPtr<SVGGeometryPaintable> SVGGeometryPaintable::create(Layout::SVGGeometryBox const& layout_box)
+NonnullRefPtr<SVGGeometryPaintable> SVGGeometryPaintable::create(Layout::SVGGeometryBox const& layout_box)
 {
-    return adopt_own(*new SVGGeometryPaintable(layout_box));
+    return adopt_ref(*new SVGGeometryPaintable(layout_box));
 }
 
 SVGGeometryPaintable::SVGGeometryPaintable(Layout::SVGGeometryBox const& layout_box)

+ 1 - 1
Userland/Libraries/LibWeb/Painting/SVGGeometryPaintable.h

@@ -13,7 +13,7 @@ namespace Web::Painting {
 
 class SVGGeometryPaintable : public SVGGraphicsPaintable {
 public:
-    static NonnullOwnPtr<SVGGeometryPaintable> create(Layout::SVGGeometryBox const&);
+    static NonnullRefPtr<SVGGeometryPaintable> create(Layout::SVGGeometryBox const&);
 
     virtual void paint(PaintContext&, PaintPhase) const override;
 

+ 0 - 2
Userland/Libraries/LibWeb/Painting/SVGGraphicsPaintable.h

@@ -13,8 +13,6 @@ namespace Web::Painting {
 
 class SVGGraphicsPaintable : public SVGPaintable {
 public:
-    static NonnullOwnPtr<SVGGraphicsPaintable> create(Layout::SVGGraphicsBox const&);
-
     virtual void before_children_paint(PaintContext&, PaintPhase) const override;
 
     Layout::SVGGraphicsBox const& layout_box() const;

+ 0 - 2
Userland/Libraries/LibWeb/Painting/SVGPaintable.h

@@ -13,8 +13,6 @@ namespace Web::Painting {
 
 class SVGPaintable : public PaintableBox {
 public:
-    static NonnullOwnPtr<SVGPaintable> create(Layout::SVGBox const&);
-
     virtual void before_children_paint(PaintContext&, PaintPhase) const override;
     virtual void after_children_paint(PaintContext&, PaintPhase) const override;
 

+ 5 - 0
Userland/Libraries/LibWeb/Painting/SVGSVGPaintable.cpp

@@ -9,6 +9,11 @@
 
 namespace Web::Painting {
 
+NonnullRefPtr<SVGSVGPaintable> SVGSVGPaintable::create(Layout::SVGSVGBox const& layout_box)
+{
+    return adopt_ref(*new SVGSVGPaintable(layout_box));
+}
+
 SVGSVGPaintable::SVGSVGPaintable(Layout::SVGSVGBox const& layout_box)
     : SVGGraphicsPaintable(layout_box)
 {

+ 1 - 1
Userland/Libraries/LibWeb/Painting/SVGSVGPaintable.h

@@ -13,7 +13,7 @@ namespace Web::Painting {
 
 class SVGSVGPaintable : public SVGGraphicsPaintable {
 public:
-    static NonnullOwnPtr<SVGSVGPaintable> create(Layout::SVGSVGBox const&);
+    static NonnullRefPtr<SVGSVGPaintable> create(Layout::SVGSVGBox const&);
 
     virtual void before_children_paint(PaintContext&, PaintPhase) const override;
     virtual void after_children_paint(PaintContext&, PaintPhase) const override;

+ 5 - 2
Userland/Libraries/LibWeb/Painting/TextPaintable.cpp

@@ -4,13 +4,16 @@
  * SPDX-License-Identifier: BSD-2-Clause
  */
 
+#include <LibWeb/HTML/BrowsingContext.h>
+#include <LibWeb/Layout/Label.h>
+#include <LibWeb/Page/EventHandler.h>
 #include <LibWeb/Painting/TextPaintable.h>
 
 namespace Web::Painting {
 
-NonnullOwnPtr<TextPaintable> TextPaintable::create(Layout::TextNode const& layout_node)
+NonnullRefPtr<TextPaintable> TextPaintable::create(Layout::TextNode const& layout_node)
 {
-    return adopt_own(*new TextPaintable(layout_node));
+    return adopt_ref(*new TextPaintable(layout_node));
 }
 
 TextPaintable::TextPaintable(Layout::TextNode const& layout_node)

+ 1 - 1
Userland/Libraries/LibWeb/Painting/TextPaintable.h

@@ -12,7 +12,7 @@ namespace Web::Painting {
 
 class TextPaintable : public Paintable {
 public:
-    static NonnullOwnPtr<TextPaintable> create(Layout::TextNode const&);
+    static NonnullRefPtr<TextPaintable> create(Layout::TextNode const&);
 
     Layout::TextNode const& layout_node() const { return static_cast<Layout::TextNode const&>(Paintable::layout_node()); }