HTMLCanvasElement.h 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. * Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/ByteBuffer.h>
  8. #include <LibGfx/Forward.h>
  9. #include <LibWeb/HTML/HTMLElement.h>
  10. namespace Web::HTML {
  11. class HTMLCanvasElement final : public HTMLElement {
  12. public:
  13. using WrapperType = Bindings::HTMLCanvasElementWrapper;
  14. HTMLCanvasElement(DOM::Document&, DOM::QualifiedName);
  15. virtual ~HTMLCanvasElement() override;
  16. const Gfx::Bitmap* bitmap() const { return m_bitmap; }
  17. Gfx::Bitmap* bitmap() { return m_bitmap; }
  18. bool create_bitmap();
  19. CanvasRenderingContext2D* get_context(String type);
  20. unsigned width() const;
  21. unsigned height() const;
  22. void set_width(unsigned);
  23. void set_height(unsigned);
  24. String to_data_url(const String& type, Optional<double> quality) const;
  25. private:
  26. virtual RefPtr<Layout::Node> create_layout_node(NonnullRefPtr<CSS::StyleProperties>) override;
  27. RefPtr<Gfx::Bitmap> m_bitmap;
  28. RefPtr<CanvasRenderingContext2D> m_context;
  29. };
  30. }