diff options
author | Andreas Kling <kling@serenityos.org> | 2021-11-13 00:54:21 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-11-13 00:55:07 +0100 |
commit | 778268b1a5b4c9b02c3c816855a40d32db932e65 (patch) | |
tree | d6e6dbd16f859f5bbab222c33d30bd62b4b3916a /Userland/Libraries/LibWeb | |
parent | 47edd6ae894c7c303e0ea2cec00b8519ff962bc4 (diff) | |
download | serenity-778268b1a5b4c9b02c3c816855a40d32db932e65.zip |
LibWeb: Allow setting the width & height properties on <canvas> elements
Diffstat (limited to 'Userland/Libraries/LibWeb')
-rw-r--r-- | Userland/Libraries/LibWeb/HTML/HTMLCanvasElement.cpp | 10 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/HTML/HTMLCanvasElement.h | 3 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/HTML/HTMLCanvasElement.idl | 4 |
3 files changed, 15 insertions, 2 deletions
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLCanvasElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLCanvasElement.cpp index 3a813af475..2dd25930ca 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLCanvasElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLCanvasElement.cpp @@ -37,6 +37,16 @@ unsigned HTMLCanvasElement::height() const return attribute(HTML::AttributeNames::height).to_uint().value_or(150); } +void HTMLCanvasElement::set_width(unsigned value) +{ + set_attribute(HTML::AttributeNames::width, String::number(value)); +} + +void HTMLCanvasElement::set_height(unsigned value) +{ + set_attribute(HTML::AttributeNames::height, String::number(value)); +} + RefPtr<Layout::Node> HTMLCanvasElement::create_layout_node() { auto style = document().style_computer().compute_style(*this); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLCanvasElement.h b/Userland/Libraries/LibWeb/HTML/HTMLCanvasElement.h index ececac4ccc..e022a67c3f 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLCanvasElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLCanvasElement.h @@ -28,6 +28,9 @@ public: unsigned width() const; unsigned height() const; + void set_width(unsigned); + void set_height(unsigned); + String to_data_url(const String& type, Optional<double> quality) const; private: diff --git a/Userland/Libraries/LibWeb/HTML/HTMLCanvasElement.idl b/Userland/Libraries/LibWeb/HTML/HTMLCanvasElement.idl index 6fc0a0ba4a..50a3cb8b15 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLCanvasElement.idl +++ b/Userland/Libraries/LibWeb/HTML/HTMLCanvasElement.idl @@ -1,8 +1,8 @@ interface HTMLCanvasElement : HTMLElement { CanvasRenderingContext2D? getContext(DOMString contextId); - readonly attribute unsigned long width; - readonly attribute unsigned long height; + attribute unsigned long width; + attribute unsigned long height; USVString toDataURL(optional DOMString type = "image/png", optional double quality); |