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::cut(EditorCommandSource source) {
  if (tryDHTMLCut())
    return;  // DHTML did the whole operation
  if (!canCut())
    return;

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

  if (canDeleteRange(selectedRange())) {
    spellChecker().updateMarkersForWordsAffectedByEditing(true);
    if (enclosingTextControl(frame()
                                 .selection()
                                 .computeVisibleSelectionInDOMTreeDeprecated()
                                 .start())) {
      String plainText = frame().selectedTextForClipboard();
      Pasteboard::generalPasteboard()->writePlainText(
          plainText, canSmartCopyOrDelete() ? Pasteboard::CanSmartReplace
                                            : Pasteboard::CannotSmartReplace);
    } else {
      writeSelectionToPasteboard();
    }

    if (source == CommandFromMenuOrKeyBinding) {
      if (dispatchBeforeInputDataTransfer(findEventTargetFromSelection(),
                                          InputEvent::InputType::DeleteByCut,
                                          nullptr) !=
          DispatchEventResult::NotCanceled)
        return;
      if (m_frame->document()->frame() != m_frame)
        return;
    }
    deleteSelectionWithSmartDelete(
        canSmartCopyOrDelete() ? DeleteMode::Smart : DeleteMode::Simple,
        InputEvent::InputType::DeleteByCut);
  }
}

void Editor::cut(EditorCommandSource source) {
  if (tryDHTMLCut())
    return;  // DHTML did the whole operation
  if (!canCut())
    return;

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

  if (canDeleteRange(selectedRange())) {
    spellChecker().updateMarkersForWordsAffectedByEditing(true);
    if (enclosingTextControl(frame()
                                 .selection()
                                 .computeVisibleSelectionInDOMTreeDeprecated()
                                 .start())) {
      String plainText = frame().selectedTextForClipboard();
      Pasteboard::generalPasteboard()->writePlainText(
          plainText, canSmartCopyOrDelete() ? Pasteboard::CanSmartReplace
                                            : Pasteboard::CannotSmartReplace);
    } else {
      writeSelectionToPasteboard();
    }

    if (source == CommandFromMenuOrKeyBinding) {
      if (dispatchBeforeInputDataTransfer(findEventTargetFromSelection(),
                                          InputEvent::InputType::DeleteByCut,
                                          nullptr) !=
          DispatchEventResult::NotCanceled)
        return;
      if (m_frame->document()->frame() != m_frame)
        return;
    }
    deleteSelectionWithSmartDelete(
        canSmartCopyOrDelete() ? DeleteMode::Smart : DeleteMode::Simple,
        InputEvent::InputType::DeleteByCut);
  }
}
