SVGSVGBox.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*
  2. * Copyright (c) 2020, Matthew Olsson <mattco@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <LibWeb/Layout/ReplacedBox.h>
  8. #include <LibWeb/SVG/SVGSVGElement.h>
  9. namespace Web::Layout {
  10. class SVGSVGBox final : public ReplacedBox {
  11. JS_CELL(SVGSVGBox, ReplacedBox);
  12. public:
  13. SVGSVGBox(DOM::Document&, SVG::SVGSVGElement&, NonnullRefPtr<CSS::StyleProperties>);
  14. virtual ~SVGSVGBox() override = default;
  15. SVG::SVGSVGElement& dom_node() { return verify_cast<SVG::SVGSVGElement>(ReplacedBox::dom_node()); }
  16. SVG::SVGSVGElement const& dom_node() const { return verify_cast<SVG::SVGSVGElement>(ReplacedBox::dom_node()); }
  17. virtual bool can_have_children() const override { return true; }
  18. virtual JS::GCPtr<Painting::Paintable> create_paintable() const override;
  19. virtual void prepare_for_replaced_layout() override;
  20. private:
  21. virtual bool is_svg_svg_box() const final { return true; }
  22. [[nodiscard]] Optional<CSSPixelFraction> calculate_intrinsic_aspect_ratio() const;
  23. };
  24. template<>
  25. inline bool Node::fast_is<SVGSVGBox>() const { return is_svg_svg_box(); }
  26. }