Skip to content

Commit

Permalink
Bug 1740295 [wpt PR 31560] - GetTopExecutionContext method for Canvas…
Browse files Browse the repository at this point in the history
… rendering contexts, a=testonly

Automatic update from web-platform-tests
GetTopExecutionContext method for Canvas rendering contexts

BaseRenderingContext2D and CanvasPath access UMA, UseCounters and
RuntimeFlags through
GetCanvasRenderingContextHost()->GetTopExecutionContext(). This doesn't
work and has never worked for PaintRenderingContexts as there is no
class that works as a "host" for these contexts.

This CL adds a GetTopExecutionContext() function to all canvas rendering
2d contexts that returns a pointer to the execution context directly.
For canvas elements and offscreen canvases, this works exactly as before
(i.e. host->execution_context). For paint rendering contexts a pointer
to the PaintWorkletGlobalScope is passed in on creation.

Before this change some new Canvas2D API features would cause crashes
in paint worklets.

Change-Id: Icb6529c285d1aff2c001291a4387c613fb24fba7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3260452
Reviewed-by: Robert Flack <[email protected]>
Reviewed-by: Fernando Serboncini <[email protected]>
Commit-Queue: Aaron Krajeski <[email protected]>
Cr-Commit-Position: refs/heads/main@{#940114}

--

wpt-commits: 755553ec4f8eb116eea31556a6cfc83b18bcde1d
wpt-pr: 31560
  • Loading branch information
mysteryDate authored and moz-wptsync-bot committed Nov 15, 2021
1 parent e79338d commit 3963907
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
15 changes: 15 additions & 0 deletions testing/web-platform/tests/css/css-paint-api/roundrect-ref.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html>
<body>
<canvas id ="output" width="300" height="400"></canvas>
<script>
var canvas = document.getElementById('output');
var ctx = canvas.getContext('2d');

ctx.beginPath();
ctx.roundRect(10, 10, 100, 100, [20]);
ctx.fill();
</script>
</body>
</html>

31 changes: 31 additions & 0 deletions testing/web-platform/tests/css/css-paint-api/roundrect.https.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!DOCTYPE html>
<html class="reftest-wait">
<link rel="help" href="https://drafts.css-houdini.org/css-paint-api/">
<link rel="match" href="roundrect-ref.html">
<style>
#output {
width: 300px;
height: 400px;
background-image: paint(paths);
}
</style>
<script src="/common/reftest-wait.js"></script>
<script src="/common/worklet-reftest.js"></script>
<body>
<div id="output"></div>

<script id="code" type="text/worklet">
registerPaint('paths', class {
paint(ctx, geom) {
ctx.beginPath();
ctx.roundRect(10, 10, 100, 100, [20]);
ctx.fill();
}
});
</script>

<script>
importWorkletAndTerminateTestAfterAsyncPaint(CSS.paintWorklet, document.getElementById('code').textContent);
</script>
</body>
</html>

0 comments on commit 3963907

Please sign in to comment.