Title: [166407] trunk/Source/WebCore
Revision
166407
Author
[email protected]
Date
2014-03-28 08:36:40 -0700 (Fri, 28 Mar 2014)

Log Message

Remove NodeListRootType flag
https://bugs.webkit.org/show_bug.cgi?id=130896

Reviewed by Anders Carlsson.

This can be handled statically (except for the RadioNodeList case) removing
a branch from NodeList traversal.

* dom/ClassNodeList.h:
* dom/Document.cpp:
(WebCore::Document::registerNodeListForInvalidation):
(WebCore::Document::unregisterNodeListForInvalidation):
(WebCore::Document::registerNodeList): Deleted.
(WebCore::Document::unregisterNodeList): Deleted.
        
    Mark document invalidation registered lists with a bit.
    Renamed for clarity.

* dom/Document.h:
* dom/LiveNodeList.cpp:
(WebCore::LiveNodeList::LiveNodeList):
(WebCore::LiveNodeList::rootNode):
        
    Base class version that invokes virtual isRootedAtDocument. It is needed to support 
    LiveNodeList::namedItem.

* dom/LiveNodeList.h:
(WebCore::LiveNodeList::isRegisteredForInvalidationAtDocument):
(WebCore::LiveNodeList::setRegisteredForInvalidationAtDocument):
(WebCore::LiveNodeList::document):
(WebCore::CachedLiveNodeList<NodeListType>::CachedLiveNodeList):
(WebCore::CachedLiveNodeList<NodeListType>::~CachedLiveNodeList):
(WebCore::CachedLiveNodeList<NodeListType>::rootNode):
        
    Call isRootedAtDocument on the final leaf type. Except for RadioNodeList this
    resolves statically.

(WebCore::CachedLiveNodeList<NodeListType>::willValidateIndexCache):
(WebCore::CachedLiveNodeList<NodeListType>::invalidateCache):
(WebCore::LiveNodeList::isRootedAtDocument): Deleted.
(WebCore::LiveNodeList::rootType): Deleted.
(WebCore::LiveNodeList::rootNode): Deleted.
* dom/NameNodeList.h:
* dom/NodeRareData.h:
(WebCore::NodeListsNodeData::adoptDocument):
* dom/TagNodeList.h:
* html/HTMLCollection.cpp:
(WebCore::rootTypeFromCollectionType):
* html/HTMLCollection.h:
(WebCore::HTMLCollection::isRootedAtDocument):
(WebCore::HTMLCollection::rootType):
        
    HTMLCollections still needs the flag.

* html/LabelsNodeList.cpp:
(WebCore::LabelsNodeList::LabelsNodeList):
* html/LabelsNodeList.h:
* html/RadioNodeList.cpp:
(WebCore::RadioNodeList::RadioNodeList):
* html/RadioNodeList.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (166406 => 166407)


