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

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

Issue 1891473002: WTF: Implement explicit RefPtr::operator bool. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 bool next(RefPtr<ShapeResult>* wordResult) 58 bool next(RefPtr<ShapeResult>* wordResult)
59 { 59 {
60 if (UNLIKELY(m_textRun.allowTabs())) 60 if (UNLIKELY(m_textRun.allowTabs()))
61 return nextForAllowTabs(wordResult); 61 return nextForAllowTabs(wordResult);
62 62
63 if (!m_shapeByWord) { 63 if (!m_shapeByWord) {
64 if (m_startIndex) 64 if (m_startIndex)
65 return false; 65 return false;
66 *wordResult = shapeWord(m_textRun, m_font); 66 *wordResult = shapeWord(m_textRun, m_font);
67 m_startIndex = 1; 67 m_startIndex = 1;
68 return *wordResult; 68 return wordResult->get();
69 } 69 }
70 70
71 return nextWord(wordResult); 71 return nextWord(wordResult);
72 } 72 }
73 73
74 private: 74 private:
75 PassRefPtr<ShapeResult> shapeWordWithoutSpacing(const TextRun& wordRun, cons t Font* font) 75 PassRefPtr<ShapeResult> shapeWordWithoutSpacing(const TextRun& wordRun, cons t Font* font)
76 { 76 {
77 ShapeCacheEntry* cacheEntry = m_shapeCache->add(wordRun, ShapeCacheEntry ()); 77 ShapeCacheEntry* cacheEntry = m_shapeCache->add(wordRun, ShapeCacheEntry ());
78 if (cacheEntry && cacheEntry->m_shapeResult) 78 if (cacheEntry && cacheEntry->m_shapeResult)
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 168
169 const unsigned length = m_textRun.length(); 169 const unsigned length = m_textRun.length();
170 if (!m_startIndex && endIndex == length) { 170 if (!m_startIndex && endIndex == length) {
171 *result = shapeWord(m_textRun, m_font); 171 *result = shapeWord(m_textRun, m_font);
172 } else { 172 } else {
173 ASSERT(endIndex <= length); 173 ASSERT(endIndex <= length);
174 TextRun subRun = m_textRun.subRun(m_startIndex, endIndex - m_startIn dex); 174 TextRun subRun = m_textRun.subRun(m_startIndex, endIndex - m_startIn dex);
175 *result = shapeWord(subRun, m_font); 175 *result = shapeWord(subRun, m_font);
176 } 176 }
177 m_startIndex = endIndex; 177 m_startIndex = endIndex;
178 return *result; 178 return result->get();
179 } 179 }
180 180
181 unsigned endIndexUntil(UChar ch) 181 unsigned endIndexUntil(UChar ch)
182 { 182 {
183 unsigned length = m_textRun.length(); 183 unsigned length = m_textRun.length();
184 ASSERT(m_startIndex < length); 184 ASSERT(m_startIndex < length);
185 for (unsigned i = m_startIndex + 1; ; i++) { 185 for (unsigned i = m_startIndex + 1; ; i++) {
186 if (i == length || m_textRun[i] == ch) 186 if (i == length || m_textRun[i] == ch)
187 return i; 187 return i;
188 } 188 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 const Font* m_font; 220 const Font* m_font;
221 ShapeResultSpacing m_spacing; 221 ShapeResultSpacing m_spacing;
222 float m_widthSoFar; // Used only when allowTabs() 222 float m_widthSoFar; // Used only when allowTabs()
223 unsigned m_startIndex : 31; 223 unsigned m_startIndex : 31;
224 unsigned m_shapeByWord : 1; 224 unsigned m_shapeByWord : 1;
225 }; 225 };
226 226
227 } // namespace blink 227 } // namespace blink
228 228
229 #endif // CachingWordShapeIterator_h 229 #endif // CachingWordShapeIterator_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698