Browse Source

LibWeb: Reset canvas elements when their width/height attribute are set

Andreas Kling 3 years ago
parent
commit
b4a8be5dc9
1 changed files with 6 additions and 0 deletions
  1. 6 0
      Userland/Libraries/LibWeb/HTML/HTMLCanvasElement.cpp

+ 6 - 0
Userland/Libraries/LibWeb/HTML/HTMLCanvasElement.cpp

@@ -38,11 +38,17 @@ unsigned HTMLCanvasElement::height() const
 void HTMLCanvasElement::set_width(unsigned value)
 void HTMLCanvasElement::set_width(unsigned value)
 {
 {
     set_attribute(HTML::AttributeNames::width, String::number(value));
     set_attribute(HTML::AttributeNames::width, String::number(value));
+    m_bitmap = nullptr;
+    if (m_context)
+        m_context->reset_to_default_state();
 }
 }
 
 
 void HTMLCanvasElement::set_height(unsigned value)
 void HTMLCanvasElement::set_height(unsigned value)
 {
 {
     set_attribute(HTML::AttributeNames::height, String::number(value));
     set_attribute(HTML::AttributeNames::height, String::number(value));
+    m_bitmap = nullptr;
+    if (m_context)
+        m_context->reset_to_default_state();
 }
 }
 
 
 RefPtr<Layout::Node> HTMLCanvasElement::create_layout_node(NonnullRefPtr<CSS::StyleProperties> style)
 RefPtr<Layout::Node> HTMLCanvasElement::create_layout_node(NonnullRefPtr<CSS::StyleProperties> style)