Changeset 143071 in webkit
- Timestamp:
- Feb 15, 2013 5:01:03 PM (11 years ago)
- Location:
- trunk/Source
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WTF/ChangeLog
r143061 r143071 1 2013-02-15 Anders Carlsson <andersca@apple.com> 2 3 Add HashMap::isValidKey and HashSet::isValidValue 4 https://bugs.webkit.org/show_bug.cgi?id=109977 5 6 Reviewed by Sam Weinig and Darin Adler. 7 8 Add helper functions for determining whether keys are valid, i.e. if 9 they are _not_ empty or deleted according to the hash traits. 10 11 * wtf/HashMap.h: 12 * wtf/HashSet.h: 13 1 14 2013-02-15 Laszlo Gombos <l.gombos@samsung.com> 2 15 -
trunk/Source/WTF/wtf/HashMap.h
r130612 r143071 132 132 void checkConsistency() const; 133 133 134 static bool isValidKey(const KeyType&); 135 134 136 private: 135 137 AddResult inlineAdd(const KeyType&, MappedPassInReferenceType); … … 412 414 413 415 template<typename T, typename U, typename V, typename W, typename X> 416 inline bool HashMap<T, U, V, W, X>::isValidKey(const KeyType& key) 417 { 418 if (KeyTraits::isDeletedValue(key)) 419 return false; 420 421 if (HashFunctions::safeToCompareToEmptyOrDeleted) { 422 if (key == KeyTraits::emptyValue()) 423 return false; 424 } else { 425 if (isHashTraitsEmptyValue<KeyTraits>(key)) 426 return false; 427 } 428 429 return true; 430 } 431 432 template<typename T, typename U, typename V, typename W, typename X> 414 433 bool operator==(const HashMap<T, U, V, W, X>& a, const HashMap<T, U, V, W, X>& b) 415 434 { -
trunk/Source/WTF/wtf/HashSet.h
r131362 r143071 92 92 void clear(); 93 93 94 static bool isValidValue(const ValueType&); 95 94 96 private: 95 97 friend void deleteAllValues<>(const HashSet&); … … 210 212 } 211 213 214 template<typename T, typename U, typename V> 215 inline bool HashSet<T, U, V>::isValidValue(const ValueType& value) 216 { 217 if (ValueTraits::isDeletedValue(value)) 218 return false; 219 220 if (HashFunctions::safeToCompareToEmptyOrDeleted) { 221 if (value == ValueTraits::emptyValue()) 222 return false; 223 } else { 224 if (isHashTraitsEmptyValue<ValueTraits>(value)) 225 return false; 226 } 227 228 return true; 229 } 230 212 231 template<typename ValueType, typename HashTableType> 213 232 void deleteAllValues(HashTableType& collection) -
trunk/Source/WebKit2/ChangeLog
r143065 r143071 1 2013-02-15 Anders Carlsson <andersca@apple.com> 2 3 Add HashMap::isValidKey and HashSet::isValidValue 4 https://bugs.webkit.org/show_bug.cgi?id=109977 5 6 Reviewed by Sam Weinig and Darin Adler. 7 8 Just call HashMap::isValidKey directly. 9 10 * UIProcess/WebProcessProxy.cpp: 11 (WebKit::generatePageID): 12 Initialize the id to 0 and use prefix increment. 13 14 (WebKit::WebProcessProxy::webFrame): 15 (WebKit::WebProcessProxy::canCreateFrame): 16 (WebKit::WebProcessProxy::didDestroyFrame): 17 1 18 2013-02-15 Csaba Osztrogonác <ossy@webkit.org> 2 19 -
trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp
r142656 r143071 70 70 namespace WebKit { 71 71 72 template<typename HashMap>73 static inline bool isGoodKey(const typename HashMap::KeyType& key)74 {75 return key != HashTraits<typename HashMap::KeyType>::emptyValue() && !HashTraits<typename HashMap::KeyType>::isDeletedValue(key);76 }77 78 72 static uint64_t generatePageID() 79 73 { 80 static uint64_t uniquePageID = 1;81 return uniquePageID++;74 static uint64_t uniquePageID; 75 return ++uniquePageID; 82 76 } 83 77 … … 459 453 WebFrameProxy* WebProcessProxy::webFrame(uint64_t frameID) const 460 454 { 461 return isGoodKey<WebFrameProxyMap>(frameID) ? m_frameMap.get(frameID).get() : 0; 455 if (!WebFrameProxyMap::isValidKey(frameID)) 456 return 0; 457 458 return m_frameMap.get(frameID).get(); 462 459 } 463 460 464 461 bool WebProcessProxy::canCreateFrame(uint64_t frameID) const 465 462 { 466 return isGoodKey<WebFrameProxyMap>(frameID) && !m_frameMap.contains(frameID);463 return WebFrameProxyMap::isValidKey(frameID) && !m_frameMap.contains(frameID); 467 464 } 468 465 … … 478 475 // back to the UIProcess, then the frameDestroyed message will still be received because it 479 476 // gets sent directly to the WebProcessProxy. 480 ASSERT( isGoodKey<WebFrameProxyMap>(frameID));477 ASSERT(WebFrameProxyMap::isValidKey(frameID)); 481 478 m_frameMap.remove(frameID); 482 479 }
Note: See TracChangeset
for help on using the changeset viewer.