using namespace HTMLNames;
-TypingCommand::TypingCommand(Document *document, ETypingCommand commandType, const String &textToInsert, bool selectInsertedText, TextGranularity granularity, bool killRing)
+TypingCommand::TypingCommand(Document *document, ETypingCommand commandType, const String &textToInsert, bool selectInsertedText, TextGranularity granularity, TextCompositionType compositionType,
+ bool killRing)
: CompositeEditCommand(document),
m_commandType(commandType),
m_textToInsert(textToInsert),
m_selectInsertedText(selectInsertedText),
m_smartDelete(false),
m_granularity(granularity),
+ m_compositionType(compositionType),
m_killRing(killRing),
m_openedByBackwardDelete(false)
{
}
-void TypingCommand::insertText(Document* document, const String& text, bool selectInsertedText, bool insertedTextIsComposition)
+void TypingCommand::insertText(Document* document, const String& text, bool selectInsertedText, TextCompositionType composition)
{
ASSERT(document);
Frame* frame = document->frame();
ASSERT(frame);
- insertText(document, text, frame->selection()->selection(), selectInsertedText, insertedTextIsComposition);
+ insertText(document, text, frame->selection()->selection(), selectInsertedText, composition);
}
// FIXME: We shouldn't need to take selectionForInsertion. It should be identical to SelectionController's current selection.
-void TypingCommand::insertText(Document* document, const String& text, const VisibleSelection& selectionForInsertion, bool selectInsertedText, bool insertedTextIsComposition)
+void TypingCommand::insertText(Document* document, const String& text, const VisibleSelection& selectionForInsertion, bool selectInsertedText, TextCompositionType compositionType)
{
#if REMOVE_MARKERS_UPON_EDITING
if (!text.isEmpty())
String newText = text;
Node* startNode = selectionForInsertion.start().node();
- if (startNode && startNode->rootEditableElement() && !insertedTextIsComposition) {
+ if (startNode && startNode->rootEditableElement() && compositionType != TextCompositionUpdate) {
// Send BeforeTextInsertedEvent. The event handler will update text if necessary.
ExceptionCode ec = 0;
RefPtr<BeforeTextInsertedEvent> evt = BeforeTextInsertedEvent::create(text);
lastTypingCommand->setStartingSelection(selectionForInsertion);
lastTypingCommand->setEndingSelection(selectionForInsertion);
}
+
+ lastTypingCommand->setCompositionType(compositionType);
lastTypingCommand->insertText(newText, selectInsertedText);
return;
}
- RefPtr<TypingCommand> cmd = TypingCommand::create(document, InsertText, newText, selectInsertedText);
+ RefPtr<TypingCommand> cmd = TypingCommand::create(document, InsertText, newText, selectInsertedText, compositionType);
if (changeSelection) {
cmd->setStartingSelection(selectionForInsertion);
cmd->setEndingSelection(selectionForInsertion);
command->setStartingSelection(endingSelection());
command->setEndingSelection(endingSelection());
}
- command->input(text, selectInsertedText);
+ command->input(text, selectInsertedText,
+ m_compositionType == TextCompositionNone ? InsertTextCommand::RebalanceLeadingAndTrailingWhitespaces : InsertTextCommand::RebalanceAllWhitespaces);
typingAddedToOpenCommand(InsertText);
}
removeNode(child);
addBlockPlaceholderIfNeeded(root);
- setEndingSelection(VisibleSelection(Position(root, 0), DOWNSTREAM));
+ setEndingSelection(VisibleSelection(firstPositionInNode(root), DOWNSTREAM));
return true;
}
selection.modify(SelectionController::AlterationExtend, DirectionBackward, granularity);
// If the caret is just after a table, select the table and don't delete anything.
} else if (Node* table = isFirstPositionAfterTable(visibleStart)) {
- setEndingSelection(VisibleSelection(Position(table, 0), endingSelection().start(), DOWNSTREAM));
+ setEndingSelection(VisibleSelection(positionAfterNode(table), endingSelection().start(), DOWNSTREAM));
typingAddedToOpenCommand(DeleteKey);
return;
}
extraCharacters = selectionToDelete.end().deprecatedEditingOffset() - selectionToDelete.start().deprecatedEditingOffset();
else
extraCharacters = selectionToDelete.end().deprecatedEditingOffset();
- extent = Position(extent.node(), extent.deprecatedEditingOffset() + extraCharacters);
+ extent = Position(extent.node(), extent.deprecatedEditingOffset() + extraCharacters, Position::PositionIsOffsetInAnchor);
}
selectionAfterUndo.setWithoutValidation(startingSelection().start(), extent);
}