Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Enumerations | Functions
nsPluginNativeWindowOS2.cpp File Reference
#include "os2.h"
#include "nsDebug.h"
#include "plevent.h"
#include "nsIEventQueueService.h"
#include "nsIPluginInstancePeer.h"
#include "nsPluginSafety.h"
#include "nsPluginNativeWindow.h"

Go to the source code of this file.

Classes

class  PluginWindowEvent
 PLEvent handling code. More...
class  nsPluginNativeWindowOS2

Defines

#define INCL_WIN
#define NS_PLUGIN_WINDOW_PROPERTY_ASSOCIATION   "MozillaPluginWindowPropertyAssociation"

Enumerations

enum  nsPluginType {
  nsPluginType_Unknown = 0, nsPluginType_Flash, nsPluginType_Java_vm, nsPluginType_Other,
  nsPluginType_Unknown = 0, nsPluginType_Flash, nsPluginType_Real, nsPluginType_Other
}
 nsPluginNativeWindow Windows specific class declaration More...

Functions

static NS_DEFINE_CID (kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID)
static NS_DEFINE_CID (kCPluginManagerCID, NS_PLUGINMANAGER_CID)
PVOID APIENTRY WinQueryProperty (HWND hwnd, PCSZ pszNameOrAtom)
PVOID APIENTRY WinRemoveProperty (HWND hwnd, PCSZ pszNameOrAtom)
BOOL APIENTRY WinSetProperty (HWND hwnd, PCSZ pszNameOrAtom, PVOID pvData, ULONG ulFlags)
static PRBool ProcessFlashMessageDelayed (nsPluginNativeWindowOS2 *aWin, HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2)
MRESULT EXPENTRY PluginWndProc (HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2)
 New plugin window procedure.
 PluginWindowEvent_Handle (PLEvent *self)
 PluginWindowEvent_Destroy (PLEvent *self)
nsresult PLUG_NewPluginNativeWindow (nsPluginNativeWindow **aPluginNativeWindow)
nsresult PLUG_DeletePluginNativeWindow (nsPluginNativeWindow *aPluginNativeWindow)

Define Documentation

Definition at line 40 of file nsPluginNativeWindowOS2.cpp.

#define NS_PLUGIN_WINDOW_PROPERTY_ASSOCIATION   "MozillaPluginWindowPropertyAssociation"

Definition at line 55 of file nsPluginNativeWindowOS2.cpp.


Enumeration Type Documentation

nsPluginNativeWindow Windows specific class declaration

Enumerator:
nsPluginType_Unknown 
nsPluginType_Flash 
nsPluginType_Java_vm 
nsPluginType_Other 
nsPluginType_Unknown 
nsPluginType_Flash 
nsPluginType_Real 
nsPluginType_Other 

Definition at line 117 of file nsPluginNativeWindowOS2.cpp.


Function Documentation

static NS_DEFINE_CID ( kCPluginManagerCID  ,
NS_PLUGINMANAGER_CID   
) [static]

Definition at line 412 of file nsPluginNativeWindowOS2.cpp.

{
  NS_ENSURE_ARG_POINTER(aPluginNativeWindow);
  nsPluginNativeWindowOS2 *p = (nsPluginNativeWindowOS2 *)aPluginNativeWindow;
  delete p;
  return NS_OK;
}

Definition at line 403 of file nsPluginNativeWindowOS2.cpp.

{
  NS_ENSURE_ARG_POINTER(aPluginNativeWindow);

  *aPluginNativeWindow = new nsPluginNativeWindowOS2();

  return *aPluginNativeWindow ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
}

Definition at line 291 of file nsPluginNativeWindowOS2.cpp.

{
  if (!self)
    return;

  PluginWindowEvent *event = NS_STATIC_CAST(PluginWindowEvent*, self);
  if (event->GetIsAlloced()) {
    delete event;
  }
  else
    event->Clear();
}

Here is the caller graph for this function:

Definition at line 264 of file nsPluginNativeWindowOS2.cpp.

{
  if (!self)
    return nsnull;

  PluginWindowEvent *event = NS_STATIC_CAST(PluginWindowEvent*, self);
  
  HWND hWnd = event->GetWnd();
  if (!hWnd)
    return nsnull;

  nsPluginNativeWindowOS2 * win = (nsPluginNativeWindowOS2 *)::WinQueryProperty(hWnd, NS_PLUGIN_WINDOW_PROPERTY_ASSOCIATION);
  if (win) {
    nsCOMPtr<nsIPluginInstance> inst;
    win->GetPluginInstance(inst);
    NS_TRY_SAFE_CALL_VOID((win->GetWindowProc())
                         (hWnd, 
                          event->GetMsg(), 
                          event->GetWParam(), 
                          event->GetLParam()),
                          nsnull, inst);
  }

  return nsnull;
}

