Added
Link Here
|
1 |
https://chromium.googlesource.com/chromium/src.git/+/e60b571faa3f14dd9119a6792dccf12f8bf80192%5E%21/ |
2 |
|
3 |
--- third_party/WebKit/Source/platform/text/TextBreakIterator.cpp.orig 2016-08-03 19:02:36 UTC |
4 |
+++ third_party/WebKit/Source/platform/text/TextBreakIterator.cpp |
5 |
@@ -27,6 +27,9 @@ |
6 |
#include "wtf/StdLibExtras.h" |
7 |
#include "wtf/text/CharacterNames.h" |
8 |
|
9 |
+#include <unicode/uchar.h> |
10 |
+#include <unicode/uvernum.h> |
11 |
+ |
12 |
namespace blink { |
13 |
|
14 |
unsigned numGraphemeClusters(const String& string) |
15 |
@@ -123,13 +126,18 @@ static const unsigned char asciiLineBrea |
16 |
{ 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 |
17 |
}; |
18 |
|
19 |
+#if U_ICU_VERSION_MAJOR_NUM >= 58 |
20 |
+#define BA_LB_COUNT (U_LB_COUNT - 3) |
21 |
+#else |
22 |
+#define BA_LB_COUNT U_LB_COUNT |
23 |
+#endif |
24 |
// Line breaking table for CSS word-break: break-all. This table differs from |
25 |
// asciiLineBreakTable in: |
26 |
// - Indices are Line Breaking Classes defined in UAX#14 Unicode Line Breaking |
27 |
// Algorithm: http://unicode.org/reports/tr14/#DescriptionOfProperties |
28 |
// - 1 indicates additional break opportunities. 0 indicates to fallback to |
29 |
// normal line break, not "prohibit break." |
30 |
-static const unsigned char breakAllLineBreakClassTable[][U_LB_COUNT / 8 + 1] = { |
31 |
+static const unsigned char breakAllLineBreakClassTable[][BA_LB_COUNT / 8 + 1] = { |
32 |
// 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 |
33 |
{ 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 |
34 |
{ 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 |
35 |
@@ -179,10 +187,10 @@ static const unsigned char breakAllLineB |
36 |
#undef AL |
37 |
|
38 |
static_assert(WTF_ARRAY_LENGTH(asciiLineBreakTable) == asciiLineBreakTableLastChar - asciiLineBreakTableFirstChar + 1, "asciiLineBreakTable should be consistent"); |
39 |
-static_assert(WTF_ARRAY_LENGTH(breakAllLineBreakClassTable) == U_LB_COUNT, "breakAllLineBreakClassTable should be consistent"); |
40 |
+static_assert(WTF_ARRAY_LENGTH(breakAllLineBreakClassTable) == BA_LB_COUNT, |
41 |
+ "breakAllLineBreakClassTable should be consistent"); |
42 |
|
43 |
-static inline bool shouldBreakAfter(UChar lastCh, UChar ch, UChar nextCh) |
44 |
-{ |
45 |
+static inline bool shouldBreakAfter(UChar lastCh, UChar ch, UChar nextCh) { |
46 |
// Don't allow line breaking between '-' and a digit if the '-' may mean a minus sign in the context, |
47 |
// while allow breaking in 'ABCD-1234' and '1234-5678' which may be in long URLs. |
48 |
if (ch == '-' && isASCIIDigit(nextCh)) |
49 |
@@ -210,10 +218,11 @@ static inline ULineBreak lineBreakProper |
50 |
|
51 |
static inline bool shouldBreakAfterBreakAll(ULineBreak lastLineBreak, ULineBreak lineBreak) |
52 |
{ |
53 |
- if (lineBreak >= 0 && lineBreak < U_LB_COUNT && lastLineBreak >= 0 && lastLineBreak < U_LB_COUNT) { |
54 |
- const unsigned char* tableRow = breakAllLineBreakClassTable[lastLineBreak]; |
55 |
- return tableRow[lineBreak / 8] & (1 << (lineBreak % 8)); |
56 |
- } |
57 |
+ if (lineBreak >= 0 && lineBreak < BA_LB_COUNT && lastLineBreak >= 0 && |
58 |
+ lastLineBreak < BA_LB_COUNT) { |
59 |
+ const unsigned char* tableRow = breakAllLineBreakClassTable[lastLineBreak]; |
60 |
+ return tableRow[lineBreak / 8] & (1 << (lineBreak % 8)); |
61 |
+ } |
62 |
return false; |
63 |
} |
64 |
|