/* * Copyright (c) 2022, Andreas Kling * * SPDX-License-Identifier: BSD-2-Clause */ #include #include #include #include #include #include #include #include namespace Web::SVG { SVGForeignObjectElement::SVGForeignObjectElement(DOM::Document& document, DOM::QualifiedName qualified_name) : SVGGraphicsElement(document, move(qualified_name)) { } SVGForeignObjectElement::~SVGForeignObjectElement() = default; JS::ThrowCompletionOr SVGForeignObjectElement::initialize(JS::Realm& realm) { auto& vm = realm.vm(); MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype(realm, "SVGForeignObjectElement")); // FIXME: These never actually get updated! m_x = TRY(Bindings::throw_dom_exception_if_needed(vm, [&]() -> WebIDL::ExceptionOr> { return SVGAnimatedLength::create(realm, TRY(SVGLength::create(realm, 0, 0)), TRY(SVGLength::create(realm, 0, 0))); })); m_y = TRY(Bindings::throw_dom_exception_if_needed(vm, [&]() -> WebIDL::ExceptionOr> { return SVGAnimatedLength::create(realm, TRY(SVGLength::create(realm, 0, 0)), TRY(SVGLength::create(realm, 0, 0))); })); m_width = TRY(Bindings::throw_dom_exception_if_needed(vm, [&]() -> WebIDL::ExceptionOr> { return SVGAnimatedLength::create(realm, TRY(SVGLength::create(realm, 0, 0)), TRY(SVGLength::create(realm, 0, 0))); })); m_height = TRY(Bindings::throw_dom_exception_if_needed(vm, [&]() -> WebIDL::ExceptionOr> { return SVGAnimatedLength::create(realm, TRY(SVGLength::create(realm, 0, 0)), TRY(SVGLength::create(realm, 0, 0))); })); return {}; } void SVGForeignObjectElement::visit_edges(Cell::Visitor& visitor) { Base::visit_edges(visitor); visitor.visit(m_x); visitor.visit(m_y); visitor.visit(m_width); visitor.visit(m_height); } JS::GCPtr SVGForeignObjectElement::create_layout_node(NonnullRefPtr style) { return heap().allocate_without_realm(document(), this, move(style)); } void SVGForeignObjectElement::apply_presentational_hints(CSS::StyleProperties& style) const { Base::apply_presentational_hints(style); auto parsing_context = CSS::Parser::ParsingContext { document() }; if (auto width_value = parse_css_value(parsing_context, attribute(Web::HTML::AttributeNames::width), CSS::PropertyID::Width)) style.set_property(CSS::PropertyID::Width, width_value.release_nonnull()); if (auto height_value = parse_css_value(parsing_context, attribute(Web::HTML::AttributeNames::height), CSS::PropertyID::Height)) style.set_property(CSS::PropertyID::Height, height_value.release_nonnull()); } JS::NonnullGCPtr SVGForeignObjectElement::x() { return *m_x; } JS::NonnullGCPtr SVGForeignObjectElement::y() { return *m_y; } JS::NonnullGCPtr SVGForeignObjectElement::width() { return *m_width; } JS::NonnullGCPtr SVGForeignObjectElement::height() { return *m_height; } }