2008-05-06 Anders Carlsson <andersca@apple.com>
authorandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 6 May 2008 20:40:45 +0000 (20:40 +0000)
committerandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 6 May 2008 20:40:45 +0000 (20:40 +0000)
        Reviewed by Darin.

        Add implementation of NPN_PopUpContextMenu.

        * Plugins/WebBaseNetscapePluginView.mm:
        (-[WebBaseNetscapePluginView popUpContextMenu:]):
        * Plugins/WebBaseNetscapePluginViewPrivate.h:
        * Plugins/WebNetscapePluginPackage.m:
        (-[WebNetscapePluginPackage load]):
        * Plugins/npapi.m:
        (NPN_PopUpContextMenu):

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

WebKit/mac/ChangeLog
WebKit/mac/Plugins/WebBaseNetscapePluginView.mm
WebKit/mac/Plugins/WebBaseNetscapePluginViewPrivate.h
WebKit/mac/Plugins/WebNetscapePluginPackage.m
WebKit/mac/Plugins/npapi.m

index a55a81e..47f9fef 100644 (file)
@@ -1,5 +1,19 @@
 2008-05-06  Anders Carlsson  <andersca@apple.com>
 
+        Reviewed by Darin.
+
+        Add implementation of NPN_PopUpContextMenu.
+        
+        * Plugins/WebBaseNetscapePluginView.mm:
+        (-[WebBaseNetscapePluginView popUpContextMenu:]):
+        * Plugins/WebBaseNetscapePluginViewPrivate.h:
+        * Plugins/WebNetscapePluginPackage.m:
+        (-[WebNetscapePluginPackage load]):
+        * Plugins/npapi.m:
+        (NPN_PopUpContextMenu):
+
+2008-05-06  Anders Carlsson  <andersca@apple.com>
+
         Fix typo (don't read random memory).
         
         * Plugins/WebBasePluginPackage.m:
index 9fd543b..7794b07 100644 (file)
@@ -2508,6 +2508,18 @@ static inline void getNPRect(const NSRect& nr, NPRect& npr)
         delete timer;
 }
 
+- (NPError)popUpContextMenu:(NPMenu *)menu
+{
+    NSEvent *currentEvent = [NSApp currentEvent];
+    
+    // NPN_PopUpContextMenu must be called from within the plug-in's NPP_HandleEvent.
+    if (!currentEvent)
+        return NPERR_GENERIC_ERROR;
+    
+    [NSMenu popUpContextMenu:(NSMenu *)menu withEvent:currentEvent forView:self];
+    return NPERR_NO_ERROR;
+}
+
 @end
 
 @implementation WebPluginRequest
index cecc7b3..da696d8 100644 (file)
@@ -50,6 +50,7 @@
 - (NPError)setVariable:(NPPVariable)variable value:(void *)value;
 - (uint32)scheduleTimerWithInterval:(uint32)interval repeat:(NPBool)repeat timerFunc:(void (*)(NPP npp, uint32 timerID))timerFunc;
 - (void)unscheduleTimer:(uint32)timerID;
+- (NPError)popUpContextMenu:(NPMenu *)menu;
 
 @end
 #endif
index 978db7b..307c861 100644 (file)
@@ -426,7 +426,8 @@ static TransitionVector tVectorForFunctionPointer(FunctionPointer);
         browserFuncs.poppopupsenabledstate = (NPN_PopPopupsEnabledStateProcPtr)tVectorForFunctionPointer((FunctionPointer)NPN_PopPopupsEnabledState);
         browserFuncs.scheduletimer = (NPN_ScheduleTimerProcPtr)tVectorForFunctionPointer((FunctionPointer)NPN_ScheduleTimer);
         browserFuncs.unscheduletimer = (NPN_UnscheduleTimerProcPtr)tVectorForFunctionPointer((FunctionPointer)NPN_UnscheduleTimer);
-
+        browserFuncs.popupcontextmenu = (NPN_PopUpContextMenuProcPtr)tVectorForFunctionPointer((FunctionPointer)NPN_PopUpContextMenu);
+        
         browserFuncs.releasevariantvalue = (NPN_ReleaseVariantValueProcPtr)tVectorForFunctionPointer((FunctionPointer)_NPN_ReleaseVariantValue);
         browserFuncs.getstringidentifier = (NPN_GetStringIdentifierProcPtr)tVectorForFunctionPointer((FunctionPointer)_NPN_GetStringIdentifier);
         browserFuncs.getstringidentifiers = (NPN_GetStringIdentifiersProcPtr)tVectorForFunctionPointer((FunctionPointer)_NPN_GetStringIdentifiers);
@@ -530,6 +531,7 @@ static TransitionVector tVectorForFunctionPointer(FunctionPointer);
         browserFuncs.poppopupsenabledstate = NPN_PopPopupsEnabledState;
         browserFuncs.scheduletimer = NPN_ScheduleTimer;
         browserFuncs.unscheduletimer = NPN_UnscheduleTimer;
+        browserFuncs.popupcontextmenu = NPN_PopUpContextMenu;
         
         browserFuncs.releasevariantvalue = _NPN_ReleaseVariantValue;
         browserFuncs.getstringidentifier = _NPN_GetStringIdentifier;
index ec9f5a4..5751cef 100644 (file)
@@ -180,4 +180,9 @@ void NPN_UnscheduleTimer(NPP instance, uint32 timerID)
     [pluginViewForInstance(instance) unscheduleTimer:timerID];
 }
 
+NPError NPN_PopUpContextMenu(NPP instance, NPMenu *menu)
+{
+    return [pluginViewForInstance(instance) popUpContextMenu:menu];
+}
+
 #endif