Make TypingCommand::insertText() to take SelectionInDOMTree instead of VisibleSelection

This patch makes |TypingCommand::insertText()| to take |SelectionInDOMTree|
instead of |VisibleSelection| to reduce usage of |VisibleSelection| for
improving code health.

BUG=657237
TEST=n/a

Review-Url: https://codereview.chromium.org/2733183002
Cr-Commit-Position: refs/heads/master@{#455368}
void Editor::appliedEditing(CompositeEditCommand* cmd) {
  DCHECK(!cmd->isCommandGroupWrapper());
  EventQueueScope scope;

  spellChecker().markMisspellingsAfterApplyingCommand(*cmd);

  UndoStep* undoStep = cmd->undoStep();
  DCHECK(undoStep);
  dispatchEditableContentChangedEvents(undoStep->startingRootEditableElement(),
                                       undoStep->endingRootEditableElement());
  dispatchInputEventEditableContentChanged(
      undoStep->startingRootEditableElement(),
      undoStep->endingRootEditableElement(), cmd->inputType(),
      cmd->textDataForInputEvent(), isComposingFromCommand(cmd));

  frame().document()->updateStyleAndLayoutIgnorePendingStylesheets();

  const VisibleSelection& newSelection =
      correctedVisibleSelection(cmd->endingSelection());

  changeSelectionAfterCommand(newSelection.asSelection(), 0);

  if (!cmd->preservesTypingStyle())
    clearTypingStyle();

  if (m_lastEditCommand.get() == cmd) {
    DCHECK(cmd->isTypingCommand());
  } else if (m_lastEditCommand && m_lastEditCommand->isDragAndDropCommand() &&
             (cmd->inputType() == InputEvent::InputType::DeleteByDrag ||
              cmd->inputType() == InputEvent::InputType::InsertFromDrop)) {
    if (!m_lastEditCommand->undoStep())
      m_undoStack->registerUndoStep(m_lastEditCommand->ensureUndoStep());
    m_lastEditCommand->appendCommandToUndoStep(cmd);
  } else {
    m_lastEditCommand = cmd;
    m_undoStack->registerUndoStep(m_lastEditCommand->ensureUndoStep());
  }

  respondToChangedContents(newSelection.start());
}

void Editor::appliedEditing(CompositeEditCommand* cmd) {
  DCHECK(!cmd->isCommandGroupWrapper());
  EventQueueScope scope;

  spellChecker().markMisspellingsAfterApplyingCommand(*cmd);

  UndoStep* undoStep = cmd->undoStep();
  DCHECK(undoStep);
  dispatchEditableContentChangedEvents(undoStep->startingRootEditableElement(),
                                       undoStep->endingRootEditableElement());
  dispatchInputEventEditableContentChanged(
      undoStep->startingRootEditableElement(),
      undoStep->endingRootEditableElement(), cmd->inputType(),
      cmd->textDataForInputEvent(), isComposingFromCommand(cmd));

  frame().document()->updateStyleAndLayoutIgnorePendingStylesheets();

  const VisibleSelection& newSelection =
      correctedVisibleSelection(cmd->endingSelection());

  changeSelectionAfterCommand(newSelection.asSelection(), 0);

  if (!cmd->preservesTypingStyle())
    clearTypingStyle();

  if (m_lastEditCommand.get() == cmd) {
    DCHECK(cmd->isTypingCommand());
  } else if (m_lastEditCommand && m_lastEditCommand->isDragAndDropCommand() &&
             (cmd->inputType() == InputEvent::InputType::DeleteByDrag ||
              cmd->inputType() == InputEvent::InputType::InsertFromDrop)) {
    if (!m_lastEditCommand->undoStep())
      m_undoStack->registerUndoStep(m_lastEditCommand->ensureUndoStep());
    m_lastEditCommand->appendCommandToUndoStep(cmd);
  } else {
    m_lastEditCommand = cmd;
    m_undoStack->registerUndoStep(m_lastEditCommand->ensureUndoStep());
  }

  respondToChangedContents(newSelection.start());
}
