Title: [147752] trunk/Source/WebKit2
- Revision
- 147752
- Author
- [email protected]
- Date
- 2013-04-05 09:26:40 -0700 (Fri, 05 Apr 2013)
Log Message
Add SPI to get a copy of the context menu at a given point.
<rdar://problem/13450908> and https://bugs.webkit.org/show_bug.cgi?id=113958
Reviewed by Andy Estes.
Add the new accessor:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::contextMenuAtPoint):
* WebProcess/WebPage/WebPage.h:
Expose the new SPI:
* WebProcess/InjectedBundle/API/c/WKBundlePage.cpp:
(WKBundlePageCopyContextMenuAtPoint):
* WebProcess/InjectedBundle/API/c/WKBundlePagePrivate.h:
Modified Paths
Diff
Modified: trunk/Source/WebKit2/ChangeLog (147751 => 147752)
--- trunk/Source/WebKit2/ChangeLog 2013-04-05 16:13:06 UTC (rev 147751)
+++ trunk/Source/WebKit2/ChangeLog 2013-04-05 16:26:40 UTC (rev 147752)
@@ -1,3 +1,20 @@
+2013-04-04 Brady Eidson <[email protected]>
+
+ Add SPI to get a copy of the context menu at a given point.
+ <rdar://problem/13450908> and https://bugs.webkit.org/show_bug.cgi?id=113958
+
+ Reviewed by Andy Estes.
+
+ Add the new accessor:
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::WebPage::contextMenuAtPoint):
+ * WebProcess/WebPage/WebPage.h:
+
+ Expose the new SPI:
+ * WebProcess/InjectedBundle/API/c/WKBundlePage.cpp:
+ (WKBundlePageCopyContextMenuAtPoint):
+ * WebProcess/InjectedBundle/API/c/WKBundlePagePrivate.h:
+
2013-04-05 Mikhail Pozdnyakov <[email protected]>
[WK2][EFL] WebView should own page position and scale factor
Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp (147751 => 147752)
--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp 2013-04-05 16:13:06 UTC (rev 147751)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp 2013-04-05 16:26:40 UTC (rev 147752)
@@ -163,6 +163,27 @@
#endif
}
+WKArrayRef WKBundlePageCopyContextMenuAtPointInWindow(WKBundlePageRef pageRef, WKPoint point)
+{
+#if ENABLE(CONTEXT_MENUS)
+ WebContextMenu* contextMenu = toImpl(pageRef)->contextMenuAtPointInWindow(toIntPoint(point));
+ if (!contextMenu)
+ return 0;
+
+ const Vector<WebContextMenuItemData>& items = contextMenu->items();
+ size_t arrayLength = items.size();
+
+ RefPtr<MutableArray> menuArray = MutableArray::create();
+ menuArray->reserveCapacity(arrayLength);
+ for (unsigned i = 0; i < arrayLength; ++i)
+ menuArray->append(WebContextMenuItem::create(items[i]).get());
+
+ return toAPI(menuArray.release().leakRef());
+#else
+ return 0;
+#endif
+}
+
void* WKAccessibilityRootObject(WKBundlePageRef pageRef)
{
#if HAVE(ACCESSIBILITY)
Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePagePrivate.h (147751 => 147752)
--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePagePrivate.h 2013-04-05 16:13:06 UTC (rev 147751)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePagePrivate.h 2013-04-05 16:26:40 UTC (rev 147752)
@@ -78,6 +78,7 @@
WK_EXPORT void* WKAccessibilityFocusedObject(WKBundlePageRef);
WK_EXPORT WKArrayRef WKBundlePageCopyContextMenuItemTitles(WKBundlePageRef);
+WK_EXPORT WKArrayRef WKBundlePageCopyContextMenuAtPointInWindow(WKBundlePageRef, WKPoint);
#ifdef __cplusplus
}
Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (147751 => 147752)
--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp 2013-04-05 16:13:06 UTC (rev 147751)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp 2013-04-05 16:26:40 UTC (rev 147752)
@@ -1454,6 +1454,19 @@
m_contextMenu = WebContextMenu::create(this);
return m_contextMenu.get();
}
+
+WebContextMenu* WebPage::contextMenuAtPointInWindow(const IntPoint& point)
+{
+ corePage()->contextMenuController()->clearContextMenu();
+
+ // Simulate a mouse click to generate the correct menu.
+ PlatformMouseEvent mouseEvent(point, point, RightButton, PlatformEvent::MousePressed, 1, false, false, false, false, currentTime());
+ bool handled = corePage()->mainFrame()->eventHandler()->sendContextMenuEvent(mouseEvent);
+ if (!handled)
+ return 0;
+
+ return contextMenu();
+}
#endif
// Events
Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h (147751 => 147752)
--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h 2013-04-05 16:13:06 UTC (rev 147751)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h 2013-04-05 16:26:40 UTC (rev 147752)
@@ -408,6 +408,7 @@
#if ENABLE(CONTEXT_MENUS)
WebContextMenu* contextMenu();
+ WebContextMenu* contextMenuAtPointInWindow(const WebCore::IntPoint&);
#endif
bool hasLocalDataForURL(const WebCore::KURL&);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes