Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1795)

Unified Diff: Source/platform/fonts/Character.h

Issue 567543002: Avoid re-parsing of string in fillText and measureText in Canvas (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Updating test expectation file Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/html/canvas/CanvasRenderingContext2D.cpp ('k') | Source/platform/fonts/Font.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/fonts/Character.h
diff --git a/Source/platform/fonts/Character.h b/Source/platform/fonts/Character.h
index f887e8bca1e67f1a02645a0f99abdeb25aff2947..39e79ae94b3ac43bc1729a9b47f81d5d7b41c35b 100644
--- a/Source/platform/fonts/Character.h
+++ b/Source/platform/fonts/Character.h
@@ -51,7 +51,7 @@ public:
static unsigned expansionOpportunityCount(const LChar*, size_t length, TextDirection, bool& isAfterExpansion);
static unsigned expansionOpportunityCount(const UChar*, size_t length, TextDirection, bool& isAfterExpansion);
- static bool treatAsSpace(UChar c) { return c == ' ' || c == '\t' || c == '\n' || c == noBreakSpace; }
+ static bool treatAsSpace(UChar c) { return c == space || c == characterTabulation || c == newlineCharacter || c == noBreakSpace; }
static bool treatAsZeroWidthSpace(UChar c) { return treatAsZeroWidthSpaceInComplexScript(c) || c == 0x200c || c == 0x200d; }
static bool treatAsZeroWidthSpaceInComplexScript(UChar c) { return c < 0x20 || (c >= 0x7F && c < 0xA0) || c == softHyphen || c == zeroWidthSpace || (c >= 0x200e && c <= 0x200f) || (c >= 0x202a && c <= 0x202e) || c == zeroWidthNoBreakSpace || c == objectReplacementCharacter; }
static bool canReceiveTextEmphasis(UChar32);
@@ -67,6 +67,17 @@ public:
return character;
}
+ static inline bool isNormalizedCanvasSpaceCharacter(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 <= 0x000D);
+ }
+
static String normalizeSpaces(const LChar*, unsigned length);
static String normalizeSpaces(const UChar*, unsigned length);
« no previous file with comments | « Source/core/html/canvas/CanvasRenderingContext2D.cpp ('k') | Source/platform/fonts/Font.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698