Commit b6fb8ae4 authored by Shimi Zhang's avatar Shimi Zhang Committed by Commit Bot

[Smart Selection] Set |selected_text| when |kMenuSourceAdjustSelection|

Java adjustSelectionByCharacterOffset() will be triggered if
|TextClassifier| API thinks we should adjust previous selection, the
renderer FrameInputHandlerImpl::AdjustSelectionByCharacterOffset() is
called with the need to show context menu later.

Eventually it will call EventHanlder::ShowNonLocatedContextMenu(),
which will give us the left selection bound's middle point as the new
point for MouseEvent.

In ContextMenuController#ShowContextMenu() there is another hit test
based on this point. In some cases, this point is under other HTML
element, so we won't get current selection text based on the hit test
result.

Later in SelectionPopupController::ShowSelectionMenu() we checked that
if the selection text is empty and this is non-editable element, we
won't call Java side SelectionPopupControllerImpl#showSelectionMenu().

Users are expecting context menu, but there won't be one.

In this CL, we set |data.selected_text| when |source_type| is
|kMenuSourceAdjustSelection|. Hit test isn't needed in this case.

Bug: 840007, b/78631924
Change-Id: I9631773655300b2fc1dc5f84faa161093fae900f
Reviewed-on: https://chromium-review.googlesource.com/1045510Reviewed-by: default avatarDave Tapuska <dtapuska@chromium.org>
Commit-Queue: Shimi Zhang <ctzsm@chromium.org>
Cr-Commit-Position: refs/heads/master@{#556856}
parent 8777aaa6
......@@ -445,10 +445,11 @@ bool ContextMenuController::ShowContextMenu(const ContextMenu* default_menu,
data.selection_start_offset = 0;
// HitTestResult::isSelected() ensures clean layout by performing a hit test.
// If source_type is |kMenuSourceAdjustSelectionReset| we know the original
// HitTestResult in SelectionController passed the inside check already, so
// let it pass.
if (r.IsSelected() || source_type == kMenuSourceAdjustSelectionReset) {
// If source_type is |kMenuSourceAdjustSelection| or
// |kMenuSourceAdjustSelectionReset| we know the original HitTestResult in
// SelectionController passed the inside check already, so let it pass.
if (r.IsSelected() || source_type == kMenuSourceAdjustSelection ||
source_type == kMenuSourceAdjustSelectionReset) {
data.selected_text = selected_frame->SelectedText();
WebRange range =
selected_frame->GetInputMethodController().GetSelectionOffsets();
......
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