Title: [154682] trunk/Source/WebCore
Revision
154682
Author
[email protected]
Date
2013-08-27 07:39:46 -0700 (Tue, 27 Aug 2013)

Log Message

Remove branch from DescendantIteratorAdapter::begin() when invoking for ContainerNode
https://bugs.webkit.org/show_bug.cgi?id=120358

Reviewed by Andreas Kling.

* dom/ContainerNode.h:
        
    Delete isContainerNode() so it can't be called if there is static knowledge that the object is a ContainerNode.

* dom/DescendantIterator.h:
(WebCore::::DescendantIterator):

    Make DescendantIterator use Node* as root instead of ContainerNode*. It is only used for equality comparison.

(WebCore::::begin):
        
    Remove branch. Rely on ElementTraversal specialization for ContainerNodes.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (154681 => 154682)


--- trunk/Source/WebCore/ChangeLog	2013-08-27 14:13:31 UTC (rev 154681)
+++ trunk/Source/WebCore/ChangeLog	2013-08-27 14:39:46 UTC (rev 154682)
@@ -1,3 +1,23 @@
+2013-08-27  Antti Koivisto  <[email protected]>
+
+        Remove branch from DescendantIteratorAdapter::begin() when invoking for ContainerNode
+        https://bugs.webkit.org/show_bug.cgi?id=120358
+
+        Reviewed by Andreas Kling.
+
+        * dom/ContainerNode.h:
+        
+            Delete isContainerNode() so it can't be called if there is static knowledge that the object is a ContainerNode.
+
+        * dom/DescendantIterator.h:
+        (WebCore::::DescendantIterator):
+
+            Make DescendantIterator use Node* as root instead of ContainerNode*. It is only used for equality comparison.
+
+        (WebCore::::begin):
+        
+            Remove branch. Rely on ElementTraversal specialization for ContainerNodes.
+
 2013-08-27  Joseph Pecoraro  <[email protected]>
 
         Web Inspector: Column Breakpoint not working, may be off by 1

Modified: trunk/Source/WebCore/dom/ContainerNode.h (154681 => 154682)


--- trunk/Source/WebCore/dom/ContainerNode.h	2013-08-27 14:13:31 UTC (rev 154681)
+++ trunk/Source/WebCore/dom/ContainerNode.h	2013-08-27 14:39:46 UTC (rev 154682)
@@ -147,6 +147,8 @@
     bool getUpperLeftCorner(FloatPoint&) const;
     bool getLowerRightCorner(FloatPoint&) const;
 
+    bool isContainerNode() const WTF_DELETED_FUNCTION;
+
     Node* m_firstChild;
     Node* m_lastChild;
 };

Modified: trunk/Source/WebCore/dom/DescendantIterator.h (154681 => 154682)


--- trunk/Source/WebCore/dom/DescendantIterator.h	2013-08-27 14:13:31 UTC (rev 154681)
+++ trunk/Source/WebCore/dom/DescendantIterator.h	2013-08-27 14:39:46 UTC (rev 154682)
@@ -37,15 +37,15 @@
 template <typename ElementType>
 class DescendantIterator {
 public:
-    DescendantIterator(const ContainerNode* root);
-    DescendantIterator(const ContainerNode* root, ElementType* current);
+    DescendantIterator(const Node* root);
+    DescendantIterator(const Node* root, ElementType* current);
     DescendantIterator& operator++();
     ElementType& operator*() { return *m_current; }
     ElementType* operator->() { return m_current; }
     bool operator!=(const DescendantIterator& other) const;
 
 private:
-    const ContainerNode* m_root;
+    const Node* m_root;
     ElementType* m_current;
 #ifndef NDEBUG
     OwnPtr<NoEventDispatchAssertion> m_noEventDispatchAssertion;
@@ -70,7 +70,7 @@
 template <typename ElementType> DescendantIteratorAdapter<ElementType, Node> descendantsOfType(Node* root);
 
 template <typename ElementType>
-inline DescendantIterator<ElementType>::DescendantIterator(const ContainerNode* root)
+inline DescendantIterator<ElementType>::DescendantIterator(const Node* root)
     : m_root(root)
     , m_current(nullptr)
 #ifndef NDEBUG
@@ -80,7 +80,7 @@
 }
 
 template <typename ElementType>
-inline DescendantIterator<ElementType>::DescendantIterator(const ContainerNode* root, ElementType* current)
+inline DescendantIterator<ElementType>::DescendantIterator(const Node* root, ElementType* current)
     : m_root(root)
     , m_current(current)
 #ifndef NDEBUG
@@ -115,9 +115,7 @@
 template <typename ElementType, typename ContainerType>
 inline DescendantIterator<ElementType> DescendantIteratorAdapter<ElementType, ContainerType>::begin()
 {
-    if (!m_root->isContainerNode())
-        return DescendantIterator<ElementType>(m_root);
-    return DescendantIterator<ElementType>(m_root, Traversal<ElementType>::firstWithin(static_cast<ContainerNode*>(m_root)));
+    return DescendantIterator<ElementType>(m_root, Traversal<ElementType>::firstWithin(m_root));
 }
 
 template <typename ElementType, typename ContainerType>
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to