PaintContext.cpp 843 B

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