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

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

Issue 2063773002: Reland: WTF: Implement explicit RefPtr::operator bool. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
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<const ShapeResult>* wordResult) 58 bool next(RefPtr<const 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<const ShapeResult> shapeWordWithoutSpacing( 75 PassRefPtr<const ShapeResult> shapeWordWithoutSpacing(
76 const TextRun& wordRun, const Font* font) 76 const TextRun& wordRun, const Font* font)
77 { 77 {
78 ShapeCacheEntry* cacheEntry = m_shapeCache->add(wordRun, 78 ShapeCacheEntry* cacheEntry = m_shapeCache->add(wordRun,
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 170
171 const unsigned length = m_textRun.length(); 171 const unsigned length = m_textRun.length();
172 if (!m_startIndex && endIndex == length) { 172 if (!m_startIndex && endIndex == length) {
173 *result = shapeWord(m_textRun, m_font); 173 *result = shapeWord(m_textRun, m_font);
174 } else { 174 } else {
175 ASSERT(endIndex <= length); 175 ASSERT(endIndex <= length);
176 TextRun subRun = m_textRun.subRun(m_startIndex, endIndex - m_startIn dex); 176 TextRun subRun = m_textRun.subRun(m_startIndex, endIndex - m_startIn dex);
177 *result = shapeWord(subRun, m_font); 177 *result = shapeWord(subRun, m_font);
178 } 178 }
179 m_startIndex = endIndex; 179 m_startIndex = endIndex;
180 return *result; 180 return result->get();
181 } 181 }
182 182
183 unsigned endIndexUntil(UChar ch) 183 unsigned endIndexUntil(UChar ch)
184 { 184 {
185 unsigned length = m_textRun.length(); 185 unsigned length = m_textRun.length();
186 ASSERT(m_startIndex < length); 186 ASSERT(m_startIndex < length);
187 for (unsigned i = m_startIndex + 1; ; i++) { 187 for (unsigned i = m_startIndex + 1; ; i++) {
188 if (i == length || m_textRun[i] == ch) 188 if (i == length || m_textRun[i] == ch)
189 return i; 189 return i;
190 } 190 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 const Font* m_font; 222 const Font* m_font;
223 ShapeResultSpacing m_spacing; 223 ShapeResultSpacing m_spacing;
224 float m_widthSoFar; // Used only when allowTabs() 224 float m_widthSoFar; // Used only when allowTabs()
225 unsigned m_startIndex : 31; 225 unsigned m_startIndex : 31;
226 unsigned m_shapeByWord : 1; 226 unsigned m_shapeByWord : 1;
227 }; 227 };
228 228
229 } // namespace blink 229 } // namespace blink
230 230
231 #endif // CachingWordShapeIterator_h 231 #endif // CachingWordShapeIterator_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698