Skip to content

Commit

Permalink
Bug 1722787 [wpt PR 29821] - Rename Canvas2D.textWordSpacing to Canva…
Browse files Browse the repository at this point in the history
…s2D.wordSpacing, a=testonly

Automatic update from web-platform-tests
Rename Canvas2D.textWordSpacing to Canvas2D.wordSpacing

Per discussion in w3ctag/design-reviews#627,
we have agreed to remove text prefix for attribute textWordSpacing. So
that thee attribute name wordSpacing follows the same naming conversion
of other text attributes.

Bug: 1233706

Change-Id: Ic735c7c4617572511fd37fe0928f8919e7fd3f69
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3056391
Reviewed-by: Bo <[email protected]>
Reviewed-by: Aaron Krajeski <[email protected]>
Commit-Queue: Yi Xu <[email protected]>
Cr-Commit-Position: refs/heads/master@{#906470}

--

wpt-commits: 7666067297aef38ba695aac42f703e627d9c6dd9
wpt-pr: 29821
  • Loading branch information
yiyix authored and moz-wptsync-bot committed Jul 31, 2021
1 parent 3cb28fa commit 0d93636
Show file tree
Hide file tree
Showing 11 changed files with 75 additions and 75 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ <h1>2d.text.drawing.style.nonfinite.spacing</h1>
_addTest(function(canvas, ctx) {

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

function test_word_spacing(value) {
ctx.textWordSpacing = value;
ctx.wordSpacing = value;
ctx.textLetterSpacing = value;
_assertSame(ctx.textWordSpacing, 0, "ctx.textWordSpacing", "0");
_assertSame(ctx.wordSpacing, 0, "ctx.wordSpacing", "0");
_assertSame(ctx.textLetterSpacing, 0, "ctx.textLetterSpacing", "0");
}
test_word_spacing(NaN);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,20 @@ <h1>2d.text.drawing.style.spacing</h1>
_addTest(function(canvas, ctx) {

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

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

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

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


});
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>
_addTest(function(canvas, ctx) {

_assertSame(ctx.textLetterSpacing, 0, "ctx.textLetterSpacing", "0");
_assertSame(ctx.textWordSpacing, 0, "ctx.textWordSpacing", "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");
_assertSame(ctx.textWordSpacing, 0, "ctx.textWordSpacing", "0");
_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.textWordSpacing = 5;
ctx.wordSpacing = 5;
ctx.textLetterSpacing = 0;
_assertSame(ctx.textLetterSpacing, 0, "ctx.textLetterSpacing", "0");
_assertSame(ctx.textWordSpacing, 5, "ctx.textWordSpacing", "5");
_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.textWordSpacing = -1;
ctx.wordSpacing = -1;
_assertSame(ctx.textLetterSpacing, -2, "ctx.textLetterSpacing", "-2");
_assertSame(ctx.textWordSpacing, -1, "ctx.textWordSpacing", "-1");
_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.
width_with_spacing = ctx.measureText('Hello World').width;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ <h1>2d.text.drawing.style.nonfinite.spacing</h1>
var ctx = offscreenCanvas.getContext('2d');

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

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

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

function test_word_spacing(value) {
ctx.textWordSpacing = value;
ctx.wordSpacing = value;
ctx.textLetterSpacing = value;
_assertSame(ctx.textWordSpacing, 0, "ctx.textWordSpacing", "0");
_assertSame(ctx.wordSpacing, 0, "ctx.wordSpacing", "0");
_assertSame(ctx.textLetterSpacing, 0, "ctx.textLetterSpacing", "0");
}
test_word_spacing(NaN);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,20 @@ <h1>2d.text.drawing.style.spacing</h1>
var ctx = offscreenCanvas.getContext('2d');

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

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

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

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

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

_assertSame(ctx.textLetterSpacing, 0, "ctx.textLetterSpacing", "0");
_assertSame(ctx.textWordSpacing, 0, "ctx.textWordSpacing", "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");
_assertSame(ctx.textWordSpacing, 0, "ctx.textWordSpacing", "0");
_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.textWordSpacing = 5;
ctx.wordSpacing = 5;
ctx.textLetterSpacing = 0;
_assertSame(ctx.textLetterSpacing, 0, "ctx.textLetterSpacing", "0");
_assertSame(ctx.textWordSpacing, 5, "ctx.textWordSpacing", "5");
_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.textWordSpacing = -1;
ctx.wordSpacing = -1;
_assertSame(ctx.textLetterSpacing, -2, "ctx.textLetterSpacing", "-2");
_assertSame(ctx.textWordSpacing, -1, "ctx.textWordSpacing", "-1");
_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.
width_with_spacing = ctx.measureText('Hello World').width;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,28 @@ var offscreenCanvas = new OffscreenCanvas(100, 50);
var ctx = offscreenCanvas.getContext('2d');

_assertSame(ctx.textLetterSpacing, 0, "ctx.textLetterSpacing", "0");
_assertSame(ctx.textWordSpacing, 0, "ctx.textWordSpacing", "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");
_assertSame(ctx.textWordSpacing, 0, "ctx.textWordSpacing", "0");
_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.textWordSpacing = 5;
ctx.wordSpacing = 5;
ctx.textLetterSpacing = 0;
_assertSame(ctx.textLetterSpacing, 0, "ctx.textLetterSpacing", "0");
_assertSame(ctx.textWordSpacing, 5, "ctx.textWordSpacing", "5");
_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.textWordSpacing = -1;
ctx.wordSpacing = -1;
_assertSame(ctx.textLetterSpacing, -2, "ctx.textLetterSpacing", "-2");
_assertSame(ctx.textWordSpacing, -1, "ctx.textWordSpacing", "-1");
_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.
width_with_spacing = ctx.measureText('Hello World').width;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@ var offscreenCanvas = new OffscreenCanvas(100, 50);
var ctx = offscreenCanvas.getContext('2d');

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

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

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

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

});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -744,33 +744,33 @@
- 2d.text.drawing.style.spacing
code: |
@assert ctx.textLetterSpacing === 0;
@assert ctx.textWordSpacing === 0;
@assert ctx.wordSpacing === 0;
ctx.textLetterSpacing = 3;
@assert ctx.textLetterSpacing === 3;
@assert ctx.textWordSpacing === 0;
@assert ctx.wordSpacing === 0;
ctx.textWordSpacing = 5;
ctx.wordSpacing = 5;
@assert ctx.textLetterSpacing === 3;
@assert ctx.textWordSpacing === 5;
@assert ctx.wordSpacing === 5;
ctx.textLetterSpacing = -1;
ctx.textWordSpacing = -1;
ctx.wordSpacing = -1;
@assert ctx.textLetterSpacing === -1;
@assert ctx.textWordSpacing === -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.textWordSpacing === 0;
@assert ctx.wordSpacing === 0;
function test_word_spacing(value) {
ctx.textWordSpacing = value;
ctx.wordSpacing = value;
ctx.textLetterSpacing = value;
@assert ctx.textWordSpacing === 0;
@assert ctx.wordSpacing === 0;
@assert ctx.textLetterSpacing === 0;
}
@nonfinite test_word_spacing(<0 NaN Infinity -Infinity>);
Expand All @@ -781,28 +781,28 @@
- 2d.text.drawing.style.spacing
code: |
@assert ctx.textLetterSpacing === 0;
@assert ctx.textWordSpacing === 0;
@assert ctx.wordSpacing === 0;
var width_normal = ctx.measureText('Hello World').width;
ctx.textLetterSpacing = 3;
@assert ctx.textLetterSpacing === 3;
@assert ctx.textWordSpacing === 0;
@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.textWordSpacing = 5;
ctx.wordSpacing = 5;
ctx.textLetterSpacing = 0;
@assert ctx.textLetterSpacing === 0;
@assert ctx.textWordSpacing === 5;
@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.textWordSpacing = -1;
ctx.wordSpacing = -1;
@assert ctx.textLetterSpacing === -2;
@assert ctx.textWordSpacing === -1;
@assert ctx.wordSpacing === -1;
// Add Word Spacing and letter spacing, so it's -11*2 = -22px from
// letter spacing and -1px from word spacing.
width_with_spacing = ctx.measureText('Hello World').width;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1242,20 +1242,20 @@
- 2d.text.drawing.style.spacing
code: |
@assert ctx.textLetterSpacing === 0;
@assert ctx.textWordSpacing === 0;
@assert ctx.wordSpacing === 0;
ctx.textLetterSpacing = 3;
@assert ctx.textLetterSpacing === 3;
@assert ctx.textWordSpacing === 0;
@assert ctx.wordSpacing === 0;
ctx.textWordSpacing = 5;
ctx.wordSpacing = 5;
@assert ctx.textLetterSpacing === 3;
@assert ctx.textWordSpacing === 5;
@assert ctx.wordSpacing === 5;
ctx.textLetterSpacing = -1;
ctx.textWordSpacing = -1;
ctx.wordSpacing = -1;
@assert ctx.textLetterSpacing === -1;
@assert ctx.textWordSpacing === -1;
@assert ctx.wordSpacing === -1;
t.done();
- name: 2d.text.drawing.style.nonfinite.spacing
Expand All @@ -1264,12 +1264,12 @@
- 2d.text.drawing.style.spacing
code: |
@assert ctx.textLetterSpacing === 0;
@assert ctx.textWordSpacing === 0;
@assert ctx.wordSpacing === 0;
function test_word_spacing(value) {
ctx.textWordSpacing = value;
ctx.wordSpacing = value;
ctx.textLetterSpacing = value;
@assert ctx.textWordSpacing === 0;
@assert ctx.wordSpacing === 0;
@assert ctx.textLetterSpacing === 0;
}
@nonfinite test_word_spacing(<0 NaN Infinity -Infinity>);
Expand All @@ -1282,28 +1282,28 @@
- 2d.text.drawing.style.spacing
code: |
@assert ctx.textLetterSpacing === 0;
@assert ctx.textWordSpacing === 0;
@assert ctx.wordSpacing === 0;
var width_normal = ctx.measureText('Hello World').width;
ctx.textLetterSpacing = 3;
@assert ctx.textLetterSpacing === 3;
@assert ctx.textWordSpacing === 0;
@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.textWordSpacing = 5;
ctx.wordSpacing = 5;
ctx.textLetterSpacing = 0;
@assert ctx.textLetterSpacing === 0;
@assert ctx.textWordSpacing === 5;
@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.textWordSpacing = -1;
ctx.wordSpacing = -1;
@assert ctx.textLetterSpacing === -2;
@assert ctx.textWordSpacing === -1;
@assert ctx.wordSpacing === -1;
// Add Word Spacing and letter spacing, so it's -11*2 = -22px from
// letter spacing and -1px from word spacing.
width_with_spacing = ctx.measureText('Hello World').width;
Expand Down

0 comments on commit 0d93636

Please sign in to comment.