diff --git a/components/canvas/canvas_data.rs b/components/canvas/canvas_data.rs index 7d90742f3a8..dbde4bd408c 100644 --- a/components/canvas/canvas_data.rs +++ b/components/canvas/canvas_data.rs @@ -1185,15 +1185,27 @@ impl<'a, B: Backend> CanvasData<'a, B> { self.backend.set_global_composition(op, &mut self.state); } + /// pub(crate) fn recreate(&mut self, size: Option>) { let size = size .unwrap_or_else(|| self.drawtarget.get_size().to_u64()) .max(MIN_WR_IMAGE_SIZE); + + // Step 1. Clear canvas's bitmap to transparent black. self.drawtarget = self .backend .create_drawtarget(Size2D::new(size.width, size.height)); - self.state = self.backend.new_paint_state(); + + // Step 2. Empty the list of subpaths in context's current default path. + self.path_state = None; + + // Step 3. Clear the context's drawing state stack. self.saved_states.clear(); + + // Step 4. Reset everything that drawing state consists of to their + // initial values. + self.state = self.backend.new_paint_state(); + self.update_image_rendering(); } diff --git a/tests/wpt/meta/html/canvas/element/canvas-host/2d.canvas.host.initial.reset.path.html.ini b/tests/wpt/meta/html/canvas/element/canvas-host/2d.canvas.host.initial.reset.path.html.ini deleted file mode 100644 index e12e364d828..00000000000 --- a/tests/wpt/meta/html/canvas/element/canvas-host/2d.canvas.host.initial.reset.path.html.ini +++ /dev/null @@ -1,3 +0,0 @@ -[2d.canvas.host.initial.reset.path.html] - [Resetting the canvas state resets the current path] - expected: FAIL diff --git a/tests/wpt/meta/html/canvas/offscreen/canvas-host/2d.canvas.host.initial.reset.path.html.ini b/tests/wpt/meta/html/canvas/offscreen/canvas-host/2d.canvas.host.initial.reset.path.html.ini deleted file mode 100644 index e12e364d828..00000000000 --- a/tests/wpt/meta/html/canvas/offscreen/canvas-host/2d.canvas.host.initial.reset.path.html.ini +++ /dev/null @@ -1,3 +0,0 @@ -[2d.canvas.host.initial.reset.path.html] - [Resetting the canvas state resets the current path] - expected: FAIL diff --git a/tests/wpt/meta/html/canvas/offscreen/canvas-host/2d.canvas.host.initial.reset.path.worker.js.ini b/tests/wpt/meta/html/canvas/offscreen/canvas-host/2d.canvas.host.initial.reset.path.worker.js.ini deleted file mode 100644 index d37d5bc29d9..00000000000 --- a/tests/wpt/meta/html/canvas/offscreen/canvas-host/2d.canvas.host.initial.reset.path.worker.js.ini +++ /dev/null @@ -1,3 +0,0 @@ -[2d.canvas.host.initial.reset.path.worker.html] - [Resetting the canvas state resets the current path] - expected: FAIL