--- trunk/Source/WebCore/ChangeLog	2014-03-28 15:34:03 UTC (rev 166406)
+++ trunk/Source/WebCore/ChangeLog	2014-03-28 15:36:40 UTC (rev 166407)
@@ -1,3 +1,66 @@
+2014-03-28  Antti Koivisto  <[email protected]>
+
+        Remove NodeListRootType flag
+        https://bugs.webkit.org/show_bug.cgi?id=130896
+
+        Reviewed by Anders Carlsson.
+
+        This can be handled statically (except for the RadioNodeList case) removing
+        a branch from NodeList traversal.
+
+        * dom/ClassNodeList.h:
+        * dom/Document.cpp:
+        (WebCore::Document::registerNodeListForInvalidation):
+        (WebCore::Document::unregisterNodeListForInvalidation):
+        (WebCore::Document::registerNodeList): Deleted.
+        (WebCore::Document::unregisterNodeList): Deleted.
+        
+            Mark document invalidation registered lists with a bit.
+            Renamed for clarity.
+
+        * dom/Document.h:
+        * dom/LiveNodeList.cpp:
+        (WebCore::LiveNodeList::LiveNodeList):
+        (WebCore::LiveNodeList::rootNode):
+        
+            Base class version that invokes virtual isRootedAtDocument. It is needed to support 
+            LiveNodeList::namedItem.
+
+        * dom/LiveNodeList.h:
+        (WebCore::LiveNodeList::isRegisteredForInvalidationAtDocument):
+        (WebCore::LiveNodeList::setRegisteredForInvalidationAtDocument):
+        (WebCore::LiveNodeList::document):
+        (WebCore::CachedLiveNodeList<NodeListType>::CachedLiveNodeList):
+        (WebCore::CachedLiveNodeList<NodeListType>::~CachedLiveNodeList):
+        (WebCore::CachedLiveNodeList<NodeListType>::rootNode):
+        
+            Call isRootedAtDocument on the final leaf type. Except for RadioNodeList this
+            resolves statically.
+
+        (WebCore::CachedLiveNodeList<NodeListType>::willValidateIndexCache):
+        (WebCore::CachedLiveNodeList<NodeListType>::invalidateCache):
+        (WebCore::LiveNodeList::isRootedAtDocument): Deleted.
+        (WebCore::LiveNodeList::rootType): Deleted.
+        (WebCore::LiveNodeList::rootNode): Deleted.
+        * dom/NameNodeList.h:
+        * dom/NodeRareData.h:
+        (WebCore::NodeListsNodeData::adoptDocument):
+        * dom/TagNodeList.h:
+        * html/HTMLCollection.cpp:
+        (WebCore::rootTypeFromCollectionType):
+        * html/HTMLCollection.h:
+        (WebCore::HTMLCollection::isRootedAtDocument):
+        (WebCore::HTMLCollection::rootType):
+        
+            HTMLCollections still needs the flag.
+
+        * html/LabelsNodeList.cpp:
+        (WebCore::LabelsNodeList::LabelsNodeList):
+        * html/LabelsNodeList.h:
+        * html/RadioNodeList.cpp:
+        (WebCore::RadioNodeList::RadioNodeList):
+        * html/RadioNodeList.h:
+
 2014-03-28  Mario Sanchez Prada  <[email protected]>
 
         [GTK] Geoclue2 providers won't work after reloading

Modified: trunk/Source/WebCore/dom/ClassNodeList.cpp (166406 => 166407)


--- trunk/Source/WebCore/dom/ClassNodeList.cpp	2014-03-28 15:34:03 UTC (rev 166406)
+++ trunk/Source/WebCore/dom/ClassNodeList.cpp	2014-03-28 15:36:40 UTC (rev 166407)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2007-2008, 2014 Apple Inc. All rights reserved.
  * Copyright (C) 2007 David Smith ([email protected])
  *
  * Redistribution and use in source and binary forms, with or without

Modified: trunk/Source/WebCore/dom/ClassNodeList.h (166406 => 166407)


--- trunk/Source/WebCore/dom/ClassNodeList.h	2014-03-28 15:34:03 UTC (rev 166406)
+++ trunk/Source/WebCore/dom/ClassNodeList.h	2014-03-28 15:36:40 UTC (rev 166407)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
+ * Copyright (C) 2007, 2014 Apple Inc. All rights reserved.
  * Copyright (C) 2007 David Smith ([email protected])
  *
  * Redistribution and use in source and binary forms, with or without
@@ -47,6 +47,7 @@
     virtual ~ClassNodeList();
 
     virtual bool nodeMatches(Element*) const override;
+    virtual bool isRootedAtDocument() const override { return false; }
 
 private:
     ClassNodeList(ContainerNode& rootNode, const String& classNames);

Modified: trunk/Source/WebCore/dom/Document.cpp (166406 => 166407)


--- trunk/Source/WebCore/dom/Document.cpp	2014-03-28 15:34:03 UTC (rev 166406)
+++ trunk/Source/WebCore/dom/Document.cpp	2014-03-28 15:36:40 UTC (rev 166407)
@@ -3452,24 +3452,28 @@
         n->didAffectSelector(AffectedSelectorTarget);
 }
 
-void Document::registerNodeList(LiveNodeList& list)
+void Document::registerNodeListForInvalidation(LiveNodeList& list)
 {
     m_nodeListAndCollectionCounts[list.invalidationType()]++;
-    if (list.isRootedAtDocument())
-        m_listsInvalidatedAtDocument.add(&list);
+    if (!list.isRootedAtDocument())
+        return;
+    ASSERT(!list.isRegisteredForInvalidationAtDocument());
+    list.setRegisteredForInvalidationAtDocument(true);
+    m_listsInvalidatedAtDocument.add(&list);
 }
 
