void TypingCommand::setEndingSelectionOnLastInsertCommand(const VisibleSelection& selection) { if (!m_commands.isEmpty()) { EditCommand* lastCommand = m_commands.last().get(); if (lastCommand->isInsertTextCommand()) static_cast<FriendlyEditCommand*>(lastCommand)->setEndingSelection(selection); } }
// TODO(yosin): We will make |SelectionInDOMTree| version of // |setEndingSelection()| as primary function instead of wrapper. void EditCommand::setEndingVisibleSelection(const VisibleSelection& selection) { for (EditCommand* command = this; command; command = command->m_parent) { if (EditCommandComposition* composition = compositionIfPossible(command)) { DCHECK(command->isTopLevelCommand()); composition->setEndingSelection(selection); } command->m_endingSelection = selection; } }
void EditCommand::setEndingSelection(const VisibleSelection &s) { for (EditCommand* cmd = this; cmd; cmd = cmd->m_parent) { if (EditCommandComposition* composition = compositionIfPossible(cmd)) { ASSERT(cmd->isTopLevelCommand()); composition->setEndingSelection(s); } cmd->m_endingSelection = s; } }
void EditCommand::setStartingSelection(const VisibleSelection& selection) { for (EditCommand* command = this;; command = command->m_parent) { if (EditCommandComposition* composition = compositionIfPossible(command)) { DCHECK(command->isTopLevelCommand()); composition->setStartingSelection(selection); } command->m_startingSelection = selection; if (!command->m_parent || command->m_parent->isFirstCommand(command)) break; } }
void EditCommand::setStartingSelection(const VisibleSelection& s) { for (EditCommand* cmd = this; ; cmd = cmd->m_parent) { if (EditCommandComposition* composition = compositionIfPossible(cmd)) { ASSERT(cmd->isTopLevelCommand()); composition->setStartingSelection(s); } cmd->m_startingSelection = s; if (!cmd->m_parent || cmd->m_parent->isFirstCommand(cmd)) break; } }
void TypingCommand::insertTextRunWithoutNewlines(const String &text, bool selectInsertedText) { RefPtr<InsertTextCommand> command; if (!document()->frame()->typingStyle() && !m_commands.isEmpty()) { EditCommand* lastCommand = m_commands.last().get(); if (lastCommand->isInsertTextCommand()) command = static_cast<InsertTextCommand*>(lastCommand); } if (!command) { command = InsertTextCommand::create(document()); applyCommandToComposite(command); } command->input(text, selectInsertedText); typingAddedToOpenCommand(InsertText); }
void TypingCommand::insertTextRunWithoutNewlines(const String &text, bool selectInsertedText) { RefPtr<InsertTextCommand> command; if (!document()->frame()->selection()->typingStyle() && !m_commands.isEmpty()) { EditCommand* lastCommand = m_commands.last().get(); if (lastCommand->isInsertTextCommand()) command = static_cast<InsertTextCommand*>(lastCommand); } if (!command) { command = InsertTextCommand::create(document()); applyCommandToComposite(command); } if (endingSelection() != command->endingSelection()) { command->setStartingSelection(endingSelection()); command->setEndingSelection(endingSelection()); } command->input(text, selectInsertedText, m_compositionType == TextCompositionNone ? InsertTextCommand::RebalanceLeadingAndTrailingWhitespaces : InsertTextCommand::RebalanceAllWhitespaces); typingAddedToOpenCommand(InsertText); }