dom/plugins/base/nsPluginNativeWindow.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 #ifndef _nsPluginNativeWindow_h_
     7 #define _nsPluginNativeWindow_h_
     9 #include "nscore.h"
    10 #include "nsAutoPtr.h"
    11 #include "nsCOMPtr.h"
    12 #include "nsISupportsImpl.h"
    13 #include "nsNPAPIPluginInstance.h"
    14 #include "npapi.h"
    15 #include "nsIWidget.h"
    17 /**
    18  * base class for native plugin window implementations
    19  */
    20 class nsPluginNativeWindow : public NPWindow
    21 {
    22 public: 
    23   nsPluginNativeWindow() : NPWindow() {
    24     MOZ_COUNT_CTOR(nsPluginNativeWindow);
    25   }
    27   virtual ~nsPluginNativeWindow() {
    28     MOZ_COUNT_DTOR(nsPluginNativeWindow);
    29   }
    31   /**
    32    *   !!! CAUTION !!!
    33    *
    34    * The base class |nsPluginWindow| is defined as a struct in nsplugindefs.h,
    35    * thus it does not have a destructor of its own.
    36    * One should never attempt to delete |nsPluginNativeWindow| object instance
    37    * (or derivatives) using a pointer of |nsPluginWindow *| type. Should such
    38    * necessity occur it must be properly casted first.
    39    */
    41 public:
    42   nsresult GetPluginInstance(nsRefPtr<nsNPAPIPluginInstance> &aPluginInstance) { 
    43     aPluginInstance = mPluginInstance;
    44     return NS_OK;
    45   }
    46   nsresult SetPluginInstance(nsNPAPIPluginInstance *aPluginInstance) { 
    47     if (mPluginInstance != aPluginInstance)
    48       mPluginInstance = aPluginInstance;
    49     return NS_OK;
    50   }
    52   nsresult GetPluginWidget(nsIWidget **aWidget) {
    53     NS_IF_ADDREF(*aWidget = mWidget);
    54     return NS_OK;
    55   }
    56   nsresult SetPluginWidget(nsIWidget *aWidget) { 
    57     mWidget = aWidget;
    58     return NS_OK;
    59   }
    61 public:
    62   virtual nsresult CallSetWindow(nsRefPtr<nsNPAPIPluginInstance> &aPluginInstance) {
    63     // null aPluginInstance means that we want to call SetWindow(null)
    64     if (aPluginInstance)
    65       aPluginInstance->SetWindow(this);
    66     else if (mPluginInstance)
    67       mPluginInstance->SetWindow(nullptr);
    69     SetPluginInstance(aPluginInstance);
    70     return NS_OK;
    71   }
    73 protected:
    74   nsRefPtr<nsNPAPIPluginInstance> mPluginInstance;
    75   nsCOMPtr<nsIWidget> mWidget;
    76 };
    78 nsresult PLUG_NewPluginNativeWindow(nsPluginNativeWindow ** aPluginNativeWindow);
    79 nsresult PLUG_DeletePluginNativeWindow(nsPluginNativeWindow * aPluginNativeWindow);
    81 #endif //_nsPluginNativeWindow_h_

mercurial