Commit cb4583bb authored by Tessa Nijssen's avatar Tessa Nijssen Committed by Commit Bot

Fix Selection in FrameInputHandlerImpl::Replace()

According to the description for Replace() in input_handler.mojom,
Replace() will replace the current selection, and if there is none, it
will select the word around the caret and replace that word.

However, in FrameInputHandlerImpl::Replace(), the word around the caret
is only selected if there is a selection (and not just a caret). This
is not in line with the description given above.

To fix this, the check that the WebLocalFrame has a selection is
negated. If the WebLocalFrame does not have a selection, the word
around the caret should be selected. Otherwise, the selection should
be left as is.

Bug: 869512
Change-Id: I288ab40fcfa10e0c04ad442e25f2404e0c700a14
Reviewed-on: https://chromium-review.googlesource.com/1157035Reviewed-by: default avatarDave Tapuska <dtapuska@chromium.org>
Commit-Queue: Dave Tapuska <dtapuska@chromium.org>
Cr-Commit-Position: refs/heads/master@{#579546}
parent 4e0335cf
...@@ -214,7 +214,7 @@ void FrameInputHandlerImpl::Replace(const base::string16& word) { ...@@ -214,7 +214,7 @@ void FrameInputHandlerImpl::Replace(const base::string16& word) {
if (!render_frame_) if (!render_frame_)
return; return;
blink::WebLocalFrame* frame = render_frame_->GetWebFrame(); blink::WebLocalFrame* frame = render_frame_->GetWebFrame();
if (frame->HasSelection()) if (!frame->HasSelection())
frame->SelectWordAroundCaret(); frame->SelectWordAroundCaret();
frame->ReplaceSelection(blink::WebString::FromUTF16(word)); frame->ReplaceSelection(blink::WebString::FromUTF16(word));
render_frame_->SyncSelectionIfRequired(); render_frame_->SyncSelectionIfRequired();
......
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