Commit 174f0b5e authored by Ryan Landay's avatar Ryan Landay Committed by Commit Bot

Refactor TypingCommand.cpp's GetSelectionOffsets() to take SelectionInDOMTree

It came up in review of
be able to call TypingCommand.cpp's GetSelectionOffsets() method on an arbitrary
SelectionInDOMTree (currently the method takes a LocalFrame and returns the
offsets for the frame's current selection), so I am making that change in this
CL.

https: //chromium-review.googlesource.com/c/chromium/src/+/801979 that we want to
Change-Id: I2e0d580a17819ea7136cd973de6a3aa4685dae9c
Reviewed-on: https://chromium-review.googlesource.com/804416Reviewed-by: default avatarYoichi Osato <yoichio@chromium.org>
Reviewed-by: default avataryosin (OOO Dec 11 to Jan 8) <yosin@chromium.org>
Reviewed-by: default avatarXiaocheng Hu <xiaochengh@chromium.org>
Commit-Queue: Ryan Landay <rlanday@chromium.org>
Cr-Commit-Position: refs/heads/master@{#521908}
parent a2e1ab5c
......@@ -104,13 +104,13 @@ DispatchEventResult DispatchTextInputEvent(LocalFrame* frame,
return result;
}
PlainTextRange GetSelectionOffsets(LocalFrame* frame) {
EphemeralRange range = FirstEphemeralRangeOf(
frame->Selection().ComputeVisibleSelectionInDOMTreeDeprecated());
PlainTextRange GetSelectionOffsets(const SelectionInDOMTree& selection) {
const VisibleSelection visible_selection = CreateVisibleSelection(selection);
const EphemeralRange range = FirstEphemeralRangeOf(visible_selection);
if (range.IsNull())
return PlainTextRange();
ContainerNode* const editable = RootEditableElementOrTreeScopeRootNodeOf(
frame->Selection().ComputeVisibleSelectionInDOMTree().Base());
ContainerNode* const editable =
RootEditableElementOrTreeScopeRootNodeOf(selection.Base());
DCHECK(editable);
return PlainTextRange::Create(*editable, range);
}
......@@ -395,7 +395,8 @@ void TypingCommand::InsertText(
// needs to be audited. see http://crbug.com/590369 for more details.
document.UpdateStyleAndLayoutIgnorePendingStylesheets();
const PlainTextRange selection_offsets = GetSelectionOffsets(frame);
const PlainTextRange selection_offsets =
GetSelectionOffsets(frame->Selection().GetSelectionInDOMTree());
if (selection_offsets.IsNull())
return;
const size_t selection_start = selection_offsets.Start();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment