/* * Copyright (c) 2020, Matthew Olsson * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include #include #include #include #include #include #include #include namespace Web::SVG { class SVGSVGElement final : public SVGGraphicsElement , public SVGViewport { WEB_PLATFORM_OBJECT(SVGSVGElement, SVGGraphicsElement); GC_DECLARE_ALLOCATOR(SVGSVGElement); public: virtual GC::Ptr create_layout_node(GC::Ref) override; virtual bool is_presentational_hint(FlyString const&) const override; virtual void apply_presentational_hints(GC::Ref) 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); GC::Ref view_box_for_bindings() { return *m_view_box_for_bindings; } GC::Ref x() const; GC::Ref y() const; GC::Ref width() const; GC::Ref height() const; float current_scale() const; void set_current_scale(float); GC::Ref current_translate() const; GC::Ref get_intersection_list(GC::Ref rect, GC::Ptr reference_element) const; GC::Ref get_enclosure_list(GC::Ref rect, GC::Ptr reference_element) const; bool check_intersection(GC::Ref element, GC::Ref rect) const; bool check_enclosure(GC::Ref element, GC::Ref rect) const; void deselect_all() const; GC::Ref create_svg_length() const; GC::Ref create_svg_point() const; GC::Ref create_svg_matrix() const; GC::Ref create_svg_rect() const; GC::Ref 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 { } [[nodiscard]] RefPtr width_style_value_from_attribute() const; [[nodiscard]] RefPtr height_style_value_from_attribute() const; struct NaturalMetrics { Optional width; Optional height; Optional aspect_ratio; }; static NaturalMetrics negotiate_natural_metrics(SVGSVGElement 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& old_value, Optional const& value, Optional const& namespace_) 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; GC::Ptr m_view_box_for_bindings; }; } namespace Web::DOM { template<> inline bool Node::fast_is() const { return is_svg_svg_element(); } }