コード例 #1
0
ファイル: InsertTextCommand.cpp プロジェクト: oroisec/ios
Position InsertTextCommand::prepareForTextInsertion(const Position& pos)
{
    // Prepare for text input by looking at the specified position.
    // It may be necessary to insert a text node to receive characters.
    // FIXME: What is the rootEditable() check about?  Seems like it
    // assumes that the content before (or after) pos.node() is editable
    // (i.e. pos is at an editable/non-editable boundary).  That seems
    // like a bad assumption.
    if (!pos.node()->isTextNode()) {
        RefPtr<Node> textNode = document()->createEditingTextNode("");

        // Now insert the node in the right place
        if (pos.node()->rootEditableElement() != NULL) {
            insertNodeAt(textNode.get(), pos.node(), pos.offset());
        } else if (pos.node()->caretMinOffset() == pos.offset()) {
            insertNodeBefore(textNode.get(), pos.node());
        } else if (pos.node()->caretMaxOffset() == pos.offset()) {
            insertNodeAfter(textNode.get(), pos.node());
        } else
            ASSERT_NOT_REACHED();
        
        return Position(textNode.get(), 0);
    }

    if (isTabSpanTextNode(pos.node())) {
        RefPtr<Node> textNode = document()->createEditingTextNode("");
        insertNodeAtTabSpanPosition(textNode.get(), pos);
        return Position(textNode.get(), 0);
    }

    return pos;
}
コード例 #2
0
Position InsertTextCommand::positionInsideTextNode(const Position& p)
{
    Position pos = p;
    if (isTabSpanTextNode(pos.anchorNode())) {
        RefPtrWillBeRawPtr<Node> textNode = document().createEditingTextNode("");
        insertNodeAtTabSpanPosition(textNode.get(), pos);
        return firstPositionInNode(textNode.get());
    }

    // Prepare for text input by looking at the specified position.
    // It may be necessary to insert a text node to receive characters.
    if (!pos.containerNode()->isTextNode()) {
        RefPtrWillBeRawPtr<Node> textNode = document().createEditingTextNode("");
        insertNodeAt(textNode.get(), pos);
        return firstPositionInNode(textNode.get());
    }

    return pos;
}
コード例 #3
0
ファイル: InsertTextCommand.cpp プロジェクト: Fale/qtmoko
Position InsertTextCommand::prepareForTextInsertion(const Position& p)
{
    Position pos = p;
    // Prepare for text input by looking at the specified position.
    // It may be necessary to insert a text node to receive characters.
    if (!pos.node()->isTextNode()) {
        RefPtr<Node> textNode = document()->createEditingTextNode("");
        insertNodeAt(textNode.get(), pos);
        return Position(textNode.get(), 0);
    }

    if (isTabSpanTextNode(pos.node())) {
        RefPtr<Node> textNode = document()->createEditingTextNode("");
        insertNodeAtTabSpanPosition(textNode.get(), pos);
        return Position(textNode.get(), 0);
    }

    return pos;
}