本文整理汇总了C++中InlineTextBox::offsetForPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ InlineTextBox::offsetForPosition方法的具体用法?C++ InlineTextBox::offsetForPosition怎么用?C++ InlineTextBox::offsetForPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类InlineTextBox
的用法示例。
在下文中一共展示了InlineTextBox::offsetForPosition方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: positionForPoint
VisiblePosition RenderTextLineBoxes::positionForPoint(const RenderText& renderer, const LayoutPoint& point) const
{
if (!m_first || !renderer.textLength())
return renderer.createVisiblePosition(0, DOWNSTREAM);
LayoutUnit pointLineDirection = m_first->isHorizontal() ? point.x() : point.y();
LayoutUnit pointBlockDirection = m_first->isHorizontal() ? point.y() : point.x();
bool blocksAreFlipped = renderer.style().isFlippedBlocksWritingMode();
InlineTextBox* lastBox = nullptr;
for (auto box = m_first; box; box = box->nextTextBox()) {
if (box->isLineBreak() && !box->prevLeafChild() && box->nextLeafChild() && !box->nextLeafChild()->isLineBreak())
box = box->nextTextBox();
auto& rootBox = box->root();
LayoutUnit top = std::min(rootBox.selectionTop(), rootBox.lineTop());
if (pointBlockDirection > top || (!blocksAreFlipped && pointBlockDirection == top)) {
LayoutUnit bottom = rootBox.selectionBottom();
if (rootBox.nextRootBox())
bottom = std::min(bottom, rootBox.nextRootBox()->lineTop());
if (pointBlockDirection < bottom || (blocksAreFlipped && pointBlockDirection == bottom)) {
ShouldAffinityBeDownstream shouldAffinityBeDownstream;
#if PLATFORM(IOS)
if (pointLineDirection != box->logicalLeft() && point.x() < box->x() + box->logicalWidth()) {
int half = box->x() + box->logicalWidth() / 2;
EAffinity affinity = point.x() < half ? DOWNSTREAM : VP_UPSTREAM_IF_POSSIBLE;
return renderer.createVisiblePosition(box->offsetForPosition(pointLineDirection) + box->start(), affinity);
}
#endif
if (lineDirectionPointFitsInBox(pointLineDirection, *box, shouldAffinityBeDownstream))
return createVisiblePositionAfterAdjustingOffsetForBiDi(*box, box->offsetForPosition(pointLineDirection), shouldAffinityBeDownstream);
}
}
lastBox = box;
}
if (lastBox) {
ShouldAffinityBeDownstream shouldAffinityBeDownstream;
lineDirectionPointFitsInBox(pointLineDirection, *lastBox, shouldAffinityBeDownstream);
return createVisiblePositionAfterAdjustingOffsetForBiDi(*lastBox, lastBox->offsetForPosition(pointLineDirection) + lastBox->start(), shouldAffinityBeDownstream);
}
return renderer.createVisiblePosition(0, DOWNSTREAM);
}