-void Document::unregisterNodeList(LiveNodeList& list)
+void Document::unregisterNodeListForInvalidation(LiveNodeList& list)
 {
     m_nodeListAndCollectionCounts[list.invalidationType()]--;
-    if (list.isRootedAtDocument()) {
-        if (!m_listsInvalidatedAtDocument.size()) {
-            ASSERT(m_inInvalidateNodeListAndCollectionCaches);
-            return;
-        }
-        ASSERT(m_listsInvalidatedAtDocument.contains(&list));
-        m_listsInvalidatedAtDocument.remove(&list);
+    if (!list.isRegisteredForInvalidationAtDocument())
+        return;
+    if (!m_listsInvalidatedAtDocument.size()) {
+        ASSERT(m_inInvalidateNodeListAndCollectionCaches);
+        return;
     }
+    ASSERT(m_listsInvalidatedAtDocument.contains(&list));
+    m_listsInvalidatedAtDocument.remove(&list);
+    list.setRegisteredForInvalidationAtDocument(false);
 }
 
 void Document::registerCollection(HTMLCollection& collection)

Modified: trunk/Source/WebCore/dom/Document.h (166406 => 166407)


--- trunk/Source/WebCore/dom/Document.h	2014-03-28 15:34:03 UTC (rev 166406)
+++ trunk/Source/WebCore/dom/Document.h	2014-03-28 15:36:40 UTC (rev 166407)
@@ -761,8 +761,8 @@
     void styleRecalcTimerFired(Timer<Document>&);
     void optimizedStyleSheetUpdateTimerFired(Timer<Document>&);
 
-    void registerNodeList(LiveNodeList&);
-    void unregisterNodeList(LiveNodeList&);
+    void registerNodeListForInvalidation(LiveNodeList&);
+    void unregisterNodeListForInvalidation(LiveNodeList&);
     void registerCollection(HTMLCollection&);
     void unregisterCollection(HTMLCollection&);
     void collectionCachedIdNameMap(const HTMLCollection&);

Modified: trunk/Source/WebCore/dom/LiveNodeList.cpp (166406 => 166407)


--- trunk/Source/WebCore/dom/LiveNodeList.cpp	2014-03-28 15:34:03 UTC (rev 166406)
+++ trunk/Source/WebCore/dom/LiveNodeList.cpp	2014-03-28 15:36:40 UTC (rev 166407)
@@ -2,7 +2,7 @@
  * Copyright (C) 1999 Lars Knoll ([email protected])
  *           (C) 1999 Antti Koivisto ([email protected])
  *           (C) 2001 Dirk Mueller ([email protected])
- * Copyright (C) 2004, 2006, 2007, 2008, 2010, 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2004, 2006-2008, 2010, 2013-2014 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -31,12 +31,11 @@
 
 namespace WebCore {
 
-LiveNodeList::LiveNodeList(ContainerNode& ownerNode, NodeListInvalidationType invalidationType, NodeListRootType rootType)
+LiveNodeList::LiveNodeList(ContainerNode& ownerNode, NodeListInvalidationType invalidationType)
     : m_ownerNode(ownerNode)
-    , m_rootType(rootType)
     , m_invalidationType(invalidationType)
+    , m_isRegisteredForInvalidationAtDocument(false)
 {
-    ASSERT(m_rootType == static_cast<unsigned>(rootType));
     ASSERT(m_invalidationType == static_cast<unsigned>(invalidationType));
 }
 
@@ -44,7 +43,14 @@
 {
 }
 
+ContainerNode& LiveNodeList::rootNode() const
+{
+    if (isRootedAtDocument() && ownerNode().inDocument())
+        return ownerNode().document();
 
+    return ownerNode();
+}
+
 Node* LiveNodeList::namedItem(const AtomicString& elementId) const
 {
     // FIXME: Why doesn't this look into the name attribute like HTMLCollection::namedItem does?

Modified: trunk/Source/WebCore/dom/LiveNodeList.h (166406 => 166407)


--- trunk/Source/WebCore/dom/LiveNodeList.h	2014-03-28 15:34:03 UTC (rev 166406)
+++ trunk/Source/WebCore/dom/LiveNodeList.h	2014-03-28 15:36:40 UTC (rev 166407)
@@ -2,7 +2,7 @@
  * Copyright (C) 1999 Lars Knoll ([email protected])
  *           (C) 1999 Antti Koivisto ([email protected])
  *           (C) 2001 Dirk Mueller ([email protected])
- * Copyright (C) 2004, 2006, 2007, 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2004, 2006-2007, 2013-2014 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -37,22 +37,18 @@
 
 class Element;
 
-enum NodeListRootType {
-    NodeListIsRootedAtNode,
-    NodeListIsRootedAtDocument
-};
-
 static bool shouldInvalidateTypeOnAttributeChange(NodeListInvalidationType, const QualifiedName&);
 
 class LiveNodeList : public NodeList {
 public:
-    LiveNodeList(ContainerNode& ownerNode, NodeListInvalidationType, NodeListRootType);
+    LiveNodeList(ContainerNode& ownerNode, NodeListInvalidationType);
+    virtual ~LiveNodeList();
+
     virtual Node* namedItem(const AtomicString&) const override final;
+
     virtual bool nodeMatches(Element*) const = 0;
+    virtual bool isRootedAtDocument() const = 0;
 
-    virtual ~LiveNodeList();
-
-    ALWAYS_INLINE bool isRootedAtDocument() const { return m_rootType == NodeListIsRootedAtDocument; }
     ALWAYS_INLINE NodeListInvalidationType invalidationType() const { return static_cast<NodeListInvalidationType>(m_invalidationType); }
     ContainerNode& ownerNode() const { return const_cast<ContainerNode&>(m_ownerNode.get()); }
     ALWAYS_INLINE void invalidateCacheForAttribute(const QualifiedName* attrName) const
@@ -62,21 +58,23 @@
     }
     virtual void invalidateCache(Document&) const = 0;
 
+    bool isRegisteredForInvalidationAtDocument() const { return m_isRegisteredForInvalidationAtDocument; }
+    void setRegisteredForInvalidationAtDocument(bool f) { m_isRegisteredForInvalidationAtDocument = f; }
+
 protected:
     Document& document() const { return m_ownerNode->document(); }
-    ContainerNode& rootNode() const;
 
-    ALWAYS_INLINE NodeListRootType rootType() const { return static_cast<NodeListRootType>(m_rootType); }
-
 private:
-    virtual bool isLiveNodeList() const override { return true; }
+    virtual bool isLiveNodeList() const override final { return true; }
 
+    ContainerNode& rootNode() const;
+
     Element* iterateForPreviousElement(Element* current) const;
 
     Ref<ContainerNode> m_ownerNode;
 
-    const unsigned m_rootType : 1;
-    const unsigned m_invalidationType : 4;
+    const unsigned m_invalidationType;
+    bool m_isRegisteredForInvalidationAtDocument;
 };
 
 template <class NodeListType>
@@ -99,9 +97,11 @@
     virtual size_t memoryCost() const override;
 
 protected:
-    CachedLiveNodeList(ContainerNode& rootNode, NodeListInvalidationType, NodeListRootType = NodeListIsRootedAtNode);
+    CachedLiveNodeList(ContainerNode& rootNode, NodeListInvalidationType);
 
 private:
+    ContainerNode& rootNode() const;
+
     mutable CollectionIndexCache<NodeListType, Element> m_indexCache;
 };
 
@@ -129,25 +129,26 @@
     return false;
 }
 
