Closed Bug 1903642 Opened 5 months ago Closed 4 months ago

[wpt-sync] Sync PR 46833 - Use visual runs and save ShapeResults in TextMetrics

Categories

(Core :: Graphics: Canvas2D, task, P4)

task

Tracking

()

RESOLVED FIXED
130 Branch
Tracking Status
firefox130 --- fixed

People

(Reporter: wpt-sync, Unassigned)

References

()

Details

(Whiteboard: [wptsync downstream])

Sync web-platform-tests PR 46833 into mozilla-central (this bug is closed when the sync is complete).

PR: https://github.com/web-platform-tests/wpt/pull/46833
Details from upstream follow.

Andres Ricardo Perez <andresrperez@chromium.org> wrote:

Use visual runs and save ShapeResults in TextMetrics

A previous CL implemented TextMetrics::getSelectionRects() by saving
the logical runs produced by BidiParagraph. This approach can fail
when the direction of text in the canvas is set directly with
ctx.direction, as the visual order of the runs (and therefore the
correct selection rects) can change without modifying the order in which
the logical runs are processed.

This change uses BidiParagraph::GetVisualRuns() instead, to iterate the
runs in the visual order. To calculate selection rects from these runs,
it is necessary to save the starting x position and character offset in
the input string.

Additionally, in order to avoid shaping the text over and over again,
the ShapeResult cache is only generated the first time the new method
is called. A new struct was created to hold the information needed for
each run. We defer the actual shaping of its ShapeResult as to not
significantly affect the performance of ctx.measureText().

Bug: 341213359
Change-Id: Iba4c461cddafa3d00d309f9a48e848b75ca84ff6
Reviewed-on: https://chromium-review.googlesource.com/5593278
WPT-Export-Revision: 0a3e301c2c0cff2d7c47916821618ed3ce428e3a

Component: web-platform-tests → Graphics: Canvas2D
Product: Testing → Core

CI Results

Ran 0 Firefox configurations based on mozilla-central, and Firefox, Chrome, and Safari on GitHub CI

Total 8 tests and 24 subtests

Status Summary

Firefox

OK : 8
FAIL: 54

Chrome

OK : 8
PASS: 18
FAIL: 36

Safari

OK : 8
FAIL: 54

Links

GitHub PR Head
GitHub PR Base

Details

