Chromium Code Reviews| 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..22fa96433581cc0b1b13b842f0f48f3167123926 100644 |
| --- a/third_party/WebKit/Source/core/input/EventHandler.cpp |
| +++ b/third_party/WebKit/Source/core/input/EventHandler.cpp |
| @@ -1802,6 +1802,16 @@ WebInputEventResult EventHandler::SendContextMenuEvent( |
| event, mev.GetHitTestResult().CanvasRegionId(), 0); |
| } |
| +static bool ShouldShowContextMenuAtSelection(const LocalFrame& frame) { |
|
Xiaocheng
2017/05/17 19:20:26
nit: I prefer passing FrameSelection to reduce a c
yosin_UTC9
2017/05/18 01:17:15
me too.
hugoh_UTC2
2017/05/22 12:26:12
Done.
|
| + FrameSelection& selection = frame.Selection(); |
| + VisibleSelection visible_selection = |
| + selection.ComputeVisibleSelectionInDOMTreeDeprecated(); |
| + if (!visible_selection.IsRange() && !visible_selection.RootEditableElement()) |
| + return false; |
| + |
|
yosin_UTC9
2017/05/18 01:17:15
nit: Please remove an extra blank line.
hugoh_UTC2
2017/05/22 12:26:12
Done.
|
| + return selection.SelectionHasFocus(); |
| +} |
| + |
| WebInputEventResult EventHandler::SendContextMenuEventForKey( |
| Element* override_target_element) { |
| FrameView* view = frame_->View(); |
| @@ -1824,14 +1834,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(*frame_)) { |
| // TODO(editing-dev): Use of updateStyleAndLayoutIgnorePendingStylesheets |
| // needs to be audited. See http://crbug.com/590369 for more details. |
| doc->UpdateStyleAndLayoutIgnorePendingStylesheets(); |