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}
static PassRefPtr<Image> imageFromNode(const Node& node) {
  DCHECK(!node.document().needsLayoutTreeUpdate());
  DocumentLifecycle::DisallowTransitionScope disallowTransition(
      node.document().lifecycle());

  LayoutObject* layoutObject = node.layoutObject();
  if (!layoutObject)
    return nullptr;

  if (layoutObject->isCanvas()) {
    return toHTMLCanvasElement(node).copiedImage(
        FrontBuffer, PreferNoAcceleration, SnapshotReasonCopyToClipboard);
  }

  if (layoutObject->isImage()) {
    LayoutImage* layoutImage = toLayoutImage(layoutObject);
    if (!layoutImage)
      return nullptr;

    ImageResourceContent* cachedImage = layoutImage->cachedImage();
    if (!cachedImage || cachedImage->errorOccurred())
      return nullptr;
    return cachedImage->getImage();
  }

  return nullptr;
}

static PassRefPtr<Image> imageFromNode(const Node& node) {
  DCHECK(!node.document().needsLayoutTreeUpdate());
  DocumentLifecycle::DisallowTransitionScope disallowTransition(
      node.document().lifecycle());

  LayoutObject* layoutObject = node.layoutObject();
  if (!layoutObject)
    return nullptr;

  if (layoutObject->isCanvas()) {
    return toHTMLCanvasElement(node).copiedImage(
        FrontBuffer, PreferNoAcceleration, SnapshotReasonCopyToClipboard);
  }

  if (layoutObject->isImage()) {
    LayoutImage* layoutImage = toLayoutImage(layoutObject);
    if (!layoutImage)
      return nullptr;

    ImageResourceContent* cachedImage = layoutImage->cachedImage();
    if (!cachedImage || cachedImage->errorOccurred())
      return nullptr;
    return cachedImage->getImage();
  }

  return nullptr;
}
