CanvasBox.cpp 705 B

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