Bug 1725132 [wpt PR 29986] - Rely on the CSS serializer for CanvasTextDrawingStyles...
commit3468dcbc96f2f1f6c502050e22a1c1cd7c92f7ab
authorFrédéric Wang <fwang@igalia.com>
Sat, 14 Aug 2021 21:15:50 +0000 (14 21:15 +0000)
committermoz-wptsync-bot <wptsync@mozilla.com>
Sun, 15 Aug 2021 07:15:45 +0000 (15 07:15 +0000)
tree2390cddd57fcc301b76383c478a8dc20f89a6ac3
parenteccee44be374a78dc9da8d073a36db55c51ca6f3
Bug 1725132 [wpt PR 29986] - Rely on the CSS serializer for CanvasTextDrawingStyles.font, a=testonly

Automatic update from web-platform-tests
Rely on the CSS serializer for CanvasTextDrawingStyles.font

According to the canvas specification [1]:

"On getting, the font attribute must return the serialized form of the
current font of the context (with no 'line-height' component)."

This patch changes the implementations of CanvasRenderingContext2D
OffscreenCanvasRenderingContext2D so that the font-family part is
serialized via the CSS serializer [2] [3] [4]. This reduces code
duplication and makes things more consistent in preparation for
[5]. In particular, this changes the following:

- Font family names are always quoted when necessary (e.g. if they
  contain a quote or a comma), while this used to only be done when
  they contain an ASCII space U+0020.
- The "-webkit" prefix prepended to some generic font families names
  (namely "cursive", "fantasy", "monospace", "sans-serif" and "serif")
  is removed ; while this used to be done for all font family names
  with a "-webkit" prefix.
- Various character substitutions from [3] are performed, while no
  no such substitutions used to happen. One noticeable edge case is
  the escaping of double quote and backslash characters.

The new serialization behavior aligns with Firefox. This is a considered
a minor bug fix that "does not affect web API behavior to the point that
developers need to be aware of it" and so is exempt from an I2S [6].

[1] https://html.spec.whatwg.org/multipage/canvas.html#text-styles
[2] https://drafts.csswg.org/cssom/#serialize-a-comma-separated-list
[3] https://drafts.csswg.org/cssom/#serialize-a-string
[4] https://drafts.csswg.org/cssom/#serialize-an-identifier
[5] https://bugs.chromium.org/p/chromium/issues/detail?id=1065468
[6] https://www.chromium.org/blink/launching-features

Bug: 1065468
Change-Id: I7003705af8010cbb9723ee8d0a6c39e083f9eef7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3086444
Reviewed-by: Yi Xu <yiyix@chromium.org>
Reviewed-by: Rune Lillesveen <futhark@chromium.org>
Commit-Queue: Frédéric Wang <fwang@igalia.com>
Cr-Commit-Position: refs/heads/master@{#911930}

--

wpt-commits: 6fc4f27b2befb9e5cb8256fd41617dedd16d691a
wpt-pr: 29986
testing/web-platform/tests/html/canvas/element/text-styles/2d.text.font.parse.family.html [new file with mode: 0644]
testing/web-platform/tests/html/canvas/offscreen/text/2d.text.font.parse.family.html [new file with mode: 0644]
testing/web-platform/tests/html/canvas/offscreen/text/2d.text.font.parse.family.worker.js [new file with mode: 0644]
testing/web-platform/tests/html/canvas/tools/yaml/element/text-styles.yaml
testing/web-platform/tests/html/canvas/tools/yaml/offscreen/text.yaml