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

Side by Side Diff: third_party/WebKit/Source/platform/fonts/shaping/CachingWordShapeIterator.h

Issue 1894863002: (CANCELED) Limit word length to shape when !getTypesettingFeatures (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix typo Created 4 years, 8 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 | third_party/WebKit/Source/platform/fonts/shaping/ShapeCache.h » ('j') | 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) 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 : m_shapeCache(cache), m_textRun(run), m_font(font) 46 : m_shapeCache(cache), m_textRun(run), m_font(font)
47 , m_spacing(run, font->getFontDescription()) 47 , m_spacing(run, font->getFontDescription())
48 , m_widthSoFar(0), m_startIndex(0) 48 , m_widthSoFar(0), m_startIndex(0)
49 { 49 {
50 ASSERT(font); 50 ASSERT(font);
51 51
52 // Shaping word by word is faster as each word is cached. If we cannot 52 // Shaping word by word is faster as each word is cached. If we cannot
53 // use the cache or if the font doesn't support word by word shaping 53 // use the cache or if the font doesn't support word by word shaping
54 // fall back on shaping the entire run. 54 // fall back on shaping the entire run.
55 m_shapeByWord = m_font->canShapeWordByWord(); 55 m_shapeByWord = m_font->canShapeWordByWord();
56
57 // Minified JS/CSS and hex/base64 data have extraordinary long "words".
58 m_limitWordLength = m_shapeByWord && m_textRun.is8Bit()
59 && !m_font->getFontDescription().getTypesettingFeatures();
56 } 60 }
57 61
58 bool next(RefPtr<ShapeResult>* wordResult) 62 bool next(RefPtr<ShapeResult>* wordResult)
59 { 63 {
60 if (UNLIKELY(m_textRun.allowTabs())) 64 if (UNLIKELY(m_textRun.allowTabs()))
61 return nextForAllowTabs(wordResult); 65 return nextForAllowTabs(wordResult);
62 66
63 if (!m_shapeByWord) { 67 if (!m_shapeByWord) {
64 if (m_startIndex) 68 if (m_startIndex)
65 return false; 69 return false;
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 hasAnyScript = true; 145 hasAnyScript = true;
142 continue; 146 continue;
143 } 147 }
144 } 148 }
145 return end; 149 return end;
146 } 150 }
147 return length; 151 return length;
148 } 152 }
149 } 153 }
150 154
155 const unsigned limit = m_limitWordLength
156 ? std::min(length, m_startIndex + ShapeCache::maxLengthToCache())
157 : length;
151 for (unsigned i = m_startIndex + 1; ; i++) { 158 for (unsigned i = m_startIndex + 1; ; i++) {
152 if (i == length || isWordDelimiter(m_textRun[i])) { 159 if (i == limit || isWordDelimiter(m_textRun[i]))
153 return i; 160 return i;
154 } 161
155 if (!m_textRun.is8Bit()) { 162 if (!m_textRun.is8Bit()) {
156 UChar32 nextChar; 163 UChar32 nextChar;
157 U16_GET(m_textRun.characters16(), 0, i, length, nextChar); 164 U16_GET(m_textRun.characters16(), 0, i, length, nextChar);
158 if (Character::isCJKIdeographOrSymbolBase(nextChar)) 165 if (Character::isCJKIdeographOrSymbolBase(nextChar))
159 return i; 166 return i;
160 } 167 }
161 } 168 }
162 } 169 }
163 170
164 bool shapeToEndIndex(RefPtr<ShapeResult>* result, unsigned endIndex) 171 bool shapeToEndIndex(RefPtr<ShapeResult>* result, unsigned endIndex)
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 ASSERT(*wordResult); 220 ASSERT(*wordResult);
214 m_widthSoFar += (*wordResult)->width(); 221 m_widthSoFar += (*wordResult)->width();
215 return true; 222 return true;
216 } 223 }
217 224
218 ShapeCache* m_shapeCache; 225 ShapeCache* m_shapeCache;
219 const TextRun& m_textRun; 226 const TextRun& m_textRun;
220 const Font* m_font; 227 const Font* m_font;
221 ShapeResultSpacing m_spacing; 228 ShapeResultSpacing m_spacing;
222 float m_widthSoFar; // Used only when allowTabs() 229 float m_widthSoFar; // Used only when allowTabs()
223 unsigned m_startIndex : 31; 230 unsigned m_startIndex : 30;
224 unsigned m_shapeByWord : 1; 231 unsigned m_shapeByWord : 1;
232 unsigned m_limitWordLength : 1;
225 }; 233 };
226 234
227 } // namespace blink 235 } // namespace blink
228 236
229 #endif // CachingWordShapeIterator_h 237 #endif // CachingWordShapeIterator_h
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/fonts/shaping/ShapeCache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698