| Index: third_party/WebKit/Source/core/input/EventHandler.cpp
|
| diff --git a/third_party/WebKit/Source/core/input/EventHandler.cpp b/third_party/WebKit/Source/core/input/EventHandler.cpp
|
| index dc72afdad9c6949bd47ce1ce91fbc5316c683ffc..502b435461eb0f3cec894715916cc420310d9bd4 100644
|
| --- a/third_party/WebKit/Source/core/input/EventHandler.cpp
|
| +++ b/third_party/WebKit/Source/core/input/EventHandler.cpp
|
| @@ -1802,6 +1802,14 @@ WebInputEventResult EventHandler::SendContextMenuEvent(
|
| event, mev.GetHitTestResult().CanvasRegionId(), 0);
|
| }
|
|
|
| +static bool ShouldShowContextMenuAtSelection(const FrameSelection& selection) {
|
| + const VisibleSelection& visible_selection =
|
| + selection.ComputeVisibleSelectionInDOMTreeDeprecated();
|
| + if (!visible_selection.IsRange() && !visible_selection.RootEditableElement())
|
| + return false;
|
| + return selection.SelectionHasFocus();
|
| +}
|
| +
|
| WebInputEventResult EventHandler::SendContextMenuEventForKey(
|
| Element* override_target_element) {
|
| FrameView* view = frame_->View();
|
| @@ -1824,14 +1832,9 @@ WebInputEventResult EventHandler::SendContextMenuEventForKey(
|
| Element* focused_element =
|
| override_target_element ? override_target_element : doc->FocusedElement();
|
| FrameSelection& selection = frame_->Selection();
|
| - Position start =
|
| - selection.ComputeVisibleSelectionInDOMTreeDeprecated().Start();
|
| VisualViewport& visual_viewport = frame_->GetPage()->GetVisualViewport();
|
|
|
| - if (!override_target_element && start.AnchorNode() && !selection.IsHidden() &&
|
| - (selection.ComputeVisibleSelectionInDOMTreeDeprecated()
|
| - .RootEditableElement() ||
|
| - selection.ComputeVisibleSelectionInDOMTreeDeprecated().IsRange())) {
|
| + if (!override_target_element && ShouldShowContextMenuAtSelection(selection)) {
|
| // TODO(editing-dev): Use of updateStyleAndLayoutIgnorePendingStylesheets
|
| // needs to be audited. See http://crbug.com/590369 for more details.
|
| doc->UpdateStyleAndLayoutIgnorePendingStylesheets();
|
|
|