SVGFormattingContext.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <LibGfx/DeprecatedPath.h>
  8. #include <LibWeb/Forward.h>
  9. #include <LibWeb/Layout/FormattingContext.h>
  10. #include <LibWeb/Layout/SVGSVGBox.h>
  11. #include <LibWeb/Layout/SVGTextBox.h>
  12. #include <LibWeb/Layout/SVGTextPathBox.h>
  13. namespace Web::Layout {
  14. class SVGFormattingContext : public FormattingContext {
  15. public:
  16. explicit SVGFormattingContext(LayoutState&, Box const&, FormattingContext* parent, Gfx::AffineTransform parent_viewbox_transform = {});
  17. ~SVGFormattingContext();
  18. virtual void run(Box const&, LayoutMode, AvailableSpace const&) override;
  19. virtual CSSPixels automatic_content_width() const override;
  20. virtual CSSPixels automatic_content_height() const override;
  21. private:
  22. void layout_svg_element(Box const&);
  23. void layout_nested_viewport(Box const&);
  24. void layout_container_element(SVGBox const&);
  25. void layout_graphics_element(SVGGraphicsBox const&);
  26. void layout_path_like_element(SVGGraphicsBox const&);
  27. void layout_mask_or_clip(SVGBox const&);
  28. Gfx::DeprecatedPath compute_path_for_text(SVGTextBox const&);
  29. Gfx::DeprecatedPath compute_path_for_text_path(SVGTextPathBox const&);
  30. Gfx::AffineTransform m_parent_viewbox_transform {};
  31. Optional<AvailableSpace> m_available_space {};
  32. Gfx::AffineTransform m_current_viewbox_transform {};
  33. CSSPixelSize m_viewport_size {};
  34. CSSPixelPoint m_svg_offset {};
  35. };
  36. }