New Tests That Don't Pass

  • /html/canvas/element/text/2d.text.measure.selection-rects-baselines.tentative.html [wpt.fyi]
    • Check that TextMetrics::getSelectionRects() works correctly with textBaseline.: FAIL (Chrome: PASS, Safari: FAIL)
  • /html/canvas/element/text/2d.text.measure.selection-rects-exceptions.tentative.html [wpt.fyi]
    • Check that TextMetrics::getSelectionRects() throws when using invalid indexes.: FAIL (Chrome: PASS, Safari: FAIL)
  • /html/canvas/element/text/2d.text.measure.selection-rects.tentative.html [wpt.fyi]
    • Check that TextMetrics::getSelectionRects() matches its DOM equivalent, with direction ltr, text align left, 0px letter spacing, and no-directional-override.: FAIL (Chrome: PASS, Safari: FAIL)
    • Check that TextMetrics::getSelectionRects() matches its DOM equivalent, with direction rtl, text align left, 0px letter spacing, and no-directional-override.: FAIL (Chrome: FAIL, Safari: FAIL)
    • Check that TextMetrics::getSelectionRects() matches its DOM equivalent, with direction ltr, text align center, 0px letter spacing, and no-directional-override.: FAIL (Chrome: PASS, Safari: FAIL)
    • Check that TextMetrics::getSelectionRects() matches its DOM equivalent, with direction rtl, text align center, 0px letter spacing, and no-directional-override.: FAIL (Chrome: FAIL, Safari: FAIL)
    • Check that TextMetrics::getSelectionRects() matches its DOM equivalent, with direction ltr, text align right, 0px letter spacing, and no-directional-override.: FAIL (Chrome: PASS, Safari: FAIL)
    • Check that TextMetrics::getSelectionRects() matches its DOM equivalent, with direction rtl, text align right, 0px letter spacing, and no-directional-override.: FAIL (Chrome: FAIL, Safari: FAIL)
    • Check that TextMetrics::getSelectionRects() matches its DOM equivalent, with direction ltr, text align left, 10px letter spacing, and no-directional-override.: FAIL (Chrome: PASS, Safari: FAIL)
    • Check that TextMetrics::getSelectionRects() matches its DOM equivalent, with direction rtl, text align left, 10px letter spacing, and no-directional-override.: FAIL (Chrome: FAIL, Safari: FAIL)
    • Check that TextMetrics::getSelectionRects() matches its DOM equivalent, with direction ltr, text align center, 10px letter spacing, and no-directional-override.: FAIL (Chrome: PASS, Safari: FAIL)
    • Check that TextMetrics::getSelectionRects() matches its DOM equivalent, with direction rtl, text align center, 10px letter spacing, and no-directional-override.: FAIL (Chrome: FAIL, Safari: FAIL)
    • Check that TextMetrics::getSelectionRects() matches its DOM equivalent, with direction ltr, text align right, 10px letter spacing, and no-directional-override.: FAIL (Chrome: PASS, Safari: FAIL)
    • Check that TextMetrics::getSelectionRects() matches its DOM equivalent, with direction rtl, text align right, 10px letter spacing, and no-directional-override.: FAIL (Chrome: FAIL, Safari: FAIL)
    • Check that TextMetrics::getSelectionRects() matches its DOM equivalent, with direction ltr, text align left, 0px letter spacing, and directional-override.: FAIL (Chrome: FAIL, Safari: FAIL)
    • Check that TextMetrics::getSelectionRects() matches its DOM equivalent, with direction rtl, text align left, 0px letter spacing, and directional-override.: FAIL (Chrome: FAIL, Safari: FAIL)
    • Check that TextMetrics::getSelectionRects() matches its DOM equivalent, with direction ltr, text align center, 0px letter spacing, and directional-override.: FAIL (Chrome: FAIL, Safari: FAIL)
    • Check that TextMetrics::getSelectionRects() matches its DOM equivalent, with direction rtl, text align center, 0px letter spacing, and directional-override.: FAIL (Chrome: FAIL, Safari: FAIL)
    • Check that TextMetrics::getSelectionRects() matches its DOM equivalent, with direction ltr, text align right, 0px letter spacing, and directional-override.: FAIL (Chrome: FAIL, Safari: FAIL)
    • Check that TextMetrics::getSelectionRects() matches its DOM equivalent, with direction rtl, text align right, 0px letter spacing, and directional-override.: FAIL (Chrome: FAIL, Safari: FAIL)
    • Check that TextMetrics::getSelectionRects() matches its DOM equivalent, with direction ltr, text align left, 10px letter spacing, and directional-override.: FAIL (Chrome: FAIL, Safari: FAIL)
    • Check that TextMetrics::getSelectionRects() matches its DOM equivalent, with direction rtl, text align left, 10px letter spacing, and directional-override.: FAIL (Chrome: FAIL, Safari: FAIL)
    • Check that TextMetrics::getSelectionRects() matches its DOM equivalent, with direction ltr, text align center, 10px letter spacing, and directional-override.: FAIL (Chrome: FAIL, Safari: FAIL)
    • Check that TextMetrics::getSelectionRects() matches its DOM equivalent, with direction rtl, text align center, 10px letter spacing, and directional-override.: FAIL (Chrome: FAIL, Safari: FAIL)
    • Check that TextMetrics::getSelectionRects() matches its DOM equivalent, with direction ltr, text align right, 10px letter spacing, and directional-override.: FAIL (Chrome: FAIL, Safari: FAIL)
    • Check that TextMetrics::getSelectionRects() matches its DOM equivalent, with direction rtl, text align right, 10px letter spacing, and directional-override.: FAIL (Chrome: FAIL, Safari: FAIL)
  • /html/canvas/offscreen/text/2d.text.measure.selection-rects-baselines.tentative.html [wpt.fyi]
    • Check that TextMetrics::getSelectionRects() works correctly with textBaseline.: FAIL (Chrome: PASS, Safari: FAIL)
  • /html/canvas/offscreen/text/2d.text.measure.selection-rects-baselines.tentative.worker.html [wpt.fyi]
    • Check that TextMetrics::getSelectionRects() works correctly with textBaseline.: FAIL (Chrome: PASS, Safari: FAIL)
  • /html/canvas/offscreen/text/2d.text.measure.selection-rects-exceptions.tentative.html [wpt.fyi]
    • Check that TextMetrics::getSelectionRects() throws when using invalid indexes.: FAIL (Chrome: PASS, Safari: FAIL)
  • /html/canvas/offscreen/text/2d.text.measure.selection-rects-exceptions.tentative.worker.html [wpt.fyi]
    • Check that TextMetrics::getSelectionRects() throws when using invalid indexes.: FAIL (Chrome: PASS, Safari: FAIL)
  • /html/canvas/offscreen/text/2d.text.measure.selection-rects.tentative.html [wpt.fyi]
    • Check that TextMetrics::getSelectionRects() matches its DOM equivalent, with direction ltr, text align left, 0px letter spacing, and no-directional-override.: FAIL (Chrome: PASS, Safari: FAIL)
    • Check that TextMetrics::getSelectionRects() matches its DOM equivalent, with direction rtl, text align left, 0px letter spacing, and no-directional-override.: FAIL (Chrome: FAIL, Safari: FAIL)
    • Check that TextMetrics::getSelectionRects() matches its DOM equivalent, with direction ltr, text align center, 0px letter spacing, and no-directional-override.: FAIL (Chrome: PASS, Safari: FAIL)
    • Check that TextMetrics::getSelectionRects() matches its DOM equivalent, with direction rtl, text align center, 0px letter spacing, and no-directional-override.: FAIL (Chrome: FAIL, Safari: FAIL)
    • Check that TextMetrics::getSelectionRects() matches its DOM equivalent, with direction ltr, text align right, 0px letter spacing, and no-directional-override.: FAIL (Chrome: PASS, Safari: FAIL)
    • Check that TextMetrics::getSelectionRects() matches its DOM equivalent, with direction rtl, text align right, 0px letter spacing, and no-directional-override.: FAIL (Chrome: FAIL, Safari: FAIL)
    • Check that TextMetrics::getSelectionRects() matches its DOM equivalent, with direction ltr, text align left, 10px letter spacing, and no-directional-override.: FAIL (Chrome: PASS, Safari: FAIL)
    • Check that TextMetrics::getSelectionRects() matches its DOM equivalent, with direction rtl, text align left, 10px letter spacing, and no-directional-override.: FAIL (Chrome: FAIL, Safari: FAIL)
    • Check that TextMetrics::getSelectionRects() matches its DOM equivalent, with direction ltr, text align center, 10px letter spacing, and no-directional-override.: FAIL (Chrome: PASS, Safari: FAIL)
    • Check that TextMetrics::getSelectionRects() matches its DOM equivalent, with direction rtl, text align center, 10px letter spacing, and no-directional-override.: FAIL (Chrome: FAIL, Safari: FAIL)
    • Check that TextMetrics::getSelectionRects() matches its DOM equivalent, with direction ltr, text align right, 10px letter spacing, and no-directional-override.: FAIL (Chrome: PASS, Safari: FAIL)
    • Check that TextMetrics::getSelectionRects() matches its DOM equivalent, with direction rtl, text align right, 10px letter spacing, and no-directional-override.: FAIL (Chrome: FAIL, Safari: FAIL)
    • Check that TextMetrics::getSelectionRects() matches its DOM equivalent, with direction ltr, text align left, 0px letter spacing, and directional-override.: FAIL (Chrome: FAIL, Safari: FAIL)
    • Check that TextMetrics::getSelectionRects() matches its DOM equivalent, with direction rtl, text align left, 0px letter spacing, and directional-override.: FAIL (Chrome: FAIL, Safari: FAIL)
    • Check that TextMetrics::getSelectionRects() matches its DOM equivalent, with direction ltr, text align center, 0px letter spacing, and directional-override.: FAIL (Chrome: FAIL, Safari: FAIL)
    • Check that TextMetrics::getSelectionRects() matches its DOM equivalent, with direction rtl, text align center, 0px letter spacing, and directional-override.: FAIL (Chrome: FAIL, Safari: FAIL)
    • Check that TextMetrics::getSelectionRects() matches its DOM equivalent, with direction ltr, text align right, 0px letter spacing, and directional-override.: FAIL (Chrome: FAIL, Safari: FAIL)
    • Check that TextMetrics::getSelectionRects() matches its DOM equivalent, with direction rtl, text align right, 0px letter spacing, and directional-override.: FAIL (Chrome: FAIL, Safari: FAIL)
    • Check that TextMetrics::getSelectionRects() matches its DOM equivalent, with direction ltr, text align left, 10px letter spacing, and directional-override.: FAIL (Chrome: FAIL, Safari: FAIL)
    • Check that TextMetrics::getSelectionRects() matches its DOM equivalent, with direction rtl, text align left, 10px letter spacing, and directional-override.: FAIL (Chrome: FAIL, Safari: FAIL)
    • Check that TextMetrics::getSelectionRects() matches its DOM equivalent, with direction ltr, text align center, 10px letter spacing, and directional-override.: FAIL (Chrome: FAIL, Safari: FAIL)
    • Check that TextMetrics::getSelectionRects() matches its DOM equivalent, with direction rtl, text align center, 10px letter spacing, and directional-override.: FAIL (Chrome: FAIL, Safari: FAIL)
    • Check that TextMetrics::getSelectionRects() matches its DOM equivalent, with direction ltr, text align right, 10px letter spacing, and directional-override.: FAIL (Chrome: FAIL, Safari: FAIL)
    • Check that TextMetrics::getSelectionRects() matches its DOM equivalent, with direction rtl, text align right, 10px letter spacing, and directional-override.: FAIL (Chrome: FAIL, Safari: FAIL)
Pushed by wptsync@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/aee3605ae92c [wpt PR 46833] - Use visual runs and save ShapeResults in TextMetrics, a=testonly https://hg.mozilla.org/integration/autoland/rev/4804dfda8e9f [wpt PR 46833] - Update wpt metadata, a=testonly
Status: NEW → RESOLVED
Closed: 4 months ago
Resolution: --- → FIXED
Target Milestone: --- → 130 Branch
You need to log in before you can comment on or make changes to this bug.