1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 06:38:10 +00:00

LibWeb: Return DOMException instead of crashing when setting attributes

This commit is contained in:
PrestonLTaylor 2023-05-25 20:37:57 +01:00 committed by Andreas Kling
parent 6891676fce
commit 5d3b7a5ecc
24 changed files with 57 additions and 51 deletions

View file

@ -71,18 +71,20 @@ void HTMLCanvasElement::reset_context_to_default_state()
});
}
void HTMLCanvasElement::set_width(unsigned value)
WebIDL::ExceptionOr<void> HTMLCanvasElement::set_width(unsigned value)
{
MUST(set_attribute(HTML::AttributeNames::width, DeprecatedString::number(value)));
TRY(set_attribute(HTML::AttributeNames::width, DeprecatedString::number(value)));
m_bitmap = nullptr;
reset_context_to_default_state();
return {};
}
void HTMLCanvasElement::set_height(unsigned value)
WebIDL::ExceptionOr<void> HTMLCanvasElement::set_height(unsigned value)
{
MUST(set_attribute(HTML::AttributeNames::height, DeprecatedString::number(value)));
TRY(set_attribute(HTML::AttributeNames::height, DeprecatedString::number(value)));
m_bitmap = nullptr;
reset_context_to_default_state();
return {};
}
JS::GCPtr<Layout::Node> HTMLCanvasElement::create_layout_node(NonnullRefPtr<CSS::StyleProperties> style)