Lines 26-31
Link Here
|
26 |
#include "wtf/StdLibExtras.h" |
26 |
#include "wtf/StdLibExtras.h" |
27 |
#include "wtf/text/CharacterNames.h" |
27 |
#include "wtf/text/CharacterNames.h" |
28 |
|
28 |
|
|
|
29 |
#include <unicode/uchar.h> |
30 |
#include <unicode/uvernum.h> |
31 |
|
29 |
namespace blink { |
32 |
namespace blink { |
30 |
|
33 |
|
31 |
unsigned numGraphemeClusters(const String& string) |
34 |
unsigned numGraphemeClusters(const String& string) |
Lines 122-134
Link Here
|
122 |
{ B(0, 0, 0, 0, 0, 0, 0, 0), B(0, 0, 0, 0, 0, 0, 0, 0), 0, B(0, 0, 0, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 0, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 0, 0, 0, 0, 0, 0) }, // DEL |
125 |
{ B(0, 0, 0, 0, 0, 0, 0, 0), B(0, 0, 0, 0, 0, 0, 0, 0), 0, B(0, 0, 0, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 0, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 0, 0, 0, 0, 0, 0) }, // DEL |
123 |
}; |
126 |
}; |
124 |
|
127 |
|
|
|
128 |
#if U_ICU_VERSION_MAJOR_NUM >= 58 |
129 |
#define BA_LB_COUNT (U_LB_COUNT - 3) |
130 |
#else |
131 |
#define BA_LB_COUNT U_LB_COUNT |
132 |
#endif |
125 |
// Line breaking table for CSS word-break: break-all. This table differs from |
133 |
// Line breaking table for CSS word-break: break-all. This table differs from |
126 |
// asciiLineBreakTable in: |
134 |
// asciiLineBreakTable in: |
127 |
// - Indices are Line Breaking Classes defined in UAX#14 Unicode Line Breaking |
135 |
// - Indices are Line Breaking Classes defined in UAX#14 Unicode Line Breaking |
128 |
// Algorithm: http://unicode.org/reports/tr14/#DescriptionOfProperties |
136 |
// Algorithm: http://unicode.org/reports/tr14/#DescriptionOfProperties |
129 |
// - 1 indicates additional break opportunities. 0 indicates to fallback to |
137 |
// - 1 indicates additional break opportunities. 0 indicates to fallback to |
130 |
// normal line break, not "prohibit break." |
138 |
// normal line break, not "prohibit break." |
131 |
static const unsigned char breakAllLineBreakClassTable[][U_LB_COUNT / 8 + 1] = { |
139 |
static const unsigned char breakAllLineBreakClassTable[][BA_LB_COUNT / 8 + 1] = { |
132 |
// XX AI AL B2 BA BB BK CB CL CM CR EX GL HY ID IN IS LF NS NU OP PO PR QU SA SG SP SY ZW NL WJ H2 H3 JL JT JV CP CJ HL RI |
140 |
// XX AI AL B2 BA BB BK CB CL CM CR EX GL HY ID IN IS LF NS NU OP PO PR QU SA SG SP SY ZW NL WJ H2 H3 JL JT JV CP CJ HL RI |
133 |
{ B(0, 0, 0, 0, 0, 0, 0, 0), B(0, 0, 0, 0, 0, 0, 0, 0), B(0, 0, 0, 0, 0, 0, 0, 0), B(0, 0, 0, 0, 0, 0, 0, 0), B(0, 0, 0, 0, 0, 0, 0, 0) }, // XX |
141 |
{ B(0, 0, 0, 0, 0, 0, 0, 0), B(0, 0, 0, 0, 0, 0, 0, 0), B(0, 0, 0, 0, 0, 0, 0, 0), B(0, 0, 0, 0, 0, 0, 0, 0), B(0, 0, 0, 0, 0, 0, 0, 0) }, // XX |
134 |
{ B(0, 1, 1, 0, 1, 0, 0, 0), B(0, 0, 0, 0, 0, 1, 0, 0), B(0, 0, 0, 1, 1, 0, 1, 0), B(1, 0, 0, 0, 0, 0, 0, 0), B(0, 0, 0, 0, 0, 0, 1, 0) }, // AI |
142 |
{ B(0, 1, 1, 0, 1, 0, 0, 0), B(0, 0, 0, 0, 0, 1, 0, 0), B(0, 0, 0, 1, 1, 0, 1, 0), B(1, 0, 0, 0, 0, 0, 0, 0), B(0, 0, 0, 0, 0, 0, 1, 0) }, // AI |
Lines 178-184
Link Here
|
178 |
#undef AL |
186 |
#undef AL |
179 |
|
187 |
|
180 |
static_assert(WTF_ARRAY_LENGTH(asciiLineBreakTable) == asciiLineBreakTableLastChar - asciiLineBreakTableFirstChar + 1, "asciiLineBreakTable should be consistent"); |
188 |
static_assert(WTF_ARRAY_LENGTH(asciiLineBreakTable) == asciiLineBreakTableLastChar - asciiLineBreakTableFirstChar + 1, "asciiLineBreakTable should be consistent"); |
181 |
static_assert(WTF_ARRAY_LENGTH(breakAllLineBreakClassTable) == U_LB_COUNT, "breakAllLineBreakClassTable should be consistent"); |
189 |
static_assert(WTF_ARRAY_LENGTH(breakAllLineBreakClassTable) == BA_LB_COUNT, "breakAllLineBreakClassTable should be consistent"); |
182 |
|
190 |
|
183 |
static inline bool shouldBreakAfter(UChar lastCh, UChar ch, UChar nextCh) |
191 |
static inline bool shouldBreakAfter(UChar lastCh, UChar ch, UChar nextCh) |
184 |
{ |
192 |
{ |
Lines 209-215
Link Here
|
209 |
|
217 |
|
210 |
static inline bool shouldBreakAfterBreakAll(ULineBreak lastLineBreak, ULineBreak lineBreak) |
218 |
static inline bool shouldBreakAfterBreakAll(ULineBreak lastLineBreak, ULineBreak lineBreak) |
211 |
{ |
219 |
{ |
212 |
if (lineBreak >= 0 && lineBreak < U_LB_COUNT && lastLineBreak >= 0 && lastLineBreak < U_LB_COUNT) { |
220 |
if (lineBreak >= 0 && lineBreak < BA_LB_COUNT && lastLineBreak >= 0 && lastLineBreak < BA_LB_COUNT) { |
213 |
const unsigned char* tableRow = breakAllLineBreakClassTable[lastLineBreak]; |
221 |
const unsigned char* tableRow = breakAllLineBreakClassTable[lastLineBreak]; |
214 |
return tableRow[lineBreak / 8] & (1 << (lineBreak % 8)); |
222 |
return tableRow[lineBreak / 8] & (1 << (lineBreak % 8)); |
215 |
} |
223 |
} |