SVGGraphicsElement.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. * Copyright (c) 2020, Matthew Olsson <mattco@serenityos.org>
  3. * Copyright (c) 2021-2022, Sam Atkins <atkinssj@serenityos.org>
  4. *
  5. * SPDX-License-Identifier: BSD-2-Clause
  6. */
  7. #pragma once
  8. #include <LibGfx/PaintStyle.h>
  9. #include <LibGfx/Painter.h>
  10. #include <LibGfx/Path.h>
  11. #include <LibWeb/DOM/Node.h>
  12. #include <LibWeb/SVG/AttributeParser.h>
  13. #include <LibWeb/SVG/SVGElement.h>
  14. #include <LibWeb/SVG/SVGGradientElement.h>
  15. #include <LibWeb/SVG/TagNames.h>
  16. namespace Web::SVG {
  17. class SVGGraphicsElement : public SVGElement {
  18. WEB_PLATFORM_OBJECT(SVGGraphicsElement, SVGElement);
  19. public:
  20. virtual void apply_presentational_hints(CSS::StyleProperties&) const override;
  21. virtual void parse_attribute(DeprecatedFlyString const& name, DeprecatedString const& value) override;
  22. Optional<Gfx::Color> fill_color() const;
  23. Gfx::Painter::WindingRule fill_rule() const;
  24. Optional<Gfx::Color> stroke_color() const;
  25. Optional<float> stroke_width() const;
  26. float visible_stroke_width() const
  27. {
  28. if (auto color = stroke_color(); color.has_value() && color->alpha() > 0)
  29. return stroke_width().value_or(0);
  30. return 0;
  31. }
  32. Gfx::AffineTransform get_transform() const;
  33. Optional<Gfx::PaintStyle const&> fill_paint_style(SVGPaintContext const&) const;
  34. protected:
  35. SVGGraphicsElement(DOM::Document&, DOM::QualifiedName);
  36. virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
  37. Optional<float> m_fill_opacity = {};
  38. Gfx::AffineTransform m_transform = {};
  39. };
  40. Gfx::AffineTransform transform_from_transform_list(ReadonlySpan<Transform> transform_list);
  41. }