本文整理汇总了C++中NodeImpl::childNodeCount方法的典型用法代码示例。如果您正苦于以下问题:C++ NodeImpl::childNodeCount方法的具体用法?C++ NodeImpl::childNodeCount怎么用?C++ NodeImpl::childNodeCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NodeImpl
的用法示例。
在下文中一共展示了NodeImpl::childNodeCount方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: deepEquivalent
Position VisiblePosition::deepEquivalent(const Position &pos)
{
NodeImpl *node = pos.node();
long offset = pos.offset();
if (!node)
return Position();
if (isAtomicNode(node))
return pos;
if (offset >= (long)node->childNodeCount()) {
do {
NodeImpl *child = node->lastChild();
if (!child)
break;
node = child;
} while (!isAtomicNode(node));
return Position(node, node->caretMaxOffset());
}
node = node->childNode(offset);
ASSERT(node);
while (!isAtomicNode(node)) {
NodeImpl *child = node->firstChild();
if (!child)
break;
node = child;
}
return Position(node, 0);
}
示例2: equivalentRangeCompliantPosition
Position Position::equivalentRangeCompliantPosition() const
{
if (isNull())
return Position();
// Make sure that 0 <= constrainedOffset <= num kids, otherwise using this Position
// in DOM calls can result in exceptions.
long maxOffset = node()->isTextNode() ? static_cast<TextImpl *>(node())->length(): node()->childNodeCount();
long constrainedOffset = offset() <= 0 ? 0 : kMin(maxOffset, offset());
if (!node()->parentNode())
return Position(node(), constrainedOffset);
RenderObject *renderer = node()->renderer();
if (!renderer)
return Position(node(), constrainedOffset);
if (!renderer->isReplaced() && !renderer->isBR())
return Position(node(), constrainedOffset);
long o = offset();
const NodeImpl *n = node();
while ((n = n->previousSibling()))
o++;
// Make sure that 0 <= constrainedOffset <= num kids, as above.
NodeImpl *parent = node()->parentNode();
maxOffset = parent->isTextNode() ? static_cast<TextImpl *>(parent)->length(): parent->childNodeCount();
constrainedOffset = o <= 0 ? 0 : kMin(maxOffset, o);
return Position(parent, constrainedOffset);
}