| Index: Source/core/html/canvas/CanvasRenderingContext2D.cpp
|
| diff --git a/Source/core/html/canvas/CanvasRenderingContext2D.cpp b/Source/core/html/canvas/CanvasRenderingContext2D.cpp
|
| index e8bba71a7f9b8e321d84acb3a0e3db68c5f25874..b4bcd4560e0a7ec3649a80efe2c9e9d317067051 100644
|
| --- a/Source/core/html/canvas/CanvasRenderingContext2D.cpp
|
| +++ b/Source/core/html/canvas/CanvasRenderingContext2D.cpp
|
| @@ -2087,32 +2087,6 @@ void CanvasRenderingContext2D::strokeText(const String& text, float x, float y,
|
| drawTextInternal(text, x, y, false, maxWidth, true);
|
| }
|
|
|
| -static inline bool isSpaceCharacter(UChar c)
|
| -{
|
| - // According to specification all space characters should be replaced with 0x0020 space character.
|
| - // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#text-preparation-algorithm
|
| - // The space characters according to specification are : U+0020, U+0009, U+000A, U+000C, and U+000D.
|
| - // http://www.whatwg.org/specs/web-apps/current-work/multipage/common-microsyntaxes.html#space-character
|
| - // This function returns true for 0x000B also, so that this is backward compatible.
|
| - // Otherwise, the test LayoutTests/canvas/philip/tests/2d.text.draw.space.collapse.space.html will fail
|
| - return c == 0x0009 || c == 0x000A || c == 0x000B || c == 0x000C || c == 0x000D;
|
| -}
|
| -
|
| -static String normalizeSpaces(const String& text)
|
| -{
|
| - unsigned textLength = text.length();
|
| - Vector<UChar> charVector(textLength);
|
| -
|
| - for (unsigned i = 0; i < textLength; i++) {
|
| - if (isSpaceCharacter(text[i]))
|
| - charVector[i] = ' ';
|
| - else
|
| - charVector[i] = text[i];
|
| - }
|
| -
|
| - return String(charVector);
|
| -}
|
| -
|
| PassRefPtrWillBeRawPtr<TextMetrics> CanvasRenderingContext2D::measureText(const String& text)
|
| {
|
| RefPtrWillBeRawPtr<TextMetrics> metrics = TextMetrics::create();
|
| @@ -2124,8 +2098,7 @@ PassRefPtrWillBeRawPtr<TextMetrics> CanvasRenderingContext2D::measureText(const
|
| FontCachePurgePreventer fontCachePurgePreventer;
|
| canvas()->document().updateRenderTreeIfNeeded();
|
| const Font& font = accessFont();
|
| - String normalizedText = normalizeSpaces(text);
|
| - const TextRun textRun(normalizedText);
|
| + const TextRun textRun(text, 0, 0, TextRun::AllowTrailingExpansion | TextRun::ForbidLeadingExpansion, LTR, false, true, true);
|
| FloatRect textBounds = font.selectionRectForText(textRun, FloatPoint(), font.fontDescription().computedSize(), 0, -1, true);
|
|
|
| // x direction
|
| @@ -2189,7 +2162,6 @@ void CanvasRenderingContext2D::drawTextInternal(const String& text, float x, flo
|
|
|
| const Font& font = accessFont();
|
| const FontMetrics& fontMetrics = font.fontMetrics();
|
| - String normalizedText = normalizeSpaces(text);
|
|
|
| // FIXME: Need to turn off font smoothing.
|
|
|
| @@ -2198,11 +2170,10 @@ void CanvasRenderingContext2D::drawTextInternal(const String& text, float x, flo
|
| bool isRTL = direction == RTL;
|
| bool override = computedStyle ? isOverride(computedStyle->unicodeBidi()) : false;
|
|
|
| - TextRun textRun(normalizedText, 0, 0, TextRun::AllowTrailingExpansion, direction, override, true);
|
| + TextRun textRun(text, 0, 0, TextRun::AllowTrailingExpansion, direction, override, true, true);
|
| // Draw the item text at the correct point.
|
| FloatPoint location(x, y + getFontBaseline(fontMetrics));
|
| -
|
| - float fontWidth = font.width(TextRun(normalizedText, 0, 0, TextRun::AllowTrailingExpansion, direction, override));
|
| + float fontWidth = font.width(textRun);
|
|
|
| useMaxWidth = (useMaxWidth && maxWidth < fontWidth);
|
| float width = useMaxWidth ? maxWidth : fontWidth;
|
|
|