LayoutDescendantIterator.h [plain text]
#pragma once
#include "LayoutIterator.h"
#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
namespace WebCore {
namespace Layout {
template <typename T>
class LayoutDescendantIterator : public LayoutIterator<T> {
public:
LayoutDescendantIterator(const Container& root);
LayoutDescendantIterator(const Container& root, const T* current);
LayoutDescendantIterator& operator++();
};
template <typename T>
class LayoutDescendantIteratorAdapter {
public:
LayoutDescendantIteratorAdapter(const Container& root);
LayoutDescendantIterator<T> begin();
LayoutDescendantIterator<T> end();
LayoutDescendantIterator<T> at(const T&);
private:
const Container& m_root;
};
template <typename T> LayoutDescendantIteratorAdapter<T> descendantsOfType(const Box&);
template <typename T>
inline LayoutDescendantIterator<T>::LayoutDescendantIterator(const Container& root)
: LayoutIterator<T>(&root)
{
}
template <typename T>
inline LayoutDescendantIterator<T>::LayoutDescendantIterator(const Container& root, const T* current)
: LayoutIterator<T>(&root, current)
{
}
template <typename T>
inline LayoutDescendantIterator<T>& LayoutDescendantIterator<T>::operator++()
{
return static_cast<LayoutDescendantIterator<T>&>(LayoutIterator<T>::traverseNext());
}
template <typename T>
inline LayoutDescendantIteratorAdapter<T>::LayoutDescendantIteratorAdapter(const Container& root)
: m_root(root)
{
}
template <typename T>
inline LayoutDescendantIterator<T> LayoutDescendantIteratorAdapter<T>::begin()
{
return LayoutDescendantIterator<T>(m_root, Traversal::firstWithin<T>(m_root));
}
template <typename T>
inline LayoutDescendantIterator<T> LayoutDescendantIteratorAdapter<T>::end()
{
return LayoutDescendantIterator<T>(m_root);
}
template <typename T>
inline LayoutDescendantIterator<T> LayoutDescendantIteratorAdapter<T>::at(const T& current)
{
return LayoutDescendantIterator<T>(m_root, ¤t);
}
template <typename T>
inline LayoutDescendantIteratorAdapter<T> descendantsOfType(const Container& root)
{
return LayoutDescendantIteratorAdapter<T>(root);
}
}
}
#endif