SVGPaintable.cpp 927 B

1234567891011121314151617181920212223242526272829303132333435363738
  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/Painting/SVGPaintable.h>
  8. namespace Web::Painting {
  9. SVGPaintable::SVGPaintable(Layout::SVGBox const& layout_box)
  10. : PaintableBox(layout_box)
  11. {
  12. }
  13. Layout::SVGBox const& SVGPaintable::layout_box() const
  14. {
  15. return static_cast<Layout::SVGBox const&>(layout_node());
  16. }
  17. void SVGPaintable::before_children_paint(PaintContext& context, PaintPhase phase) const
  18. {
  19. PaintableBox::before_children_paint(context, phase);
  20. if (phase != PaintPhase::Foreground)
  21. return;
  22. context.svg_context().save();
  23. }
  24. void SVGPaintable::after_children_paint(PaintContext& context, PaintPhase phase) const
  25. {
  26. PaintableBox::after_children_paint(context, phase);
  27. if (phase != PaintPhase::Foreground)
  28. return;
  29. context.svg_context().restore();
  30. }
  31. }