SVGGraphicsBox.cpp 1.0 KB

1234567891011121314151617181920212223242526272829303132
  1. /*
  2. * Copyright (c) 2020, Matthew Olsson <mattco@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <LibWeb/Layout/SVGGraphicsBox.h>
  7. namespace Web::Layout {
  8. SVGGraphicsBox::SVGGraphicsBox(DOM::Document& document, SVG::SVGGraphicsElement& element, NonnullRefPtr<CSS::StyleProperties> properties)
  9. : SVGBox(document, element, properties)
  10. {
  11. }
  12. void SVGGraphicsBox::before_children_paint(PaintContext& context, PaintPhase phase)
  13. {
  14. SVGBox::before_children_paint(context, phase);
  15. if (phase != PaintPhase::Foreground)
  16. return;
  17. auto& graphics_element = verify_cast<SVG::SVGGraphicsElement>(dom_node());
  18. if (graphics_element.fill_color().has_value())
  19. context.svg_context().set_fill_color(graphics_element.fill_color().value());
  20. if (graphics_element.stroke_color().has_value())
  21. context.svg_context().set_stroke_color(graphics_element.stroke_color().value());
  22. if (graphics_element.stroke_width().has_value())
  23. context.svg_context().set_stroke_width(graphics_element.stroke_width().value());
  24. }
  25. }