Commit 4e851ef4 authored by antti@apple.com's avatar antti@apple.com
Browse files

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.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154682 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 979f0e61
2013-08-27 Antti Koivisto <antti@apple.com>
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 <pecoraro@apple.com> 2013-08-27 Joseph Pecoraro <pecoraro@apple.com>
   
Web Inspector: Column Breakpoint not working, may be off by 1 Web Inspector: Column Breakpoint not working, may be off by 1
...@@ -147,6 +147,8 @@ private: ...@@ -147,6 +147,8 @@ private:
bool getUpperLeftCorner(FloatPoint&) const; bool getUpperLeftCorner(FloatPoint&) const;
bool getLowerRightCorner(FloatPoint&) const; bool getLowerRightCorner(FloatPoint&) const;
bool isContainerNode() const WTF_DELETED_FUNCTION;
Node* m_firstChild; Node* m_firstChild;
Node* m_lastChild; Node* m_lastChild;
}; };
......
...@@ -37,15 +37,15 @@ namespace WebCore { ...@@ -37,15 +37,15 @@ namespace WebCore {
template <typename ElementType> template <typename ElementType>
class DescendantIterator { class DescendantIterator {
public: public:
DescendantIterator(const ContainerNode* root); DescendantIterator(const Node* root);
DescendantIterator(const ContainerNode* root, ElementType* current); DescendantIterator(const Node* root, ElementType* current);
DescendantIterator& operator++(); DescendantIterator& operator++();
ElementType& operator*() { return *m_current; } ElementType& operator*() { return *m_current; }
ElementType* operator->() { return m_current; } ElementType* operator->() { return m_current; }
bool operator!=(const DescendantIterator& other) const; bool operator!=(const DescendantIterator& other) const;
private: private:
const ContainerNode* m_root; const Node* m_root;
ElementType* m_current; ElementType* m_current;
#ifndef NDEBUG #ifndef NDEBUG
OwnPtr<NoEventDispatchAssertion> m_noEventDispatchAssertion; OwnPtr<NoEventDispatchAssertion> m_noEventDispatchAssertion;
...@@ -70,7 +70,7 @@ template <typename ElementType> DescendantIteratorAdapter<ElementType, Container ...@@ -70,7 +70,7 @@ template <typename ElementType> DescendantIteratorAdapter<ElementType, Container
template <typename ElementType> DescendantIteratorAdapter<ElementType, Node> descendantsOfType(Node* root); template <typename ElementType> DescendantIteratorAdapter<ElementType, Node> descendantsOfType(Node* root);
template <typename ElementType> template <typename ElementType>
inline DescendantIterator<ElementType>::DescendantIterator(const ContainerNode* root) inline DescendantIterator<ElementType>::DescendantIterator(const Node* root)
: m_root(root) : m_root(root)
, m_current(nullptr) , m_current(nullptr)
#ifndef NDEBUG #ifndef NDEBUG
...@@ -80,7 +80,7 @@ inline DescendantIterator<ElementType>::DescendantIterator(const ContainerNode* ...@@ -80,7 +80,7 @@ inline DescendantIterator<ElementType>::DescendantIterator(const ContainerNode*
} }
template <typename ElementType> 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_root(root)
, m_current(current) , m_current(current)
#ifndef NDEBUG #ifndef NDEBUG
...@@ -115,9 +115,7 @@ inline DescendantIteratorAdapter<ElementType, ContainerType>::DescendantIterator ...@@ -115,9 +115,7 @@ inline DescendantIteratorAdapter<ElementType, ContainerType>::DescendantIterator
template <typename ElementType, typename ContainerType> template <typename ElementType, typename ContainerType>
inline DescendantIterator<ElementType> DescendantIteratorAdapter<ElementType, ContainerType>::begin() inline DescendantIterator<ElementType> DescendantIteratorAdapter<ElementType, ContainerType>::begin()
{ {
if (!m_root->isContainerNode()) return DescendantIterator<ElementType>(m_root, Traversal<ElementType>::firstWithin(m_root));
return DescendantIterator<ElementType>(m_root);
return DescendantIterator<ElementType>(m_root, Traversal<ElementType>::firstWithin(static_cast<ContainerNode*>(m_root)));
} }
template <typename ElementType, typename ContainerType> template <typename ElementType, typename ContainerType>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment