From 625fea211d1bf15a167c201df0e75d287b0e000e Mon Sep 17 00:00:00 2001 From: Stephen Chenney Date: Wed, 22 Jan 2025 06:26:47 -0800 Subject: [PATCH] Fix direction = "inherit" for offscreen canvas Offscreen canvas was not inheriting the direction attribute in the way the spec described (which I am in the process of reworking). When the direction is inherit the offscreen should try to get it from a canvas element it is associated with, or the document if there is no associated element (i.e. it was not transferred). Also add tests for canvas text direction = "inherit" Bug: 390272618 Change-Id: I5f862a4e2337b94b2eaa721733725a860872a824 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6173291 Reviewed-by: Andres Ricardo Perez Commit-Queue: Stephen Chenney Cr-Commit-Position: refs/heads/main@{#1409617} --- .../manual/text/canvas.2d.direction-ref.html | 24 ++++++++++++ .../canvas.2d.direction.inherit.canvas.html | 29 ++++++++++++++ ...direction.inherit.disconnected.canvas.html | 38 +++++++++++++++++++ .../canvas.2d.direction.inherit.document.html | 34 +++++++++++++++++ .../canvas.2d.direction.inherit.style.html | 33 ++++++++++++++++ .../canvas.2d.offscreen.direction-ref.html | 22 +++++++++++ .../text/canvas.2d.offscreen.direction.html | 37 ++++++++++++++++++ ...ransferred.direction.inherit.document.html | 38 +++++++++++++++++++ ...fscreen.transferred.direction.inherit.html | 30 +++++++++++++++ .../canvas.2d.offscreen.worker.direction.html | 30 +++++++++++++++ .../manual/text/text-direction-worker.js | 8 ++++ 11 files changed, 323 insertions(+) create mode 100644 html/canvas/element/manual/text/canvas.2d.direction-ref.html create mode 100644 html/canvas/element/manual/text/canvas.2d.direction.inherit.canvas.html create mode 100644 html/canvas/element/manual/text/canvas.2d.direction.inherit.disconnected.canvas.html create mode 100644 html/canvas/element/manual/text/canvas.2d.direction.inherit.document.html create mode 100644 html/canvas/element/manual/text/canvas.2d.direction.inherit.style.html create mode 100644 html/canvas/offscreen/manual/text/canvas.2d.offscreen.direction-ref.html create mode 100644 html/canvas/offscreen/manual/text/canvas.2d.offscreen.direction.html create mode 100644 html/canvas/offscreen/manual/text/canvas.2d.offscreen.transferred.direction.inherit.document.html create mode 100644 html/canvas/offscreen/manual/text/canvas.2d.offscreen.transferred.direction.inherit.html create mode 100644 html/canvas/offscreen/manual/text/canvas.2d.offscreen.worker.direction.html create mode 100644 html/canvas/offscreen/manual/text/text-direction-worker.js diff --git a/html/canvas/element/manual/text/canvas.2d.direction-ref.html b/html/canvas/element/manual/text/canvas.2d.direction-ref.html new file mode 100644 index 00000000000000..e7f685244d9a5b --- /dev/null +++ b/html/canvas/element/manual/text/canvas.2d.direction-ref.html @@ -0,0 +1,24 @@ + + + + + HTML5 Canvas Test Reference: The direction attribute. + + + + + + Browser does not support HTML5 Canvas. + + + diff --git a/html/canvas/element/manual/text/canvas.2d.direction.inherit.canvas.html b/html/canvas/element/manual/text/canvas.2d.direction.inherit.canvas.html new file mode 100644 index 00000000000000..c6eee5d9a8c13b --- /dev/null +++ b/html/canvas/element/manual/text/canvas.2d.direction.inherit.canvas.html @@ -0,0 +1,29 @@ + + + + + HTML5 Canvas Test: The direction attribute inherits from the canvas + + + + + + + + + Browser does not support HTML5 Canvas. + + + + diff --git a/html/canvas/element/manual/text/canvas.2d.direction.inherit.disconnected.canvas.html b/html/canvas/element/manual/text/canvas.2d.direction.inherit.disconnected.canvas.html new file mode 100644 index 00000000000000..0499563763a8ee --- /dev/null +++ b/html/canvas/element/manual/text/canvas.2d.direction.inherit.disconnected.canvas.html @@ -0,0 +1,38 @@ + + + + + HTML5 Canvas Test: The direction attribute inherits from a disconnected canvas element + + + + + + + + + Browser does not support HTML5 Canvas. + + + + + diff --git a/html/canvas/element/manual/text/canvas.2d.direction.inherit.document.html b/html/canvas/element/manual/text/canvas.2d.direction.inherit.document.html new file mode 100644 index 00000000000000..c9a3e3bdfd0a56 --- /dev/null +++ b/html/canvas/element/manual/text/canvas.2d.direction.inherit.document.html @@ -0,0 +1,34 @@ + + + + + HTML5 Canvas Test: The direction attribute inherits correctly + + + + + + + + + + Browser does not support HTML5 Canvas. + + + diff --git a/html/canvas/element/manual/text/canvas.2d.direction.inherit.style.html b/html/canvas/element/manual/text/canvas.2d.direction.inherit.style.html new file mode 100644 index 00000000000000..8405f56443ea0b --- /dev/null +++ b/html/canvas/element/manual/text/canvas.2d.direction.inherit.style.html @@ -0,0 +1,33 @@ + + + + + HTML5 Canvas Test: The direction attribute inherits from the canvas style + + + + + + + + + + Browser does not support HTML5 Canvas. + + + + diff --git a/html/canvas/offscreen/manual/text/canvas.2d.offscreen.direction-ref.html b/html/canvas/offscreen/manual/text/canvas.2d.offscreen.direction-ref.html new file mode 100644 index 00000000000000..8949caa8486848 --- /dev/null +++ b/html/canvas/offscreen/manual/text/canvas.2d.offscreen.direction-ref.html @@ -0,0 +1,22 @@ + + + + + HTML5 Canvas Test Reference: The direction attribute in an offscreen canvas + + + + + Browser does not support HTML5 Canvas. + + diff --git a/html/canvas/offscreen/manual/text/canvas.2d.offscreen.direction.html b/html/canvas/offscreen/manual/text/canvas.2d.offscreen.direction.html new file mode 100644 index 00000000000000..422cbac3082687 --- /dev/null +++ b/html/canvas/offscreen/manual/text/canvas.2d.offscreen.direction.html @@ -0,0 +1,37 @@ + + + + + HTML5 Canvas Test: The direction attribute in offscreen canvas + + + + + + + + + + Browser does not support HTML5 Canvas. + + + + diff --git a/html/canvas/offscreen/manual/text/canvas.2d.offscreen.transferred.direction.inherit.document.html b/html/canvas/offscreen/manual/text/canvas.2d.offscreen.transferred.direction.inherit.document.html new file mode 100644 index 00000000000000..670a8036eaca17 --- /dev/null +++ b/html/canvas/offscreen/manual/text/canvas.2d.offscreen.transferred.direction.inherit.document.html @@ -0,0 +1,38 @@ + + + + + HTML5 Canvas Test: The direction attribute inherits from the document + + + + + + + + + + + Browser does not support HTML5 Canvas. + + + + diff --git a/html/canvas/offscreen/manual/text/canvas.2d.offscreen.transferred.direction.inherit.html b/html/canvas/offscreen/manual/text/canvas.2d.offscreen.transferred.direction.inherit.html new file mode 100644 index 00000000000000..2e32faf863b139 --- /dev/null +++ b/html/canvas/offscreen/manual/text/canvas.2d.offscreen.transferred.direction.inherit.html @@ -0,0 +1,30 @@ + + + + + HTML5 Canvas Test: Direction inherit in a transferred offscreen + + + + + + + + + + Browser does not support HTML5 Canvas. + + + + diff --git a/html/canvas/offscreen/manual/text/canvas.2d.offscreen.worker.direction.html b/html/canvas/offscreen/manual/text/canvas.2d.offscreen.worker.direction.html new file mode 100644 index 00000000000000..c35359b5808312 --- /dev/null +++ b/html/canvas/offscreen/manual/text/canvas.2d.offscreen.worker.direction.html @@ -0,0 +1,30 @@ + + + + + HTML5 Canvas Test: The direction attribute is respected in offscreen worker canvas + + + + + + + + + + Browser does not support HTML5 Canvas. + + + + diff --git a/html/canvas/offscreen/manual/text/text-direction-worker.js b/html/canvas/offscreen/manual/text/text-direction-worker.js new file mode 100644 index 00000000000000..9375ec16f231ec --- /dev/null +++ b/html/canvas/offscreen/manual/text/text-direction-worker.js @@ -0,0 +1,8 @@ +self.onmessage = function(e) { + offscreen = e.data.canvas; + offscreen_ctx = offscreen.getContext("2d"); + + offscreen_ctx.font = "25px serif"; + offscreen_ctx.direction = "rtl"; + offscreen_ctx.fillText("ABC!", 60, 50); +} \ No newline at end of file