Chromium Code Reviews| Index: third_party/WebKit/Source/web/ContextMenuClientImpl.cpp |
| diff --git a/third_party/WebKit/Source/web/ContextMenuClientImpl.cpp b/third_party/WebKit/Source/web/ContextMenuClientImpl.cpp |
| index ccdf9a29b18e06de6d153f65ae55c93abeedda75..404a820c70624247c5c7898137fe0df7b861c8ae 100644 |
| --- a/third_party/WebKit/Source/web/ContextMenuClientImpl.cpp |
| +++ b/third_party/WebKit/Source/web/ContextMenuClientImpl.cpp |
| @@ -131,7 +131,14 @@ static String selectMisspellingAsync(LocalFrame* selectedFrame, String& descript |
| return markerRange->text(); |
| } |
| -void ContextMenuClientImpl::showContextMenu(const ContextMenu* defaultMenu) |
| +static bool shouldShowContextMenuFromTouch(const WebContextMenuData& data) |
| +{ |
| + return !data.linkURL.isEmpty() |
| + || data.mediaType == WebContextMenuData::MediaTypeImage |
| + || data.mediaType == WebContextMenuData::MediaTypeVideo; |
| +} |
| + |
| +bool ContextMenuClientImpl::showContextMenu(const ContextMenu* defaultMenu, bool fromTouch) |
| { |
| // Displaying the context menu in this function is a big hack as we don't |
| // have context, i.e. whether this is being invoked via a script or in |
| @@ -139,7 +146,7 @@ void ContextMenuClientImpl::showContextMenu(const ContextMenu* defaultMenu) |
| // Keyboard events KeyVK_APPS, Shift+F10). Check if this is being invoked |
| // in response to the above input events before popping up the context menu. |
| if (!ContextMenuAllowedScope::isContextMenuAllowed()) |
| - return; |
| + return false; |
| HitTestResult r = m_webView->page()->contextMenuController().hitTestResult(); |
| @@ -256,6 +263,10 @@ void ContextMenuClientImpl::showContextMenu(const ContextMenu* defaultMenu) |
| } |
| } |
| + if (fromTouch && !shouldShowContextMenuFromTouch(data)) { |
| + return false; |
| + } |
|
aelias_OOO_until_Jul13
2016/05/19 02:25:21
Nit: Blink style is that one-line control clauses
amaralp
2016/05/19 18:21:09
Done.
|
| + |
| // If it's not a link, an image, a media element, or an image/media link, |
| // show a selection menu or a more generic page menu. |
| if (selectedFrame->document()->loader()) |
| @@ -362,6 +373,8 @@ void ContextMenuClientImpl::showContextMenu(const ContextMenu* defaultMenu) |
| selectedWebFrame->setContextMenuNode(r.innerNodeOrImageMapImage()); |
| if (selectedWebFrame->client()) |
| selectedWebFrame->client()->showContextMenu(data); |
| + |
| + return true; |
| } |
| void ContextMenuClientImpl::clearContextMenu() |