SVGSVGElement.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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/SVGViewport.h>
  11. #include <LibWeb/SVG/ViewBox.h>
  12. namespace Web::SVG {
  13. class SVGSVGElement final : public SVGGraphicsElement
  14. , public SVGViewport {
  15. WEB_PLATFORM_OBJECT(SVGSVGElement, SVGGraphicsElement);
  16. JS_DECLARE_ALLOCATOR(SVGSVGElement);
  17. public:
  18. virtual JS::GCPtr<Layout::Node> create_layout_node(NonnullRefPtr<CSS::StyleProperties>) override;
  19. virtual void apply_presentational_hints(CSS::StyleProperties&) const override;
  20. virtual bool requires_svg_container() const override { return false; }
  21. virtual bool is_svg_container() const override { return true; }
  22. virtual Optional<ViewBox> view_box() const override;
  23. virtual Optional<PreserveAspectRatio> preserve_aspect_ratio() const override { return m_preserve_aspect_ratio; }
  24. void set_fallback_view_box_for_svg_as_image(Optional<ViewBox>);
  25. JS::NonnullGCPtr<SVGAnimatedRect> view_box_for_bindings() { return *m_view_box_for_bindings; }
  26. private:
  27. SVGSVGElement(DOM::Document&, DOM::QualifiedName);
  28. virtual void initialize(JS::Realm&) override;
  29. virtual void visit_edges(Visitor&) override;
  30. virtual bool is_svg_svg_element() const override { return true; }
  31. virtual void attribute_changed(FlyString const& name, Optional<String> const& value) override;
  32. void update_fallback_view_box_for_svg_as_image();
  33. Optional<ViewBox> m_view_box;
  34. Optional<PreserveAspectRatio> m_preserve_aspect_ratio;
  35. Optional<ViewBox> m_fallback_view_box_for_svg_as_image;
  36. JS::GCPtr<SVGAnimatedRect> m_view_box_for_bindings;
  37. };
  38. }
  39. namespace Web::DOM {
  40. template<>
  41. inline bool Node::fast_is<SVG::SVGSVGElement>() const { return is_svg_svg_element(); }
  42. }