Changeset 58526 in webkit


Ignore:
Timestamp:
Apr 29, 2010 11:02:47 AM (14 years ago)
Author:
eric@webkit.org
Message:

2010-04-29 Anton Muhin <antonm@chromium.org>

Reviewed by Darin Adler.

Let's cache nodelists instead of DynamicNodeList::Caches
https://bugs.webkit.org/show_bug.cgi?id=33696

  • fast/dom/Element/node-list-identity-expected.txt: Added to verify that node lists are indeed cached
  • fast/dom/Element/node-list-identity.html: Added to verify that node lists are indeed cached
  • fast/dom/gc-9-expected.txt: Updated to follow changed semantics of caching
  • fast/dom/gc-9.html: Updated to follow changed semantics of caching

2010-04-29 Anton Muhin <antonm@chromium.org>

Reviewed by Darin Adler.

Let's cache nodelists instead of DynamicNodeList::Caches
https://bugs.webkit.org/show_bug.cgi?id=33696

Test: fast/dom/Element/node-list-identity.html

  • bindings/js/JSNodeCustom.cpp: (WebCore::JSNode::markChildren): Mark all cached node lists as well
  • dom/ClassNodeList.cpp: (WebCore::ClassNodeList::ClassNodeList): Don't need DynamicNodeList::Caches argument any more (WebCore::ClassNodeList::~ClassNodeList): Remove from the cache
  • dom/ClassNodeList.h: Added a field with original class names to be used as a key for removal from the cache (WebCore::ClassNodeList::create): Don't need DynamicNodeList::Caches argument any more
  • dom/NameNodeList.cpp: (WebCore::NameNodeList::NameNodeList): Don't need DynamicNodeList::Caches argument any more (WebCore::NameNodeList::~NameNodeList): Remove from the cache
  • dom/NameNodeList.h: (WebCore::NameNodeList::create): Don't need DynamicNodeList::Caches argument any more
  • dom/Node.cpp: (WebCore::Node::removeCachedClassNodeList): Remove ClassNodeList from the cache (WebCore::Node::removeCachedNameNodeList): Remove NameNodeList from the cache (WebCore::Node::removeCachedTagNodeList): Remove TagNodeList from the cache (WebCore::Node::getElementsByTagNameNS): Switch to caching node lists themselves, not the data (WebCore::Node::getElementsByName): Switch to caching node lists themselves, not the data (WebCore::Node::getElementsByClassName): Switch to caching node lists themselves, not the data (WebCore::NodeListsNodeData::invalidateCaches): Switch to caching node lists themselves, not the data (WebCore::NodeListsNodeData::invalidateCachesThatDependOnAttributes): Switch to caching node lists themselves, not the data (WebCore::NodeListsNodeData::isEmpty): Switch to caching node lists themselves, not the data (WebCore::markNodeLists): Helper to mark all the node lists in the cache (WebCore::Node::markCachedNodeListsSlow): Mark all the cached node lists if any could be present
  • dom/Node.h: (WebCore::Node::markCachedNodeLists): Fast-path marking of cached node lists---bails out if there is no rare data
  • dom/NodeRareData.h: Changed type of caches to hold raw pointers to node lists, not RefPtr's to data
  • dom/TagNodeList.cpp: (WebCore::TagNodeList::TagNodeList): Don't need DynamicNodeList::Caches argument any more (WebCore::TagNodeList::~TagNodeList): Remove from the cache
  • dom/TagNodeList.h: (WebCore::TagNodeList::create): Don't need DynamicNodeList::Caches argument any more
