Ignore:
Timestamp:
Jan 31, 2007, 5:43:13 AM (18 years ago)
Author:
mjs
Message:

JavaScriptCore:

Reviewed by Mark with help from Lars.


  • added new ListHashSet class, which combines a hashtable and a linked list to provide a set that keeps elements in inserted order


This is to assist in fixing the following:
<rdar://problem/4751164> REGRESSION: Safari places text on incorrect button when returning to a page via back [10541]
http://bugs.webkit.org/show_bug.cgi?id=10541

  • JavaScriptCore.vcproj/WTF/WTF.vcproj:
  • JavaScriptCore.xcodeproj/project.pbxproj:
  • wtf/HashTable.h: (WTF::HashTable::find): (WTF::HashTable::contains): (WTF::::find): (WTF::::contains):
  • wtf/ListHashSet.h: Added. (WTF::ListHashSetNode::ListHashSetNode): (WTF::ListHashSetNodeHashFunctions::hash): (WTF::ListHashSetNodeHashFunctions::equal): (WTF::ListHashSetIterator::ListHashSetIterator): (WTF::ListHashSetIterator::get): (WTF::ListHashSetIterator::operator*): (WTF::ListHashSetIterator::operator->): (WTF::ListHashSetIterator::operator++): (WTF::ListHashSetIterator::operator--): (WTF::ListHashSetIterator::operator==): (WTF::ListHashSetIterator::operator!=): (WTF::ListHashSetIterator::operator const_iterator): (WTF::ListHashSetIterator::node): (WTF::ListHashSetConstIterator::ListHashSetConstIterator): (WTF::ListHashSetConstIterator::get): (WTF::ListHashSetConstIterator::operator*): (WTF::ListHashSetConstIterator::operator->): (WTF::ListHashSetConstIterator::operator++): (WTF::ListHashSetConstIterator::operator--): (WTF::ListHashSetConstIterator::operator==): (WTF::ListHashSetConstIterator::operator!=): (WTF::ListHashSetConstIterator::node): (WTF::ListHashSetTranslator::hash): (WTF::ListHashSetTranslator::equal): (WTF::ListHashSetTranslator::translate): (WTF::::ListHashSet): (WTF::::operator): (WTF::::~ListHashSet): (WTF::::size): (WTF::::capacity): (WTF::::isEmpty): (WTF::::begin): (WTF::::end): (WTF::::find): (WTF::::contains): (WTF::::add): (WTF::::remove): (WTF::::clear): (WTF::::unlinkAndDelete): (WTF::::appendNode): (WTF::::deleteAllNodes): (WTF::::makeIterator): (WTF::::makeConstIterator): (WTF::deleteAllValues):

WebCore:

Reviewed by Mark.

  • dom/Document.cpp: (WebCore::Document::formElementsState):
  • dom/Document.h:


I couldn't figure out the back/forward support in the tests enough
to make an automated test, but this maual test reproduces the
problem 100% without this patch:


  • manual-tests/back.html: Added.
  • manual-tests/form-control-madness.html: Added.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/wtf/HashTable.h

    r17127 r19302  
    292292        template<typename T, typename Extra, typename HashTranslator> pair<iterator, bool> add(const T& key, const Extra&);
    293293
    294         iterator find(const KeyType&);
    295         const_iterator find(const KeyType&) const;
    296         bool contains(const KeyType&) const;
     294        iterator find(const KeyType& key) { return find<KeyType, IdentityTranslatorType>(key); }
     295        const_iterator find(const KeyType& key) const { return find<KeyType, IdentityTranslatorType>(key); }
     296        bool contains(const KeyType& key) const { return contains<KeyType, IdentityTranslatorType>(key); }
     297
     298        template <typename T, typename HashTranslator> iterator find(const T&);
     299        template <typename T, typename HashTranslator> const_iterator find(const T&) const;
     300        template <typename T, typename HashTranslator> bool contains(const T&) const;
    297301
    298302        void remove(const KeyType&);
     
    468472
    469473    template<typename Key, typename Value, typename Extractor, typename HashFunctions, typename Traits, typename KeyTraits>
    470     typename HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits>::iterator HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits>::find(const Key& key)
     474    template <typename T, typename HashTranslator>
     475    typename HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits>::iterator HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits>::find(const T& key)
    471476    {
    472477        if (!m_table)
    473478            return end();
    474479
    475         LookupType result = lookup(key);
     480        LookupType result = lookup<T, HashTranslator>(key).first;
    476481        if (!result.second)
    477482            return end();
     
    480485
    481486    template<typename Key, typename Value, typename Extractor, typename HashFunctions, typename Traits, typename KeyTraits>
    482     typename HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits>::const_iterator HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits>::find(const Key& key) const
     487    template <typename T, typename HashTranslator>
     488    typename HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits>::const_iterator HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits>::find(const T& key) const
    483489    {
    484490        if (!m_table)
    485491            return end();
    486492
    487         LookupType result = const_cast<HashTable *>(this)->lookup(key);
     493        LookupType result = const_cast<HashTable *>(this)->lookup<T, HashTranslator>(key).first;
    488494        if (!result.second)
    489495            return end();
     
    492498
    493499    template<typename Key, typename Value, typename Extractor, typename HashFunctions, typename Traits, typename KeyTraits>
    494     bool HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits>::contains(const KeyType& key) const
     500    template <typename T, typename HashTranslator>
     501    bool HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits>::contains(const T& key) const
    495502    {
    496503        if (!m_table)
    497504            return false;
    498505
    499         return const_cast<HashTable *>(this)->lookup(key).second;
     506        return const_cast<HashTable *>(this)->lookup<T, HashTranslator>(key).first.second;
    500507    }
    501508
Note: See TracChangeset for help on using the changeset viewer.