-inline ContainerNode& LiveNodeList::rootNode() const
+template <class NodeListType>
+CachedLiveNodeList<NodeListType>::CachedLiveNodeList(ContainerNode& ownerNode, NodeListInvalidationType invalidationType)
+    : LiveNodeList(ownerNode, invalidationType)
 {
-    if (isRootedAtDocument() && ownerNode().inDocument())
-        return ownerNode().document();
-
-    return ownerNode();
 }
 
 template <class NodeListType>
-CachedLiveNodeList<NodeListType>::CachedLiveNodeList(ContainerNode& ownerNode, NodeListInvalidationType invalidationType, NodeListRootType rootType)
-    : LiveNodeList(ownerNode, invalidationType, rootType)
+CachedLiveNodeList<NodeListType>::~CachedLiveNodeList()
 {
+    if (m_indexCache.hasValidCache())
+        document().unregisterNodeListForInvalidation(*this);
 }
 
 template <class NodeListType>
-CachedLiveNodeList<NodeListType>::~CachedLiveNodeList()
+inline ContainerNode& CachedLiveNodeList<NodeListType>::rootNode() const
 {
-    if (m_indexCache.hasValidCache())
-        document().unregisterNodeList(*this);
+    if (static_cast<const NodeListType&>(*this).isRootedAtDocument() && ownerNode().inDocument())
+        return ownerNode().document();
+
+    return ownerNode();
 }
 
 template <class NodeListType>
