[SCM] WebKit Debian packaging branch, webkit-1.3, updated. upstream/1.3.7-4207-g178b198
andersca at apple.com
andersca at apple.com
Sun Feb 20 23:11:10 UTC 2011
The following commit has been merged in the webkit-1.3 branch:
commit b6d7b24d19f9753206477eb8a69a664b98742e7e
Author: andersca at apple.com <andersca at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Tue Jan 18 20:09:09 2011 +0000
2011-01-18 Anders Carlsson <andersca at apple.com>
Reviewed by Sam Weinig.
Implement NPN_PopUpContextMenu
https://bugs.webkit.org/show_bug.cgi?id=52646
<rdar://problem/8735616>
* WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp:
(WebKit::NPN_PopUpContextMenu):
Call NetscapePlugin::popUpContextMenu.
* WebProcess/Plugins/Netscape/NetscapePlugin.cpp:
(WebKit::NetscapePlugin::NetscapePlugin):
Initialize m_currentMouseEvent.
* WebProcess/Plugins/Netscape/NetscapePlugin.h:
Add m_currentMouseEvent.
* WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm:
(WebKit::NetscapePlugin::popUpContextMenu):
Convert the coordinates from the current mouse event to screen coordinates and call
WKPopupContextMenu.
(WebKit::NetscapePlugin::platformHandleMouseEvent):
Update m_currentMouseEvent.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@76043 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebKit2/ChangeLog b/Source/WebKit2/ChangeLog
index f719a27..3a3608b 100644
--- a/Source/WebKit2/ChangeLog
+++ b/Source/WebKit2/ChangeLog
@@ -1,3 +1,30 @@
+2011-01-18 Anders Carlsson <andersca at apple.com>
+
+ Reviewed by Sam Weinig.
+
+ Implement NPN_PopUpContextMenu
+ https://bugs.webkit.org/show_bug.cgi?id=52646
+ <rdar://problem/8735616>
+
+ * WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp:
+ (WebKit::NPN_PopUpContextMenu):
+ Call NetscapePlugin::popUpContextMenu.
+
+ * WebProcess/Plugins/Netscape/NetscapePlugin.cpp:
+ (WebKit::NetscapePlugin::NetscapePlugin):
+ Initialize m_currentMouseEvent.
+
+ * WebProcess/Plugins/Netscape/NetscapePlugin.h:
+ Add m_currentMouseEvent.
+
+ * WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm:
+ (WebKit::NetscapePlugin::popUpContextMenu):
+ Convert the coordinates from the current mouse event to screen coordinates and call
+ WKPopupContextMenu.
+
+ (WebKit::NetscapePlugin::platformHandleMouseEvent):
+ Update m_currentMouseEvent.
+
2011-01-18 Jessie Berlin <jberlin at apple.com>
Reviewed by Darin Adler.
diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp b/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp
index 566d48d..ba21db1 100644
--- a/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp
+++ b/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp
@@ -766,10 +766,11 @@ static void NPN_UnscheduleTimer(NPP instance, uint32_t timerID)
}
#if PLATFORM(MAC)
-static NPError NPN_PopUpContextMenu(NPP instance, NPMenu* menu)
+static NPError NPN_PopUpContextMenu(NPP npp, NPMenu* menu)
{
- notImplemented();
- return NPERR_GENERIC_ERROR;
+ RefPtr<NetscapePlugin> plugin = NetscapePlugin::fromNPP(npp);
+
+ return plugin->popUpContextMenu(menu);
}
static NPBool NPN_ConvertPoint(NPP npp, double sourceX, double sourceY, NPCoordinateSpace sourceSpace, double* destX, double* destY, NPCoordinateSpace destSpace)
diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp b/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp
index 0beade2..5674ba5 100644
--- a/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp
+++ b/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp
@@ -67,6 +67,7 @@ NetscapePlugin::NetscapePlugin(PassRefPtr<NetscapePluginModule> pluginModule)
#if PLATFORM(MAC)
, m_drawingModel(static_cast<NPDrawingModel>(-1))
, m_eventModel(static_cast<NPEventModel>(-1))
+ , m_currentMouseEvent(0)
, m_pluginHasFocus(false)
, m_windowHasFocus(false)
#ifndef NP_NO_CARBON
diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h b/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h
index fb5d37e..95ff714 100644
--- a/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h
+++ b/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h
@@ -54,6 +54,7 @@ public:
NPError setDrawingModel(NPDrawingModel);
NPError setEventModel(NPEventModel);
NPBool convertPoint(double sourceX, double sourceY, NPCoordinateSpace sourceSpace, double& destX, double& destY, NPCoordinateSpace destSpace);
+ NPError popUpContextMenu(NPMenu*);
#ifndef NP_NO_CARBON
WindowRef windowRef() const;
@@ -205,6 +206,8 @@ private:
NPEventModel m_eventModel;
RetainPtr<PlatformLayer> m_pluginLayer;
+ NPCocoaEvent* m_currentMouseEvent;
+
bool m_pluginHasFocus;
bool m_windowHasFocus;
diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm b/Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm
index 1240ed7..d57e8d1 100644
--- a/Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm
+++ b/Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm
@@ -157,6 +157,20 @@ NPBool NetscapePlugin::convertPoint(double sourceX, double sourceY, NPCoordinate
return true;
}
+
+NPError NetscapePlugin::popUpContextMenu(NPMenu* npMenu)
+{
+ if (!m_currentMouseEvent)
+ return NPERR_GENERIC_ERROR;
+
+ double screenX, screenY;
+ if (!convertPoint(m_currentMouseEvent->data.mouse.pluginX, m_currentMouseEvent->data.mouse.pluginY, NPCoordinateSpacePlugin, screenX, screenY, NPCoordinateSpaceScreen))
+ ASSERT_NOT_REACHED();
+
+ WKPopupContextMenu(reinterpret_cast<NSMenu *>(npMenu), NSMakePoint(screenX, screenY));
+ return NPERR_NO_ERROR;
+}
+
#ifndef NP_NO_CARBON
typedef HashMap<WindowRef, NetscapePlugin*> WindowMap;
@@ -474,7 +488,19 @@ bool NetscapePlugin::platformHandleMouseEvent(const WebMouseEvent& mouseEvent)
switch (m_eventModel) {
case NPEventModelCocoa: {
NPCocoaEvent event = initializeMouseEvent(mouseEvent, m_frameRect.location());
- return NPP_HandleEvent(&event);
+
+ NPCocoaEvent* previousMouseEvent = m_currentMouseEvent;
+ m_currentMouseEvent = &event;
+
+ // Protect against NPP_HandleEvent causing the plug-in to be destroyed, since we
+ // access m_currentMouseEvent afterwards.
+ RefPtr<NetscapePlugin> protect(this);
+
+ bool returnValue = NPP_HandleEvent(&event);
+
+ m_currentMouseEvent = previousMouseEvent;
+
+ return returnValue;
}
#ifndef NP_NO_CARBON
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list