SVGSVGElement.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. * Copyright (c) 2020, Matthew Olsson <matthewcolsson@gmail.com>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <LibGfx/Bitmap.h>
  8. #include <LibWeb/SVG/AttributeParser.h>
  9. #include <LibWeb/SVG/SVGGraphicsElement.h>
  10. #include <LibWeb/SVG/ViewBox.h>
  11. namespace Web::SVG {
  12. class SVGSVGElement final : public SVGGraphicsElement {
  13. WEB_PLATFORM_OBJECT(SVGSVGElement, SVGGraphicsElement);
  14. public:
  15. virtual JS::GCPtr<Layout::Node> create_layout_node(NonnullRefPtr<CSS::StyleProperties>) override;
  16. virtual void apply_presentational_hints(CSS::StyleProperties&) const override;
  17. virtual bool requires_svg_container() const override { return false; }
  18. virtual bool is_svg_container() const override { return true; }
  19. [[nodiscard]] Optional<ViewBox> view_box() const;
  20. Optional<PreserveAspectRatio> const& preserve_aspect_ratio() const { return m_preserve_aspect_ratio; }
  21. void set_fallback_view_box_for_svg_as_image(Optional<ViewBox>);
  22. private:
  23. SVGSVGElement(DOM::Document&, DOM::QualifiedName);
  24. virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
  25. virtual bool is_svg_svg_element() const override { return true; }
  26. virtual void attribute_changed(DeprecatedFlyString const& name, DeprecatedString const& value) override;
  27. void update_fallback_view_box_for_svg_as_image();
  28. Optional<ViewBox> m_view_box;
  29. Optional<PreserveAspectRatio> m_preserve_aspect_ratio;
  30. Optional<ViewBox> m_fallback_view_box_for_svg_as_image;
  31. };
  32. }
  33. namespace Web::DOM {
  34. template<>
  35. inline bool Node::fast_is<SVG::SVGSVGElement>() const { return is_svg_svg_element(); }
  36. }