@@ -216,7 +217,7 @@
 template <class NodeListType>
 void CachedLiveNodeList<NodeListType>::willValidateIndexCache() const
 {
-    document().registerNodeList(const_cast<NodeListType&>(static_cast<const NodeListType&>(*this)));
+    document().registerNodeListForInvalidation(const_cast<NodeListType&>(static_cast<const NodeListType&>(*this)));
 }
 
 template <class NodeListType>
@@ -224,7 +225,7 @@
 {
     if (!m_indexCache.hasValidCache())
         return;
-    document.unregisterNodeList(const_cast<NodeListType&>(static_cast<const NodeListType&>(*this)));
+    document.unregisterNodeListForInvalidation(const_cast<NodeListType&>(static_cast<const NodeListType&>(*this)));
     m_indexCache.invalidate();
 }
 

Modified: trunk/Source/WebCore/dom/NameNodeList.cpp (166406 => 166407)


--- trunk/Source/WebCore/dom/NameNodeList.cpp	2014-03-28 15:34:03 UTC (rev 166406)
+++ trunk/Source/WebCore/dom/NameNodeList.cpp	2014-03-28 15:36:40 UTC (rev 166407)
@@ -2,7 +2,7 @@
  * Copyright (C) 1999 Lars Knoll ([email protected])
  *           (C) 1999 Antti Koivisto ([email protected])
  *           (C) 2001 Dirk Mueller ([email protected])
- * Copyright (C) 2004, 2007 Apple Inc. All rights reserved.
+ * Copyright (C) 2004, 2007, 2014 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public

Modified: trunk/Source/WebCore/dom/NameNodeList.h (166406 => 166407)


--- trunk/Source/WebCore/dom/NameNodeList.h	2014-03-28 15:34:03 UTC (rev 166406)
+++ trunk/Source/WebCore/dom/NameNodeList.h	2014-03-28 15:36:40 UTC (rev 166407)
@@ -2,7 +2,7 @@
  * Copyright (C) 1999 Lars Knoll ([email protected])
  *           (C) 1999 Antti Koivisto ([email protected])
  *           (C) 2001 Dirk Mueller ([email protected])
- * Copyright (C) 2004, 2007m 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2004, 2007-2008, 2014 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -41,6 +41,7 @@
     virtual ~NameNodeList();
 
     virtual bool nodeMatches(Element*) const override;
+    virtual bool isRootedAtDocument() const override { return false; }
 
 private:
     NameNodeList(ContainerNode& rootNode, const AtomicString& name);

Modified: trunk/Source/WebCore/dom/TagNodeList.cpp (166406 => 166407)


--- trunk/Source/WebCore/dom/TagNodeList.cpp	2014-03-28 15:34:03 UTC (rev 166406)
+++ trunk/Source/WebCore/dom/TagNodeList.cpp	2014-03-28 15:36:40 UTC (rev 166407)
@@ -2,7 +2,7 @@
  * Copyright (C) 1999 Lars Knoll ([email protected])
  *           (C) 1999 Antti Koivisto ([email protected])
  *           (C) 2001 Dirk Mueller ([email protected])
- * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
+ * Copyright (C) 2004-2007, 2014 Apple Inc. All rights reserved.
  * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
  *
  * This library is free software; you can redistribute it and/or

Modified: trunk/Source/WebCore/dom/TagNodeList.h (166406 => 166407)


