当前位置: 首页>>代码示例>>C++>>正文


C++ endingSelection函数代码示例

本文整理汇总了C++中endingSelection函数的典型用法代码示例。如果您正苦于以下问题:C++ endingSelection函数的具体用法?C++ endingSelection怎么用?C++ endingSelection使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了endingSelection函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: endingSelection

// This avoids the expense of a full fledged delete operation, and avoids a layout that typically results
// from text removal.
bool InsertTextCommand::performTrivialReplace(const String& text, bool selectInsertedText)
{
    if (!endingSelection().isRange())
        return false;
    
    if (text.contains('\t') || text.contains(' ') || text.contains('\n'))
        return false;
    
    Position start = endingSelection().start();
    Position end = endingSelection().end();
    
    if (start.node() != end.node() || !start.node()->isTextNode() || isTabSpanTextNode(start.node()))
        return false;
        
    replaceTextInNode(static_cast<Text*>(start.node()), start.offset(), end.offset() - start.offset(), text);
    
    Position endPosition(start.node(), start.offset() + text.length());
    
    // We could have inserted a part of composed character sequence,
    // so we are basically treating ending selection as a range to avoid validation.
    // <http://bugs.webkit.org/show_bug.cgi?id=15781>
    Selection forcedEndingSelection;
    forcedEndingSelection.setWithoutValidation(start, endPosition);
    setEndingSelection(forcedEndingSelection);
    
    if (!selectInsertedText)
        setEndingSelection(Selection(endingSelection().visibleEnd()));
    
    return true;
}
开发者ID:Fale,项目名称:qtmoko,代码行数:32,代码来源:InsertTextCommand.cpp

示例2: endingSelection

// This avoids the expense of a full fledged delete operation, and avoids a layout that typically results
// from text removal.
bool InsertTextCommand::performTrivialReplace(const String& text, bool selectInsertedText)
{
    if (!endingSelection().isRange())
        return false;
    
    if (text.contains('\t') || text.contains(' ') || text.contains('\n'))
        return false;

    Position start = endingSelection().start();
    Position endPosition = replaceSelectedTextInNode(text);
    if (endPosition.isNull())
        return false;

    // We could have inserted a part of composed character sequence,
    // so we are basically treating ending selection as a range to avoid validation.
    // <http://bugs.webkit.org/show_bug.cgi?id=15781>
    VisibleSelection forcedEndingSelection;
    forcedEndingSelection.setWithoutValidation(start, endPosition);
    forcedEndingSelection.setIsDirectional(endingSelection().isDirectional());
    setEndingSelection(forcedEndingSelection);

    if (!selectInsertedText)
        setEndingSelection(VisibleSelection(endingSelection().visibleEnd(), endingSelection().isDirectional()));
    
    return true;
}
开发者ID:dog-god,项目名称:iptv,代码行数:28,代码来源:InsertTextCommand.cpp

示例3: endingSelection

void MoveSelectionCommand::doApply()
{
    Selection selection = endingSelection();
    ASSERT(selection.isRange());

    Position pos = m_position;
    if (pos.isNull())
        return;
        
    // Update the position otherwise it may become invalid after the selection is deleted.
    Node *positionNode = m_position.node();
    int positionOffset = m_position.offset();
    Position selectionEnd = selection.end();
    int selectionEndOffset = selectionEnd.offset();    
    if (selectionEnd.node() == positionNode && selectionEndOffset < positionOffset) {
        positionOffset -= selectionEndOffset;
        Position selectionStart = selection.start();
        if (selectionStart.node() == positionNode) {
            positionOffset += selectionStart.offset();
        }
        pos = Position(positionNode, positionOffset);
    }

    deleteSelection(m_smartMove);

    // If the node for the destination has been removed as a result of the deletion,
    // set the destination to the ending point after the deletion.
    // Fixes: <rdar://problem/3910425> REGRESSION (Mail): Crash in ReplaceSelectionCommand; 
    //        selection is empty, leading to null deref
    if (!pos.node()->inDocument())
        pos = endingSelection().start();

    setEndingSelection(Selection(pos, endingSelection().affinity()));
    applyCommandToComposite(ReplaceSelectionCommand::create(positionNode->document(), m_fragment, true, m_smartMove));
}
开发者ID:Czerrr,项目名称:ISeeBrowser,代码行数:35,代码来源:MoveSelectionCommand.cpp

