mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-10 18:19:03 +00:00
LibWeb: Notify canvas context when width or height attribute is changed
This commit is contained in:
parent
fe25f77bcf
commit
42a8effae5
Notes:
github-actions[bot]
2024-12-28 09:38:07 +00:00
Author: https://github.com/Gingeh
Commit: 42a8effae5
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3072
4 changed files with 26 additions and 0 deletions
|
@ -185,6 +185,16 @@ WebIDL::ExceptionOr<void> HTMLCanvasElement::set_height(WebIDL::UnsignedLong val
|
|||
return {};
|
||||
}
|
||||
|
||||
void HTMLCanvasElement::attribute_changed(FlyString const& local_name, Optional<String> const& old_value, Optional<String> const& value, Optional<FlyString> const& namespace_)
|
||||
{
|
||||
Base::attribute_changed(local_name, old_value, value, namespace_);
|
||||
|
||||
if (local_name.equals_ignoring_ascii_case(HTML::AttributeNames::width) || local_name.equals_ignoring_ascii_case(HTML::AttributeNames::height)) {
|
||||
notify_context_about_canvas_size_change();
|
||||
reset_context_to_default_state();
|
||||
}
|
||||
}
|
||||
|
||||
GC::Ptr<Layout::Node> HTMLCanvasElement::create_layout_node(GC::Ref<CSS::ComputedProperties> style)
|
||||
{
|
||||
return heap().allocate<Layout::CanvasBox>(document(), *this, move(style));
|
||||
|
|
|
@ -38,6 +38,8 @@ public:
|
|||
WebIDL::ExceptionOr<void> set_width(WebIDL::UnsignedLong);
|
||||
WebIDL::ExceptionOr<void> set_height(WebIDL::UnsignedLong);
|
||||
|
||||
virtual void attribute_changed(FlyString const& local_name, Optional<String> const& old_value, Optional<String> const& value, Optional<FlyString> const& namespace_) override;
|
||||
|
||||
String to_data_url(StringView type, JS::Value quality);
|
||||
WebIDL::ExceptionOr<void> to_blob(GC::Ref<WebIDL::CallbackType> callback, StringView type, JS::Value quality);
|
||||
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
PASS (didn't crash)
|
13
Tests/LibWeb/Text/input/canvas-changed-width-attribute.html
Normal file
13
Tests/LibWeb/Text/input/canvas-changed-width-attribute.html
Normal file
|
@ -0,0 +1,13 @@
|
|||
<!DOCTYPE html>
|
||||
<script src="include.js"></script>
|
||||
<script>
|
||||
test(() => {
|
||||
const canvas = document.createElement("canvas");
|
||||
const ctx = canvas.getContext("2d");
|
||||
|
||||
canvas.setAttribute("width", "0");
|
||||
canvas.toDataURL();
|
||||
|
||||
println("PASS (didn't crash)");
|
||||
});
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue