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

Side by Side Diff: third_party/WebKit/Source/platform/text/Character.h

Issue 2288653002: Make custom element name checks faster and fewer (Closed)
Patch Set: More feedback Created 4 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 unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/core/dom/custom/CustomElementTest.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2014 Google Inc. All rights reserved. 2 * Copyright (C) 2014 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 18 matching lines...) Expand all
29 */ 29 */
30 30
31 #ifndef Character_h 31 #ifndef Character_h
32 #define Character_h 32 #define Character_h
33 33
34 #include "platform/PlatformExport.h" 34 #include "platform/PlatformExport.h"
35 #include "platform/text/CharacterProperty.h" 35 #include "platform/text/CharacterProperty.h"
36 #include "platform/text/TextDirection.h" 36 #include "platform/text/TextDirection.h"
37 #include "platform/text/TextPath.h" 37 #include "platform/text/TextPath.h"
38 #include "platform/text/TextRun.h" 38 #include "platform/text/TextRun.h"
39 #include "wtf/ASCIICType.h"
39 #include "wtf/Allocator.h" 40 #include "wtf/Allocator.h"
40 #include "wtf/HashSet.h" 41 #include "wtf/HashSet.h"
41 #include "wtf/text/CharacterNames.h" 42 #include "wtf/text/CharacterNames.h"
42 #include "wtf/text/WTFString.h" 43 #include "wtf/text/WTFString.h"
43 44
44 namespace blink { 45 namespace blink {
45 46
46 class PLATFORM_EXPORT Character { 47 class PLATFORM_EXPORT Character {
47 STATIC_ONLY(Character); 48 STATIC_ONLY(Character);
48 public: 49 public:
(...skipping 25 matching lines...) Expand all
74 static unsigned expansionOpportunityCount(const TextRun& run, bool& isAfterE xpansion) 75 static unsigned expansionOpportunityCount(const TextRun& run, bool& isAfterE xpansion)
75 { 76 {
76 if (run.is8Bit()) 77 if (run.is8Bit())
77 return expansionOpportunityCount(run.characters8(), run.length(), ru n.direction(), isAfterExpansion, run.getTextJustify()); 78 return expansionOpportunityCount(run.characters8(), run.length(), ru n.direction(), isAfterExpansion, run.getTextJustify());
78 return expansionOpportunityCount(run.characters16(), run.length(), run.d irection(), isAfterExpansion, run.getTextJustify()); 79 return expansionOpportunityCount(run.characters16(), run.length(), run.d irection(), isAfterExpansion, run.getTextJustify());
79 } 80 }
80 81
81 static bool isUprightInMixedVertical(UChar32 character); 82 static bool isUprightInMixedVertical(UChar32 character);
82 83
83 // https://html.spec.whatwg.org/multipage/scripting.html#prod-potentialcusto melementname 84 // https://html.spec.whatwg.org/multipage/scripting.html#prod-potentialcusto melementname
85 static bool isPotentialCustomElementName8BitChar(LChar ch)
86 {
87 return isASCIILower(ch)
88 || isASCIIDigit(ch)
89 || ch == '-' || ch == '.' || ch == '_' || ch == 0xb7
esprehn 2016/09/07 03:54:05 what char is 0xb7?
90 || (0xc0 <= ch && ch != 0xd7 && ch != 0xf7);
esprehn 2016/09/07 03:54:05 What latin1 chars are these?
91 }
84 static bool isPotentialCustomElementNameChar(UChar32 character); 92 static bool isPotentialCustomElementNameChar(UChar32 character);
85 93
86 static bool treatAsSpace(UChar32 c) 94 static bool treatAsSpace(UChar32 c)
87 { 95 {
88 return c == spaceCharacter 96 return c == spaceCharacter
89 || c == tabulationCharacter 97 || c == tabulationCharacter
90 || c == newlineCharacter 98 || c == newlineCharacter
91 || c == noBreakSpaceCharacter; 99 || c == noBreakSpaceCharacter;
92 } 100 }
93 static bool treatAsZeroWidthSpace(UChar32 c) 101 static bool treatAsZeroWidthSpace(UChar32 c)
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 169
162 static String normalizeSpaces(const LChar*, unsigned length); 170 static String normalizeSpaces(const LChar*, unsigned length);
163 static String normalizeSpaces(const UChar*, unsigned length); 171 static String normalizeSpaces(const UChar*, unsigned length);
164 172
165 static bool isCommonOrInheritedScript(UChar32); 173 static bool isCommonOrInheritedScript(UChar32);
166 }; 174 };
167 175
168 } // namespace blink 176 } // namespace blink
169 177
170 #endif 178 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/custom/CustomElementTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698