SVGGraphicsPaintable.cpp 1.2 KB

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/SVGGraphicsPaintable.h>
  8. namespace Web::Painting {
  9. SVGGraphicsPaintable::SVGGraphicsPaintable(Layout::SVGGraphicsBox const& layout_box)
  10. : SVGPaintable(layout_box)
  11. {
  12. }
  13. Layout::SVGGraphicsBox const& SVGGraphicsPaintable::layout_box() const
  14. {
  15. return static_cast<Layout::SVGGraphicsBox const&>(layout_node());
  16. }
  17. void SVGGraphicsPaintable::before_children_paint(PaintContext& context, PaintPhase phase) const
  18. {
  19. SVGPaintable::before_children_paint(context, phase);
  20. if (phase != PaintPhase::Foreground)
  21. return;
  22. auto& graphics_element = layout_box().dom_node();
  23. if (graphics_element.fill_color().has_value())
  24. context.svg_context().set_fill_color(graphics_element.fill_color().value());
  25. if (graphics_element.stroke_color().has_value())
  26. context.svg_context().set_stroke_color(graphics_element.stroke_color().value());
  27. if (graphics_element.stroke_width().has_value())
  28. context.svg_context().set_stroke_width(graphics_element.stroke_width().value());
  29. }
  30. }