SVGPaintable.cpp 1016 B

1234567891011121314151617181920212223242526272829303132333435
  1. /*
  2. * Copyright (c) 2018-2022, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <LibWeb/Layout/ImageBox.h>
  7. #include <LibWeb/Layout/SVGSVGBox.h>
  8. #include <LibWeb/Painting/SVGPaintable.h>
  9. #include <LibWeb/SVG/SVGMaskElement.h>
  10. namespace Web::Painting {
  11. SVGPaintable::SVGPaintable(Layout::SVGBox const& layout_box)
  12. : PaintableBox(layout_box)
  13. {
  14. }
  15. Layout::SVGBox const& SVGPaintable::layout_box() const
  16. {
  17. return static_cast<Layout::SVGBox const&>(layout_node());
  18. }
  19. CSSPixelRect SVGPaintable::compute_absolute_rect() const
  20. {
  21. if (auto* svg_svg_box = layout_box().first_ancestor_of_type<Layout::SVGSVGBox>()) {
  22. CSSPixelRect rect { offset(), content_size() };
  23. for (Layout::Box const* ancestor = svg_svg_box; ancestor && ancestor->paintable(); ancestor = ancestor->paintable()->containing_block())
  24. rect.translate_by(ancestor->paintable_box()->offset());
  25. return rect;
  26. }
  27. return PaintableBox::compute_absolute_rect();
  28. }
  29. }