2020-03-19 19:07:56 +01:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-03-19 19:07:56 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <AK/ByteBuffer.h>
|
|
|
|
#include <LibGfx/Forward.h>
|
2020-07-26 15:08:16 +02:00
|
|
|
#include <LibWeb/HTML/HTMLElement.h>
|
2020-03-19 19:07:56 +01:00
|
|
|
|
2020-07-28 18:20:36 +02:00
|
|
|
namespace Web::HTML {
|
2020-03-19 19:07:56 +01:00
|
|
|
|
2020-07-28 02:54:19 +01:00
|
|
|
class HTMLCanvasElement final : public HTMLElement {
|
2020-03-19 19:07:56 +01:00
|
|
|
public:
|
|
|
|
using WrapperType = Bindings::HTMLCanvasElementWrapper;
|
|
|
|
|
2021-02-07 11:20:15 +01:00
|
|
|
HTMLCanvasElement(DOM::Document&, QualifiedName);
|
2020-03-19 19:07:56 +01:00
|
|
|
virtual ~HTMLCanvasElement() override;
|
|
|
|
|
|
|
|
const Gfx::Bitmap* bitmap() const { return m_bitmap; }
|
2020-04-15 12:12:19 +02:00
|
|
|
Gfx::Bitmap* bitmap() { return m_bitmap; }
|
|
|
|
bool create_bitmap();
|
2020-03-19 19:07:56 +01:00
|
|
|
|
|
|
|
CanvasRenderingContext2D* get_context(String type);
|
|
|
|
|
2020-06-21 15:37:13 +02:00
|
|
|
unsigned width() const;
|
|
|
|
unsigned height() const;
|
2020-04-15 12:12:19 +02:00
|
|
|
|
2021-04-19 23:47:29 +02:00
|
|
|
String to_data_url(const String& type, Optional<double> quality) const;
|
|
|
|
|
2020-03-19 19:07:56 +01:00
|
|
|
private:
|
2021-01-06 14:27:40 +01:00
|
|
|
virtual RefPtr<Layout::Node> create_layout_node() override;
|
2020-03-19 19:07:56 +01:00
|
|
|
|
|
|
|
RefPtr<Gfx::Bitmap> m_bitmap;
|
|
|
|
RefPtr<CanvasRenderingContext2D> m_context;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|