/* * Copyright (c) 2020, Matthew Olsson * Copyright (c) 2021-2022, Sam Atkins * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include #include #include #include #include #include #include #include namespace Web::SVG { struct SVGBoundingBoxOptions { bool fill { true }; bool stroke { false }; bool markers { false }; bool clipped { false }; }; class WEB_API SVGGraphicsElement : public SVGElement { WEB_PLATFORM_OBJECT(SVGGraphicsElement, SVGElement); public: virtual void attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value, Optional const& namespace_) override; Optional fill_color() const; Optional stroke_color() const; Vector stroke_dasharray() const; Optional stroke_dashoffset() const; Optional stroke_width() const; Optional fill_opacity() const; CSS::PaintOrderList paint_order() const; Optional stroke_linecap() const; Optional stroke_linejoin() const; Optional stroke_miterlimit() const; Optional stroke_opacity() const; Optional fill_rule() const; Optional clip_rule() const; virtual Optional active_view_box() const { if (auto* svg_fit_to_view_box = as_if(*this)) return svg_fit_to_view_box->view_box(); return {}; } float visible_stroke_width() const { if (auto color = stroke_color(); color.has_value() && color->alpha() > 0) return stroke_width().value_or(0); return 0; } Optional fill_paint_style(SVGPaintContext const&) const; Optional stroke_paint_style(SVGPaintContext const&) const; GC::Ptr mask() const; GC::Ptr clip_path() const; WebIDL::ExceptionOr> get_b_box(Optional); GC::Ref transform() const; GC::Ptr get_ctm(); GC::Ptr get_screen_ctm(); virtual Gfx::AffineTransform element_transform() const { return m_transform; } protected: SVGGraphicsElement(DOM::Document&, DOM::QualifiedName); virtual void initialize(JS::Realm&) override; Optional svg_paint_computed_value_to_gfx_paint_style(SVGPaintContext const& paint_context, Optional const& paint_value) const; Gfx::AffineTransform m_transform = {}; GC::Ptr resolve_url_to_element(CSS::URL const& url) const; template GC::Ptr try_resolve_url_to(CSS::URL const& url) const { return as_if(resolve_url_to_element(url).ptr()); } private: virtual bool is_svg_graphics_element() const final { return true; } float resolve_relative_to_viewport_size(CSS::LengthPercentage const& length_percentage) const; }; Gfx::AffineTransform transform_from_transform_list(ReadonlySpan transform_list); } namespace Web::DOM { template<> inline bool Node::fast_is() const { return is_svg_graphics_element(); } }