This source file includes following definitions.
- m_isReset
- first
- next
- reset
- firstChildBox
- nextSiblingBox
- storeChild
- collectChild
#include "config.h"
#include "core/rendering/OrderIterator.h"
#include "core/rendering/RenderBox.h"
namespace WebCore {
OrderIterator::OrderIterator(const RenderBox* containerBox)
: m_containerBox(containerBox)
, m_currentChild(0)
, m_isReset(false)
{
}
RenderBox* OrderIterator::first()
{
reset();
return next();
}
RenderBox* OrderIterator::next()
{
do {
if (!m_currentChild) {
if (m_orderValuesIterator == m_orderValues.end())
return 0;
if (!m_isReset) {
++m_orderValuesIterator;
if (m_orderValuesIterator == m_orderValues.end())
return 0;
} else {
m_isReset = false;
}
m_currentChild = firstChildBox();
} else {
m_currentChild = nextSiblingBox();
}
} while (!m_currentChild || m_currentChild->style()->order() != *m_orderValuesIterator);
return m_currentChild;
}
void OrderIterator::reset()
{
m_currentChild = 0;
m_orderValuesIterator = m_orderValues.begin();
m_isReset = true;
}
RenderBox* OrderIterator::firstChildBox()
{
if (m_children.isEmpty())
return m_containerBox->firstChildBox();
m_childIndex = 0;
return m_children[0];
}
RenderBox* OrderIterator::nextSiblingBox()
{
if (m_children.isEmpty())
return m_currentChild->nextSiblingBox();
if (m_childIndex >= m_children.size() - 1)
return 0;
return m_children[++m_childIndex];
}
OrderIteratorPopulator::~OrderIteratorPopulator()
{
m_iterator.reset();
}
void OrderIteratorPopulator::storeChild(RenderBox* child)
{
m_iterator.m_children.append(child);
collectChild(child);
}
void OrderIteratorPopulator::collectChild(const RenderBox* child)
{
m_iterator.m_orderValues.insert(child->style()->order());
}
}