mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 09:00:22 +00:00
LibWeb/SVG: SVGSymbolElement includes SVGFitToViewBox
This commit is contained in:
parent
821416027d
commit
6c7089fc9e
Notes:
github-actions[bot]
2024-07-21 11:26:44 +00:00
Author: https://github.com/jamierocks Commit: https://github.com/LadybirdBrowser/ladybird/commit/6c7089fc9e5 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/744
3 changed files with 21 additions and 2 deletions
|
@ -13,6 +13,7 @@
|
|||
#include <LibWeb/DOM/ShadowRoot.h>
|
||||
#include <LibWeb/Layout/SVGGraphicsBox.h>
|
||||
#include <LibWeb/SVG/AttributeNames.h>
|
||||
#include <LibWeb/SVG/SVGAnimatedRect.h>
|
||||
#include <LibWeb/SVG/SVGSymbolElement.h>
|
||||
#include <LibWeb/SVG/SVGUseElement.h>
|
||||
|
||||
|
@ -29,6 +30,13 @@ void SVGSymbolElement::initialize(JS::Realm& realm)
|
|||
{
|
||||
Base::initialize(realm);
|
||||
WEB_SET_PROTOTYPE_FOR_INTERFACE(SVGSymbolElement);
|
||||
m_view_box_for_bindings = heap().allocate<SVGAnimatedRect>(realm, realm);
|
||||
}
|
||||
|
||||
void SVGSymbolElement::visit_edges(Cell::Visitor& visitor)
|
||||
{
|
||||
Base::visit_edges(visitor);
|
||||
visitor.visit(m_view_box_for_bindings);
|
||||
}
|
||||
|
||||
// https://svgwg.org/svg2-draft/struct.html#SymbolNotes
|
||||
|
@ -45,8 +53,14 @@ void SVGSymbolElement::apply_presentational_hints(CSS::StyleProperties& style) c
|
|||
void SVGSymbolElement::attribute_changed(FlyString const& name, Optional<String> const& old_value, Optional<String> const& value)
|
||||
{
|
||||
Base::attribute_changed(name, old_value, value);
|
||||
if (name.equals_ignoring_ascii_case(SVG::AttributeNames::viewBox))
|
||||
if (name.equals_ignoring_ascii_case(SVG::AttributeNames::viewBox)) {
|
||||
m_view_box = try_parse_view_box(value.value_or(String {}));
|
||||
m_view_box_for_bindings->set_nulled(!m_view_box.has_value());
|
||||
if (m_view_box.has_value()) {
|
||||
m_view_box_for_bindings->set_base_val(Gfx::DoubleRect { m_view_box->min_x, m_view_box->min_y, m_view_box->width, m_view_box->height });
|
||||
m_view_box_for_bindings->set_anim_val(Gfx::DoubleRect { m_view_box->min_x, m_view_box->min_y, m_view_box->width, m_view_box->height });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool SVGSymbolElement::is_direct_child_of_use_shadow_tree() const
|
||||
|
|
|
@ -28,10 +28,13 @@ public:
|
|||
return {};
|
||||
}
|
||||
|
||||
JS::NonnullGCPtr<SVGAnimatedRect> view_box_for_bindings() { return *m_view_box_for_bindings; }
|
||||
|
||||
private:
|
||||
SVGSymbolElement(DOM::Document&, DOM::QualifiedName);
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
|
||||
virtual JS::GCPtr<Layout::Node> create_layout_node(NonnullRefPtr<CSS::StyleProperties>) override;
|
||||
|
||||
|
@ -40,6 +43,8 @@ private:
|
|||
virtual void attribute_changed(FlyString const& name, Optional<String> const& old_value, Optional<String> const& value) override;
|
||||
|
||||
Optional<ViewBox> m_view_box;
|
||||
|
||||
JS::GCPtr<SVGAnimatedRect> m_view_box_for_bindings;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -6,4 +6,4 @@ interface SVGSymbolElement : SVGGraphicsElement {
|
|||
|
||||
};
|
||||
|
||||
// FIXME: SVGSymbolElement includes SVGFitToViewBox;
|
||||
SVGSymbolElement includes SVGFitToViewBox;
|
||||
|
|
Loading…
Reference in a new issue