示例4: applyStyledElement

void CreateLinkCommand::doApply(EditingState* editingState) {
  if (endingSelection().isNone())
    return;

  HTMLAnchorElement* anchorElement = HTMLAnchorElement::create(document());
  anchorElement->setHref(AtomicString(m_url));

  if (endingSelection().isRange()) {
    applyStyledElement(anchorElement, editingState);
    if (editingState->isAborted())
      return;
  } else {
    insertNodeAt(anchorElement, endingSelection().start(), editingState);
    if (editingState->isAborted())
      return;
    Text* textNode = Text::create(document(), m_url);
    appendNode(textNode, anchorElement, editingState);
    if (editingState->isAborted())
      return;
    document().updateStyleAndLayoutIgnorePendingStylesheets();
    setEndingSelection(createVisibleSelection(
        Position::inParentBeforeNode(*anchorElement),
        Position::inParentAfterNode(*anchorElement), TextAffinity::Downstream,
        endingSelection().isDirectional()));
  }
}
开发者ID:ollie314,项目名称:chromium,代码行数:26,代码来源:CreateLinkCommand.cpp

示例5: assert

void InsertTextCommand::input(const String &text, bool selectInsertedText)
{
    assert(text.find('\n') == -1);

    if (endingSelection().isNone())
        return;
    
    // Delete the current selection.
    if (endingSelection().isRange())
        deleteSelection(false, true, true);
    
    // Insert the character at the leftmost candidate.
    Position startPosition = endingSelection().start().upstream();
    deleteInsignificantText(startPosition.upstream(), startPosition.downstream());
    if (!startPosition.inRenderedContent())
        startPosition = startPosition.downstream();
        
    startPosition = positionAvoidingSpecialElementBoundary(startPosition);
    
    Position endPosition;
    
    if (text == "\t") {
        endPosition = insertTab(startPosition);
        startPosition = endPosition.previous();
        removeBlockPlaceholder(VisiblePosition(startPosition));
        m_charactersAdded += 1;
    } else {
        // Make sure the document is set up to receive text
        startPosition = prepareForTextInsertion(startPosition);
        removeBlockPlaceholder(VisiblePosition(startPosition));
        Text *textNode = static_cast<Text *>(startPosition.node());
        int offset = startPosition.offset();

        insertTextIntoNode(textNode, offset, text);
        endPosition = Position(textNode, offset + text.length());

        // The insertion may require adjusting adjacent whitespace, if it is present.
        rebalanceWhitespaceAt(endPosition);
        // Rebalancing on both sides isn't necessary if we've inserted a space.
        if (text != " ") 
            rebalanceWhitespaceAt(startPosition);
            
        m_charactersAdded += text.length();
    }

    setEndingSelection(Selection(startPosition, endPosition, DOWNSTREAM));

    // Handle the case where there is a typing style.
    // FIXME: Improve typing style.
    // See this bug: <rdar://problem/3769899> Implementation of typing style needs improvement
    CSSMutableStyleDeclaration* typingStyle = document()->frame()->typingStyle();
    RefPtr<CSSComputedStyleDeclaration> endingStyle = endPosition.computedStyle();
    endingStyle->diff(typingStyle);
    if (typingStyle && typingStyle->length() > 0)
        applyStyle(typingStyle);

    if (!selectInsertedText)
        setEndingSelection(endingSelection().end(), endingSelection().affinity());
}
开发者ID:oroisec,项目名称:ios,代码行数:59,代码来源:InsertTextCommand.cpp

示例6: insertParagraphSeparator

void DictationCommand::insertParagraphSeparator()
{
    if (!canAppendNewLineFeedToSelection(endingSelection()))
        return;

    applyCommandToComposite(InsertParagraphSeparatorCommand::create(document()));
}
开发者ID:3163504123,项目名称:phantomjs,代码行数:7,代码来源:DictationCommand.cpp

示例7: doApply

