浏览代码

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

Andreas Kling 3 年之前
父节点
当前提交
b4a8be5dc9
共有 1 个文件被更改,包括 6 次插入0 次删除
  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)
 {
     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)
 {
     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)