Skip to content

Commit

Permalink
Rename Canvas2D.textLetterSpacing to Canvas2D.letterSpacing
Browse files Browse the repository at this point in the history
Per discussion in w3ctag/design-reviews#627,
we have agreed to remove text prefix for attribute textLetterSpacing. So
that thee attribute name letterSpacing follows the same naming
conversion of other text attributes.

Bug: 1233706

Change-Id: I8b37f046f5cdbfb28848ba3930e047203b061982
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3056509
Commit-Queue: Yi Xu <[email protected]>
Reviewed-by: Bo <[email protected]>
Reviewed-by: Aaron Krajeski <[email protected]>
Cr-Commit-Position: refs/heads/master@{#906594}
  • Loading branch information
yiyix authored and chromium-wpt-export-bot committed Jul 29, 2021
1 parent 84330c9 commit 34cb7e9
Show file tree
Hide file tree
Showing 11 changed files with 80 additions and 80 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ <h1>2d.text.drawing.style.nonfinite.spacing</h1>
var t = async_test("Testing letter spacing and word spacing with nonfinite inputs");
_addTest(function(canvas, ctx) {

_assertSame(ctx.textLetterSpacing, 0, "ctx.textLetterSpacing", "0");
_assertSame(ctx.letterSpacing, 0, "ctx.letterSpacing", "0");
_assertSame(ctx.wordSpacing, 0, "ctx.wordSpacing", "0");

function test_word_spacing(value) {
ctx.wordSpacing = value;
ctx.textLetterSpacing = value;
ctx.letterSpacing = value;
_assertSame(ctx.wordSpacing, 0, "ctx.wordSpacing", "0");
_assertSame(ctx.textLetterSpacing, 0, "ctx.textLetterSpacing", "0");
_assertSame(ctx.letterSpacing, 0, "ctx.letterSpacing", "0");
}
test_word_spacing(NaN);
test_word_spacing(Infinity);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,20 @@ <h1>2d.text.drawing.style.spacing</h1>
var t = async_test("Testing letter spacing and word spacing");
_addTest(function(canvas, ctx) {

_assertSame(ctx.textLetterSpacing, 0, "ctx.textLetterSpacing", "0");
_assertSame(ctx.letterSpacing, 0, "ctx.letterSpacing", "0");
_assertSame(ctx.wordSpacing, 0, "ctx.wordSpacing", "0");

ctx.textLetterSpacing = 3;
_assertSame(ctx.textLetterSpacing, 3, "ctx.textLetterSpacing", "3");
ctx.letterSpacing = 3;
_assertSame(ctx.letterSpacing, 3, "ctx.letterSpacing", "3");
_assertSame(ctx.wordSpacing, 0, "ctx.wordSpacing", "0");

ctx.wordSpacing = 5;
_assertSame(ctx.textLetterSpacing, 3, "ctx.textLetterSpacing", "3");
_assertSame(ctx.letterSpacing, 3, "ctx.letterSpacing", "3");
_assertSame(ctx.wordSpacing, 5, "ctx.wordSpacing", "5");

ctx.textLetterSpacing = -1;
ctx.letterSpacing = -1;
ctx.wordSpacing = -1;
_assertSame(ctx.textLetterSpacing, -1, "ctx.textLetterSpacing", "-1");
_assertSame(ctx.letterSpacing, -1, "ctx.letterSpacing", "-1");
_assertSame(ctx.wordSpacing, -1, "ctx.wordSpacing", "-1");


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,28 @@ <h1>2d.text.drawing.style.spacing.measure</h1>
var t = async_test("Testing letter spacing and word spacing");
_addTest(function(canvas, ctx) {

_assertSame(ctx.textLetterSpacing, 0, "ctx.textLetterSpacing", "0");
_assertSame(ctx.letterSpacing, 0, "ctx.letterSpacing", "0");
_assertSame(ctx.wordSpacing, 0, "ctx.wordSpacing", "0");
var width_normal = ctx.measureText('Hello World').width;

ctx.textLetterSpacing = 3;
_assertSame(ctx.textLetterSpacing, 3, "ctx.textLetterSpacing", "3");
ctx.letterSpacing = 3;
_assertSame(ctx.letterSpacing, 3, "ctx.letterSpacing", "3");
_assertSame(ctx.wordSpacing, 0, "ctx.wordSpacing", "0");
var width_with_spacing = ctx.measureText('Hello World').width;
// Add letter spacing after each letter, so 11 * 3 = 33px longer.
_assertSame(width_with_spacing, width_normal + 33, "width_with_spacing", "width_normal + 33");

ctx.wordSpacing = 5;
ctx.textLetterSpacing = 0;
_assertSame(ctx.textLetterSpacing, 0, "ctx.textLetterSpacing", "0");
ctx.letterSpacing = 0;
_assertSame(ctx.letterSpacing, 0, "ctx.letterSpacing", "0");
_assertSame(ctx.wordSpacing, 5, "ctx.wordSpacing", "5");
// Add Word Spacing between "Hello" and "World", so it's 5px longer.
width_with_spacing = ctx.measureText('Hello World').width;
_assertSame(width_with_spacing, width_normal + 5, "width_with_spacing", "width_normal + 5");

ctx.textLetterSpacing = -2;
ctx.letterSpacing = -2;
ctx.wordSpacing = -1;
_assertSame(ctx.textLetterSpacing, -2, "ctx.textLetterSpacing", "-2");
_assertSame(ctx.letterSpacing, -2, "ctx.letterSpacing", "-2");
_assertSame(ctx.wordSpacing, -1, "ctx.wordSpacing", "-1");
// Add Word Spacing and letter spacing, so it's -11*2 = -22px from
// letter spacing and -1px from word spacing.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ <h1>2d.text.drawing.style.nonfinite.spacing</h1>
var offscreenCanvas = new OffscreenCanvas(100, 50);
var ctx = offscreenCanvas.getContext('2d');

_assertSame(ctx.textLetterSpacing, 0, "ctx.textLetterSpacing", "0");
_assertSame(ctx.letterSpacing, 0, "ctx.letterSpacing", "0");
_assertSame(ctx.wordSpacing, 0, "ctx.wordSpacing", "0");

function test_word_spacing(value) {
ctx.wordSpacing = value;
ctx.textLetterSpacing = value;
ctx.letterSpacing = value;
_assertSame(ctx.wordSpacing, 0, "ctx.wordSpacing", "0");
_assertSame(ctx.textLetterSpacing, 0, "ctx.textLetterSpacing", "0");
_assertSame(ctx.letterSpacing, 0, "ctx.letterSpacing", "0");
}
test_word_spacing(NaN);
test_word_spacing(Infinity);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ t.step(function() {
var offscreenCanvas = new OffscreenCanvas(100, 50);
var ctx = offscreenCanvas.getContext('2d');

_assertSame(ctx.textLetterSpacing, 0, "ctx.textLetterSpacing", "0");
_assertSame(ctx.letterSpacing, 0, "ctx.letterSpacing", "0");
_assertSame(ctx.wordSpacing, 0, "ctx.wordSpacing", "0");

function test_word_spacing(value) {
ctx.wordSpacing = value;
ctx.textLetterSpacing = value;
ctx.letterSpacing = value;
_assertSame(ctx.wordSpacing, 0, "ctx.wordSpacing", "0");
_assertSame(ctx.textLetterSpacing, 0, "ctx.textLetterSpacing", "0");
_assertSame(ctx.letterSpacing, 0, "ctx.letterSpacing", "0");
}
test_word_spacing(NaN);
test_word_spacing(Infinity);
Expand Down
12 changes: 6 additions & 6 deletions html/canvas/offscreen/text/2d.text.drawing.style.spacing.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,20 @@ <h1>2d.text.drawing.style.spacing</h1>
var offscreenCanvas = new OffscreenCanvas(100, 50);
var ctx = offscreenCanvas.getContext('2d');

_assertSame(ctx.textLetterSpacing, 0, "ctx.textLetterSpacing", "0");
_assertSame(ctx.letterSpacing, 0, "ctx.letterSpacing", "0");
_assertSame(ctx.wordSpacing, 0, "ctx.wordSpacing", "0");

ctx.textLetterSpacing = 3;
_assertSame(ctx.textLetterSpacing, 3, "ctx.textLetterSpacing", "3");
ctx.letterSpacing = 3;
_assertSame(ctx.letterSpacing, 3, "ctx.letterSpacing", "3");
_assertSame(ctx.wordSpacing, 0, "ctx.wordSpacing", "0");

ctx.wordSpacing = 5;
_assertSame(ctx.textLetterSpacing, 3, "ctx.textLetterSpacing", "3");
_assertSame(ctx.letterSpacing, 3, "ctx.letterSpacing", "3");
_assertSame(ctx.wordSpacing, 5, "ctx.wordSpacing", "5");

ctx.textLetterSpacing = -1;
ctx.letterSpacing = -1;
ctx.wordSpacing = -1;
_assertSame(ctx.textLetterSpacing, -1, "ctx.textLetterSpacing", "-1");
_assertSame(ctx.letterSpacing, -1, "ctx.letterSpacing", "-1");
_assertSame(ctx.wordSpacing, -1, "ctx.wordSpacing", "-1");
t.done();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,28 @@ <h1>2d.text.drawing.style.spacing.measure</h1>
var offscreenCanvas = new OffscreenCanvas(100, 50);
var ctx = offscreenCanvas.getContext('2d');

_assertSame(ctx.textLetterSpacing, 0, "ctx.textLetterSpacing", "0");
_assertSame(ctx.letterSpacing, 0, "ctx.letterSpacing", "0");
_assertSame(ctx.wordSpacing, 0, "ctx.wordSpacing", "0");
var width_normal = ctx.measureText('Hello World').width;

ctx.textLetterSpacing = 3;
_assertSame(ctx.textLetterSpacing, 3, "ctx.textLetterSpacing", "3");
ctx.letterSpacing = 3;
_assertSame(ctx.letterSpacing, 3, "ctx.letterSpacing", "3");
_assertSame(ctx.wordSpacing, 0, "ctx.wordSpacing", "0");
var width_with_spacing = ctx.measureText('Hello World').width;
// Add letter spacing after each letter, so 11 * 3 = 33px longer.
_assertSame(width_with_spacing, width_normal + 33, "width_with_spacing", "width_normal + 33");

ctx.wordSpacing = 5;
ctx.textLetterSpacing = 0;
_assertSame(ctx.textLetterSpacing, 0, "ctx.textLetterSpacing", "0");
ctx.letterSpacing = 0;
_assertSame(ctx.letterSpacing, 0, "ctx.letterSpacing", "0");
_assertSame(ctx.wordSpacing, 5, "ctx.wordSpacing", "5");
// Add Word Spacing between "Hello" and "World", so it's 5px longer.
width_with_spacing = ctx.measureText('Hello World').width;
_assertSame(width_with_spacing, width_normal + 5, "width_with_spacing", "width_normal + 5");

ctx.textLetterSpacing = -2;
ctx.letterSpacing = -2;
ctx.wordSpacing = -1;
_assertSame(ctx.textLetterSpacing, -2, "ctx.textLetterSpacing", "-2");
_assertSame(ctx.letterSpacing, -2, "ctx.letterSpacing", "-2");
_assertSame(ctx.wordSpacing, -1, "ctx.wordSpacing", "-1");
// Add Word Spacing and letter spacing, so it's -11*2 = -22px from
// letter spacing and -1px from word spacing.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,28 @@ t.step(function() {
var offscreenCanvas = new OffscreenCanvas(100, 50);
var ctx = offscreenCanvas.getContext('2d');

_assertSame(ctx.textLetterSpacing, 0, "ctx.textLetterSpacing", "0");
_assertSame(ctx.letterSpacing, 0, "ctx.letterSpacing", "0");
_assertSame(ctx.wordSpacing, 0, "ctx.wordSpacing", "0");
var width_normal = ctx.measureText('Hello World').width;

ctx.textLetterSpacing = 3;
_assertSame(ctx.textLetterSpacing, 3, "ctx.textLetterSpacing", "3");
ctx.letterSpacing = 3;
_assertSame(ctx.letterSpacing, 3, "ctx.letterSpacing", "3");
_assertSame(ctx.wordSpacing, 0, "ctx.wordSpacing", "0");
var width_with_spacing = ctx.measureText('Hello World').width;
// Add letter spacing after each letter, so 11 * 3 = 33px longer.
_assertSame(width_with_spacing, width_normal + 33, "width_with_spacing", "width_normal + 33");

ctx.wordSpacing = 5;
ctx.textLetterSpacing = 0;
_assertSame(ctx.textLetterSpacing, 0, "ctx.textLetterSpacing", "0");
ctx.letterSpacing = 0;
_assertSame(ctx.letterSpacing, 0, "ctx.letterSpacing", "0");
_assertSame(ctx.wordSpacing, 5, "ctx.wordSpacing", "5");
// Add Word Spacing between "Hello" and "World", so it's 5px longer.
width_with_spacing = ctx.measureText('Hello World').width;
_assertSame(width_with_spacing, width_normal + 5, "width_with_spacing", "width_normal + 5");

ctx.textLetterSpacing = -2;
ctx.letterSpacing = -2;
ctx.wordSpacing = -1;
_assertSame(ctx.textLetterSpacing, -2, "ctx.textLetterSpacing", "-2");
_assertSame(ctx.letterSpacing, -2, "ctx.letterSpacing", "-2");
_assertSame(ctx.wordSpacing, -1, "ctx.wordSpacing", "-1");
// Add Word Spacing and letter spacing, so it's -11*2 = -22px from
// letter spacing and -1px from word spacing.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,20 @@ t.step(function() {
var offscreenCanvas = new OffscreenCanvas(100, 50);
var ctx = offscreenCanvas.getContext('2d');

_assertSame(ctx.textLetterSpacing, 0, "ctx.textLetterSpacing", "0");
_assertSame(ctx.letterSpacing, 0, "ctx.letterSpacing", "0");
_assertSame(ctx.wordSpacing, 0, "ctx.wordSpacing", "0");

ctx.textLetterSpacing = 3;
_assertSame(ctx.textLetterSpacing, 3, "ctx.textLetterSpacing", "3");
ctx.letterSpacing = 3;
_assertSame(ctx.letterSpacing, 3, "ctx.letterSpacing", "3");
_assertSame(ctx.wordSpacing, 0, "ctx.wordSpacing", "0");

ctx.wordSpacing = 5;
_assertSame(ctx.textLetterSpacing, 3, "ctx.textLetterSpacing", "3");
_assertSame(ctx.letterSpacing, 3, "ctx.letterSpacing", "3");
_assertSame(ctx.wordSpacing, 5, "ctx.wordSpacing", "5");

ctx.textLetterSpacing = -1;
ctx.letterSpacing = -1;
ctx.wordSpacing = -1;
_assertSame(ctx.textLetterSpacing, -1, "ctx.textLetterSpacing", "-1");
_assertSame(ctx.letterSpacing, -1, "ctx.letterSpacing", "-1");
_assertSame(ctx.wordSpacing, -1, "ctx.wordSpacing", "-1");
t.done();

Expand Down
32 changes: 16 additions & 16 deletions html/canvas/tools/yaml/element/drawing-text-to-the-canvas.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -743,35 +743,35 @@
testing:
- 2d.text.drawing.style.spacing
code: |
@assert ctx.textLetterSpacing === 0;
@assert ctx.letterSpacing === 0;
@assert ctx.wordSpacing === 0;
ctx.textLetterSpacing = 3;
@assert ctx.textLetterSpacing === 3;
ctx.letterSpacing = 3;
@assert ctx.letterSpacing === 3;
@assert ctx.wordSpacing === 0;
ctx.wordSpacing = 5;
@assert ctx.textLetterSpacing === 3;
@assert ctx.letterSpacing === 3;
@assert ctx.wordSpacing === 5;
ctx.textLetterSpacing = -1;
ctx.letterSpacing = -1;
ctx.wordSpacing = -1;
@assert ctx.textLetterSpacing === -1;
@assert ctx.letterSpacing === -1;
@assert ctx.wordSpacing === -1;
- name: 2d.text.drawing.style.nonfinite.spacing
desc: Testing letter spacing and word spacing with nonfinite inputs
testing:
- 2d.text.drawing.style.spacing
code: |
@assert ctx.textLetterSpacing === 0;
@assert ctx.letterSpacing === 0;
@assert ctx.wordSpacing === 0;
function test_word_spacing(value) {
ctx.wordSpacing = value;
ctx.textLetterSpacing = value;
ctx.letterSpacing = value;
@assert ctx.wordSpacing === 0;
@assert ctx.textLetterSpacing === 0;
@assert ctx.letterSpacing === 0;
}
@nonfinite test_word_spacing(<0 NaN Infinity -Infinity>);
Expand All @@ -780,28 +780,28 @@
testing:
- 2d.text.drawing.style.spacing
code: |
@assert ctx.textLetterSpacing === 0;
@assert ctx.letterSpacing === 0;
@assert ctx.wordSpacing === 0;
var width_normal = ctx.measureText('Hello World').width;
ctx.textLetterSpacing = 3;
@assert ctx.textLetterSpacing === 3;
ctx.letterSpacing = 3;
@assert ctx.letterSpacing === 3;
@assert ctx.wordSpacing === 0;
var width_with_spacing = ctx.measureText('Hello World').width;
// Add letter spacing after each letter, so 11 * 3 = 33px longer.
@assert width_with_spacing === width_normal + 33;
ctx.wordSpacing = 5;
ctx.textLetterSpacing = 0;
@assert ctx.textLetterSpacing === 0;
ctx.letterSpacing = 0;
@assert ctx.letterSpacing === 0;
@assert ctx.wordSpacing === 5;
// Add Word Spacing between "Hello" and "World", so it's 5px longer.
width_with_spacing = ctx.measureText('Hello World').width;
@assert width_with_spacing === width_normal + 5;
ctx.textLetterSpacing = -2;
ctx.letterSpacing = -2;
ctx.wordSpacing = -1;
@assert ctx.textLetterSpacing === -2;
@assert ctx.letterSpacing === -2;
@assert ctx.wordSpacing === -1;
// Add Word Spacing and letter spacing, so it's -11*2 = -22px from
// letter spacing and -1px from word spacing.
Expand Down
Loading

0 comments on commit 34cb7e9

Please sign in to comment.