[wpt-sync] Sync PR 64498 - WebKit export of https://bugs.webkit.org/show_bug.cgi?id=322160
Categories
(Core :: Graphics: Canvas2D, task, P4)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox162 | --- | fixed |
People
(Reporter: wpt-sync, Unassigned)
References
()
Details
(Whiteboard: [wptsync downstream])
Sync web-platform-tests PR 64498 into mozilla-central (this bug is closed when the sync is complete).
PR: https://github.com/web-platform-tests/wpt/pull/64498
Details from upstream follow.
Ahmad Saleem <ahmad.saleem792+github@gmail.com> wrote:
WebKit export of https://bugs.webkit.org/show_bug.cgi?id=322160
WebKit export from bug: Canvas 2D hit testing and transform mutations should not require the canvas bitmap
<pre>
Canvas 2D hit testing and transform mutations should not require the canvas bitmapisPointInPath(), isPointInStroke(), drawFocusIfNeeded() and all six CTM
mutators opened withif (!effectiveDrawingContext()) return;. That runs
buffer() -> allocateImageBuffer(), so a pure geometry query on a fresh
canvas committed width * height * 4 bytes plus an IOSurface. Neither
hit-testing helper uses the context it fetched: Path::contains() is a CG
path query, and PathCG::strokeContains() builds its own GraphicsContext
over the 1x1 scratchContext().It is also a correctness bug. validateArea() returns false when the area
is zero, so a canvas with a zero width or height has no bitmap at all.
Hit tests therefore returned false for points genuinely inside the path,
and every CTM mutation was silently dropped.The spec does not permit this. Per the canvas state [1]: "The rendering
context's bitmaps are not part of the drawing state, as they depend on
whether and how the rendering context is bound to a canvas element." The
same section lists "The current transformation matrix." as the first
component of the drawing state. Nor is the CTM merely a painting input:
"The current transformation matrix is applied to coordinates when
creating the current default path, and when painting text, shapes, and
Path2D objects" [2]. Dropping a mutation therefore corrupts the path as
it is built -- which is what we do, by folding the inverse into m_path --
so the damage does not depend on there being a bitmap to paint into.Both hit-testing algorithms are likewise pure geometry once the
non-finite check has run [3][4], over inputs that all exist without a
backing store: the current default path, of which "There is only one
current default path, it is not part of the drawing state" [5], the CTM,
and for isPointInStroke() the line styles of the CanvasPathDrawingStyles
mixin. Firefox already behaves this way; Chrome matches our old behavior.Drop the check outright in the two hit-testing helpers, move the fetch to
the point of use behindif (auto* c = effectiveDrawingContext())in the
mutators so the state update happens either way, and hoist the cheap
early-outs above the fetch in drawFocusIfNeededInternal() so the common
unfocused case no longer allocates.Reordering cannot let state().transform drift from the context CTM:
m_hasCreatedImageBuffer is only cleared by didUpdateCanvasSizeProperties()
on a size change, which also resets the state stack and clears the path.[1] <a href="https://html.spec.whatwg.org/multipage/canvas.html#the-canvas-state">https://html.spec.whatwg.org/multipage/canvas.html#the-canvas-state</a>
[2] <a href="https://html.spec.whatwg.org/multipage/canvas.html#transformations">https://html.spec.whatwg.org/multipage/canvas.html#transformations</a>
[3] <a href="https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-ispointinpath">https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-ispointinpath</a>
[4] <a href="https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-ispointinstroke">https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-ispointinstroke</a>
[5] <a href="https://html.spec.whatwg.org/multipage/canvas.html#current-default-path">https://html.spec.whatwg.org/multipage/canvas.html#current-default-path</a>Those live under html/canvas/{element,offscreen}/path-objects/ and are
generated by /html/canvas/tools/gentest.py from tools/yaml/path-objects.yaml,
so the seven new YAML entries emit the HTMLCanvasElement, OffscreenCanvas and
worker flavor of each. All 21 baselines are a FAIL before this change.Add the YAML these tests were generated from to path-objects.yaml. WebKit has the generated files but not the YAML; gentest.py generates the tests from it byte for byte.
WebKit-Bug: <a href="https://bugs.webkit.org/show_bug.cgi?id=322160">https://bugs.webkit.org/show_bug.cgi?id=322160</a>
WebKit-Canonical-Link: <a href="https://commits.webkit.org/319602@main">https://commits.webkit.org/319602@main</a>
</pre>
| Assignee | ||
Updated•7 days ago
|
| Assignee | ||
Comment 1•7 days ago
|
||
Pushed to try (stability) https://treeherder.mozilla.org/jobs?repo=try&landoInstance=lando-prod-2025&landoCommitID=118020
| Assignee | ||
Comment 2•5 days ago
|
||
CI Results
Ran 4 Firefox configurations based on mozilla-central, and Firefox, Chrome, and Safari on GitHub CI
Total 632 tests and 1 subtests
Status Summary
Firefox
OK : 21[GitHub] 626[Gecko-windows11-64-25h2-debug, Gecko-windows11-64-25h2-opt] 631[Gecko-linux2404-64-debug] 632[Gecko-linux2404-64-opt]
PASS: 21[GitHub] 614[Gecko-windows11-64-25h2-debug, Gecko-windows11-64-25h2-opt] 620[Gecko-linux2404-64-debug, Gecko-linux2404-64-opt]
FAIL: 12
Chrome
OK : 21
FAIL: 21
Safari
OK : 21
PASS: 21
Links
Gecko CI (Treeherder)
GitHub PR Head
GitHub PR Base
Details
New Tests That Don't Pass
- /html/canvas/element/path-objects/2d.path.arcTo.ensuresubpath.3.html [wpt.fyi]
- If there is no subpath, the first control point is added (and nothing is drawn up to it):
FAIL
- If there is no subpath, the first control point is added (and nothing is drawn up to it):
- /html/canvas/element/path-objects/2d.path.closed.arc.html [wpt.fyi]:
OK[Gecko-linux2404-64-opt,Gecko-windows11-64-25h2-debug,Gecko-windows11-64-25h2-opt],SKIP[Gecko-linux2404-64-debug] - /html/canvas/element/path-objects/2d.path.roundrect.zero.3.html [wpt.fyi]:
OK[Gecko-linux2404-64-debug,Gecko-linux2404-64-opt],SKIP[Gecko-windows11-64-25h2-debug,Gecko-windows11-64-25h2-opt] - /html/canvas/element/path-objects/2d.path.roundrect.zero.6.html [wpt.fyi]:
OK[Gecko-linux2404-64-debug,Gecko-linux2404-64-opt],SKIP[Gecko-windows11-64-25h2-debug,Gecko-windows11-64-25h2-opt] - /html/canvas/element/path-objects/2d.path.stroke.prune.arc.html [wpt.fyi]
- Zero-length line segments from arcTo and arc are removed before stroking:
FAIL
- Zero-length line segments from arcTo and arc are removed before stroking:
- /html/canvas/element/path-objects/2d.path.stroke.prune.curve.html [wpt.fyi]
- Zero-length line segments from quadraticCurveTo and bezierCurveTo are removed before stroking:
FAIL
- Zero-length line segments from quadraticCurveTo and bezierCurveTo are removed before stroking:
- /html/canvas/element/path-objects/2d.path.stroke.prune.line.html [wpt.fyi]
- Zero-length line segments from lineTo are removed before stroking:
FAIL
- Zero-length line segments from lineTo are removed before stroking:
- /html/canvas/offscreen/path-objects/2d.path.arcTo.ensuresubpath.3.html [wpt.fyi]
- If there is no subpath, the first control point is added (and nothing is drawn up to it):
FAIL
- If there is no subpath, the first control point is added (and nothing is drawn up to it):
- /html/canvas/offscreen/path-objects/2d.path.arcTo.ensuresubpath.3.worker.html [wpt.fyi]
- If there is no subpath, the first control point is added (and nothing is drawn up to it):
FAIL
- If there is no subpath, the first control point is added (and nothing is drawn up to it):
- /html/canvas/offscreen/path-objects/2d.path.roundrect.zero.3.html [wpt.fyi]:
OK[Gecko-linux2404-64-debug,Gecko-linux2404-64-opt],SKIP[Gecko-windows11-64-25h2-debug,Gecko-windows11-64-25h2-opt] - /html/canvas/offscreen/path-objects/2d.path.roundrect.zero.3.worker.html [wpt.fyi]:
OK[Gecko-linux2404-64-debug,Gecko-linux2404-64-opt],SKIP[Gecko-windows11-64-25h2-debug,Gecko-windows11-64-25h2-opt] - /html/canvas/offscreen/path-objects/2d.path.roundrect.zero.6.html [wpt.fyi]:
OK[Gecko-linux2404-64-debug,Gecko-linux2404-64-opt],SKIP[Gecko-windows11-64-25h2-debug,Gecko-windows11-64-25h2-opt] - /html/canvas/offscreen/path-objects/2d.path.roundrect.zero.6.worker.html [wpt.fyi]:
OK[Gecko-linux2404-64-debug,Gecko-linux2404-64-opt],SKIP[Gecko-windows11-64-25h2-debug,Gecko-windows11-64-25h2-opt] - /html/canvas/offscreen/path-objects/2d.path.stroke.prune.arc.html [wpt.fyi]
- Zero-length line segments from arcTo and arc are removed before stroking:
FAIL
- Zero-length line segments from arcTo and arc are removed before stroking:
- /html/canvas/offscreen/path-objects/2d.path.stroke.prune.arc.worker.html [wpt.fyi]
- Zero-length line segments from arcTo and arc are removed before stroking:
FAIL
- Zero-length line segments from arcTo and arc are removed before stroking:
- /html/canvas/offscreen/path-objects/2d.path.stroke.prune.curve.html [wpt.fyi]
- Zero-length line segments from quadraticCurveTo and bezierCurveTo are removed before stroking:
FAIL
- Zero-length line segments from quadraticCurveTo and bezierCurveTo are removed before stroking:
- /html/canvas/offscreen/path-objects/2d.path.stroke.prune.curve.worker.html [wpt.fyi]
- Zero-length line segments from quadraticCurveTo and bezierCurveTo are removed before stroking:
FAIL
- Zero-length line segments from quadraticCurveTo and bezierCurveTo are removed before stroking:
- /html/canvas/offscreen/path-objects/2d.path.stroke.prune.line.html [wpt.fyi]
- Zero-length line segments from lineTo are removed before stroking:
FAIL
- Zero-length line segments from lineTo are removed before stroking:
- /html/canvas/offscreen/path-objects/2d.path.stroke.prune.line.worker.html [wpt.fyi]
- Zero-length line segments from lineTo are removed before stroking:
FAIL
- Zero-length line segments from lineTo are removed before stroking:
Tests Disabled in Gecko Infrastructure
- /html/canvas/element/path-objects/2d.path.closed.arc.html [wpt.fyi]:
OK[Gecko-linux2404-64-opt,Gecko-windows11-64-25h2-debug,Gecko-windows11-64-25h2-opt],SKIP[Gecko-linux2404-64-debug] - /html/canvas/element/path-objects/2d.path.roundrect.zero.3.html [wpt.fyi]:
OK[Gecko-linux2404-64-debug,Gecko-linux2404-64-opt],SKIP[Gecko-windows11-64-25h2-debug,Gecko-windows11-64-25h2-opt] - /html/canvas/element/path-objects/2d.path.roundrect.zero.6.html [wpt.fyi]:
OK[Gecko-linux2404-64-debug,Gecko-linux2404-64-opt],SKIP[Gecko-windows11-64-25h2-debug,Gecko-windows11-64-25h2-opt] - /html/canvas/offscreen/path-objects/2d.path.roundrect.zero.3.html [wpt.fyi]:
OK[Gecko-linux2404-64-debug,Gecko-linux2404-64-opt],SKIP[Gecko-windows11-64-25h2-debug,Gecko-windows11-64-25h2-opt] - /html/canvas/offscreen/path-objects/2d.path.roundrect.zero.3.worker.html [wpt.fyi]:
OK[Gecko-linux2404-64-debug,Gecko-linux2404-64-opt],SKIP[Gecko-windows11-64-25h2-debug,Gecko-windows11-64-25h2-opt] - /html/canvas/offscreen/path-objects/2d.path.roundrect.zero.6.html [wpt.fyi]:
OK[Gecko-linux2404-64-debug,Gecko-linux2404-64-opt],SKIP[Gecko-windows11-64-25h2-debug,Gecko-windows11-64-25h2-opt] - /html/canvas/offscreen/path-objects/2d.path.roundrect.zero.6.worker.html [wpt.fyi]:
OK[Gecko-linux2404-64-debug,Gecko-linux2404-64-opt],SKIP[Gecko-windows11-64-25h2-debug,Gecko-windows11-64-25h2-opt]
Comment 4•4 days ago
|
||
| bugherder | ||
Comment 5•4 days ago
|
||
| bugherder | ||
Description
•