2020-07-19 23:01:53 -07:00
|
|
|
/*
|
2021-04-22 16:53:07 -07:00
|
|
|
* Copyright (c) 2020, Matthew Olsson <mattco@serenityos.org>
|
2022-01-24 15:43:44 +00:00
|
|
|
* Copyright (c) 2021-2022, Sam Atkins <atkinssj@serenityos.org>
|
2020-07-19 23:01:53 -07:00
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-07-19 23:01:53 -07:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2023-04-23 01:31:17 +01:00
|
|
|
#include <LibGfx/PaintStyle.h>
|
2023-05-08 07:51:03 +02:00
|
|
|
#include <LibGfx/Painter.h>
|
2020-07-23 09:44:42 -07:00
|
|
|
#include <LibGfx/Path.h>
|
|
|
|
|
#include <LibWeb/DOM/Node.h>
|
2023-04-10 12:25:40 +01:00
|
|
|
#include <LibWeb/SVG/AttributeParser.h>
|
2020-07-23 09:44:42 -07:00
|
|
|
#include <LibWeb/SVG/SVGElement.h>
|
2023-04-23 01:31:17 +01:00
|
|
|
#include <LibWeb/SVG/SVGGradientElement.h>
|
2020-07-23 09:44:42 -07:00
|
|
|
#include <LibWeb/SVG/TagNames.h>
|
2020-07-19 23:01:53 -07:00
|
|
|
|
2020-07-23 09:44:42 -07:00
|
|
|
namespace Web::SVG {
|
2020-07-19 23:01:53 -07:00
|
|
|
|
2020-07-23 09:44:42 -07:00
|
|
|
class SVGGraphicsElement : public SVGElement {
|
2022-08-28 13:42:07 +02:00
|
|
|
WEB_PLATFORM_OBJECT(SVGGraphicsElement, SVGElement);
|
2020-07-19 23:01:53 -07:00
|
|
|
|
2022-08-28 13:42:07 +02:00
|
|
|
public:
|
2022-01-24 15:43:44 +00:00
|
|
|
virtual void apply_presentational_hints(CSS::StyleProperties&) const override;
|
2020-07-19 23:01:53 -07:00
|
|
|
|
2023-04-10 12:25:00 +01:00
|
|
|
virtual void parse_attribute(DeprecatedFlyString const& name, DeprecatedString const& value) override;
|
|
|
|
|
|
2021-09-16 12:28:14 +01:00
|
|
|
Optional<Gfx::Color> fill_color() const;
|
2023-06-11 16:43:46 +01:00
|
|
|
Optional<FillRule> fill_rule() const;
|
2021-09-16 12:28:14 +01:00
|
|
|
Optional<Gfx::Color> stroke_color() const;
|
|
|
|
|
Optional<float> stroke_width() const;
|
2023-05-19 20:35:39 +01:00
|
|
|
Optional<float> fill_opacity() const;
|
|
|
|
|
Optional<float> stroke_opacity() const;
|
2022-08-28 13:42:07 +02:00
|
|
|
|
2023-04-15 15:32:17 +01:00
|
|
|
float visible_stroke_width() const
|
|
|
|
|
{
|
|
|
|
|
if (auto color = stroke_color(); color.has_value() && color->alpha() > 0)
|
|
|
|
|
return stroke_width().value_or(0);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-10 12:25:40 +01:00
|
|
|
Gfx::AffineTransform get_transform() const;
|
|
|
|
|
|
2023-04-23 01:31:17 +01:00
|
|
|
Optional<Gfx::PaintStyle const&> fill_paint_style(SVGPaintContext const&) const;
|
2023-06-06 20:40:10 +01:00
|
|
|
Optional<Gfx::PaintStyle const&> stroke_paint_style(SVGPaintContext const&) const;
|
2023-04-23 01:31:17 +01:00
|
|
|
|
2022-08-28 13:42:07 +02:00
|
|
|
protected:
|
|
|
|
|
SVGGraphicsElement(DOM::Document&, DOM::QualifiedName);
|
2023-01-10 06:28:20 -05:00
|
|
|
|
2023-01-28 12:33:35 -05:00
|
|
|
virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
|
2023-04-10 12:25:00 +01:00
|
|
|
|
2023-06-06 20:40:10 +01:00
|
|
|
Optional<Gfx::PaintStyle const&> svg_paint_computed_value_to_gfx_paint_style(SVGPaintContext const& paint_context, Optional<CSS::SVGPaint> const& paint_value) const;
|
|
|
|
|
|
2023-04-10 12:25:40 +01:00
|
|
|
Gfx::AffineTransform m_transform = {};
|
2020-07-19 23:01:53 -07:00
|
|
|
};
|
|
|
|
|
|
2023-04-12 13:32:21 -04:00
|
|
|
Gfx::AffineTransform transform_from_transform_list(ReadonlySpan<Transform> transform_list);
|
2023-04-10 12:25:40 +01:00
|
|
|
|
2020-07-23 09:44:42 -07:00
|
|
|
}
|