Here is the call graph for this function:

Here is the caller graph for this function:

MRESULT EXPENTRY NP_LOADDS PluginWndProc ( HWND  hWnd,
ULONG  msg,
MPARAM  mp1,
MPARAM  mp2 
)

New plugin window procedure.

Definition at line 177 of file nsPluginNativeWindowOS2.cpp.

{
  nsPluginNativeWindowOS2 * win = (nsPluginNativeWindowOS2 *)::WinQueryProperty(hWnd, NS_PLUGIN_WINDOW_PROPERTY_ASSOCIATION);
  if (!win)
    return (MRESULT)TRUE;

  // check plugin mime type and cache whether it is Flash or java-vm or not
  // flash and java-vm will need special treatment later
  if (win->mPluginType == nsPluginType_Unknown) {
    nsCOMPtr<nsIPluginInstance> inst;
    win->GetPluginInstance(inst);
    if (inst) {
      nsCOMPtr<nsIPluginInstancePeer> pip;
      inst->GetPeer(getter_AddRefs(pip));
      if (pip) {
        nsMIMEType mimetype = nsnull;
        pip->GetMIMEType(&mimetype);
        if (mimetype) { 
          if (!strcmp(mimetype, "application/x-shockwave-flash"))
            win->mPluginType = nsPluginType_Flash;
          else if (!strcmp(mimetype, "application/x-java-vm"))
            win->mPluginType = nsPluginType_Java_vm;
          else
            win->mPluginType = nsPluginType_Other;
        }
      }
    }
  }

  // Macromedia Flash plugin may flood the message queue with some special messages
  // (WM_USER+1) causing 100% CPU consumption and GUI freeze, see mozilla bug 132759;
  // we can prevent this from happening by delaying the processing such messages;
  if (win->mPluginType == nsPluginType_Flash) {
    if (ProcessFlashMessageDelayed(win, hWnd, msg, mp1, mp2))
      return (MRESULT)TRUE;
  }

  MRESULT res = (MRESULT)TRUE;

  nsCOMPtr<nsIPluginInstance> inst;
  win->GetPluginInstance(inst);

  if (win->mPluginType == nsPluginType_Java_vm) {
    NS_TRY_SAFE_CALL_RETURN(res, WinDefWindowProc(hWnd, msg, mp1, mp2), nsnull, inst);
  } else {
    NS_TRY_SAFE_CALL_RETURN(res, (win->GetWindowProc())(hWnd, msg, mp1, mp2), nsnull, inst);
  }

  return res;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PRBool ProcessFlashMessageDelayed ( nsPluginNativeWindowOS2 aWin,
HWND  hWnd,
ULONG  msg,
MPARAM  mp1,
MPARAM  mp2 
) [static]

Definition at line 150 of file nsPluginNativeWindowOS2.cpp.

{
  NS_ENSURE_TRUE(aWin, NS_ERROR_NULL_POINTER);

  if (msg != WM_USER+1)
    return PR_FALSE; // no need to delay

  // do stuff
  nsCOMPtr<nsIEventQueueService> eventService;
  if (NS_SUCCEEDED(aWin->GetEventService(eventService))) {
    nsCOMPtr<nsIEventQueue> eventQueue;  
    eventService->GetThreadEventQueue(PR_GetCurrentThread(), getter_AddRefs(eventQueue));
    if (eventQueue) {
      PluginWindowEvent *pwe = aWin->GetPluginWindowEvent(hWnd, msg, mp1, mp2);
      if (pwe) {
        eventQueue->PostEvent(pwe);
        return PR_TRUE;  
      }
    }
  }
  return PR_FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PVOID APIENTRY WinQueryProperty ( HWND  hwnd,
PCSZ  pszNameOrAtom 
)

Here is the caller graph for this function:

PVOID APIENTRY WinRemoveProperty ( HWND  hwnd,
PCSZ  pszNameOrAtom 
)

Here is the caller graph for this function:

BOOL APIENTRY WinSetProperty ( HWND  hwnd,
PCSZ  pszNameOrAtom,
PVOID  pvData,
ULONG  ulFlags 
)

Here is the caller graph for this function: