PaintContext.cpp 770 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/Painting/PaintContext.h>
  7. namespace Web {
  8. PaintContext::PaintContext(Gfx::Painter& painter, Palette const& palette)
  9. : m_painter(painter)
  10. , m_palette(palette)
  11. {
  12. }
  13. SVGContext& PaintContext::svg_context()
  14. {
  15. // FIXME: This is a total hack to avoid crashing on content that has SVG elements embedded directly in HTML without an <svg> element.
  16. if (!m_svg_context.has_value())
  17. m_svg_context = SVGContext { {} };
  18. return m_svg_context.value();
  19. }
  20. void PaintContext::set_svg_context(SVGContext context)
  21. {
  22. m_svg_context = move(context);
  23. }
  24. void PaintContext::clear_svg_context()
  25. {
  26. m_svg_context.clear();
  27. }
  28. }