// For the moment, this is SPI and the only client (Mail.app) is satisfied.
// Here are two things to re-evaluate when making into API.
// 1. Currently, InheritedListType uses clones whereas OrderedList and
// UnorderedList create a new list node of the specified type.  That is
// inconsistent wrt style.  If that is not OK, here are some alternatives:
//  - new nodes always inherit style (probably the best choice)
//  - new nodes have always have no style
//  - new nodes of the same type inherit style
// 2. Currently, the node we return may be either a pre-existing one or
// a new one. Is it confusing to return the pre-existing one without
// somehow indicating that it is not new?  If so, here are some alternatives:
//  - only return the list node if we created it
//  - indicate whether the list node is new or pre-existing
//  - (silly) client specifies whether to return pre-existing list nodes
void IncreaseSelectionListLevelCommand::doApply()
{
    Node* startListChild;
    Node* endListChild;
    if (!canIncreaseListLevel(endingSelection(), startListChild, endListChild))
        return;

    Node* previousItem = startListChild->renderer()->previousSibling()->element();
    if (isListElement(previousItem)) {
        // move nodes up into preceding list
        appendSiblingNodeRange(startListChild, endListChild, previousItem);
        m_listElement = previousItem;
    } else {
        // create a sublist for the preceding element and move nodes there
        RefPtr<Node> newParent;
        switch (m_listType) {
            case InheritedListType:
                newParent = startListChild->parentNode()->cloneNode(false);
                break;
            case OrderedList:
                newParent = createOrderedListElement(document());
                break;
            case UnorderedList:
                newParent = createUnorderedListElement(document());
                break;
        }
        insertNodeBefore(newParent.get(), startListChild);
        appendSiblingNodeRange(startListChild, endListChild, newParent.get());
        m_listElement = newParent.get();
    }
}
开发者ID:pk-codebox-evo,项目名称:remixos-usb-tool,代码行数:45,代码来源:ModifySelectionListLevel.cpp

示例8: doApply

void DecreaseSelectionListLevelCommand::doApply()
{
    Node* startListChild;
    Node* endListChild;
    if (!canDecreaseListLevel(endingSelection(), startListChild, endListChild))
        return;

    Node* previousItem = startListChild->renderer()->previousSibling() ? startListChild->renderer()->previousSibling()->node() : 0;
    Node* nextItem = endListChild->renderer()->nextSibling() ? endListChild->renderer()->nextSibling()->node() : 0;
    Element* listNode = startListChild->parentElement();

    if (!previousItem) {
        // at start of sublist, move the child(ren) to before the sublist
        insertSiblingNodeRangeBefore(startListChild, endListChild, listNode);
        // if that was the whole sublist we moved, remove the sublist node
        if (!nextItem)
            removeNode(listNode);
    } else if (!nextItem) {
        // at end of list, move the child(ren) to after the sublist
        insertSiblingNodeRangeAfter(startListChild, endListChild, listNode);    
    } else if (listNode) {
        // in the middle of list, split the list and move the children to the divide
        splitElement(listNode, startListChild);
        insertSiblingNodeRangeBefore(startListChild, endListChild, listNode);
    }
}
开发者ID:Comcast,项目名称:WebKitForWayland,代码行数:26,代码来源:ModifySelectionListLevel.cpp

示例9: doApply

void TypingCommand::doApply()
{
    if (endingSelection().isNone())
        return;
        
    if (m_commandType == DeleteKey)
        if (m_commands.isEmpty())
            m_openedByBackwardDelete = true;

    switch (m_commandType) {
        case DeleteSelection:
            deleteSelection(m_smartDelete);
            return;
        case DeleteKey:
            deleteKeyPressed(m_granularity);
            return;
        case ForwardDeleteKey:
            forwardDeleteKeyPressed(m_granularity);
            return;
        case InsertLineBreak:
            insertLineBreak();
            return;
        case InsertParagraphSeparator:
            insertParagraphSeparator();
            return;
        case InsertParagraphSeparatorInQuotedContent:
            insertParagraphSeparatorInQuotedContent();
            return;
        case InsertText:
            insertText(m_textToInsert, m_selectInsertedText);
            return;
    }

    ASSERT_NOT_REACHED();
}
开发者ID:Chingliu,项目名称:EAWebkit,代码行数:35,代码来源:TypingCommand.cpp

示例10: collectDictationAlternativesInRange

void DictationCommand::insertTextRunWithoutNewlines(size_t lineStart, size_t lineLength)
{
    Vector<DictationAlternative> alternativesInLine;
    collectDictationAlternativesInRange(lineStart, lineLength, alternativesInLine);
    RefPtr<InsertTextCommand> command = InsertTextCommand::createWithMarkerSupplier(document(), m_textToInsert.substring(lineStart, lineLength), DictationMarkerSupplier::create(alternativesInLine));
    applyCommandToComposite(command, endingSelection());
}
开发者ID:3163504123,项目名称:phantomjs,代码行数:7,代码来源:DictationCommand.cpp

