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

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

Issue 2018253002: Change TextRun's length() and charactersLength() to return an unsigned (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and remove one static_cast added in r396668 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) 2012 Apple Inc. All rights reserved. 2 * Copyright (C) 2012 Apple Inc. All rights reserved.
3 * Copyright (C) 2015 Google Inc. All rights reserved. 3 * Copyright (C) 2015 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 static const unsigned minimumTableSize = 16; 130 static const unsigned minimumTableSize = 16;
131 }; 131 };
132 132
133 friend bool operator==(const SmallStringKey&, const SmallStringKey&); 133 friend bool operator==(const SmallStringKey&, const SmallStringKey&);
134 134
135 public: 135 public:
136 ShapeCache(): m_weakFactory(this), m_version(0) { } 136 ShapeCache(): m_weakFactory(this), m_version(0) { }
137 137
138 ShapeCacheEntry* add(const TextRun& run, ShapeCacheEntry entry) 138 ShapeCacheEntry* add(const TextRun& run, ShapeCacheEntry entry)
139 { 139 {
140 if (static_cast<unsigned>(run.length()) > SmallStringKey::capacity()) 140 if (run.length() > SmallStringKey::capacity())
141 return 0; 141 return 0;
142 142
143 return addSlowCase(run, entry); 143 return addSlowCase(run, entry);
144 } 144 }
145 145
146 void clearIfVersionChanged(unsigned version) 146 void clearIfVersionChanged(unsigned version)
147 { 147 {
148 if (version != m_version) { 148 if (version != m_version) {
149 clear(); 149 clear();
150 m_version = version; 150 m_version = version;
(...skipping 24 matching lines...) Expand all
175 } 175 }
176 176
177 WeakPtr<ShapeCache> weakPtr() 177 WeakPtr<ShapeCache> weakPtr()
178 { 178 {
179 return m_weakFactory.createWeakPtr(); 179 return m_weakFactory.createWeakPtr();
180 } 180 }
181 181
182 private: 182 private:
183 ShapeCacheEntry* addSlowCase(const TextRun& run, ShapeCacheEntry entry) 183 ShapeCacheEntry* addSlowCase(const TextRun& run, ShapeCacheEntry entry)
184 { 184 {
185 int length = run.length(); 185 unsigned length = run.length();
186 bool isNewEntry; 186 bool isNewEntry;
187 ShapeCacheEntry *value; 187 ShapeCacheEntry *value;
188 if (length == 1) { 188 if (length == 1) {
189 uint32_t key = run[0]; 189 uint32_t key = run[0];
190 // All current codepointsin UTF-32 are bewteen 0x0 and 0x10FFFF, 190 // All current codepointsin UTF-32 are bewteen 0x0 and 0x10FFFF,
191 // as such use bit 32 to indicate direction. 191 // as such use bit 32 to indicate direction.
192 if (run.direction() == RTL) 192 if (run.direction() == RTL)
193 key |= (1u << 31); 193 key |= (1u << 31);
194 SingleCharMap::AddResult addResult = m_singleCharMap.add(key, entry) ; 194 SingleCharMap::AddResult addResult = m_singleCharMap.add(key, entry) ;
195 isNewEntry = addResult.isNewEntry; 195 isNewEntry = addResult.isNewEntry;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 inline bool operator==(const ShapeCache::SmallStringKey& a, const ShapeCache::Sm allStringKey& b) 240 inline bool operator==(const ShapeCache::SmallStringKey& a, const ShapeCache::Sm allStringKey& b)
241 { 241 {
242 if (a.length() != b.length() || a.direction() != b.direction()) 242 if (a.length() != b.length() || a.direction() != b.direction())
243 return false; 243 return false;
244 return WTF::equal(a.characters(), b.characters(), a.length()); 244 return WTF::equal(a.characters(), b.characters(), a.length());
245 } 245 }
246 246
247 } // namespace blink 247 } // namespace blink
248 248
249 #endif // ShapeCache_h 249 #endif // ShapeCache_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698