Skip to content

Commit

Permalink
Rename Canvas2D.textWordSpacing to Canvas2D.wordSpacing
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 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}
  • Loading branch information
yiyix authored and Chromium LUCI CQ committed Jul 29, 2021
1 parent a1cb350 commit 561dd52
Show file tree
Hide file tree
Showing 29 changed files with 115 additions and 115 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ interface CanvasRenderingContext2D
getter textBaseline
getter textLetterSpacing
getter textRendering
getter textWordSpacing
getter wordSpacing
method arc
method arcTo
method beginPath
Expand Down Expand Up @@ -773,7 +773,7 @@ interface CanvasRenderingContext2D
setter textBaseline
setter textLetterSpacing
setter textRendering
setter textWordSpacing
setter wordSpacing
interface ChannelMergerNode : AudioNode
attribute @@toStringTag
method constructor
Expand Down Expand Up @@ -4262,7 +4262,7 @@ interface OffscreenCanvasRenderingContext2D
getter textAlign
getter textLetterSpacing
getter textRendering
getter textWordSpacing
getter wordSpacing
getter textBaseline
method arc
method arcTo
Expand Down Expand Up @@ -4330,7 +4330,7 @@ interface OffscreenCanvasRenderingContext2D
setter textBaseline
setter textLetterSpacing
setter textRendering
setter textWordSpacing
setter wordSpacing
interface Option
attribute @@toStringTag
getter defaultSelected
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2408,8 +2408,8 @@ double BaseRenderingContext2D::textLetterSpacing() const {
return GetState().GetTextLetterSpacing();
}

double BaseRenderingContext2D::textWordSpacing() const {
return GetState().GetTextWordSpacing();
double BaseRenderingContext2D::wordSpacing() const {
return GetState().GetWordSpacing();
}

String BaseRenderingContext2D::textRendering() const {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ class MODULES_EXPORT BaseRenderingContext2D : public GarbageCollectedMixin,
void setTextBaseline(const String&);

double textLetterSpacing() const;
double textWordSpacing() const;
double wordSpacing() const;
String textRendering() const;

String fontKerning() const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -798,15 +798,15 @@ void CanvasRenderingContext2D::setTextLetterSpacing(
Host()->GetFontSelector());
}

void CanvasRenderingContext2D::setTextWordSpacing(const double word_spacing) {
void CanvasRenderingContext2D::setWordSpacing(const double word_spacing) {
if (UNLIKELY(!std::isfinite(word_spacing)))
return;

if (!GetState().HasRealizedFont())
setFont(font());

float word_spacing_float = clampTo<float>(word_spacing);
GetState().SetTextWordSpacing(word_spacing_float, Host()->GetFontSelector());
GetState().SetWordSpacing(word_spacing_float, Host()->GetFontSelector());
}

void CanvasRenderingContext2D::setTextRendering(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class MODULES_EXPORT CanvasRenderingContext2D final
void setDirection(const String&);

void setTextLetterSpacing(const double letter_spacing);
void setTextWordSpacing(const double word_spacing);
void setWordSpacing(const double word_spacing);
void setTextRendering(const String&);

void setFontKerning(const String&);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ interface CanvasRenderingContext2D {
[RuntimeEnabled=NewCanvas2DAPI] attribute DOMString fontVariantCaps; // "normal", "small-caps", "all-small-caps", "petite-caps", "all-petite-caps", "unicase", "titling-caps" (default: "normal")
[RuntimeEnabled=NewCanvas2DAPI] attribute unrestricted double textLetterSpacing; // length in pixel (default: 0)
[RuntimeEnabled=NewCanvas2DAPI] attribute DOMString textRendering; // "auto", "optimizeSpeed", "optimizeLegibility", "geometricPrecision" (default: auto)
[RuntimeEnabled=NewCanvas2DAPI] attribute unrestricted double textWordSpacing; // length in pixel (default: 0)
[RuntimeEnabled=NewCanvas2DAPI] attribute unrestricted double wordSpacing; // length in pixel (default: 0)
};

CanvasRenderingContext2D includes CanvasPath;
Original file line number Diff line number Diff line change
Expand Up @@ -749,8 +749,8 @@ void CanvasRenderingContext2DState::SetTextLetterSpacing(
SetFont(font_description, selector);
}

void CanvasRenderingContext2DState::SetTextWordSpacing(float word_spacing,
FontSelector* selector) {
void CanvasRenderingContext2DState::SetWordSpacing(float word_spacing,
FontSelector* selector) {
DCHECK(realized_font_);
FontDescription font_description(GetFontDescription());
font_description.SetWordSpacing(word_spacing);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ class CanvasRenderingContext2DState final
void SetTextLetterSpacing(float letter_space, FontSelector* selector);
float GetTextLetterSpacing() const { return letter_spacing_; }

void SetTextWordSpacing(float word_space, FontSelector* selector);
float GetTextWordSpacing() const { return word_spacing_; }
void SetWordSpacing(float word_space, FontSelector* selector);
float GetWordSpacing() const { return word_spacing_; }

void SetTextRendering(TextRenderingMode text_rendering,
FontSelector* selector);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ void OffscreenCanvasRenderingContext2D::setTextLetterSpacing(
Host()->GetFontSelector());
}

void OffscreenCanvasRenderingContext2D::setTextWordSpacing(
void OffscreenCanvasRenderingContext2D::setWordSpacing(
const double word_spacing) {
if (UNLIKELY(!std::isfinite(word_spacing)))
return;
Expand All @@ -495,7 +495,7 @@ void OffscreenCanvasRenderingContext2D::setTextWordSpacing(
setFont(font());

float word_spacing_float = clampTo<float>(word_spacing);
GetState().SetTextWordSpacing(word_spacing_float, Host()->GetFontSelector());
GetState().SetWordSpacing(word_spacing_float, Host()->GetFontSelector());
}

void OffscreenCanvasRenderingContext2D::setTextRendering(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class MODULES_EXPORT OffscreenCanvasRenderingContext2D final
void setDirection(const String&);

void setTextLetterSpacing(const double letter_spacing);
void setTextWordSpacing(const double word_spacing);
void setWordSpacing(const double word_spacing);
void setTextRendering(const String&);
void setFontKerning(const String&);
void setFontStretch(const String&);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
[RuntimeEnabled=NewCanvas2DAPI] attribute DOMString fontVariantCaps; // "normal", "small-caps", "all-small-caps", "petite-caps", "all-petite-caps", "unicase", "titling-caps" (default: "normal")
[RuntimeEnabled=NewCanvas2DAPI] attribute unrestricted double textLetterSpacing; // length in pixel (default: 0)
[RuntimeEnabled=NewCanvas2DAPI] attribute DOMString textRendering; // "auto", "optimizeSpeed", "optimizeLegibility", "geometricPrecision" (default: auto)
[RuntimeEnabled=NewCanvas2DAPI] attribute unrestricted double textWordSpacing; // length in pixel (default: 0)
[RuntimeEnabled=NewCanvas2DAPI] attribute unrestricted double wordSpacing; // length in pixel (default: 0)
};

OffscreenCanvasRenderingContext2D includes CanvasPath;
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
Loading

0 comments on commit 561dd52

Please sign in to comment.