summaryrefslogtreecommitdiff
path: root/Source/WebCore/dom/ElementChildIterator.h
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/dom/ElementChildIterator.h')
-rw-r--r--Source/WebCore/dom/ElementChildIterator.h46
1 files changed, 35 insertions, 11 deletions
diff --git a/Source/WebCore/dom/ElementChildIterator.h b/Source/WebCore/dom/ElementChildIterator.h
index 170af861c..8e38fb503 100644
--- a/Source/WebCore/dom/ElementChildIterator.h
+++ b/Source/WebCore/dom/ElementChildIterator.h
@@ -23,8 +23,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef ElementChildIterator_h
-#define ElementChildIterator_h
+#pragma once
#include "ElementIterator.h"
@@ -33,16 +32,30 @@ namespace WebCore {
template <typename ElementType>
class ElementChildIterator : public ElementIterator<ElementType> {
public:
+ typedef ElementType value_type;
+ typedef ptrdiff_t difference_type;
+ typedef ElementType* pointer;
+ typedef ElementType& reference;
+ typedef std::forward_iterator_tag iterator_category;
+
ElementChildIterator(const ContainerNode& parent);
ElementChildIterator(const ContainerNode& parent, ElementType* current);
+ ElementChildIterator& operator--();
ElementChildIterator& operator++();
};
template <typename ElementType>
class ElementChildConstIterator : public ElementConstIterator<ElementType> {
public:
+ typedef const ElementType value_type;
+ typedef ptrdiff_t difference_type;
+ typedef const ElementType* pointer;
+ typedef const ElementType& reference;
+ typedef std::forward_iterator_tag iterator_category;
+
ElementChildConstIterator(const ContainerNode& parent);
ElementChildConstIterator(const ContainerNode& parent, const ElementType* current);
+ ElementChildConstIterator& operator--();
ElementChildConstIterator& operator++();
};
@@ -96,6 +109,12 @@ inline ElementChildIterator<ElementType>::ElementChildIterator(const ContainerNo
}
template <typename ElementType>
+inline ElementChildIterator<ElementType>& ElementChildIterator<ElementType>::operator--()
+{
+ return static_cast<ElementChildIterator<ElementType>&>(ElementIterator<ElementType>::traversePreviousSibling());
+}
+
+template <typename ElementType>
inline ElementChildIterator<ElementType>& ElementChildIterator<ElementType>::operator++()
{
return static_cast<ElementChildIterator<ElementType>&>(ElementIterator<ElementType>::traverseNextSibling());
@@ -116,6 +135,13 @@ inline ElementChildConstIterator<ElementType>::ElementChildConstIterator(const C
}
template <typename ElementType>
+inline ElementChildConstIterator<ElementType>& ElementChildConstIterator<ElementType>::operator--()
+{
+ return static_cast<ElementChildConstIterator<ElementType>&>(ElementConstIterator<ElementType>::traversePreviousSibling());
+}
+
+
+template <typename ElementType>
inline ElementChildConstIterator<ElementType>& ElementChildConstIterator<ElementType>::operator++()
{
return static_cast<ElementChildConstIterator<ElementType>&>(ElementConstIterator<ElementType>::traverseNextSibling());
@@ -132,7 +158,7 @@ inline ElementChildIteratorAdapter<ElementType>::ElementChildIteratorAdapter(Con
template <typename ElementType>
inline ElementChildIterator<ElementType> ElementChildIteratorAdapter<ElementType>::begin()
{
- return ElementChildIterator<ElementType>(m_parent, Traversal<ElementType>::firstChild(&m_parent));
+ return ElementChildIterator<ElementType>(m_parent, Traversal<ElementType>::firstChild(m_parent));
}
template <typename ElementType>
@@ -144,13 +170,13 @@ inline ElementChildIterator<ElementType> ElementChildIteratorAdapter<ElementType
template <typename ElementType>
inline ElementType* ElementChildIteratorAdapter<ElementType>::first()
{
- return Traversal<ElementType>::firstChild(&m_parent);
+ return Traversal<ElementType>::firstChild(m_parent);
}
template <typename ElementType>
inline ElementType* ElementChildIteratorAdapter<ElementType>::last()
{
- return Traversal<ElementType>::lastChild(&m_parent);
+ return Traversal<ElementType>::lastChild(m_parent);
}
template <typename ElementType>
@@ -171,7 +197,7 @@ inline ElementChildConstIteratorAdapter<ElementType>::ElementChildConstIteratorA
template <typename ElementType>
inline ElementChildConstIterator<ElementType> ElementChildConstIteratorAdapter<ElementType>::begin() const
{
- return ElementChildConstIterator<ElementType>(m_parent, Traversal<ElementType>::firstChild(&m_parent));
+ return ElementChildConstIterator<ElementType>(m_parent, Traversal<ElementType>::firstChild(m_parent));
}
template <typename ElementType>
@@ -183,13 +209,13 @@ inline ElementChildConstIterator<ElementType> ElementChildConstIteratorAdapter<E
template <typename ElementType>
inline const ElementType* ElementChildConstIteratorAdapter<ElementType>::first() const
{
- return Traversal<ElementType>::firstChild(&m_parent);
+ return Traversal<ElementType>::firstChild(m_parent);
}
template <typename ElementType>
inline const ElementType* ElementChildConstIteratorAdapter<ElementType>::last() const
{
- return Traversal<ElementType>::lastChild(&m_parent);
+ return Traversal<ElementType>::lastChild(m_parent);
}
template <typename ElementType>
@@ -213,6 +239,4 @@ inline ElementChildConstIteratorAdapter<ElementType> childrenOfType(const Contai
return ElementChildConstIteratorAdapter<ElementType>(parent);
}
-}
-
-#endif
+} // namespace WebCore