本文整理汇总了C++中PositionIterator::atEnd方法的典型用法代码示例。如果您正苦于以下问题:C++ PositionIterator::atEnd方法的具体用法?C++ PositionIterator::atEnd怎么用?C++ PositionIterator::atEnd使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PositionIterator
的用法示例。
在下文中一共展示了PositionIterator::atEnd方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: nextCandidate
Position nextCandidate(const Position& position)
{
PositionIterator p = position;
while (!p.atEnd()) {
p.increment();
if (p.isCandidate())
return p;
}
return Position();
}
示例2: forwardIterator
static bool forwardIterator(PositionIterator& iterator, int distance)
{
int remaining = distance;
while (!iterator.atEnd()) {
if (iterator.node()->isCharacterDataNode()) {
int length = lastOffsetForEditing(iterator.node());
int last = length - iterator.offsetInLeafNode();
if (remaining < last) {
iterator.setOffsetInLeafNode(iterator.offsetInLeafNode() + remaining);
return true;
}
remaining -= last;
iterator.setOffsetInLeafNode(iterator.offsetInLeafNode() + last);
}
iterator.increment();
}
return false;
}
示例3: downstream
// P.downstream() returns the end of the range of positions that map to the same VisiblePosition as P.
Position Position::downstream() const
{
Node* startNode = node();
if (!startNode)
return Position();
// iterate forward from there, looking for a qualified position
Node* block = enclosingBlock(startNode);
PositionIterator lastVisible = *this;
PositionIterator currentPos = lastVisible;
Node* originalRoot = node()->rootEditableElement();
for (; !currentPos.atEnd(); currentPos.increment()) {
Node* currentNode = currentPos.node();
if (currentNode->rootEditableElement() != originalRoot)
break;
// stop before going above the body, up into the head
// return the last visible streamer position
if (currentNode->hasTagName(bodyTag) && currentPos.atEndOfNode())
break;
// Do not enter a new enclosing block flow or table element, and don't leave the original one.
if (block != enclosingBlock(currentNode))
return lastVisible;
// skip position in unrendered or invisible node
RenderObject* renderer = currentNode->renderer();
if (!renderer || renderer->style()->visibility() != VISIBLE)
continue;
// track last visible streamer position
if (isStreamer(currentPos))
lastVisible = currentPos;
// Return position before brs, tables, and nodes which have content that can be ignored.
if (editingIgnoresContent(currentNode) || renderer->isBR() || isTableElement(currentNode)) {
if (currentPos.offsetInLeafNode() <= renderer->caretMinOffset())
return Position(currentNode, renderer->caretMinOffset());
continue;
}
// return current position if it is in rendered text
if (renderer->isText() && static_cast<RenderText*>(renderer)->firstTextBox()) {
if (currentNode != startNode) {
ASSERT(currentPos.atStartOfNode());
return Position(currentNode, renderer->caretMinOffset());
}
unsigned textOffset = currentPos.offsetInLeafNode();
RenderText* textRenderer = static_cast<RenderText*>(renderer);
for (InlineTextBox* box = textRenderer->firstTextBox(); box; box = box->nextTextBox()) {
if (textOffset >= box->start() && textOffset <= box->end())
return currentPos;
if (box != textRenderer->lastTextBox() &&
!box->nextOnLine() &&
textOffset == box->start() + box->len()) {
return currentPos;
}
}
}
}
return lastVisible;
}