diff --git a/Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp b/Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp index 9e2b243e86d..bc171aa20c6 100644 --- a/Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp +++ b/Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp @@ -222,6 +222,7 @@ void CanvasRenderingContext2D::set_size(Gfx::IntSize const& size) return; m_size = size; m_surface = nullptr; + m_painter = nullptr; } void CanvasRenderingContext2D::allocate_painting_surface_if_needed() @@ -238,6 +239,7 @@ void CanvasRenderingContext2D::allocate_painting_surface_if_needed() auto skia_backend_context = canvas_element().navigable()->traversable_navigable()->skia_backend_context(); m_surface = Gfx::PaintingSurface::create_with_size(skia_backend_context, canvas_element().bitmap_size_for_canvas(), color_type, Gfx::AlphaType::Premultiplied); + m_painter = nullptr; // https://html.spec.whatwg.org/multipage/canvas.html#the-canvas-settings:concept-canvas-alpha // Thus, the bitmap of such a context starts off as opaque black instead of transparent black; diff --git a/Tests/LibWeb/Text/expected/canvas/resize-canvas-and-keep-painting.txt b/Tests/LibWeb/Text/expected/canvas/resize-canvas-and-keep-painting.txt new file mode 100644 index 00000000000..fc0bdc8a71c --- /dev/null +++ b/Tests/LibWeb/Text/expected/canvas/resize-canvas-and-keep-painting.txt @@ -0,0 +1,4 @@ +0 +128 +0 +255 diff --git a/Tests/LibWeb/Text/input/canvas/resize-canvas-and-keep-painting.html b/Tests/LibWeb/Text/input/canvas/resize-canvas-and-keep-painting.html new file mode 100644 index 00000000000..ebf190e425f --- /dev/null +++ b/Tests/LibWeb/Text/input/canvas/resize-canvas-and-keep-painting.html @@ -0,0 +1,20 @@ + + + +