示例11: applyStyledElement

void CreateLinkCommand::doApply()
{
    if (endingSelection().isNone())
        return;

    RefPtrWillBeRawPtr<HTMLAnchorElement> anchorElement = HTMLAnchorElement::create(document());
    anchorElement->setHref(AtomicString(m_url));

    if (endingSelection().isRange()) {
        applyStyledElement(anchorElement.get());
    } else {
        insertNodeAt(anchorElement.get(), endingSelection().start());
        RefPtrWillBeRawPtr<Text> textNode = Text::create(document(), m_url);
        appendNode(textNode.get(), anchorElement.get());
        setEndingSelection(VisibleSelection(positionInParentBeforeNode(*anchorElement), positionInParentAfterNode(*anchorElement), TextAffinity::Downstream, endingSelection().isDirectional()));
    }
}
开发者ID:howardroark2018,项目名称:chromium,代码行数:17,代码来源:CreateLinkCommand.cpp

示例12: applyStyledElement

void CreateLinkCommand::doApply()
{
    if (endingSelection().isNone())
        return;
        
    RefPtr<HTMLAnchorElement> anchorElement = HTMLAnchorElement::create(document());
    anchorElement->setHref(m_url);
    
    if (endingSelection().isRange())
        applyStyledElement(anchorElement.get());
    else {
        insertNodeAt(anchorElement.get(), endingSelection().start());
        RefPtr<Text> textNode = Text::create(document(), m_url);
        appendNode(textNode.get(), anchorElement.get());
        setEndingSelection(VisibleSelection(positionInParentBeforeNode(anchorElement.get()), positionInParentAfterNode(anchorElement.get()), DOWNSTREAM));
    }
}
开发者ID:0omega,项目名称:platform_external_webkit,代码行数:17,代码来源:CreateLinkCommand.cpp

示例13: doApply

void UnlinkCommand::doApply()
{
    // FIXME: If a caret is inside a link, we should remove it, but currently we don't.
    if (!endingSelection().isNonOrphanedRange())
        return;

    removeStyledElement(HTMLAnchorElement::create(document()));
}
开发者ID:0omega,项目名称:platform_external_webkit,代码行数:8,代码来源:UnlinkCommand.cpp

示例14: start

void TypingCommand::markMisspellingsAfterTyping()
{
    if (!document()->frame()->editor()->isContinuousSpellCheckingEnabled())
        return;
    // Take a look at the selection that results after typing and determine whether we need to spellcheck. 
    // Since the word containing the current selection is never marked, this does a check to
    // see if typing made a new word that is not in the current selection. Basically, you
    // get this by being at the end of a word and typing a space.    
    VisiblePosition start(endingSelection().start(), endingSelection().affinity());
    VisiblePosition previous = start.previous();
    if (previous.isNotNull()) {
        VisiblePosition p1 = startOfWord(previous, LeftWordIfOnBoundary);
        VisiblePosition p2 = startOfWord(start, LeftWordIfOnBoundary);
        if (p1 != p2)
            document()->frame()->editor()->markMisspellingsAfterTypingToPosition(p1);
    }
}
开发者ID:Chingliu,项目名称:EAWebkit,代码行数:17,代码来源:TypingCommand.cpp

示例15: HTMLAnchorElement

void CreateLinkCommand::doApply()
{
    if (endingSelection().isNone())
        return;
        
    RefPtr<HTMLAnchorElement> anchorElement = new HTMLAnchorElement(document());
    anchorElement->setHref(m_url);
    
    if (endingSelection().isRange()) {
        pushPartiallySelectedAnchorElementsDown();
        applyStyledElement(anchorElement.get());
    } else {
        insertNodeAt(anchorElement.get(), endingSelection().start());
        RefPtr<Text> textNode = new Text(document(), m_url);
        appendNode(textNode.get(), anchorElement.get());
        setEndingSelection(Selection(positionBeforeNode(anchorElement.get()), positionAfterNode(anchorElement.get()), DOWNSTREAM));
    }
}
开发者ID:Gin-Rye,项目名称:duibrowser,代码行数:18,代码来源:CreateLinkCommand.cpp


注:本文中的endingSelection函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。