Commit b6d7b24d authored by andersca@apple.com's avatar andersca@apple.com
Browse files

2011-01-18 Anders Carlsson <andersca@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
parent 13cf2448
2011-01-18 Anders Carlsson <andersca@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@apple.com>
 
Reviewed by Darin Adler.
......@@ -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)
......
......@@ -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
......
......@@ -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;
......
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment