/* * Copyright (c) 2020, Matthew Olsson * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include #include #include #include #include #include #include #include #include namespace Web::SVG { class SVGSVGElement final : public SVGGraphicsElement , public SVGViewport // SVGSVGElement is not strictly a NonElementParentNode, but it implements the same get_element_by_id() method. , public DOM::NonElementParentNode { WEB_PLATFORM_OBJECT(SVGSVGElement, SVGGraphicsElement); JS_DECLARE_ALLOCATOR(SVGSVGElement); public: virtual JS::GCPtr create_layout_node(NonnullRefPtr) override; virtual void apply_presentational_hints(CSS::StyleProperties&) const override; virtual bool requires_svg_container() const override { return false; } virtual bool is_svg_container() const override { return true; } virtual Optional view_box() const override; virtual Optional preserve_aspect_ratio() const override { return m_preserve_aspect_ratio; } void set_fallback_view_box_for_svg_as_image(Optional); JS::NonnullGCPtr view_box_for_bindings() { return *m_view_box_for_bindings; } JS::NonnullGCPtr x() const; JS::NonnullGCPtr y() const; JS::NonnullGCPtr width() const; JS::NonnullGCPtr height() const; float current_scale() const; void set_current_scale(float); JS::NonnullGCPtr current_translate() const; JS::NonnullGCPtr get_intersection_list(JS::NonnullGCPtr rect, JS::GCPtr reference_element) const; JS::NonnullGCPtr get_enclosure_list(JS::NonnullGCPtr rect, JS::GCPtr reference_element) const; bool check_intersection(JS::NonnullGCPtr element, JS::NonnullGCPtr rect) const; bool check_enclosure(JS::NonnullGCPtr element, JS::NonnullGCPtr rect) const; void deselect_all() const; JS::NonnullGCPtr create_svg_length() const; JS::NonnullGCPtr create_svg_point() const; JS::NonnullGCPtr create_svg_matrix() const; JS::NonnullGCPtr create_svg_rect() const; JS::NonnullGCPtr create_svg_transform() const; // Deprecated methods that have no effect when called, but which are kept for compatibility reasons. WebIDL::UnsignedLong suspend_redraw(WebIDL::UnsignedLong max_wait_milliseconds) const { (void)max_wait_milliseconds; // When the suspendRedraw method is called, it must return 1. return 1; } void unsuspend_redraw(WebIDL::UnsignedLong suspend_handle_id) const { (void)suspend_handle_id; } void unsuspend_redraw_all() const {}; void force_redraw() const {}; private: SVGSVGElement(DOM::Document&, DOM::QualifiedName); virtual void initialize(JS::Realm&) override; virtual void visit_edges(Visitor&) override; virtual bool is_svg_svg_element() const override { return true; } virtual void attribute_changed(FlyString const& name, Optional const& value) override; void update_fallback_view_box_for_svg_as_image(); Optional m_view_box; Optional m_preserve_aspect_ratio; Optional m_fallback_view_box_for_svg_as_image; JS::GCPtr m_view_box_for_bindings; }; } namespace Web::DOM { template<> inline bool Node::fast_is() const { return is_svg_svg_element(); } }