CanvasBox.cpp 734 B

12345678910111213141516171819202122232425262728293031
  1. /*
  2. * Copyright (c) 2020-2022, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <LibGfx/Painter.h>
  7. #include <LibWeb/Layout/CanvasBox.h>
  8. #include <LibWeb/Painting/CanvasPaintable.h>
  9. namespace Web::Layout {
  10. CanvasBox::CanvasBox(DOM::Document& document, HTML::HTMLCanvasElement& element, NonnullRefPtr<CSS::StyleProperties> style)
  11. : ReplacedBox(document, element, move(style))
  12. {
  13. }
  14. CanvasBox::~CanvasBox() = default;
  15. void CanvasBox::prepare_for_replaced_layout()
  16. {
  17. set_intrinsic_width(dom_node().width());
  18. set_intrinsic_height(dom_node().height());
  19. }
  20. RefPtr<Painting::Paintable> CanvasBox::create_paintable() const
  21. {
  22. return Painting::CanvasPaintable::create(*this);
  23. }
  24. }