--- trunk/Source/WebCore/dom/TagNodeList.h	2014-03-28 15:34:03 UTC (rev 166406)
+++ trunk/Source/WebCore/dom/TagNodeList.h	2014-03-28 15:36:40 UTC (rev 166407)
@@ -2,7 +2,7 @@
  * Copyright (C) 1999 Lars Knoll ([email protected])
  *           (C) 1999 Antti Koivisto ([email protected])
  *           (C) 2001 Dirk Mueller ([email protected])
- * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2004-2008, 2014 Apple Inc. All rights reserved.
  * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
  *
  * This library is free software; you can redistribute it and/or
@@ -47,6 +47,7 @@
     virtual ~TagNodeList();
 
     virtual bool nodeMatches(Element*) const override;
+    virtual bool isRootedAtDocument() const override { return false; }
 
 protected:
     TagNodeList(ContainerNode& rootNode, const AtomicString& namespaceURI, const AtomicString& localName);
@@ -74,6 +75,7 @@
     virtual ~HTMLTagNodeList();
 
     virtual bool nodeMatches(Element*) const override;
+    virtual bool isRootedAtDocument() const override { return false; }
 
 private:
     HTMLTagNodeList(ContainerNode& rootNode, const AtomicString& localName);

Modified: trunk/Source/WebCore/html/HTMLCollection.cpp (166406 => 166407)


--- trunk/Source/WebCore/html/HTMLCollection.cpp	2014-03-28 15:34:03 UTC (rev 166406)
+++ trunk/Source/WebCore/html/HTMLCollection.cpp	2014-03-28 15:36:40 UTC (rev 166407)
@@ -65,7 +65,7 @@
     return false;
 }
 
-static NodeListRootType rootTypeFromCollectionType(CollectionType type)
+static HTMLCollection::RootType rootTypeFromCollectionType(CollectionType type)
 {
     switch (type) {
     case DocImages:
@@ -79,7 +79,7 @@
     case WindowNamedItems:
     case DocumentNamedItems:
     case FormControls:
-        return NodeListIsRootedAtDocument;
+        return HTMLCollection::IsRootedAtDocument;
     case NodeChildren:
     case TableTBodies:
     case TSectionRows:
@@ -89,10 +89,10 @@
     case SelectedOptions:
     case DataListOptions:
     case MapAreas:
-        return NodeListIsRootedAtNode;
+        return HTMLCollection::IsRootedAtNode;
     }
     ASSERT_NOT_REACHED();
-    return NodeListIsRootedAtNode;
+    return HTMLCollection::IsRootedAtNode;
 }
 
 static NodeListInvalidationType invalidationTypeExcludingIdAndNameAttributes(CollectionType type)

Modified: trunk/Source/WebCore/html/HTMLCollection.h (166406 => 166407)


--- trunk/Source/WebCore/html/HTMLCollection.h	2014-03-28 15:34:03 UTC (rev 166406)
+++ trunk/Source/WebCore/html/HTMLCollection.h	2014-03-28 15:36:40 UTC (rev 166407)
@@ -100,7 +100,11 @@
     void namedItems(const AtomicString& name, Vector<Ref<Element>>&) const;
     size_t memoryCost() const { return m_indexCache.memoryCost() + (m_namedElementCache ? m_namedElementCache->memoryCost() : 0); }
 
-    bool isRootedAtDocument() const { return m_rootType == NodeListIsRootedAtDocument; }
+    enum RootType {
+        IsRootedAtNode,
+        IsRootedAtDocument
+    };
+    bool isRootedAtDocument() const { return m_rootType == IsRootedAtDocument; }
     NodeListInvalidationType invalidationType() const { return static_cast<NodeListInvalidationType>(m_invalidationType); }
     CollectionType type() const { return static_cast<CollectionType>(m_collectionType); }
     ContainerNode& ownerNode() const { return const_cast<ContainerNode&>(m_ownerNode.get()); }
@@ -133,7 +137,7 @@
     ContainerNode& rootNode() const;
     bool usesCustomForwardOnlyTraversal() const { return m_usesCustomForwardOnlyTraversal; }
 
