Truly independent web browser
LibWeb: Publish a canvas’s paint facts once it has backing storage
sideshowbarker17eac2c33c80
diff --git a/Libraries/LibWeb/HTML/HTMLCanvasElement.cpp b/Libraries/LibWeb/HTML/HTMLCanvasElement.cppindex 30b763fdbff..d4d1cc74b67 100644--- a/Libraries/LibWeb/HTML/HTMLCanvasElement.cpp+++ b/Libraries/LibWeb/HTML/HTMLCanvasElement.cpp@@ -231,6 +231,8 @@ void HTMLCanvasElement::did_change_canvas_content()void HTMLCanvasElement::did_create_canvas_backing_storage(){+ // The canvas has content to paint from now on, which a layout that reached it before has to hear of.+ Painting::push_canvas_paint_facts(*this);set_needs_repaint(InvalidateDisplayList::PaintCommands);}diff --git a/Tests/LibWeb/Text/expected/display_list/canvas-drawn-on-after-layout-reached-it.txt b/Tests/LibWeb/Text/expected/display_list/canvas-drawn-on-after-layout-reached-it.txtnew file mode 100644index 00000000000..2e2f0d2ee52--- /dev/null+++ b/Tests/LibWeb/Text/expected/display_list/canvas-drawn-on-after-layout-reached-it.txt@@ -0,0 +1,14 @@+AccumulatedVisualContext Tree:+ spatial:+ [s0] transform=[1,0,0,1,0,0] origin=(0,0) (Viewport<#document>)+ [s1] scroll (Viewport<#document>)+ effects:+ [e0 in s0] effects=[]++Layers:+ [L0] base rect=[0,0 800x600]+ [L1] canvas rect=[5,5 206x126] shown by the window server: clip=[0,0 800x600]++DisplayList:+L1 DrawCanvas@s1/e0 dst_rect=[8,8 200x120]+diff --git a/Tests/LibWeb/Text/input/display_list/canvas-drawn-on-after-layout-reached-it.html b/Tests/LibWeb/Text/input/display_list/canvas-drawn-on-after-layout-reached-it.htmlnew file mode 100644index 00000000000..72aa377fef0--- /dev/null+++ b/Tests/LibWeb/Text/input/display_list/canvas-drawn-on-after-layout-reached-it.html@@ -0,0 +1,13 @@+<!DOCTYPE html>+<script src="../include.js"></script>+<canvas id="canvas" width="200" height="120"></canvas>+<script>+ test(() => {+ // Layout reaches the canvas before it has anything to paint, then its first drawing gives it content.+ canvas.getBoundingClientRect();+ const context = canvas.getContext("2d");+ context.fillStyle = "blue";+ context.fillRect(0, 0, canvas.width, canvas.height);+ println(internals.dumpDisplayList());+ });+</script>