mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 13:37:44 +00:00
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.
This commit is contained in:
parent
702cee3d7c
commit
ed84fbce47
58 changed files with 94 additions and 75 deletions
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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()); }
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue