Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(561)

Unified Diff: third_party/WebKit/Source/web/ContextMenuClientImpl.cpp

Issue 1986783002: Text selected with double-tap should not cause vibration (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: added description of return value of showContextMenu Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..26769772aa8856be4d52edd888be54a4d5038e63 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,9 @@ void ContextMenuClientImpl::showContextMenu(const ContextMenu* defaultMenu)
}
}
+ if (fromTouch && !shouldShowContextMenuFromTouch(data))
+ return false;
+
// 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 +372,8 @@ void ContextMenuClientImpl::showContextMenu(const ContextMenu* defaultMenu)
selectedWebFrame->setContextMenuNode(r.innerNodeOrImageMapImage());
if (selectedWebFrame->client())
selectedWebFrame->client()->showContextMenu(data);
+
+ return true;
}
void ContextMenuClientImpl::clearContextMenu()
« no previous file with comments | « third_party/WebKit/Source/web/ContextMenuClientImpl.h ('k') | third_party/WebKit/Source/web/tests/WebViewTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698