| OLD | NEW |
| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 // Used to optimize small strings as hash table keys. Avoids malloc'ing an | 52 // Used to optimize small strings as hash table keys. Avoids malloc'ing an |
| 53 // out-of-line StringImpl. | 53 // out-of-line StringImpl. |
| 54 class SmallStringKey { | 54 class SmallStringKey { |
| 55 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | 55 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
| 56 | 56 |
| 57 public: | 57 public: |
| 58 static unsigned capacity() { return s_capacity; } | 58 static unsigned capacity() { return s_capacity; } |
| 59 | 59 |
| 60 SmallStringKey() | 60 SmallStringKey() |
| 61 : m_length(s_emptyValueLength), | 61 : m_length(s_emptyValueLength), |
| 62 m_direction(static_cast<unsigned>(TextDirection::Ltr)) {} | 62 m_direction(static_cast<unsigned>(TextDirection::kLtr)) {} |
| 63 | 63 |
| 64 SmallStringKey(WTF::HashTableDeletedValueType) | 64 SmallStringKey(WTF::HashTableDeletedValueType) |
| 65 : m_length(s_deletedValueLength), | 65 : m_length(s_deletedValueLength), |
| 66 m_direction(static_cast<unsigned>(TextDirection::Ltr)) {} | 66 m_direction(static_cast<unsigned>(TextDirection::kLtr)) {} |
| 67 | 67 |
| 68 template <typename CharacterType> | 68 template <typename CharacterType> |
| 69 SmallStringKey(CharacterType* characters, | 69 SmallStringKey(CharacterType* characters, |
| 70 unsigned short length, | 70 unsigned short length, |
| 71 TextDirection direction) | 71 TextDirection direction) |
| 72 : m_length(length), m_direction(static_cast<unsigned>(direction)) { | 72 : m_length(length), m_direction(static_cast<unsigned>(direction)) { |
| 73 ASSERT(length <= s_capacity); | 73 ASSERT(length <= s_capacity); |
| 74 | 74 |
| 75 StringHasher hasher; | 75 StringHasher hasher; |
| 76 | 76 |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 | 181 |
| 182 private: | 182 private: |
| 183 ShapeCacheEntry* addSlowCase(const TextRun& run, ShapeCacheEntry entry) { | 183 ShapeCacheEntry* addSlowCase(const TextRun& run, ShapeCacheEntry entry) { |
| 184 unsigned length = run.length(); | 184 unsigned length = run.length(); |
| 185 bool isNewEntry; | 185 bool isNewEntry; |
| 186 ShapeCacheEntry* value; | 186 ShapeCacheEntry* value; |
| 187 if (length == 1) { | 187 if (length == 1) { |
| 188 uint32_t key = run[0]; | 188 uint32_t key = run[0]; |
| 189 // All current codepointsin UTF-32 are bewteen 0x0 and 0x10FFFF, | 189 // All current codepointsin UTF-32 are bewteen 0x0 and 0x10FFFF, |
| 190 // as such use bit 32 to indicate direction. | 190 // as such use bit 32 to indicate direction. |
| 191 if (run.direction() == TextDirection::Rtl) | 191 if (run.direction() == TextDirection::kRtl) |
| 192 key |= (1u << 31); | 192 key |= (1u << 31); |
| 193 SingleCharMap::AddResult addResult = m_singleCharMap.add(key, entry); | 193 SingleCharMap::AddResult addResult = m_singleCharMap.add(key, entry); |
| 194 isNewEntry = addResult.isNewEntry; | 194 isNewEntry = addResult.isNewEntry; |
| 195 value = &addResult.storedValue->value; | 195 value = &addResult.storedValue->value; |
| 196 } else { | 196 } else { |
| 197 SmallStringKey smallStringKey; | 197 SmallStringKey smallStringKey; |
| 198 if (run.is8Bit()) | 198 if (run.is8Bit()) |
| 199 smallStringKey = | 199 smallStringKey = |
| 200 SmallStringKey(run.characters8(), length, run.direction()); | 200 SmallStringKey(run.characters8(), length, run.direction()); |
| 201 else | 201 else |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 inline bool operator==(const ShapeCache::SmallStringKey& a, | 250 inline bool operator==(const ShapeCache::SmallStringKey& a, |
| 251 const ShapeCache::SmallStringKey& b) { | 251 const ShapeCache::SmallStringKey& b) { |
| 252 if (a.length() != b.length() || a.direction() != b.direction()) | 252 if (a.length() != b.length() || a.direction() != b.direction()) |
| 253 return false; | 253 return false; |
| 254 return WTF::equal(a.characters(), b.characters(), a.length()); | 254 return WTF::equal(a.characters(), b.characters(), a.length()); |
| 255 } | 255 } |
| 256 | 256 |
| 257 } // namespace blink | 257 } // namespace blink |
| 258 | 258 |
| 259 #endif // ShapeCache_h | 259 #endif // ShapeCache_h |
| OLD | NEW |