LayoutChildIterator.h [plain text]
#pragma once
#include "LayoutIterator.h"
#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
namespace WebCore {
namespace Layout {
template <typename T>
class LayoutChildIterator : public LayoutIterator<T> {
public:
LayoutChildIterator(const ContainerBox& parent);
LayoutChildIterator(const ContainerBox& parent, const T* current);
LayoutChildIterator& operator++();
};
template <typename T>
class LayoutChildIteratorAdapter {
public:
LayoutChildIteratorAdapter(const ContainerBox& parent);
LayoutChildIterator<T> begin() const;
LayoutChildIterator<T> end() const;
const T* first() const;
const T* last() const;
private:
const ContainerBox& m_parent;
};
template <typename T> LayoutChildIteratorAdapter<T> childrenOfType(const ContainerBox&);
template <typename T>
inline LayoutChildIterator<T>::LayoutChildIterator(const ContainerBox& parent)
: LayoutIterator<T>(&parent)
{
}
template <typename T>
inline LayoutChildIterator<T>::LayoutChildIterator(const ContainerBox& parent, const T* current)
: LayoutIterator<T>(&parent, current)
{
}
template <typename T>
inline LayoutChildIterator<T>& LayoutChildIterator<T>::operator++()
{
return static_cast<LayoutChildIterator<T>&>(LayoutIterator<T>::traverseNextSibling());
}
template <typename T>
inline LayoutChildIteratorAdapter<T>::LayoutChildIteratorAdapter(const ContainerBox& parent)
: m_parent(parent)
{
}
template <typename T>
inline LayoutChildIterator<T> LayoutChildIteratorAdapter<T>::begin() const
{
return LayoutChildIterator<T>(m_parent, Traversal::firstChild<T>(m_parent));
}
template <typename T>
inline LayoutChildIterator<T> LayoutChildIteratorAdapter<T>::end() const
{
return LayoutChildIterator<T>(m_parent);
}
template <typename T>
inline const T* LayoutChildIteratorAdapter<T>::first() const
{
return Traversal::firstChild<T>(m_parent);
}
template <typename T>
inline LayoutChildIteratorAdapter<T> childrenOfType(const ContainerBox& parent)
{
return LayoutChildIteratorAdapter<T>(parent);
}
}
}
#endif