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

Side by Side Diff: ui/gfx/render_text_harfbuzz.cc

Issue 2942843002: RenderText: always break runs at whitespace (Closed)
Patch Set: Helper method comments Created 3 years, 6 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 | « no previous file | ui/gfx/render_text_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/gfx/render_text_harfbuzz.h" 5 #include "ui/gfx/render_text_harfbuzz.h"
6 6
7 #include <limits> 7 #include <limits>
8 #include <set> 8 #include <set>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 } 166 }
167 167
168 // Find the longest sequence of characters from 0 and up to |length| that 168 // Find the longest sequence of characters from 0 and up to |length| that
169 // have at least one common UScriptCode value. Writes the common script value to 169 // have at least one common UScriptCode value. Writes the common script value to
170 // |script| and returns the length of the sequence. Takes the characters' script 170 // |script| and returns the length of the sequence. Takes the characters' script
171 // extensions into account. http://www.unicode.org/reports/tr24/#ScriptX 171 // extensions into account. http://www.unicode.org/reports/tr24/#ScriptX
172 // 172 //
173 // Consider 3 characters with the script values {Kana}, {Hira, Kana}, {Kana}. 173 // Consider 3 characters with the script values {Kana}, {Hira, Kana}, {Kana}.
174 // Without script extensions only the first script in each set would be taken 174 // Without script extensions only the first script in each set would be taken
175 // into account, resulting in 3 runs where 1 would be enough. 175 // into account, resulting in 3 runs where 1 would be enough.
176 // TODO(ckocagil): Write a unit test for the case above.
177 int ScriptInterval(const base::string16& text, 176 int ScriptInterval(const base::string16& text,
178 size_t start, 177 size_t start,
179 size_t length, 178 size_t length,
180 UScriptCode* script) { 179 UScriptCode* script) {
181 DCHECK_GT(length, 0U); 180 DCHECK_GT(length, 0U);
182 181
183 UScriptCode scripts[kMaxScripts] = { USCRIPT_INVALID_CODE }; 182 UScriptCode scripts[kMaxScripts] = { USCRIPT_INVALID_CODE };
184 183
185 base::i18n::UTF16CharIterator char_iterator(text.c_str() + start, length); 184 base::i18n::UTF16CharIterator char_iterator(text.c_str() + start, length);
186 size_t scripts_size = GetScriptExtensions(char_iterator.get(), scripts); 185 size_t scripts_size = GetScriptExtensions(char_iterator.get(), scripts);
187 *script = scripts[0]; 186 *script = scripts[0];
188 187
189 while (char_iterator.Advance()) { 188 while (char_iterator.Advance()) {
190 // Special handling to merge white space into the previous run.
191 if (u_isUWhiteSpace(char_iterator.get()))
192 continue;
193 ScriptSetIntersect(char_iterator.get(), scripts, &scripts_size); 189 ScriptSetIntersect(char_iterator.get(), scripts, &scripts_size);
194 if (scripts_size == 0U) 190 if (scripts_size == 0U)
195 return char_iterator.array_pos(); 191 return char_iterator.array_pos();
196 *script = scripts[0]; 192 *script = scripts[0];
197 } 193 }
198 194
199 return length; 195 return length;
200 } 196 }
201 197
202 // A port of hb_icu_script_to_script because harfbuzz on CrOS is built without 198 // A port of hb_icu_script_to_script because harfbuzz on CrOS is built without
(...skipping 1528 matching lines...) Expand 10 before | Expand all | Expand 10 after
1731 1727
1732 attribute.strike = run.strike; 1728 attribute.strike = run.strike;
1733 attribute.diagonal_strike = run.diagonal_strike; 1729 attribute.diagonal_strike = run.diagonal_strike;
1734 decorated_text->attributes.push_back(attribute); 1730 decorated_text->attributes.push_back(attribute);
1735 } 1731 }
1736 } 1732 }
1737 return true; 1733 return true;
1738 } 1734 }
1739 1735
1740 } // namespace gfx 1736 } // namespace gfx
OLDNEW
« no previous file with comments | « no previous file | ui/gfx/render_text_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698