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

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: Raw 16-bit chars, too. 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 static unsigned expansionOpportunityCount(const TextRun& run, bool& isAfterE xpansion) 74 static unsigned expansionOpportunityCount(const TextRun& run, bool& isAfterE xpansion)
75 { 75 {
76 if (run.is8Bit()) 76 if (run.is8Bit())
77 return expansionOpportunityCount(run.characters8(), run.length(), ru n.direction(), isAfterExpansion, run.getTextJustify()); 77 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()); 78 return expansionOpportunityCount(run.characters16(), run.length(), run.d irection(), isAfterExpansion, run.getTextJustify());
79 } 79 }
80 80
81 static bool isUprightInMixedVertical(UChar32 character); 81 static bool isUprightInMixedVertical(UChar32 character);
82 82
83 // https://html.spec.whatwg.org/multipage/scripting.html#prod-potentialcusto melementname 83 // https://html.spec.whatwg.org/multipage/scripting.html#prod-potentialcusto melementname
84 static bool isPotentialCustomElementNameStartChar(UChar ch)
85 {
86 return 'a' <= ch && ch <= 'z';
esprehn 2016/09/02 09:22:24 Can we just use isASCIILower :)
87 }
88 static bool isPotentialCustomElementName8BitChar(UChar ch)
esprehn 2016/09/02 09:22:24 LChar since this is 8bit
89 {
90 DCHECK_LE(ch, 0xff);
91 return ('a' <= ch && ch <= 'z')
esprehn 2016/09/02 09:22:24 isASCIILower || isASCIIDigit || ...
92 || ('0' <= ch && ch <= '9')
93 || ch == '-' || ch == '.' || ch == '_' || ch == 0xb7
94 || (0xc0 <= ch && ch != 0xd7 && ch != 0xf7);
95 }
84 static bool isPotentialCustomElementNameChar(UChar32 character); 96 static bool isPotentialCustomElementNameChar(UChar32 character);
85 97
86 static bool treatAsSpace(UChar32 c) 98 static bool treatAsSpace(UChar32 c)
87 { 99 {
88 return c == spaceCharacter 100 return c == spaceCharacter
89 || c == tabulationCharacter 101 || c == tabulationCharacter
90 || c == newlineCharacter 102 || c == newlineCharacter
91 || c == noBreakSpaceCharacter; 103 || c == noBreakSpaceCharacter;
92 } 104 }
93 static bool treatAsZeroWidthSpace(UChar32 c) 105 static bool treatAsZeroWidthSpace(UChar32 c)
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 173
162 static String normalizeSpaces(const LChar*, unsigned length); 174 static String normalizeSpaces(const LChar*, unsigned length);
163 static String normalizeSpaces(const UChar*, unsigned length); 175 static String normalizeSpaces(const UChar*, unsigned length);
164 176
165 static bool isCommonOrInheritedScript(UChar32); 177 static bool isCommonOrInheritedScript(UChar32);
166 }; 178 };
167 179
168 } // namespace blink 180 } // namespace blink
169 181
170 #endif 182 #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