OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2015 Google Inc. All rights reserved. | 2 * Copyright (C) 2015 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 | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
110 | 110 |
111 unsigned nextWordEndIndex() | 111 unsigned nextWordEndIndex() |
112 { | 112 { |
113 const unsigned length = m_textRun.length(); | 113 const unsigned length = m_textRun.length(); |
114 if (m_startIndex >= length) | 114 if (m_startIndex >= length) |
115 return 0; | 115 return 0; |
116 | 116 |
117 if (m_startIndex + 1u == length || isWordDelimiter(m_textRun[m_startInde x])) | 117 if (m_startIndex + 1u == length || isWordDelimiter(m_textRun[m_startInde x])) |
118 return m_startIndex + 1; | 118 return m_startIndex + 1; |
119 | 119 |
120 // Delimit every CJK character because these scripts do not delimit | |
121 // words by spaces, and not delimiting hits the performance. | |
122 if (!m_textRun.is8Bit()) { | |
123 UChar32 ch; | |
124 unsigned end = m_startIndex; | |
125 U16_NEXT(m_textRun.characters16(), end, length, ch); | |
126 if (Character::isCJKIdeographOrSymbol(ch)) { | |
127 bool hasAnyScript = !Character::isCommonOrInheritedScript(ch); | |
128 for (unsigned i = end; i < length; end = i) { | |
129 U16_NEXT(m_textRun.characters16(), i, length, ch); | |
130 if (U_GET_GC_MASK(ch) & (U_GC_M_MASK | U_GC_LM_MASK | U_GC_S K_MASK)) | |
131 continue; | |
132 // Avoid delimiting COMMON/INHERITED alone, which makes hard er to | |
133 // identify the script. | |
134 if (Character::isCJKIdeographOrSymbol(ch)) { | |
135 if (Character::isCommonOrInheritedScript(ch)) | |
136 continue; | |
137 if (!hasAnyScript) { | |
138 hasAnyScript = true; | |
139 continue; | |
140 } | |
141 } | |
142 return end; | |
143 } | |
144 return length; | |
145 } | |
146 } | |
147 | |
120 for (unsigned i = m_startIndex + 1; ; i++) { | 148 for (unsigned i = m_startIndex + 1; ; i++) { |
121 if (i == length || isWordDelimiter(m_textRun[i])) | 149 if (i == length || isWordDelimiter(m_textRun[i]) |
150 || (!m_textRun.is8Bit() | |
drott
2015/12/21 14:57:41
Am I understanding correctly that this covers the
kojii
2015/12/21 15:34:53
Yes, that is correct. SegmentCJKByCharacter() has
| |
151 && Character::isCJKIdeographOrSymbol(m_textRun[i]))) { | |
122 return i; | 152 return i; |
153 } | |
123 } | 154 } |
124 } | 155 } |
125 | 156 |
126 bool shapeToEndIndex(RefPtr<ShapeResult>* result, unsigned endIndex) | 157 bool shapeToEndIndex(RefPtr<ShapeResult>* result, unsigned endIndex) |
127 { | 158 { |
128 if (!endIndex || endIndex <= m_startIndex) | 159 if (!endIndex || endIndex <= m_startIndex) |
129 return false; | 160 return false; |
130 | 161 |
131 const unsigned length = m_textRun.length(); | 162 const unsigned length = m_textRun.length(); |
132 if (!m_startIndex && endIndex == length) { | 163 if (!m_startIndex && endIndex == length) { |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
182 const Font* m_font; | 213 const Font* m_font; |
183 float m_widthSoFar; // Used only when allowTabs() | 214 float m_widthSoFar; // Used only when allowTabs() |
184 unsigned m_startIndex : 30; | 215 unsigned m_startIndex : 30; |
185 unsigned m_wordResultCachable : 1; | 216 unsigned m_wordResultCachable : 1; |
186 unsigned m_shapeByWord : 1; | 217 unsigned m_shapeByWord : 1; |
187 }; | 218 }; |
188 | 219 |
189 } // namespace blink | 220 } // namespace blink |
190 | 221 |
191 #endif // CachingWordShapeIterator_h | 222 #endif // CachingWordShapeIterator_h |
OLD | NEW |