本文整理汇总了C++中VisiblePosition::getInlineBoxAndOffset方法的典型用法代码示例。如果您正苦于以下问题:C++ VisiblePosition::getInlineBoxAndOffset方法的具体用法?C++ VisiblePosition::getInlineBoxAndOffset怎么用?C++ VisiblePosition::getInlineBoxAndOffset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VisiblePosition
的用法示例。
在下文中一共展示了VisiblePosition::getInlineBoxAndOffset方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rendererFromPosition
RenderedPosition::RenderedPosition(const VisiblePosition& position)
: m_offset(0)
, m_prevLeafChild(uncachedInlineBox())
, m_nextLeafChild(uncachedInlineBox())
{
if (position.isNull())
return;
position.getInlineBoxAndOffset(m_inlineBox, m_offset);
if (m_inlineBox)
m_renderer = &m_inlineBox->renderer();
else
m_renderer = rendererFromPosition(position.deepEquivalent());
}
示例2: nextLinePosition
VisiblePosition nextLinePosition(const VisiblePosition &visiblePosition, int x)
{
Position p = visiblePosition.deepEquivalent();
Node *node = p.node();
Node* highestRoot = highestEditableRoot(p);
if (!node)
return VisiblePosition();
node->document()->updateLayoutIgnorePendingStylesheets();
RenderObject *renderer = node->renderer();
if (!renderer)
return VisiblePosition();
RenderBlock *containingBlock = 0;
RootInlineBox *root = 0;
InlineBox* box;
int ignoredCaretOffset;
visiblePosition.getInlineBoxAndOffset(box, ignoredCaretOffset);
if (box) {
root = box->root()->nextRootBox();
if (root)
containingBlock = renderer->containingBlock();
}
if (!root) {
// This containing editable block does not have a next line.
// Need to move forward to next containing editable block in this root editable
// block and find the first root line box in that block.
Node* startBlock = enclosingNodeWithNonInlineRenderer(node);
Node* n = nextLeafWithSameEditability(node, p.deprecatedEditingOffset());
while (n && startBlock == enclosingNodeWithNonInlineRenderer(n))
n = nextLeafWithSameEditability(n);
while (n) {
if (highestEditableRoot(Position(n, 0)) != highestRoot)
break;
Position pos(n, caretMinOffset(n));
if (pos.isCandidate()) {
ASSERT(n->renderer());
pos.getInlineBoxAndOffset(DOWNSTREAM, box, ignoredCaretOffset);
if (box) {
// next root line box found
root = box->root();
containingBlock = n->renderer()->containingBlock();
break;
}
return VisiblePosition(pos, DOWNSTREAM);
}
n = nextLeafWithSameEditability(n);
}
}
if (root) {
// FIXME: Can be wrong for multi-column layout and with transforms.
FloatPoint absPos = containingBlock->localToAbsolute(FloatPoint());
if (containingBlock->hasOverflowClip())
absPos -= containingBlock->layer()->scrolledContentOffset();
RenderObject* renderer = root->closestLeafChildForXPos(x - absPos.x(), isEditablePosition(p))->renderer();
Node* node = renderer->node();
if (node && editingIgnoresContent(node))
return Position(node->parent(), node->nodeIndex());
return renderer->positionForPoint(IntPoint(x - absPos.x(), root->lineTop()));
}
// Could not find a next line. This means we must already be on the last line.
// Move to the end of the content in this block, which effectively moves us
// to the end of the line we're on.
Element* rootElement = node->isContentEditable() ? node->rootEditableElement() : node->document()->documentElement();
return VisiblePosition(rootElement, rootElement ? rootElement->childNodeCount() : 0, DOWNSTREAM);
}
示例3: previousLinePosition
VisiblePosition previousLinePosition(const VisiblePosition &visiblePosition, int x)
{
Position p = visiblePosition.deepEquivalent();
Node *node = p.node();
Node* highestRoot = highestEditableRoot(p);
if (!node)
return VisiblePosition();
node->document()->updateLayoutIgnorePendingStylesheets();
RenderObject *renderer = node->renderer();
if (!renderer)
return VisiblePosition();
RenderBlock *containingBlock = 0;
RootInlineBox *root = 0;
InlineBox* box;
int ignoredCaretOffset;
visiblePosition.getInlineBoxAndOffset(box, ignoredCaretOffset);
if (box) {
root = box->root()->prevRootBox();
if (root)
containingBlock = renderer->containingBlock();
}
if (!root) {
// This containing editable block does not have a previous line.
// Need to move back to previous containing editable block in this root editable
// block and find the last root line box in that block.
Node* startBlock = enclosingBlock(node);
Node* n = previousLeafWithSameEditability(node);
while (n && startBlock == enclosingBlock(n))
n = previousLeafWithSameEditability(n);
while (n) {
if (highestEditableRoot(Position(n, 0)) != highestRoot)
break;
Position pos(n, caretMinOffset(n));
if (pos.isCandidate()) {
ASSERT(n->renderer());
Position maxPos(n, caretMaxOffset(n));
maxPos.getInlineBoxAndOffset(DOWNSTREAM, box, ignoredCaretOffset);
if (box) {
// previous root line box found
root = box->root();
containingBlock = n->renderer()->containingBlock();
break;
}
return VisiblePosition(pos, DOWNSTREAM);
}
n = previousLeafWithSameEditability(n);
}
}
if (root) {
// FIXME: Can be wrong for multi-column layout.
int absx, absy;
containingBlock->absolutePositionForContent(absx, absy);
if (containingBlock->hasOverflowClip())
containingBlock->layer()->subtractScrollOffset(absx, absy);
RenderObject *renderer = root->closestLeafChildForXPos(x - absx, isEditablePosition(p))->object();
Node* node = renderer->element();
if (editingIgnoresContent(node))
return Position(node->parent(), node->nodeIndex());
return renderer->positionForCoordinates(x - absx, root->topOverflow());
}
// Could not find a previous line. This means we must already be on the first line.
// Move to the start of the content in this block, which effectively moves us
// to the start of the line we're on.
Node* rootElement = node->isContentEditable() ? node->rootEditableElement() : node->document()->documentElement();
return VisiblePosition(rootElement, 0, DOWNSTREAM);
}