-    NodeListRootType rootType() const { return static_cast<NodeListRootType>(m_rootType); }
+    RootType rootType() const { return static_cast<RootType>(m_rootType); }
 
     CollectionNamedElementCache& createNameItemCache() const
     {

Modified: trunk/Source/WebCore/html/LabelsNodeList.cpp (166406 => 166407)


--- trunk/Source/WebCore/html/LabelsNodeList.cpp	2014-03-28 15:34:03 UTC (rev 166406)
+++ trunk/Source/WebCore/html/LabelsNodeList.cpp	2014-03-28 15:36:40 UTC (rev 166407)
@@ -2,7 +2,7 @@
  * Copyright (C) 1999 Lars Knoll ([email protected])
  *           (C) 1999 Antti Koivisto ([email protected])
  *           (C) 2001 Dirk Mueller ([email protected])
- * Copyright (C) 2004, 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2004, 2007, 2008, 2014 Apple Inc. All rights reserved.
  * Copyright (C) 2010 Nokia Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
@@ -34,7 +34,7 @@
 using namespace HTMLNames;
 
 LabelsNodeList::LabelsNodeList(LabelableElement& forNode)
-    : CachedLiveNodeList(forNode, InvalidateOnForAttrChange, NodeListIsRootedAtDocument)
+    : CachedLiveNodeList(forNode, InvalidateOnForAttrChange)
 {
 }
 

Modified: trunk/Source/WebCore/html/LabelsNodeList.h (166406 => 166407)


--- trunk/Source/WebCore/html/LabelsNodeList.h	2014-03-28 15:34:03 UTC (rev 166406)
+++ trunk/Source/WebCore/html/LabelsNodeList.h	2014-03-28 15:36:40 UTC (rev 166407)
@@ -2,7 +2,7 @@
  * Copyright (C) 1999 Lars Knoll ([email protected])
  *           (C) 1999 Antti Koivisto ([email protected])
  *           (C) 2001 Dirk Mueller ([email protected])
- * Copyright (C) 2004, 2007 Apple Inc. All rights reserved.
+ * Copyright (C) 2004, 2007, 2014 Apple Inc. All rights reserved.
  * Copyright (C) 2010 Nokia Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
@@ -39,6 +39,7 @@
     ~LabelsNodeList();
 
     virtual bool nodeMatches(Element*) const override;
+    virtual bool isRootedAtDocument() const override { return true; }
 
 private:
     explicit LabelsNodeList(LabelableElement& forNode);

Modified: trunk/Source/WebCore/html/RadioNodeList.cpp (166406 => 166407)


--- trunk/Source/WebCore/html/RadioNodeList.cpp	2014-03-28 15:34:03 UTC (rev 166406)
+++ trunk/Source/WebCore/html/RadioNodeList.cpp	2014-03-28 15:36:40 UTC (rev 166407)
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2012 Motorola Mobility, Inc. All rights reserved.
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -38,8 +39,9 @@
 using namespace HTMLNames;
 
 RadioNodeList::RadioNodeList(ContainerNode& rootNode, const AtomicString& name)
-    : CachedLiveNodeList(rootNode, InvalidateForFormControls, isHTMLFormElement(rootNode) ? NodeListIsRootedAtDocument : NodeListIsRootedAtNode)
+    : CachedLiveNodeList(rootNode, InvalidateForFormControls)
     , m_name(name)
+    , m_isRootedAtDocument(isHTMLFormElement(ownerNode()))
 {
 }
 

Modified: trunk/Source/WebCore/html/RadioNodeList.h (166406 => 166407)


--- trunk/Source/WebCore/html/RadioNodeList.h	2014-03-28 15:34:03 UTC (rev 166406)
+++ trunk/Source/WebCore/html/RadioNodeList.h	2014-03-28 15:36:40 UTC (rev 166407)
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2012 Motorola Mobility, Inc. All rights reserved.
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -45,12 +46,14 @@
     void setValue(const String&);
 
     virtual bool nodeMatches(Element*) const override;
+    virtual bool isRootedAtDocument() const override { return m_isRootedAtDocument; }
 
 private:
     RadioNodeList(ContainerNode&, const AtomicString& name);
     bool checkElementMatchesRadioNodeListFilter(Element*) const;
 
     AtomicString m_name;
+    bool m_isRootedAtDocument;
 };
 
 } // namepsace
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to