Add new webkit API to invoke a context menu.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 28 Feb 2013 19:11:04 +0000 (19:11 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 28 Feb 2013 19:11:04 +0000 (19:11 +0000)
https://bugs.webkit.org/show_bug.cgi?id=111040

Patch by Varun Jain <varunjain@chromium.org> on 2013-02-28
Reviewed by Adam Barth.

* public/WebView.h:
(WebView):
* src/WebViewImpl.cpp:
(WebKit::WebViewImpl::showContextMenu):
(WebKit):
* src/WebViewImpl.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@144332 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/public/WebView.h
Source/WebKit/chromium/src/WebViewImpl.cpp
Source/WebKit/chromium/src/WebViewImpl.h

index 8ec07fc..46e7cea 100644 (file)
@@ -1,3 +1,17 @@
+2013-02-28  Varun Jain  <varunjain@chromium.org>
+
+        Add new webkit API to invoke a context menu.
+        https://bugs.webkit.org/show_bug.cgi?id=111040
+
+        Reviewed by Adam Barth.
+
+        * public/WebView.h:
+        (WebView):
+        * src/WebViewImpl.cpp:
+        (WebKit::WebViewImpl::showContextMenu):
+        (WebKit):
+        * src/WebViewImpl.h:
+
 2013-02-28  Aaron Colwell  <acolwell@chromium.org>
 
         Factor SourceBuffer methods out of MediaSourcePrivate & WebMediaSource
index 285b9b6..64dfa1b 100644 (file)
@@ -411,6 +411,9 @@ public:
 
     virtual void performCustomContextMenuAction(unsigned action) = 0;
 
+    // Shows a context menu for the currently focused element.
+    virtual void showContextMenu() = 0;
+
 
     // Popup menu ----------------------------------------------------------
 
index 1ad9fbf..4e13a1e 100644 (file)
@@ -3679,6 +3679,18 @@ void WebViewImpl::performCustomContextMenuAction(unsigned action)
     m_page->contextMenuController()->clearContextMenu();
 }
 
+void WebViewImpl::showContextMenu()
+{
+    if (!page())
+        return;
+
+    page()->contextMenuController()->clearContextMenu();
+    m_contextMenuAllowed = true;
+    if (Frame* focusedFrame = page()->focusController()->focusedOrMainFrame())
+        focusedFrame->eventHandler()->sendContextMenuEventForKey();
+    m_contextMenuAllowed = false;
+}
+
 // WebView --------------------------------------------------------------------
 
 void WebViewImpl::setIsTransparent(bool isTransparent)
index 23aa381..c45dcfa 100644 (file)
@@ -302,6 +302,7 @@ public:
                                     unsigned inactiveBackgroundColor,
                                     unsigned inactiveForegroundColor);
     virtual void performCustomContextMenuAction(unsigned action);
+    virtual void showContextMenu();
     virtual void addPageOverlay(WebPageOverlay*, int /* zOrder */);
     virtual void removePageOverlay(WebPageOverlay*);
 #if ENABLE(BATTERY_STATUS)