mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 08:27:46 +00:00
LibWeb: Move setting of Web object prototypes to initialize()
This needs to happen before prototype/constructor intitialization can be made lazy. Otherwise, GC could run during the C++ constructor and try to collect the object currently being created.
This commit is contained in:
parent
7bd8fd000f
commit
834202aeb9
339 changed files with 1294 additions and 187 deletions
|
@ -19,14 +19,18 @@ SVGAnimatedLength::SVGAnimatedLength(JS::Realm& realm, JS::NonnullGCPtr<SVGLengt
|
|||
, m_base_val(move(base_val))
|
||||
, m_anim_val(move(anim_val))
|
||||
{
|
||||
set_prototype(&Bindings::cached_web_prototype(realm, "SVGAnimatedLength"));
|
||||
|
||||
// The object referenced by animVal will always be distinct from the one referenced by baseVal, even when the attribute is not animated.
|
||||
VERIFY(m_base_val.ptr() != m_anim_val.ptr());
|
||||
}
|
||||
|
||||
SVGAnimatedLength::~SVGAnimatedLength() = default;
|
||||
|
||||
void SVGAnimatedLength::initialize(JS::Realm& realm)
|
||||
{
|
||||
Base::initialize(realm);
|
||||
set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGAnimatedLengthPrototype>(realm, "SVGAnimatedLength"));
|
||||
}
|
||||
|
||||
void SVGAnimatedLength::visit_edges(Cell::Visitor& visitor)
|
||||
{
|
||||
Base::visit_edges(visitor);
|
||||
|
|
|
@ -25,6 +25,7 @@ public:
|
|||
private:
|
||||
SVGAnimatedLength(JS::Realm&, JS::NonnullGCPtr<SVGLength> base_val, JS::NonnullGCPtr<SVGLength> anim_val);
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
|
||||
JS::NonnullGCPtr<SVGLength> m_base_val;
|
||||
|
|
|
@ -14,7 +14,12 @@ namespace Web::SVG {
|
|||
SVGCircleElement::SVGCircleElement(DOM::Document& document, DOM::QualifiedName qualified_name)
|
||||
: SVGGeometryElement(document, qualified_name)
|
||||
{
|
||||
set_prototype(&Bindings::cached_web_prototype(realm(), "SVGCircleElement"));
|
||||
}
|
||||
|
||||
void SVGCircleElement::initialize(JS::Realm& realm)
|
||||
{
|
||||
Base::initialize(realm);
|
||||
set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGCircleElementPrototype>(realm, "SVGCircleElement"));
|
||||
}
|
||||
|
||||
void SVGCircleElement::parse_attribute(DeprecatedFlyString const& name, DeprecatedString const& value)
|
||||
|
|
|
@ -28,6 +28,8 @@ public:
|
|||
private:
|
||||
SVGCircleElement(DOM::Document&, DOM::QualifiedName);
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
|
||||
Optional<Gfx::Path> m_path;
|
||||
|
||||
Optional<float> m_center_x;
|
||||
|
|
|
@ -12,13 +12,18 @@ namespace Web::SVG {
|
|||
SVGClipPathElement::SVGClipPathElement(DOM::Document& document, DOM::QualifiedName qualified_name)
|
||||
: SVGElement(document, move(qualified_name))
|
||||
{
|
||||
set_prototype(&Bindings::cached_web_prototype(realm(), "SVGClipPathElement"));
|
||||
}
|
||||
|
||||
SVGClipPathElement::~SVGClipPathElement()
|
||||
{
|
||||
}
|
||||
|
||||
void SVGClipPathElement::initialize(JS::Realm& realm)
|
||||
{
|
||||
Base::initialize(realm);
|
||||
set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGClipPathElementPrototype>(realm, "SVGClipPathElement"));
|
||||
}
|
||||
|
||||
JS::GCPtr<Layout::Node> SVGClipPathElement::create_layout_node(NonnullRefPtr<CSS::StyleProperties>)
|
||||
{
|
||||
return nullptr;
|
||||
|
|
|
@ -20,6 +20,8 @@ public:
|
|||
|
||||
private:
|
||||
SVGClipPathElement(DOM::Document&, DOM::QualifiedName);
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -12,13 +12,18 @@ namespace Web::SVG {
|
|||
SVGDefsElement::SVGDefsElement(DOM::Document& document, DOM::QualifiedName qualified_name)
|
||||
: SVGGraphicsElement(document, move(qualified_name))
|
||||
{
|
||||
set_prototype(&Bindings::cached_web_prototype(realm(), "SVGDefsElement"));
|
||||
}
|
||||
|
||||
SVGDefsElement::~SVGDefsElement()
|
||||
{
|
||||
}
|
||||
|
||||
void SVGDefsElement::initialize(JS::Realm& realm)
|
||||
{
|
||||
Base::initialize(realm);
|
||||
set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGDefsElementPrototype>(realm, "SVGDefsElement"));
|
||||
}
|
||||
|
||||
JS::GCPtr<Layout::Node> SVGDefsElement::create_layout_node(NonnullRefPtr<CSS::StyleProperties>)
|
||||
{
|
||||
return nullptr;
|
||||
|
|
|
@ -20,6 +20,8 @@ public:
|
|||
|
||||
private:
|
||||
SVGDefsElement(DOM::Document&, DOM::QualifiedName);
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -14,7 +14,12 @@ SVGElement::SVGElement(DOM::Document& document, DOM::QualifiedName qualified_nam
|
|||
: Element(document, move(qualified_name))
|
||||
, m_dataset(HTML::DOMStringMap::create(*this))
|
||||
{
|
||||
set_prototype(&Bindings::cached_web_prototype(realm(), "SVGElement"));
|
||||
}
|
||||
|
||||
void SVGElement::initialize(JS::Realm& realm)
|
||||
{
|
||||
Base::initialize(realm);
|
||||
set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGElementPrototype>(realm, "SVGElement"));
|
||||
}
|
||||
|
||||
void SVGElement::visit_edges(Cell::Visitor& visitor)
|
||||
|
|
|
@ -22,6 +22,7 @@ public:
|
|||
protected:
|
||||
SVGElement(DOM::Document&, DOM::QualifiedName);
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
|
||||
JS::NonnullGCPtr<HTML::DOMStringMap> m_dataset;
|
||||
|
|
|
@ -14,7 +14,12 @@ namespace Web::SVG {
|
|||
SVGEllipseElement::SVGEllipseElement(DOM::Document& document, DOM::QualifiedName qualified_name)
|
||||
: SVGGeometryElement(document, qualified_name)
|
||||
{
|
||||
set_prototype(&Bindings::cached_web_prototype(realm(), "SVGEllipseElement"));
|
||||
}
|
||||
|
||||
void SVGEllipseElement::initialize(JS::Realm& realm)
|
||||
{
|
||||
Base::initialize(realm);
|
||||
set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGEllipseElementPrototype>(realm, "SVGEllipseElement"));
|
||||
}
|
||||
|
||||
void SVGEllipseElement::parse_attribute(DeprecatedFlyString const& name, DeprecatedString const& value)
|
||||
|
|
|
@ -29,6 +29,8 @@ public:
|
|||
private:
|
||||
SVGEllipseElement(DOM::Document&, DOM::QualifiedName);
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
|
||||
Optional<Gfx::Path> m_path;
|
||||
|
||||
Optional<float> m_center_x;
|
||||
|
|
|
@ -17,7 +17,6 @@ namespace Web::SVG {
|
|||
SVGForeignObjectElement::SVGForeignObjectElement(DOM::Document& document, DOM::QualifiedName qualified_name)
|
||||
: SVGGraphicsElement(document, move(qualified_name))
|
||||
{
|
||||
set_prototype(&Bindings::cached_web_prototype(realm(), "SVGForeignObjectElement"));
|
||||
}
|
||||
|
||||
SVGForeignObjectElement::~SVGForeignObjectElement() = default;
|
||||
|
@ -25,6 +24,7 @@ SVGForeignObjectElement::~SVGForeignObjectElement() = default;
|
|||
void SVGForeignObjectElement::initialize(JS::Realm& realm)
|
||||
{
|
||||
Base::initialize(realm);
|
||||
set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGForeignObjectElementPrototype>(realm, "SVGForeignObjectElement"));
|
||||
|
||||
// FIXME: These never actually get updated!
|
||||
m_x = SVGAnimatedLength::create(realm, SVGLength::create(realm, 0, 0), SVGLength::create(realm, 0, 0));
|
||||
|
|
|
@ -13,7 +13,12 @@ namespace Web::SVG {
|
|||
SVGGeometryElement::SVGGeometryElement(DOM::Document& document, DOM::QualifiedName qualified_name)
|
||||
: SVGGraphicsElement(document, move(qualified_name))
|
||||
{
|
||||
set_prototype(&Bindings::cached_web_prototype(realm(), "SVGGeometryElement"));
|
||||
}
|
||||
|
||||
void SVGGeometryElement::initialize(JS::Realm& realm)
|
||||
{
|
||||
Base::initialize(realm);
|
||||
set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGGeometryElementPrototype>(realm, "SVGGeometryElement"));
|
||||
}
|
||||
|
||||
JS::GCPtr<Layout::Node> SVGGeometryElement::create_layout_node(NonnullRefPtr<CSS::StyleProperties> style)
|
||||
|
|
|
@ -25,6 +25,8 @@ public:
|
|||
|
||||
protected:
|
||||
SVGGeometryElement(DOM::Document& document, DOM::QualifiedName qualified_name);
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -16,7 +16,12 @@ namespace Web::SVG {
|
|||
SVGGraphicsElement::SVGGraphicsElement(DOM::Document& document, DOM::QualifiedName qualified_name)
|
||||
: SVGElement(document, move(qualified_name))
|
||||
{
|
||||
set_prototype(&Bindings::cached_web_prototype(realm(), "SVGGraphicsElement"));
|
||||
}
|
||||
|
||||
void SVGGraphicsElement::initialize(JS::Realm& realm)
|
||||
{
|
||||
Base::initialize(realm);
|
||||
set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGGraphicsElementPrototype>(realm, "SVGGraphicsElement"));
|
||||
}
|
||||
|
||||
void SVGGraphicsElement::apply_presentational_hints(CSS::StyleProperties& style) const
|
||||
|
|
|
@ -26,6 +26,8 @@ public:
|
|||
|
||||
protected:
|
||||
SVGGraphicsElement(DOM::Document&, DOM::QualifiedName);
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -19,7 +19,12 @@ SVGLength::SVGLength(JS::Realm& realm, u8 unit_type, float value)
|
|||
, m_unit_type(unit_type)
|
||||
, m_value(value)
|
||||
{
|
||||
set_prototype(&Bindings::cached_web_prototype(realm, "SVGLength"));
|
||||
}
|
||||
|
||||
void SVGLength::initialize(JS::Realm& realm)
|
||||
{
|
||||
Base::initialize(realm);
|
||||
set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGLengthPrototype>(realm, "SVGLength"));
|
||||
}
|
||||
|
||||
SVGLength::~SVGLength() = default;
|
||||
|
|
|
@ -27,6 +27,8 @@ public:
|
|||
private:
|
||||
SVGLength(JS::Realm&, u8 unit_type, float value);
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
|
||||
u8 m_unit_type { 0 };
|
||||
float m_value { 0 };
|
||||
};
|
||||
|
|
|
@ -14,7 +14,12 @@ namespace Web::SVG {
|
|||
SVGLineElement::SVGLineElement(DOM::Document& document, DOM::QualifiedName qualified_name)
|
||||
: SVGGeometryElement(document, qualified_name)
|
||||
{
|
||||
set_prototype(&Bindings::cached_web_prototype(realm(), "SVGLineElement"));
|
||||
}
|
||||
|
||||
void SVGLineElement::initialize(JS::Realm& realm)
|
||||
{
|
||||
Base::initialize(realm);
|
||||
set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGLineElementPrototype>(realm, "SVGLineElement"));
|
||||
}
|
||||
|
||||
void SVGLineElement::parse_attribute(DeprecatedFlyString const& name, DeprecatedString const& value)
|
||||
|
|
|
@ -29,6 +29,8 @@ public:
|
|||
private:
|
||||
SVGLineElement(DOM::Document&, DOM::QualifiedName);
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
|
||||
Optional<Gfx::Path> m_path;
|
||||
|
||||
Optional<float> m_x1;
|
||||
|
|
|
@ -87,7 +87,12 @@ namespace Web::SVG {
|
|||
SVGPathElement::SVGPathElement(DOM::Document& document, DOM::QualifiedName qualified_name)
|
||||
: SVGGeometryElement(document, move(qualified_name))
|
||||
{
|
||||
set_prototype(&Bindings::cached_web_prototype(realm(), "SVGPathElement"));
|
||||
}
|
||||
|
||||
void SVGPathElement::initialize(JS::Realm& realm)
|
||||
{
|
||||
Base::initialize(realm);
|
||||
set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGPathElementPrototype>(realm, "SVGPathElement"));
|
||||
}
|
||||
|
||||
void SVGPathElement::parse_attribute(DeprecatedFlyString const& name, DeprecatedString const& value)
|
||||
|
|
|
@ -26,6 +26,8 @@ public:
|
|||
private:
|
||||
SVGPathElement(DOM::Document&, DOM::QualifiedName);
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
|
||||
Vector<PathInstruction> m_instructions;
|
||||
Optional<Gfx::Path> m_path;
|
||||
};
|
||||
|
|
|
@ -14,7 +14,12 @@ namespace Web::SVG {
|
|||
SVGPolygonElement::SVGPolygonElement(DOM::Document& document, DOM::QualifiedName qualified_name)
|
||||
: SVGGeometryElement(document, qualified_name)
|
||||
{
|
||||
set_prototype(&Bindings::cached_web_prototype(realm(), "SVGPolygonElement"));
|
||||
}
|
||||
|
||||
void SVGPolygonElement::initialize(JS::Realm& realm)
|
||||
{
|
||||
Base::initialize(realm);
|
||||
set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGPolygonElementPrototype>(realm, "SVGPolygonElement"));
|
||||
}
|
||||
|
||||
void SVGPolygonElement::parse_attribute(DeprecatedFlyString const& name, DeprecatedString const& value)
|
||||
|
|
|
@ -23,6 +23,8 @@ public:
|
|||
private:
|
||||
SVGPolygonElement(DOM::Document&, DOM::QualifiedName);
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
|
||||
Optional<Gfx::Path> m_path;
|
||||
|
||||
Vector<Gfx::FloatPoint> m_points;
|
||||
|
|
|
@ -14,7 +14,12 @@ namespace Web::SVG {
|
|||
SVGPolylineElement::SVGPolylineElement(DOM::Document& document, DOM::QualifiedName qualified_name)
|
||||
: SVGGeometryElement(document, qualified_name)
|
||||
{
|
||||
set_prototype(&Bindings::cached_web_prototype(realm(), "SVGPolylineElement"));
|
||||
}
|
||||
|
||||
void SVGPolylineElement::initialize(JS::Realm& realm)
|
||||
{
|
||||
Base::initialize(realm);
|
||||
set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGPolylineElementPrototype>(realm, "SVGPolylineElement"));
|
||||
}
|
||||
|
||||
void SVGPolylineElement::parse_attribute(DeprecatedFlyString const& name, DeprecatedString const& value)
|
||||
|
|
|
@ -23,6 +23,8 @@ public:
|
|||
private:
|
||||
SVGPolylineElement(DOM::Document&, DOM::QualifiedName);
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
|
||||
Optional<Gfx::Path> m_path;
|
||||
|
||||
Vector<Gfx::FloatPoint> m_points;
|
||||
|
|
|
@ -16,7 +16,12 @@ namespace Web::SVG {
|
|||
SVGRectElement::SVGRectElement(DOM::Document& document, DOM::QualifiedName qualified_name)
|
||||
: SVGGeometryElement(document, qualified_name)
|
||||
{
|
||||
set_prototype(&Bindings::cached_web_prototype(realm(), "SVGRectElement"));
|
||||
}
|
||||
|
||||
void SVGRectElement::initialize(JS::Realm& realm)
|
||||
{
|
||||
Base::initialize(realm);
|
||||
set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGRectElementPrototype>(realm, "SVGRectElement"));
|
||||
}
|
||||
|
||||
void SVGRectElement::parse_attribute(DeprecatedFlyString const& name, DeprecatedString const& value)
|
||||
|
|
|
@ -31,6 +31,8 @@ public:
|
|||
private:
|
||||
SVGRectElement(DOM::Document&, DOM::QualifiedName);
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
|
||||
Gfx::FloatPoint calculate_used_corner_radius_values();
|
||||
|
||||
Optional<Gfx::Path> m_path;
|
||||
|
|
|
@ -20,7 +20,12 @@ namespace Web::SVG {
|
|||
SVGSVGElement::SVGSVGElement(DOM::Document& document, DOM::QualifiedName qualified_name)
|
||||
: SVGGraphicsElement(document, qualified_name)
|
||||
{
|
||||
set_prototype(&Bindings::cached_web_prototype(realm(), "SVGSVGElement"));
|
||||
}
|
||||
|
||||
void SVGSVGElement::initialize(JS::Realm& realm)
|
||||
{
|
||||
Base::initialize(realm);
|
||||
set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGSVGElementPrototype>(realm, "SVGSVGElement"));
|
||||
}
|
||||
|
||||
JS::GCPtr<Layout::Node> SVGSVGElement::create_layout_node(NonnullRefPtr<CSS::StyleProperties> style)
|
||||
|
|
|
@ -28,6 +28,8 @@ public:
|
|||
private:
|
||||
SVGSVGElement(DOM::Document&, DOM::QualifiedName);
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
|
||||
virtual bool is_svg_svg_element() const override { return true; }
|
||||
|
||||
virtual void parse_attribute(DeprecatedFlyString const& name, DeprecatedString const& value) override;
|
||||
|
|
|
@ -15,7 +15,12 @@ namespace Web::SVG {
|
|||
SVGTextContentElement::SVGTextContentElement(DOM::Document& document, DOM::QualifiedName qualified_name)
|
||||
: SVGGraphicsElement(document, move(qualified_name))
|
||||
{
|
||||
set_prototype(&Bindings::cached_web_prototype(realm(), "SVGTextContentElement"));
|
||||
}
|
||||
|
||||
void SVGTextContentElement::initialize(JS::Realm& realm)
|
||||
{
|
||||
Base::initialize(realm);
|
||||
set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGTextContentElementPrototype>(realm, "SVGTextContentElement"));
|
||||
}
|
||||
|
||||
// https://svgwg.org/svg2-draft/text.html#__svg__SVGTextContentElement__getNumberOfChars
|
||||
|
|
|
@ -20,6 +20,8 @@ public:
|
|||
|
||||
protected:
|
||||
SVGTextContentElement(DOM::Document&, DOM::QualifiedName);
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue