Reviewed by Eric Seidel.
authorweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 26 Dec 2007 07:25:09 +0000 (07:25 +0000)
committerweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 26 Dec 2007 07:25:09 +0000 (07:25 +0000)
        Clean up the files relating to NodeLists.

        * dom/ChildNodeList.cpp:
        (WebCore::ChildNodeList::ChildNodeList):
        (WebCore::ChildNodeList::length):
        (WebCore::ChildNodeList::item):
        (WebCore::ChildNodeList::nodeMatches):
        * dom/ChildNodeList.h:
        * dom/DynamicNodeList.cpp:
        (WebCore::DynamicNodeList::itemForwardsFromCurrent):
        (WebCore::DynamicNodeList::itemBackwardsFromCurrent):
        (WebCore::DynamicNodeList::itemWithName):
        * dom/DynamicNodeList.h:
        (WebCore::DynamicNodeList::needsNotifications):
        * dom/NameNodeList.cpp:
        (WebCore::NameNodeList::NameNodeList):
        (WebCore::NameNodeList::rootNodeAttributeChanged):
        (WebCore::NameNodeList::nodeMatches):
        * dom/NameNodeList.h:
        * dom/NodeList.h:
        * dom/SelectorNodeList.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@28990 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/dom/ChildNodeList.cpp
WebCore/dom/ChildNodeList.h
WebCore/dom/DynamicNodeList.cpp
WebCore/dom/DynamicNodeList.h
WebCore/dom/NameNodeList.cpp
WebCore/dom/NameNodeList.h
WebCore/dom/NodeList.h
WebCore/dom/SelectorNodeList.h

index 09b66916906330a70411852ec17ddc9fef5342d0..c1274e072399ac1f5023edfa94285f9b83b02fa9 100644 (file)
@@ -1,3 +1,29 @@
+2007-12-25  Sam Weinig  <sam@webkit.org>
+
+        Reviewed by Eric Seidel.
+
+        Clean up the files relating to NodeLists.
+
+        * dom/ChildNodeList.cpp:
+        (WebCore::ChildNodeList::ChildNodeList):
+        (WebCore::ChildNodeList::length):
+        (WebCore::ChildNodeList::item):
+        (WebCore::ChildNodeList::nodeMatches):
+        * dom/ChildNodeList.h:
+        * dom/DynamicNodeList.cpp:
+        (WebCore::DynamicNodeList::itemForwardsFromCurrent):
+        (WebCore::DynamicNodeList::itemBackwardsFromCurrent):
+        (WebCore::DynamicNodeList::itemWithName):
+        * dom/DynamicNodeList.h:
+        (WebCore::DynamicNodeList::needsNotifications):
+        * dom/NameNodeList.cpp:
+        (WebCore::NameNodeList::NameNodeList):
+        (WebCore::NameNodeList::rootNodeAttributeChanged):
+        (WebCore::NameNodeList::nodeMatches):
+        * dom/NameNodeList.h:
+        * dom/NodeList.h:
+        * dom/SelectorNodeList.h:
+
 2007-12-25  Sam Weinig  <sam@webkit.org>
 
         Fix non-mac builds.
index 5b1d3e8bb4733ab5d0ad1794fd7fb2d3dbfe72b6..4befe4068fc63715ce56d233257cc1f984d9b08b 100644 (file)
@@ -1,10 +1,8 @@
 /**
- * This file is part of the DOM implementation for KDE.
- *
  * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
  *           (C) 1999 Antti Koivisto (koivisto@kde.org)
  *           (C) 2001 Dirk Mueller (mueller@kde.org)
- * Copyright (C) 2004 Apple Computer, Inc.
+ * Copyright (C) 2004, 2007 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
 
 #include "config.h"
 #include "ChildNodeList.h"
-#include "Node.h"
 
-using namespace WebCore;
+#include "Node.h"
 
 namespace WebCore {
 
-ChildNodeList::ChildNodeList(Node* n, DynamicNodeList::Caches* info)
-    : DynamicNodeList(n, info, false)
+ChildNodeList::ChildNodeList(PassRefPtr<Node> rootNode, DynamicNodeList::Caches* info)
+    : DynamicNodeList(rootNode, info, false)
 {
 }
 
@@ -41,8 +38,7 @@ unsigned ChildNodeList::length() const
         return m_caches->cachedLength;
 
     unsigned len = 0;
-    Node *n;
-    for (n = m_rootNode->firstChild(); n != 0; n = n->nextSibling())
+    for (Node* n = m_rootNode->firstChild(); n; n = n->nextSibling())
         len++;
 
     m_caches->cachedLength = len;
@@ -80,16 +76,17 @@ Node* ChildNodeList::item(unsigned index) const
         }
     }
 
-    if (pos <= index)
+    if (pos <= index) {
         while (n && pos < index) {
             n = n->nextSibling();
             ++pos;
         }
-    else
+    } else {
         while (n && pos > index) {
             n = n->previousSibling();
             --pos;
         }
+    }
 
     if (n) {
         m_caches->lastItem = n;
@@ -101,7 +98,7 @@ Node* ChildNodeList::item(unsigned index) const
     return 0;
 }
 
-bool ChildNodeList::nodeMatches(Node *testNode) const
+bool ChildNodeList::nodeMatches(NodetestNode) const
 {
     return testNode->parentNode() == m_rootNode;
 }
@@ -112,4 +109,4 @@ void ChildNodeList::rootNodeChildrenChanged()
     ASSERT(!m_ownsCaches);
 }
 
-}
+} // namespace WebCore
index b9e56c622e46ac34d08416ef96999b892029865a..efdc606a98fb40848f0bb4ea6a08e6886abbe532 100644 (file)
 
 namespace WebCore {
 
-class ChildNodeList : public DynamicNodeList {
-public:
-    ChildNodeList(Node*, DynamicNodeList::Caches*);
+    class ChildNodeList : public DynamicNodeList {
+    public:
+        ChildNodeList(PassRefPtr<Node> rootNode, DynamicNodeList::Caches*);
 
-    virtual unsigned length() const;
-    virtual Node* item(unsigned index) const;
+        virtual unsigned length() const;
+        virtual Node* item(unsigned index) const;
 
-    virtual void rootNodeChildrenChanged();
+        virtual void rootNodeChildrenChanged();
 
-protected:
-    virtual bool nodeMatches(Node* testNode) const;
-};
+    protected:
+        virtual bool nodeMatches(Node*) const;
+    };
 
 } // namespace WebCore
 
index 71b6f4c30330d965229e06e04d6d906225b7c075..5a515d20fecb2b893bdf5de8bc6c15941108e1b3 100644 (file)
@@ -76,8 +76,7 @@ unsigned DynamicNodeList::length() const
 Node* DynamicNodeList::itemForwardsFromCurrent(Node* start, unsigned offset, int remainingOffset) const
 {
     ASSERT(remainingOffset >= 0);
-
-    for (Node *n = start; n; n = n->traverseNextNode(m_rootNode.get())) {
+    for (Node* n = start; n; n = n->traverseNextNode(m_rootNode.get())) {
         if (n->isElementNode()) {
             if (nodeMatches(n)) {
                 if (!remainingOffset) {
@@ -97,7 +96,7 @@ Node* DynamicNodeList::itemForwardsFromCurrent(Node* start, unsigned offset, int
 Node* DynamicNodeList::itemBackwardsFromCurrent(Node* start, unsigned offset, int remainingOffset) const
 {
     ASSERT(remainingOffset < 0);
-    for (Node *n = start; n; n = n->traversePreviousNode(m_rootNode.get())) {
+    for (Noden = start; n; n = n->traversePreviousNode(m_rootNode.get())) {
         if (n->isElementNode()) {
             if (nodeMatches(n)) {
                 if (!remainingOffset) {
@@ -140,9 +139,10 @@ Node* DynamicNodeList::itemWithName(const AtomicString& elementId) const
         if (!node || !nodeMatches(node))
             return 0;
 
-        for (Node* p = node->parentNode(); p; p = p->parentNode())
+        for (Node* p = node->parentNode(); p; p = p->parentNode()) {
             if (p == m_rootNode)
                 return node;
+        }
 
         return 0;
     }
@@ -180,4 +180,4 @@ void DynamicNodeList::Caches::reset()
     isItemCacheValid = false;     
 }
 
-}
+} // namespace WebCore
index 13041b9d4e3530da6cc73e3805c1b5e6dcfb7151..58e50fdeedcaff586279f163c8faa11e6811fceb 100644 (file)
 
 namespace WebCore {
 
-class AtomicString;
-class Node;
+    class AtomicString;
+    class Node;
 
-class DynamicNodeList : public NodeList {
-public:
-    struct Caches {
-        Caches();
-        void reset();
+    class DynamicNodeList : public NodeList {
+    public:
+        struct Caches {
+            Caches();
+            void reset();
 
-        unsigned cachedLength;
-        Node* lastItem;
-        unsigned lastItemOffset;
-        bool isLengthCacheValid : 1;
-        bool isItemCacheValid : 1;
-    };
+            unsigned cachedLength;
+            Node* lastItem;
+            unsigned lastItemOffset;
+            bool isLengthCacheValid : 1;
+            bool isItemCacheValid : 1;
+        };
 
-    DynamicNodeList(PassRefPtr<Node> rootNode, bool needsNotifications);
-    DynamicNodeList(PassRefPtr<Node> rootNode, Caches*, bool needsNotifications);
-    virtual ~DynamicNodeList();
+        DynamicNodeList(PassRefPtr<Node> rootNode, bool needsNotifications);
+        DynamicNodeList(PassRefPtr<Node> rootNode, Caches*, bool needsNotifications);
+        virtual ~DynamicNodeList();
 
-    bool needsNotifications() const { return m_needsNotifications; }
+        bool needsNotifications() const { return m_needsNotifications; }
 
-    // DOM methods & attributes for NodeList
-    virtual unsigned length() const;
-    virtual Node* item(unsigned index) const;
-    virtual Node* itemWithName(const AtomicString&) const;
+        // DOM methods & attributes for NodeList
+        virtual unsigned length() const;
+        virtual Node* item(unsigned index) const;
+        virtual Node* itemWithName(const AtomicString&) const;
 
-    // Other methods (not part of DOM)
-    virtual void rootNodeChildrenChanged();
-    virtual void rootNodeAttributeChanged();
+        // Other methods (not part of DOM)
+        virtual void rootNodeChildrenChanged();
+        virtual void rootNodeAttributeChanged();
 
-protected:
-    virtual bool nodeMatches(Node*) const = 0;
+    protected:
+        virtual bool nodeMatches(Node*) const = 0;
 
-    RefPtr<Node> m_rootNode;
-    mutable Caches* m_caches;
-    bool m_ownsCaches;
-    bool m_needsNotifications;
+        RefPtr<Node> m_rootNode;
+        mutable Caches* m_caches;
+        bool m_ownsCaches;
+        bool m_needsNotifications;
 
-private:
-    Node* itemForwardsFromCurrent(Node* start, unsigned offset, int remainingOffset) const;
-    Node* itemBackwardsFromCurrent(Node* start, unsigned offset, int remainingOffset) const;
-};
+    private:
+        Node* itemForwardsFromCurrent(Node* start, unsigned offset, int remainingOffset) const;
+        Node* itemBackwardsFromCurrent(Node* start, unsigned offset, int remainingOffset) const;
+    };
 
 } // namespace WebCore
 
index 0e9c8a58297c299db20104813811f6ce46d09782..be6e72baaf5c02f1a66a48451ad2a80e6504e428 100644 (file)
 
 #include "Element.h"
 #include "HTMLNames.h"
+#include <wtf/Assertions.h>
 
 namespace WebCore {
 
 using namespace HTMLNames;
 
-NameNodeList::NameNodeList(Node* root, const String& name, DynamicNodeList::Caches* caches)
-    : DynamicNodeList(root, caches, true)
+NameNodeList::NameNodeList(PassRefPtr<Node> rootNode, const String& name, DynamicNodeList::Caches* caches)
+    : DynamicNodeList(rootNode, caches, true)
     , m_nodeName(name)
 {
 }
 
+void NameNodeList::rootNodeAttributeChanged()
+{
+    DynamicNodeList::rootNodeChildrenChanged();
+}
+
 bool NameNodeList::nodeMatches(Node* testNode) const
 {
+    ASSERT(testNode->isElementNode());
     return static_cast<Element*>(testNode)->getAttribute(nameAttr) == m_nodeName;
 }
 
index d36241f19369fbee3c497fd3911c8d591326f232..bb8c7f4cbae3f659c44d8a63a68a7bd48470d03b 100644 (file)
 #define NameNodeList_h
 
 #include "DynamicNodeList.h"
-#include "PlatformString.h"
+#include "AtomicString.h"
 
 namespace WebCore {
 
-/**
- * NodeList which lists all Nodes in a Element with a given "name=" tag
- */
-class NameNodeList : public DynamicNodeList {
-public:
-    NameNodeList(Node* root, const String& name, DynamicNodeList::Caches*);
+    class String;
+
+    // NodeList which lists all Nodes in a Element with a given "name" attribute
+    class NameNodeList : public DynamicNodeList {
+    public:
+        NameNodeList(PassRefPtr<Node> rootNode, const String& name, DynamicNodeList::Caches*);
 
-    // Other methods (not part of DOM)
-    
-    virtual void rootNodeAttributeChanged() { DynamicNodeList::rootNodeChildrenChanged(); }
+        virtual void rootNodeAttributeChanged();
 
-private:
-    virtual bool nodeMatches(Node*) const;
+    private:
+        virtual bool nodeMatches(Node*) const;
 
-    String m_nodeName;
-};
+        AtomicString m_nodeName;
+    };
 
 } // namespace WebCore
 
index bbb9c15988f5e6e3c380f1938b358f941f118578..4e37b17dc9bb5eeff169571149f794c960eb6a74 100644 (file)
@@ -1,10 +1,8 @@
 /*
- * This file is part of the DOM implementation for KDE.
- *
  * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
  *           (C) 1999 Antti Koivisto (koivisto@kde.org)
  *           (C) 2001 Dirk Mueller (mueller@kde.org)
- * Copyright (C) 2004, 2006 Apple Computer, Inc.
+ * Copyright (C) 2004, 2006, 2007 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
@@ -27,7 +25,6 @@
 #define NodeList_h
 
 #include <wtf/RefCounted.h>
-#include <wtf/Forward.h>
 
 namespace WebCore {
 
index 952258f18ad37de74a9f19a181843de80e89d569..147e0285f60d0a376c6e5bd07f243899e38dbcaa 100644 (file)
@@ -39,7 +39,7 @@ namespace WebCore {
 
     class SelectorNodeList : public StaticNodeList {
     public:
-        SelectorNodeList(PassRefPtr<Node> rootNode, CSSSelector* selector);
+        SelectorNodeList(PassRefPtr<Node> rootNode, CSSSelector*);
     };
 
 } // namespace WebCore