本文整理汇总了C++中VisiblePosition::deepEquivalent方法的典型用法代码示例。如果您正苦于以下问题:C++ VisiblePosition::deepEquivalent方法的具体用法?C++ VisiblePosition::deepEquivalent怎么用?C++ VisiblePosition::deepEquivalent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VisiblePosition
的用法示例。
在下文中一共展示了VisiblePosition::deepEquivalent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: tryIndentingAsListItem
bool IndentOutdentCommand::tryIndentingAsListItem(const VisiblePosition& endOfCurrentParagraph)
{
// If our selection is not inside a list, bail out.
Node* lastNodeInSelectedParagraph = endOfCurrentParagraph.deepEquivalent().node();
RefPtr<Element> listNode = enclosingList(lastNodeInSelectedParagraph);
if (!listNode)
return false;
// Find the list item enclosing the current paragraph
Element* selectedListItem = static_cast<Element*>(enclosingBlock(lastNodeInSelectedParagraph));
// FIXME: enclosingBlock shouldn't return the passed in element. See the
// comment on the function about how to fix rather than having to adjust here.
if (selectedListItem == lastNodeInSelectedParagraph)
selectedListItem = static_cast<Element*>(enclosingBlock(lastNodeInSelectedParagraph->parentNode()));
// FIXME: we need to deal with the case where there is no li (malformed HTML)
if (!selectedListItem->hasTagName(liTag))
return false;
// FIXME: previousElementSibling does not ignore non-rendered content like <span></span>. Should we?
Element* previousList = selectedListItem->previousElementSibling();
Element* nextList = selectedListItem->nextElementSibling();
RefPtr<Element> newList = document()->createElement(listNode->tagQName(), false);
insertNodeBefore(newList, selectedListItem);
moveParagraphWithClones(startOfParagraph(endOfCurrentParagraph), endOfCurrentParagraph, newList.get(), selectedListItem);
if (canMergeLists(previousList, newList.get()))
mergeIdenticalElements(previousList, newList);
if (canMergeLists(newList.get(), nextList))
mergeIdenticalElements(newList, nextList);
return true;
}
示例2: indexForVisiblePosition
int HTMLTextFormControlElement::indexForVisiblePosition(const VisiblePosition& pos) const
{
if (enclosingTextFormControl(pos.deepEquivalent()) != this)
return 0;
bool forSelectionPreservation = false;
return WebCore::indexForVisiblePosition(innerTextElement(), pos, forSelectionPreservation);
}
示例3: textMarkerDataForVisiblePosition
void AXObjectCache::textMarkerDataForVisiblePosition(TextMarkerData& textMarkerData, const VisiblePosition& visiblePos)
{
// This memory must be bzero'd so instances of TextMarkerData can be tested for byte-equivalence.
// This also allows callers to check for failure by looking at textMarkerData upon return.
memset(&textMarkerData, 0, sizeof(TextMarkerData));
if (visiblePos.isNull())
return;
Position deepPos = visiblePos.deepEquivalent();
Node* domNode = deepPos.node();
ASSERT(domNode);
if (!domNode)
return;
if (domNode->isHTMLElement()) {
InputElement* inputElement = toInputElement(static_cast<Element*>(domNode));
if (inputElement && inputElement->isPasswordField())
return;
}
// locate the renderer, which must exist for a visible dom node
RenderObject* renderer = domNode->renderer();
ASSERT(renderer);
// find or create an accessibility object for this renderer
AXObjectCache* cache = renderer->document()->axObjectCache();
RefPtr<AccessibilityObject> obj = cache->getOrCreate(renderer);
textMarkerData.axID = obj.get()->axObjectID();
textMarkerData.node = domNode;
textMarkerData.offset = deepPos.deprecatedEditingOffset();
textMarkerData.affinity = visiblePos.affinity();
}
示例4: indentIntoBlockquote
void IndentOutdentCommand::indentIntoBlockquote(const VisiblePosition& endOfCurrentParagraph, const VisiblePosition& endOfNextParagraph, RefPtr<Element>& targetBlockquote)
{
Node* enclosingCell = 0;
Position start = startOfParagraph(endOfCurrentParagraph).deepEquivalent();
enclosingCell = enclosingNodeOfType(start, &isTableCell);
Node* nodeToSplitTo;
if (enclosingCell)
nodeToSplitTo = enclosingCell;
else if (enclosingList(start.node()))
nodeToSplitTo = enclosingBlock(start.node());
else
nodeToSplitTo = editableRootForPosition(start);
RefPtr<Node> outerBlock = splitTreeToNode(start.node(), nodeToSplitTo);
if (!targetBlockquote) {
// Create a new blockquote and insert it as a child of the root editable element. We accomplish
// this by splitting all parents of the current paragraph up to that point.
targetBlockquote = createIndentBlockquoteElement(document());
insertNodeBefore(targetBlockquote, outerBlock);
}
moveParagraphWithClones(startOfParagraph(endOfCurrentParagraph), endOfCurrentParagraph, targetBlockquote.get(), outerBlock.get());
// Don't put the next paragraph in the blockquote we just created for this paragraph unless
// the next paragraph is in the same cell.
if (enclosingCell && enclosingCell != enclosingNodeOfType(endOfNextParagraph.deepEquivalent(), &isTableCell))
targetBlockquote = 0;
}
示例5: endOfParagraph
VisiblePosition endOfParagraph(const VisiblePosition &c)
{
if (c.isNull())
return VisiblePosition();
Position p = c.deepEquivalent();
Node* startNode = p.node();
if (isRenderedAsNonInlineTableImageOrHR(startNode))
return lastDeepEditingPositionForNode(startNode);
Node* startBlock = enclosingBlock(startNode);
Node *stayInsideBlock = startBlock;
Node *node = startNode;
int offset = p.deprecatedEditingOffset();
Node *n = startNode;
while (n) {
if (n->isContentEditable() != startNode->isContentEditable())
break;
RenderObject *r = n->renderer();
if (!r) {
n = n->traverseNextNode(stayInsideBlock);
continue;
}
RenderStyle *style = r->style();
if (style->visibility() != VISIBLE) {
n = n->traverseNextNode(stayInsideBlock);
continue;
}
if (r->isBR() || isBlock(n))
break;
// FIXME: We avoid returning a position where the renderer can't accept the caret.
// We should probably do this in other cases such as startOfParagraph.
if (r->isText() && r->caretMaxRenderedOffset() > 0) {
int length = toRenderText(r)->textLength();
if (style->preserveNewline()) {
const UChar* chars = toRenderText(r)->characters();
int o = n == startNode ? offset : 0;
for (int i = o; i < length; ++i)
if (chars[i] == '\n')
return VisiblePosition(n, i, DOWNSTREAM);
}
node = n;
offset = r->caretMaxOffset();
n = n->traverseNextNode(stayInsideBlock);
} else if (editingIgnoresContent(n) || isTableElement(n)) {
node = n;
offset = lastOffsetForEditing(n);
n = n->traverseNextSibling(stayInsideBlock);
} else
n = n->traverseNextNode(stayInsideBlock);
}
return VisiblePosition(node, offset, DOWNSTREAM);
}
示例6: endOfEditableContent
VisiblePosition endOfEditableContent(const VisiblePosition& visiblePosition)
{
Node* highestRoot = highestEditableRoot(visiblePosition.deepEquivalent());
if (!highestRoot)
return VisiblePosition();
return VisiblePosition(highestRoot, maxDeepOffset(highestRoot), DOWNSTREAM);
}
示例7: isLastVisiblePositionInNode
bool isLastVisiblePositionInNode(const VisiblePosition &pos, const NodeImpl *node)
{
if (pos.isNull())
return false;
VisiblePosition next = pos.next();
return next.isNull() || !next.deepEquivalent().node()->isAncestor(node);
}
示例8: endOfEditableContent
VisiblePosition endOfEditableContent(const VisiblePosition& visiblePosition)
{
Node* highestRoot = highestEditableRoot(visiblePosition.deepEquivalent());
if (!highestRoot)
return VisiblePosition();
return lastDeepEditingPositionForNode(highestRoot);
}
示例9: startOfBlock
VisiblePosition startOfBlock(const VisiblePosition &c)
{
Position p = c.deepEquivalent();
Node *startNode = p.node();
if (!startNode)
return VisiblePosition();
return VisiblePosition(Position(startNode->enclosingBlockFlowElement(), 0), DOWNSTREAM);
}
示例10: indexForVisiblePosition
int indexForVisiblePosition(const VisiblePosition& visiblePosition)
{
if (visiblePosition.isNull())
return 0;
Position p(visiblePosition.deepEquivalent());
RefPtr<Range> range = Range::create(p.node()->document(), Position(p.node()->document(), 0), rangeCompliantEquivalent(p));
return TextIterator::rangeLength(range.get(), true);
}
示例11: setBase
void VisibleSelection::setBase(const VisiblePosition& visiblePosition)
{
Position oldBase = m_base;
m_base = visiblePosition.deepEquivalent();
validate();
if (m_base != oldBase)
didChange();
}
示例12: selectionHasListOfType
bool InsertListCommand::selectionHasListOfType(const VisibleSelection& selection, const HTMLQualifiedName& listTag)
{
VisiblePosition start = selection.visibleStart();
if (!enclosingList(start.deepEquivalent().deprecatedNode()))
return false;
VisiblePosition end = startOfParagraph(selection.visibleEnd());
while (start.isNotNull() && start != end) {
HTMLElement* listElement = enclosingList(start.deepEquivalent().deprecatedNode());
if (!listElement || !listElement->hasTagName(listTag))
return false;
start = startOfNextParagraph(start);
}
return true;
}
示例13: visiblePositionsOnDifferentLines
bool visiblePositionsOnDifferentLines(const VisiblePosition &pos1, const VisiblePosition &pos2)
{
if (pos1.isNull() || pos2.isNull())
return false;
if (pos1 == pos2)
return false;
Position p1 = pos1.deepEquivalent();
Position p2 = pos2.deepEquivalent();
RenderObject *r1 = p1.node()->renderer();
RenderObject *r2 = p2.node()->renderer();
if (r1->isBlockFlow() || r2->isBlockFlow())
return r1 == r2 ? false : true;
InlineBox *b1 = r1 ? r1->inlineBox(p1.offset(), pos1.affinity()) : 0;
InlineBox *b2 = r2 ? r2->inlineBox(p2.offset(), pos2.affinity()) : 0;
return (b1 && b2 && b1->root() != b2->root());
}
示例14: isFirstVisiblePositionInBlock
bool isFirstVisiblePositionInBlock(const VisiblePosition &pos)
{
if (pos.isNull())
return false;
Position upstream = pos.deepEquivalent().upstream(StayInBlock);
return upstream.node()->isBlockFlow() && upstream.offset() == 0;
}
示例15: isFirstVisiblePositionInNode
bool isFirstVisiblePositionInNode(const VisiblePosition &pos, const NodeImpl *node)
{
if (pos.isNull())
return false;
VisiblePosition previous = pos.previous();
return previous.isNull() || !previous.deepEquivalent().node()->isAncestor(node);
}