Location:
trunk
Files:
2 added
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r58524 r58526  
     12010-04-29  Anton Muhin  <antonm@chromium.org>
     2
     3        Reviewed by Darin Adler.
     4
     5        Let's cache nodelists instead of DynamicNodeList::Caches
     6        https://bugs.webkit.org/show_bug.cgi?id=33696
     7
     8        * fast/dom/Element/node-list-identity-expected.txt: Added to verify that node lists are indeed cached
     9        * fast/dom/Element/node-list-identity.html: Added to verify that node lists are indeed cached
     10        * fast/dom/gc-9-expected.txt: Updated to follow changed semantics of caching
     11        * fast/dom/gc-9.html: Updated to follow changed semantics of caching
     12
    1132010-04-29  Marcus Bulach  <bulach@chromium.org>
    214
  • trunk/LayoutTests/fast/dom/gc-9-expected.txt

    r47165 r58526  
    1010PASS: document.body.myCustomProperty should be 1 and is.
    1111PASS: document.body.attributes.myCustomProperty should be 1 and is.
    12 PASS: document.getElementsByTagName('body').myCustomProperty should be undefined and is.
     12PASS: document.getElementsByTagName('body').myCustomProperty should be 1 and is.
    1313PASS: document.getElementsByTagName('canvas')[0].getContext('2d').myCustomProperty should be 1 and is.
    1414PASS: document.getElementsByTagName('canvas')[0].getContext('2d').createLinearGradient(0, 0, 0, 0).myCustomProperty should be undefined and is.
     
    4646PASS: document.body.myCustomProperty should be 1 and is.
    4747PASS: document.body.attributes.myCustomProperty should be 1 and is.
    48 PASS: document.getElementsByTagName('body').myCustomProperty should be undefined and is.
     48PASS: document.getElementsByTagName('body').myCustomProperty should be 1 and is.
    4949PASS: document.getElementsByTagName('canvas')[0].getContext('2d').myCustomProperty should be 1 and is.
    5050PASS: document.getElementsByTagName('canvas')[0].getContext('2d').createLinearGradient(0, 0, 0, 0).myCustomProperty should be undefined and is.
  • trunk/LayoutTests/fast/dom/gc-9.html

    r47165 r58526  
    111111    [ "document.body", "allow custom" ],
    112112    [ "document.body.attributes", "allow custom" ], // NamedNodeMap
    113     [ "document.getElementsByTagName('body')" ], // NodeList
     113    [ "document.getElementsByTagName('body')", "allow custom" ], // NodeList
    114114    [ "document.getElementsByTagName('canvas')[0].getContext('2d')", "allow custom" ], // CanvasRenderingContext2D
    115115    [ "document.getElementsByTagName('canvas')[0].getContext('2d').createLinearGradient(0, 0, 0, 0)" ], // CanvasGradient
  • trunk/WebCore/ChangeLog

    r58525 r58526  
     12010-04-29  Anton Muhin  <antonm@chromium.org>
     2
     3        Reviewed by Darin Adler.
     4
     5        Let's cache nodelists instead of DynamicNodeList::Caches
     6        https://bugs.webkit.org/show_bug.cgi?id=33696
     7
     8        Test: fast/dom/Element/node-list-identity.html
     9
     10        * bindings/js/JSNodeCustom.cpp:
     11        (WebCore::JSNode::markChildren): Mark all cached node lists as well
     12        * dom/ClassNodeList.cpp:
     13        (WebCore::ClassNodeList::ClassNodeList): Don't need DynamicNodeList::Caches argument any more
     14        (WebCore::ClassNodeList::~ClassNodeList): Remove from the cache
     15        * dom/ClassNodeList.h: Added a field with original class names to be used as a key for removal from the cache
     16        (WebCore::ClassNodeList::create): Don't need DynamicNodeList::Caches argument any more
     17        * dom/NameNodeList.cpp:
     18        (WebCore::NameNodeList::NameNodeList): Don't need DynamicNodeList::Caches argument any more
     19        (WebCore::NameNodeList::~NameNodeList): Remove from the cache
     20        * dom/NameNodeList.h:
     21        (WebCore::NameNodeList::create): Don't need DynamicNodeList::Caches argument any more
     22        * dom/Node.cpp:
     23        (WebCore::Node::removeCachedClassNodeList): Remove ClassNodeList from the cache
     24        (WebCore::Node::removeCachedNameNodeList): Remove NameNodeList from the cache
     25        (WebCore::Node::removeCachedTagNodeList): Remove TagNodeList from the cache
     26        (WebCore::Node::getElementsByTagNameNS): Switch to caching node lists themselves, not the data
     27        (WebCore::Node::getElementsByName): Switch to caching node lists themselves, not the data
     28        (WebCore::Node::getElementsByClassName): Switch to caching node lists themselves, not the data
     29        (WebCore::NodeListsNodeData::invalidateCaches): Switch to caching node lists themselves, not the data
     30        (WebCore::NodeListsNodeData::invalidateCachesThatDependOnAttributes): Switch to caching node lists themselves, not the data
     31        (WebCore::NodeListsNodeData::isEmpty): Switch to caching node lists themselves, not the data
     32        (WebCore::markNodeLists): Helper to mark all the node lists in the cache
     33        (WebCore::Node::markCachedNodeListsSlow): Mark all the cached node lists if any could be present
     34        * dom/Node.h:
     35        (WebCore::Node::markCachedNodeLists): Fast-path marking of cached node lists---bails out if there is no rare data
     36        * dom/NodeRareData.h: Changed type of caches to hold raw pointers to node lists, not RefPtr's to data
     37        * dom/TagNodeList.cpp:
     38        (WebCore::TagNodeList::TagNodeList): Don't need DynamicNodeList::Caches argument any more
     39        (WebCore::TagNodeList::~TagNodeList): Remove from the cache
     40        * dom/TagNodeList.h:
     41        (WebCore::TagNodeList::create): Don't need DynamicNodeList::Caches argument any more
     42
    1432010-04-29  Mikhail Naganov  <mnaganov@chromium.org>
    244
  • trunk/WebCore/bindings/js/JSNodeCustom.cpp

    r58330 r58526  
    180180    Node* node = m_impl.get();
    181181    node->markJSEventListeners(markStack);
     182    node->markCachedNodeLists(markStack, *Heap::heap(this)->globalData());
    182183
    183184    // Nodes in the document are kept alive by JSDocument::mark, so, if we're in
  • trunk/WebCore/dom/ClassNodeList.cpp

    r37037 r58526  
    3636namespace WebCore {
    3737
    38 ClassNodeList::ClassNodeList(PassRefPtr<Node> rootNode, const String& classNames, DynamicNodeList::Caches* caches)
    39     : DynamicNodeList(rootNode, caches)
     38ClassNodeList::ClassNodeList(PassRefPtr<Node> rootNode, const String& classNames)
     39    : DynamicNodeList(rootNode)
    4040    , m_classNames(classNames, m_rootNode->document()->inCompatMode())
     41    , m_originalClassNames(classNames)
    4142{
    4243}
     44
     45ClassNodeList::~ClassNodeList()
     46{
     47    m_rootNode->removeCachedClassNodeList(this, m_originalClassNames);
     48}
    4349
    4450bool ClassNodeList::nodeMatches(Element* testNode) const
  • trunk/WebCore/dom/ClassNodeList.h

    r51902 r58526  
    3838    class ClassNodeList : public DynamicNodeList {
    3939    public:
    40         static PassRefPtr<ClassNodeList> create(PassRefPtr<Node> rootNode, const String& classNames, Caches* caches)
     40        static PassRefPtr<ClassNodeList> create(PassRefPtr<Node> rootNode, const String& classNames)
    4141        {
    42             return adoptRef(new ClassNodeList(rootNode, classNames, caches));
     42            return adoptRef(new ClassNodeList(rootNode, classNames));
    4343        }
    4444
     45        virtual ~ClassNodeList();
     46
    4547    private:
    46         ClassNodeList(PassRefPtr<Node> rootNode, const String& classNames, Caches*);
     48        ClassNodeList(PassRefPtr<Node> rootNode, const String& classNames);
    4749
    4850        virtual bool nodeMatches(Element*) const;
    4951
    5052        SpaceSplitString m_classNames;
     53        String m_originalClassNames;
    5154    };
    5255
  • trunk/WebCore/dom/NameNodeList.cpp

    r37037 r58526  
    3232using namespace HTMLNames;
    3333
    34 NameNodeList::NameNodeList(PassRefPtr<Node> rootNode, const String& name, DynamicNodeList::Caches* caches)
    35     : DynamicNodeList(rootNode, caches)
     34NameNodeList::NameNodeList(PassRefPtr<Node> rootNode, const String& name)
     35    : DynamicNodeList(rootNode)
    3636    , m_nodeName(name)
    3737{
    3838}
     39
     40NameNodeList::~NameNodeList()
     41{
     42    m_rootNode->removeCachedNameNodeList(this, m_nodeName);
     43}
    3944
    4045bool NameNodeList::nodeMatches(Element* testNode) const
  • trunk/WebCore/dom/NameNodeList.h

    r37037 r58526  
    3535    class NameNodeList : public DynamicNodeList {
    3636    public:
    37         static PassRefPtr<NameNodeList> create(PassRefPtr<Node> rootNode, const String& name, Caches* caches)
     37        static PassRefPtr<NameNodeList> create(PassRefPtr<Node> rootNode, const String& name)
    3838        {
    39             return adoptRef(new NameNodeList(rootNode, name, caches));
     39            return adoptRef(new NameNodeList(rootNode, name));
    4040        }
    4141
     42        virtual ~NameNodeList();
     43
    4244    private:
    43         NameNodeList(PassRefPtr<Node> rootNode, const String& name, Caches*);
     45        NameNodeList(PassRefPtr<Node> rootNode, const String& name);
    4446
    4547        virtual bool nodeMatches(Element*) const;
  • trunk/WebCore/dom/Node.cpp

    r58362 r58526  
    9797#if ENABLE(XHTMLMP)
    9898#include "HTMLNoScriptElement.h"
     99#endif
     100
     101#if USE(JSC)
     102#include <runtime/JSGlobalData.h>
    99103#endif
    100104
     
    978982}
    979983
     984void Node::removeCachedClassNodeList(ClassNodeList* list, const String& className)
     985{
     986    ASSERT(rareData());
     987    ASSERT(rareData()->nodeLists());
     988    ASSERT_UNUSED(list, list->hasOwnCaches());
     989
     990    NodeListsNodeData* data = rareData()->nodeLists();
     991    ASSERT_UNUSED(list, list == data->m_classNodeListCache.get(className));
     992    data->m_classNodeListCache.remove(className);
     993}
     994
     995void Node::removeCachedNameNodeList(NameNodeList* list, const String& nodeName)
     996{
     997    ASSERT(rareData());
     998    ASSERT(rareData()->nodeLists());
     999    ASSERT_UNUSED(list, list->hasOwnCaches());
     1000
     1001    NodeListsNodeData* data = rareData()->nodeLists();
     1002    ASSERT_UNUSED(list, list == data->m_nameNodeListCache.get(nodeName));
     1003    data->m_nameNodeListCache.remove(nodeName);
     1004}
     1005
     1006void Node::removeCachedTagNodeList(TagNodeList* list, const QualifiedName& name)
     1007{
     1008    ASSERT(rareData());
     1009    ASSERT(rareData()->nodeLists());
     1010    ASSERT_UNUSED(list, list->hasOwnCaches());
     1011
     1012    NodeListsNodeData* data = rareData()->nodeLists();
     1013    ASSERT_UNUSED(list, list == data->m_tagNodeListCache.get(name));
     1014    data->m_tagNodeListCache.remove(name);
     1015}
     1016
    9801017Node *Node::traverseNextNode(const Node *stayWithin) const
    9811018{
     
    16081645    AtomicString localNameAtom = name;
    16091646       
    1610     pair<NodeListsNodeData::TagCacheMap::iterator, bool> result = data->nodeLists()->m_tagNodeListCaches.add(QualifiedName(nullAtom, localNameAtom, namespaceURI), 0);
    1611     if (result.second)
    1612         result.first->second = DynamicNodeList::Caches::create();
    1613    
    1614     return TagNodeList::create(this, namespaceURI.isEmpty() ? nullAtom : namespaceURI, localNameAtom, result.first->second.get());
     1647    pair<NodeListsNodeData::TagNodeListCache::iterator, bool> result = data->nodeLists()->m_tagNodeListCache.add(QualifiedName(nullAtom, localNameAtom, namespaceURI), 0);
     1648    if (!result.second)
     1649        return PassRefPtr<TagNodeList>(result.first->second);
     1650   
     1651    RefPtr<TagNodeList> list = TagNodeList::create(this, namespaceURI.isEmpty() ? nullAtom : namespaceURI, localNameAtom);
     1652    result.first->second = list.get();
     1653    return list.release();
    16151654}
    16161655
     
    16231662    }
    16241663
    1625     pair<NodeListsNodeData::CacheMap::iterator, bool> result = data->nodeLists()->m_nameNodeListCaches.add(elementName, 0);
    1626     if (result.second)
    1627         result.first->second = DynamicNodeList::Caches::create();
    1628    
    1629     return NameNodeList::create(this, elementName, result.first->second.get());
     1664    pair<NodeListsNodeData::NameNodeListCache::iterator, bool> result = data->nodeLists()->m_nameNodeListCache.add(elementName, 0);
     1665    if (!result.second)
     1666        return PassRefPtr<NodeList>(result.first->second);
     1667
     1668    RefPtr<NameNodeList> list = NameNodeList::create(this, elementName);
     1669    result.first->second = list.get();
     1670    return list.release();
    16301671}
    16311672
     
    16381679    }
    16391680
    1640     pair<NodeListsNodeData::CacheMap::iterator, bool> result = data->nodeLists()->m_classNodeListCaches.add(classNames, 0);
    1641     if (result.second)
    1642         result.first->second = DynamicNodeList::Caches::create();
    1643    
    1644     return ClassNodeList::create(this, classNames, result.first->second.get());
     1681    pair<NodeListsNodeData::ClassNodeListCache::iterator, bool> result = data->nodeLists()->m_classNodeListCache.add(classNames, 0);
     1682    if (!result.second)
     1683        return PassRefPtr<NodeList>(result.first->second);
     1684
     1685    RefPtr<ClassNodeList> list = ClassNodeList::create(this, classNames);
     1686    result.first->second = list.get();
     1687    return list.release();
    16451688}
    16461689
     
    22482291{
    22492292    m_childNodeListCaches->reset();
    2250     TagCacheMap::const_iterator tagCachesEnd = m_tagNodeListCaches.end();
    2251     for (TagCacheMap::const_iterator it = m_tagNodeListCaches.begin(); it != tagCachesEnd; ++it)
    2252         it->second->reset();
     2293    TagNodeListCache::const_iterator tagCacheEnd = m_tagNodeListCache.end();
     2294    for (TagNodeListCache::const_iterator it = m_tagNodeListCache.begin(); it != tagCacheEnd; ++it)
     2295        it->second->invalidateCache();
    22532296    invalidateCachesThatDependOnAttributes();
    22542297}
     
    22562299void NodeListsNodeData::invalidateCachesThatDependOnAttributes()
    22572300{
    2258     CacheMap::iterator classCachesEnd = m_classNodeListCaches.end();
    2259     for (CacheMap::iterator it = m_classNodeListCaches.begin(); it != classCachesEnd; ++it)
    2260         it->second->reset();
    2261 
    2262     CacheMap::iterator nameCachesEnd = m_nameNodeListCaches.end();
    2263     for (CacheMap::iterator it = m_nameNodeListCaches.begin(); it != nameCachesEnd; ++it)
    2264         it->second->reset();
     2301    ClassNodeListCache::iterator classCacheEnd = m_classNodeListCache.end();
     2302    for (ClassNodeListCache::iterator it = m_classNodeListCache.begin(); it != classCacheEnd; ++it)
     2303        it->second->invalidateCache();
     2304
     2305    NameNodeListCache::iterator nameCacheEnd = m_nameNodeListCache.end();
     2306    for (NameNodeListCache::iterator it = m_nameNodeListCache.begin(); it != nameCacheEnd; ++it)
     2307        it->second->invalidateCache();
    22652308}
    22662309
     
    22732316        return false;
    22742317   
    2275     TagCacheMap::const_iterator tagCachesEnd = m_tagNodeListCaches.end();
    2276     for (TagCacheMap::const_iterator it = m_tagNodeListCaches.begin(); it != tagCachesEnd; ++it) {
     2318    TagNodeListCache::const_iterator tagCacheEnd = m_tagNodeListCache.end();
     2319    for (TagNodeListCache::const_iterator it = m_tagNodeListCache.begin(); it != tagCacheEnd; ++it) {
    22772320        if (it->second->refCount())
    22782321            return false;
    22792322    }
    22802323
    2281     CacheMap::const_iterator classCachesEnd = m_classNodeListCaches.end();
    2282     for (CacheMap::const_iterator it = m_classNodeListCaches.begin(); it != classCachesEnd; ++it) {
     2324    ClassNodeListCache::const_iterator classCacheEnd = m_classNodeListCache.end();
     2325    for (ClassNodeListCache::const_iterator it = m_classNodeListCache.begin(); it != classCacheEnd; ++it) {
    22832326        if (it->second->refCount())
    22842327            return false;
    22852328    }
    22862329
    2287     CacheMap::const_iterator nameCachesEnd = m_nameNodeListCaches.end();
    2288     for (CacheMap::const_iterator it = m_nameNodeListCaches.begin(); it != nameCachesEnd; ++it) {
     2330    NameNodeListCache::const_iterator nameCacheEnd = m_nameNodeListCache.end();
     2331    for (NameNodeListCache::const_iterator it = m_nameNodeListCache.begin(); it != nameCacheEnd; ++it) {
    22892332        if (it->second->refCount())
    22902333            return false;
     
    25122555    return ensureRareData()->ensureEventTargetData();
    25132556}
     2557
     2558#if USE(JSC)
     2559
     2560template <class NodeListMap>
     2561void markNodeLists(const NodeListMap& map, JSC::MarkStack& markStack, JSC::JSGlobalData& globalData)
     2562{
     2563    for (typename NodeListMap::const_iterator it = map.begin(); it != map.end(); ++it)
     2564        markDOMObjectWrapper(markStack, globalData, it->second);
     2565}
     2566
     2567void Node::markCachedNodeListsSlow(JSC::MarkStack& markStack, JSC::JSGlobalData& globalData)
     2568{
     2569    NodeListsNodeData* nodeLists = rareData()->nodeLists();
     2570    if (!nodeLists)
     2571        return;
     2572
     2573    markNodeLists(nodeLists->m_classNodeListCache, markStack, globalData);
     2574    markNodeLists(nodeLists->m_nameNodeListCache, markStack, globalData);
     2575    markNodeLists(nodeLists->m_tagNodeListCache, markStack, globalData);
     2576}
     2577
     2578#endif
    25142579
    25152580void Node::handleLocalEvents(Event* event)
  • trunk/WebCore/dom/Node.h

    r58362 r58526  
    3333#include <wtf/ListHashSet.h>
    3434
     35#if USE(JSC)
     36namespace JSC {
     37
     38    class JSGlobalData;
     39    class MarkStack;
     40
     41}
     42#endif
     43
    3544namespace WebCore {
    3645
    3746class AtomicString;
    3847class Attribute;
     48class ClassNodeList;
    3949class ContainerNode;
    4050class Document;
     
    4959class NSResolver;
    5060class NamedNodeMap;
     61class NameNodeList;
    5162class NodeList;
    5263class NodeRareData;
     
    6273class RenderStyle;
    6374class StringBuilder;
     75class TagNodeList;
    6476
    6577typedef int ExceptionCode;
     
    503515    void notifyNodeListsAttributeChanged();
    504516    void notifyLocalNodeListsAttributeChanged();
     517    void removeCachedClassNodeList(ClassNodeList*, const String&);
     518    void removeCachedNameNodeList(NameNodeList*, const String&);
     519    void removeCachedTagNodeList(TagNodeList*, const QualifiedName&);
    505520   
    506521    PassRefPtr<NodeList> getElementsByTagName(const String&);
     
    565580    virtual EventTargetData* ensureEventTargetData();
    566581
     582#if USE(JSC)
     583    void markCachedNodeLists(JSC::MarkStack& markStack, JSC::JSGlobalData& globalData)
     584    {
     585        // NodeLists may be present.  If so, they need to be marked.
     586        if (!hasRareData())
     587            return;
     588
     589        markCachedNodeListsSlow(markStack, globalData);
     590    }
     591#endif
     592
    567593protected:
    568594    // CreateElementZeroRefCount is deprecated and can be removed once we convert all element
     
    586612
    587613private:
     614#if USE(JSC)
     615    void markCachedNodeListsSlow(JSC::MarkStack&, JSC::JSGlobalData&);
     616#endif
     617
    588618    static bool initialRefCount(ConstructionType);
    589619    static bool isContainer(ConstructionType);
  • trunk/WebCore/dom/NodeRareData.h

    r50464 r58526  
    2323#define NodeRareData_h
    2424
     25#include "ClassNodeList.h"
    2526#include "DynamicNodeList.h"
    2627#include "EventListener.h"
     28#include "NameNodeList.h"
     29#include "QualifiedName.h"
    2730#include "RegisteredEventListener.h"
    2831#include "StringHash.h"
    29 #include "QualifiedName.h"
     32#include "TagNodeList.h"
    3033#include <wtf/HashSet.h>
    3134#include <wtf/PassOwnPtr.h>
     
    4043    RefPtr<DynamicNodeList::Caches> m_childNodeListCaches;
    4144   
    42     typedef HashMap<String, RefPtr<DynamicNodeList::Caches> > CacheMap;
    43     CacheMap m_classNodeListCaches;
    44     CacheMap m_nameNodeListCaches;
     45    typedef HashMap<String, ClassNodeList*> ClassNodeListCache;
     46    ClassNodeListCache m_classNodeListCache;
     47
     48    typedef HashMap<String, NameNodeList*> NameNodeListCache;
     49    NameNodeListCache m_nameNodeListCache;
    4550   
    46     typedef HashMap<QualifiedName, RefPtr<DynamicNodeList::Caches> > TagCacheMap;
    47     TagCacheMap m_tagNodeListCaches;
     51    typedef HashMap<QualifiedName, TagNodeList*> TagNodeListCache;
     52    TagNodeListCache m_tagNodeListCache;
    4853
    4954    static PassOwnPtr<NodeListsNodeData> create()
  • trunk/WebCore/dom/TagNodeList.cpp

    r39563 r58526  
    3030namespace WebCore {
    3131
    32 TagNodeList::TagNodeList(PassRefPtr<Node> rootNode, const AtomicString& namespaceURI, const AtomicString& localName, DynamicNodeList::Caches* caches)
    33     : DynamicNodeList(rootNode, caches)
     32TagNodeList::TagNodeList(PassRefPtr<Node> rootNode, const AtomicString& namespaceURI, const AtomicString& localName)
     33    : DynamicNodeList(rootNode)
    3434    , m_namespaceURI(namespaceURI)
    3535    , m_localName(localName)
     
    3737    ASSERT(m_namespaceURI.isNull() || !m_namespaceURI.isEmpty());
    3838}
     39
     40TagNodeList::~TagNodeList()
     41{
     42    m_rootNode->removeCachedTagNodeList(this, QualifiedName(nullAtom, m_localName, m_namespaceURI));
     43}
    3944
    4045bool TagNodeList::nodeMatches(Element* testNode) const
  • trunk/WebCore/dom/TagNodeList.h

    r39563 r58526  
    3333    class TagNodeList : public DynamicNodeList {
    3434    public:
    35         static PassRefPtr<TagNodeList> create(PassRefPtr<Node> rootNode, const AtomicString& namespaceURI, const AtomicString& localName, DynamicNodeList::Caches* caches)
     35        static PassRefPtr<TagNodeList> create(PassRefPtr<Node> rootNode, const AtomicString& namespaceURI, const AtomicString& localName)
    3636        {
    37             return adoptRef(new TagNodeList(rootNode, namespaceURI, localName, caches));
     37            return adoptRef(new TagNodeList(rootNode, namespaceURI, localName));
    3838        }
    3939
     40        virtual ~TagNodeList();
     41
    4042    private:
    41         TagNodeList(PassRefPtr<Node> rootNode, const AtomicString& namespaceURI, const AtomicString& localName, DynamicNodeList::Caches* caches);
     43        TagNodeList(PassRefPtr<Node> rootNode, const AtomicString& namespaceURI, const AtomicString& localName);
    4244
    4345        virtual bool nodeMatches(Element*) const;
Note: See TracChangeset for help on using the changeset viewer.