本文整理汇总了C++中VisiblePosition::isNull方法的典型用法代码示例。如果您正苦于以下问题:C++ VisiblePosition::isNull方法的具体用法?C++ VisiblePosition::isNull怎么用?C++ VisiblePosition::isNull使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VisiblePosition
的用法示例。
在下文中一共展示了VisiblePosition::isNull方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: visiblePositionForPoint
VisiblePosition Frame::visiblePositionForPoint(const IntPoint& framePoint)
{
HitTestResult result = eventHandler()->hitTestResultAtPoint(framePoint, true);
Node* node = result.innerNonSharedNode();
if (!node)
return VisiblePosition();
RenderObject* renderer = node->renderer();
if (!renderer)
return VisiblePosition();
VisiblePosition visiblePos = renderer->positionForPoint(result.localPoint());
if (visiblePos.isNull())
visiblePos = firstPositionInOrBeforeNode(node);
return visiblePos;
}
示例2: previousSentenceStartPosition
VisiblePosition AccessibilityObject::previousSentenceStartPosition(const VisiblePosition& visiblePos) const
{
// FIXME: FO 2 IMPLEMENT (currently returns incorrect answer)
// Related? <rdar://problem/3927736> Text selection broken in 8A336
if (visiblePos.isNull())
return VisiblePosition();
// make sure we move off of a sentence start
VisiblePosition previousVisiblePos = visiblePos.previous();
if (previousVisiblePos.isNull())
return VisiblePosition();
// treat empty line as a separate sentence.
VisiblePosition startPosition;
String lineString = plainText(makeRange(startOfLine(previousVisiblePos), endOfLine(previousVisiblePos)).get());
if (lineString.isEmpty())
startPosition = previousVisiblePos;
else
startPosition = startOfSentence(previousVisiblePos);
return startPosition;
}
示例3: layoutObjectFromPosition
RenderedPosition::RenderedPosition(const VisiblePosition& position)
: m_layoutObject(nullptr)
, m_inlineBox(nullptr)
, m_offset(0)
, m_prevLeafChild(uncachedInlineBox())
, m_nextLeafChild(uncachedInlineBox())
{
if (position.isNull())
return;
position.getInlineBoxAndOffset(m_inlineBox, m_offset);
if (m_inlineBox)
m_layoutObject = &m_inlineBox->layoutObject();
else
m_layoutObject = layoutObjectFromPosition(position.deepEquivalent());
}
示例4: previousLineStartPosition
VisiblePosition AccessibilityObject::previousLineStartPosition(const VisiblePosition& visiblePos) const
{
if (visiblePos.isNull())
return VisiblePosition();
// make sure we move off of a line start
VisiblePosition prevVisiblePos = visiblePos.previous();
if (prevVisiblePos.isNull())
return VisiblePosition();
VisiblePosition startPosition = startOfLine(prevVisiblePos);
// as long as the position hasn't reached the beginning of the doc, keep searching for a valid line start position
// There are cases like when the position is next to a floating object that'll return null for start of line. This code will avoid returning null.
if (startPosition.isNull()) {
while (startPosition.isNull() && prevVisiblePos.isNotNull()) {
prevVisiblePos = prevVisiblePos.previous();
startPosition = startOfLine(prevVisiblePos);
}
} else
startPosition = updateAXLineStartForVisiblePosition(startPosition);
return startPosition;
}
示例5: endOfWord
VisiblePosition endOfWord(const VisiblePosition &c, EWordSide side)
{
VisiblePosition p = c;
if (side == LeftWordIfOnBoundary) {
if (isStartOfParagraph(c))
return c;
p = c.previous();
if (p.isNull())
return c;
} else if (isEndOfParagraph(c))
return c;
return nextBoundary(p, endWordBoundary);
}
示例6: rendererFromPosition
RenderedPosition::RenderedPosition(const VisiblePosition& position)
: m_renderer(0)
, m_inlineBox(0)
, 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());
}
示例7: visiblePositionForPoint
static VisiblePosition visiblePositionForPoint(Frame* frame, IntPoint outerPoint)
{
ASSERT(frame);
HitTestResult result = frame->eventHandler()->hitTestResultAtPoint(outerPoint, true);
Node* node = result.innerNode();
if (!node)
return VisiblePosition();
RenderObject* renderer = node->renderer();
if (!renderer)
return VisiblePosition();
VisiblePosition visiblePos = renderer->positionForCoordinates(result.localPoint().x(), result.localPoint().y());
if (visiblePos.isNull())
visiblePos = VisiblePosition(Position(node, 0));
return visiblePos;
}
示例8: nextSentenceEndPosition
VisiblePosition AccessibilityObject::nextSentenceEndPosition(const VisiblePosition& visiblePos) const
{
// FIXME: FO 2 IMPLEMENT (currently returns incorrect answer)
// Related? <rdar://problem/3927736> Text selection broken in 8A336
if (visiblePos.isNull())
return VisiblePosition();
// make sure we move off of a sentence end
VisiblePosition nextVisiblePos = visiblePos.next();
if (nextVisiblePos.isNull())
return VisiblePosition();
// an empty line is considered a sentence. If it's skipped, then the sentence parser will not
// see this empty line. Instead, return the end position of the empty line.
VisiblePosition endPosition;
String lineString = plainText(makeRange(startOfLine(nextVisiblePos), endOfLine(nextVisiblePos)).get());
if (lineString.isEmpty())
endPosition = nextVisiblePos;
else
endPosition = endOfSentence(nextVisiblePos);
return endPosition;
}
示例9: startOfWord
VisiblePosition startOfWord(const VisiblePosition &c, EWordSide side)
{
// FIXME: This returns a null VP for c at the start of the document
// and side == LeftWordIfOnBoundary
VisiblePosition p = c;
if (side == RightWordIfOnBoundary) {
// at paragraph end, the startofWord is the current position
if (isEndOfParagraph(c))
return c;
p = c.next();
if (p.isNull())
return c;
}
return previousBoundary(p, startWordBoundary);
}
示例10: endPositionForLine
static VisiblePosition endPositionForLine(const VisiblePosition& c)
{
if (c.isNull())
return VisiblePosition();
RootInlineBox *rootBox = rootBoxForLine(c);
if (!rootBox) {
// There are VisiblePositions at offset 0 in blocks without
// RootInlineBoxes, like empty editable blocks and bordered blocks.
Position p = c.deepEquivalent();
if (p.node()->renderer() && p.node()->renderer()->isRenderBlock() && p.deprecatedEditingOffset() == 0)
return c;
return VisiblePosition();
}
// Generated content (e.g. list markers and CSS :before and :after
// pseudoelements) have no corresponding DOM element, and so cannot be
// represented by a VisiblePosition. Use whatever precedes instead.
Node *endNode;
InlineBox *endBox = rootBox->lastLeafChild();
while (1) {
if (!endBox)
return VisiblePosition();
RenderObject *endRenderer = endBox->renderer();
if (!endRenderer)
return VisiblePosition();
endNode = endRenderer->node();
if (endNode)
break;
endBox = endBox->prevLeafChild();
}
int endOffset = 1;
if (endNode->hasTagName(brTag)) {
endOffset = 0;
} else if (endBox->isInlineTextBox()) {
InlineTextBox *endTextBox = static_cast<InlineTextBox *>(endBox);
endOffset = endTextBox->start();
if (!endTextBox->isLineBreak())
endOffset += endTextBox->len();
}
return VisiblePosition(endNode, endOffset, VP_UPSTREAM_IF_POSSIBLE);
}
示例11: computeInlineBoxPosition
RenderedPosition::RenderedPosition(const VisiblePosition& position)
: m_layoutObject(nullptr)
, m_inlineBox(nullptr)
, m_offset(0)
, m_prevLeafChild(uncachedInlineBox())
, m_nextLeafChild(uncachedInlineBox())
{
if (position.isNull())
return;
InlineBoxPosition boxPosition = computeInlineBoxPosition(position);
m_inlineBox = boxPosition.inlineBox;
m_offset = boxPosition.offsetInBox;
if (m_inlineBox)
m_layoutObject = &m_inlineBox->layoutObject();
else
m_layoutObject = layoutObjectFromPosition(position.deepEquivalent());
}
示例12: startPositionForLine
static VisiblePosition startPositionForLine(const VisiblePosition& c)
{
if (c.isNull())
return VisiblePosition();
RootInlineBox *rootBox = rootBoxForLine(c);
if (!rootBox) {
// There are VisiblePositions at offset 0 in blocks without
// RootInlineBoxes, like empty editable blocks and bordered blocks.
Position p = c.deepEquivalent();
if (p.node()->renderer() && p.node()->renderer()->isRenderBlock() && p.deprecatedEditingOffset() == 0)
return positionAvoidingFirstPositionInTable(c);
return VisiblePosition();
}
// Generated content (e.g. list markers and CSS :before and :after
// pseudoelements) have no corresponding DOM element, and so cannot be
// represented by a VisiblePosition. Use whatever follows instead.
InlineBox *startBox = rootBox->firstLeafChild();
Node *startNode;
while (1) {
if (!startBox)
return VisiblePosition();
RenderObject *startRenderer = startBox->renderer();
if (!startRenderer)
return VisiblePosition();
startNode = startRenderer->node();
if (startNode)
break;
startBox = startBox->nextLeafChild();
}
int startOffset = 0;
if (startBox->isInlineTextBox()) {
InlineTextBox *startTextBox = static_cast<InlineTextBox *>(startBox);
startOffset = startTextBox->start();
}
VisiblePosition visPos = VisiblePosition(startNode, startOffset, DOWNSTREAM);
return positionAvoidingFirstPositionInTable(visPos);
}
示例13: indexForVisiblePosition
// FIXME: indexForVisiblePosition and visiblePositionForIndex use TextIterators to convert between
// VisiblePositions and indices. But TextIterator iteration using TextIteratorEmitsCharactersBetweenAllVisiblePositions
// does not exactly match VisiblePosition iteration, so using them to preserve a selection during an editing
// opertion is unreliable. TextIterator's TextIteratorEmitsCharactersBetweenAllVisiblePositions mode needs to be fixed,
// or these functions need to be changed to iterate using actual VisiblePositions.
// FIXME: Deploy these functions everywhere that TextIterators are used to convert between VisiblePositions and indices.
int indexForVisiblePosition(const VisiblePosition& visiblePosition, RefPtr<ContainerNode>& scope)
{
if (visiblePosition.isNull())
return 0;
Position p(visiblePosition.deepEquivalent());
Document* document = p.anchorNode()->document();
ShadowRoot* shadowRoot = p.anchorNode()->containingShadowRoot();
if (shadowRoot)
scope = shadowRoot;
else
scope = document->documentElement();
RefPtr<Range> range = Range::create(document, firstPositionInNode(scope.get()), p.parentAnchoredEquivalent());
return TextIterator::rangeLength(range.get(), true);
}
示例14: endOfLine
VisiblePosition endOfLine(const VisiblePosition& c)
{
VisiblePosition visPos = endPositionForLine(c);
// Make sure the end of line is at the same line as the given input position. Else use the previous position to
// obtain end of line. This condition happens when the input position is before the space character at the end
// of a soft-wrapped non-editable line. In this scenario, endPositionForLine would incorrectly hand back a position
// in the next line instead. This fix is to account for the discrepancy between lines with webkit-line-break:after-white-space style
// versus lines without that style, which would break before a space by default.
if (!inSameLine(c, visPos)) {
visPos = c.previous();
if (visPos.isNull())
return VisiblePosition();
visPos = endPositionForLine(visPos);
}
return c.honorEditableBoundaryAtOrBefore(visPos);
}
示例15: canDeleteRange
bool Editor::canDeleteRange(Range* range) const
{
Node* startContainer = range->startContainer();
Node* endContainer = range->endContainer();
if (!startContainer || !endContainer)
return false;
if (!startContainer->hasEditableStyle() || !endContainer->hasEditableStyle())
return false;
if (range->collapsed()) {
VisiblePosition start(range->startPosition(), DOWNSTREAM);
VisiblePosition previous = start.previous();
// FIXME: We sometimes allow deletions at the start of editable roots, like when the caret is in an empty list item.
if (previous.isNull() || previous.deepEquivalent().deprecatedNode()->rootEditableElement() != startContainer->rootEditableElement())
return false;
}
return true;
}