Get rid of nsIWindowlessPluginInstancePeer. b=500672 r/sr=jst
authorJosh Aas <joshmoz@gmail.com>
Fri, 26 Jun 2009 13:30:36 -0400
changeset 29603 0c6c65345b3ff36c84791a1b1ff5ebb4bce63e96
parent 29602 0f97932be66310c49ff28025743171e6f8e000b6
child 29604 c25385c417b95e203fae87438315bd98f20d267c
child 35728 84b7c31ce666394f83edb20e197e624ba7ec66f5
push id7741
push userjosh@mozilla.com
push dateFri, 26 Jun 2009 17:31:20 +0000
treeherdermozilla-central@0c6c65345b3f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs500672
milestone1.9.2a1pre
Get rid of nsIWindowlessPluginInstancePeer. b=500672 r/sr=jst
modules/plugin/base/public/Makefile.in
modules/plugin/base/public/nsIPluginInstance.idl
modules/plugin/base/public/nsIWindowlessPlugInstPeer.idl
modules/plugin/base/public/nsplugin.h
modules/plugin/base/public/nsplugindefs.h
modules/plugin/base/src/nsNPAPIPlugin.cpp
modules/plugin/base/src/nsNPAPIPlugin.h
modules/plugin/base/src/nsNPAPIPluginInstance.cpp
modules/plugin/base/src/nsPluginInstancePeer.cpp
modules/plugin/base/src/nsPluginInstancePeer.h
modules/plugin/base/src/nsPluginNativeWindowGtk2.cpp
--- a/modules/plugin/base/public/Makefile.in
+++ b/modules/plugin/base/public/Makefile.in
@@ -66,17 +66,16 @@ SDK_HEADERS	 = \
 XPIDLSRCS 	= \
 		nspluginroot.idl \
 		nsIPluginStreamInfo.idl \
 		nsIPluginInstancePeer.idl \
 		nsIPluginInstancePeer2.idl \
 		nsIPluginInstanceOwner.idl \
 		nsIPlugin.idl \
 		nsIHTTPHeaderListener.idl \
-		nsIWindowlessPlugInstPeer.idl \
 		nsIPluginTag.idl \
 		nsIPluginTagInfo.idl \
 		nsIPluginTagInfo2.idl \
 		nsIPluginInputStream.idl \
 		nsIPluginStreamListener.idl \
 		nsIPluginInstance.idl \
 		nsPIPluginHost.idl \
 		nsPIPluginInstancePeer.idl \
--- a/modules/plugin/base/public/nsIPluginInstance.idl
+++ b/modules/plugin/base/public/nsIPluginInstance.idl
@@ -140,9 +140,24 @@ interface nsIPluginInstance : nsISupport
      *
      * (Corresponds to NPP_HandleEvent.)
      *
      * @param aEvent   - the event to be handled
      * @param aHandled - set to PR_TRUE if event was handled
      * @result - NS_OK if this operation was successful
      */
     void handleEvent(in nsPluginEventPtr aEvent, out boolean aHandled);
+
+    /** 
+     * Corresponds to NPN_InvalidateRect
+     */
+    void invalidateRect(in nsPluginRectPtr aRect);
+
+    /** 
+     * Corresponds to NPN_InvalidateRegion
+     */
+    void invalidateRegion(in nsPluginRegion aRegion);
+
+    /** 
+     * Corresponds to NPN_ForceRedraw
+     */
+    void forceRedraw();
 };
deleted file mode 100644
--- a/modules/plugin/base/public/nsIWindowlessPlugInstPeer.idl
+++ /dev/null
@@ -1,62 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1998
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#include "nsISupports.idl"
-#include "nspluginroot.idl"
-
-%{C++
-#include "nsplugindefs.h"
-%}
-
-[uuid(57b4e2f0-019b-11d2-815b-006008119d7a)]
-interface nsIWindowlessPluginInstancePeer : nsISupports
-{
-  /** 
-   * Corresponds to NPN_InvalidateRect
-   */
-  void invalidateRect(in nsPluginRectPtr aRect);
-
-  /** 
-   * Corresponds to NPN_InvalidateRegion
-   */
-  void invalidateRegion(in nsPluginRegion aRegion);
-
-  /** 
-   * Corresponds to NPN_ForceRedraw
-   */
-  void forceRedraw();
-};
--- a/modules/plugin/base/public/nsplugin.h
+++ b/modules/plugin/base/public/nsplugin.h
@@ -123,24 +123,16 @@
 /**
  * The nsIPluginTagInfo interface provides information about the html tag
  * that was used to instantiate the plugin instance. 
  *
  * To obtain: QueryInterface on nsIPluginInstancePeer
  */
 #include "nsIPluginTagInfo.h"
 
-/**
- * The nsIWindowlessPluginInstancePeer provides additional operations for 
- * windowless plugins. 
- *
- * To obtain: QueryInterface on nsIPluginInstancePeer
- */
-#include "nsIWindowlessPlugInstPeer.h"
-
 ////////////////////////////////////////////////////////////////////////////////
 /**
  * <B>Interfaces implemented by the browser (new for 5.0):
  */
 ////////////////////////////////////////////////////////////////////////////////
 
 /**
  * The nsIPluginTagInfo2 interface provides additional html tag information
--- a/modules/plugin/base/public/nsplugindefs.h
+++ b/modules/plugin/base/public/nsplugindefs.h
@@ -394,17 +394,16 @@ enum nsPluginReason {
 ////////////////////////////////////////////////////////////////////////////////
 
 // Classes that must be implemented by the plugin DLL:
 class nsIPlugin;                        // plugin class (MIME-type handler)
 class nsIPluginInstance;                // plugin instance
 
 // Classes that are implemented by the browser:
 class nsIPluginInstancePeer;            // parts of nsIPluginInstance implemented by the browser
-class nsIWindowlessPluginInstancePeer;  // subclass of nsIPluginInstancePeer for windowless plugins
 class nsIPluginTagInfo;                 // describes html tag (accessible from nsIPluginInstancePeer)
 ////////////////////////////////////////////////////////////////////////////////
 
 #endif /* RC_INVOKED */
 #ifdef __OS2__
 #pragma pack()
 #endif
 
--- a/modules/plugin/base/src/nsNPAPIPlugin.cpp
+++ b/modules/plugin/base/src/nsNPAPIPlugin.cpp
@@ -1065,24 +1065,17 @@ void NP_CALLBACK
     NS_WARNING("_invalidaterect: npp or npp->ndata == 0");
     return;
   }
 
   nsIPluginInstance *inst = (nsIPluginInstance *) npp->ndata;
 
   PluginDestructionGuard guard(inst);
 
-  nsCOMPtr<nsIPluginInstancePeer> peer;
-  if (NS_SUCCEEDED(inst->GetPeer(getter_AddRefs(peer))) && peer) {
-    nsCOMPtr<nsIWindowlessPluginInstancePeer> wpeer(do_QueryInterface(peer));
-    if (wpeer) {
-      // XXX nsRect & NPRect are structurally equivalent
-      wpeer->InvalidateRect((nsPluginRect *)invalidRect);
-    }
-  }
+  inst->InvalidateRect((nsPluginRect *)invalidRect);
 }
 
 void NP_CALLBACK
 _invalidateregion(NPP npp, NPRegion invalidRegion)
 {
   if (!NS_IsMainThread()) {
     NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_invalidateregion called from the wrong thread\n"));
     return;
@@ -1095,24 +1088,17 @@ void NP_CALLBACK
     NS_WARNING("_invalidateregion: npp or npp->ndata == 0");
     return;
   }
 
   nsIPluginInstance *inst = (nsIPluginInstance *)npp->ndata;
 
   PluginDestructionGuard guard(inst);
 
-  nsCOMPtr<nsIPluginInstancePeer> peer;
-  if (NS_SUCCEEDED(inst->GetPeer(getter_AddRefs(peer))) && peer) {
-    nsCOMPtr<nsIWindowlessPluginInstancePeer> wpeer(do_QueryInterface(peer));
-    if (wpeer) {
-      // nsPluginRegion & NPRegion are typedef'd to the same thing
-      wpeer->InvalidateRegion((nsPluginRegion)invalidRegion);
-    }
-  }
+  inst->InvalidateRegion((nsPluginRegion)invalidRegion);
 }
 
 void NP_CALLBACK
 _forceredraw(NPP npp)
 {
   if (!NS_IsMainThread()) {
     NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_forceredraw called from the wrong thread\n"));
     return;
@@ -1123,23 +1109,17 @@ void NP_CALLBACK
     NS_WARNING("_forceredraw: npp or npp->ndata == 0");
     return;
   }
 
   nsIPluginInstance *inst = (nsIPluginInstance *) npp->ndata;
 
   PluginDestructionGuard guard(inst);
 
-  nsCOMPtr<nsIPluginInstancePeer> peer;
-  if (NS_SUCCEEDED(inst->GetPeer(getter_AddRefs(peer))) && peer) {
-    nsCOMPtr<nsIWindowlessPluginInstancePeer> wpeer(do_QueryInterface(peer));
-    if (wpeer) {
-      wpeer->ForceRedraw();
-    }
-  }
+  inst->ForceRedraw();
 }
 
 static nsIDocument *
 GetDocumentFromNPP(NPP npp)
 {
   NS_ENSURE_TRUE(npp, nsnull);
 
   nsNPAPIPluginInstance *inst = (nsNPAPIPluginInstance *)npp->ndata;
--- a/modules/plugin/base/src/nsNPAPIPlugin.h
+++ b/modules/plugin/base/src/nsNPAPIPlugin.h
@@ -36,17 +36,16 @@
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef nsNPAPIPlugin_h_
 #define nsNPAPIPlugin_h_
 
 #include "nsIFactory.h"
 #include "nsIPlugin.h"
 #include "nsIPluginInstancePeer.h"
-#include "nsIWindowlessPlugInstPeer.h"
 #include "prlink.h"
 #include "npfunctions.h"
 #include "nsPluginHostImpl.h"
 
 /*
  * Use this macro before each exported function
  * (between the return address and the function
  * itself), to ensure that the function has the
--- a/modules/plugin/base/src/nsNPAPIPluginInstance.cpp
+++ b/modules/plugin/base/src/nsNPAPIPluginInstance.cpp
@@ -1454,8 +1454,53 @@ nsresult nsNPAPIPluginInstance::PrivateM
 
       NPError error;
       NS_TRY_SAFE_CALL_RETURN(error, (*fCallbacks->setvalue)(&fNPP, NPNVprivateModeBool, &pme), fLibrary, this);
       return (error == NPERR_NO_ERROR) ? NS_OK : NS_ERROR_FAILURE;
     }
   }
   return NS_ERROR_FAILURE;
 }
+
+NS_IMETHODIMP
+nsNPAPIPluginInstance::InvalidateRect(nsPluginRect *invalidRect)
+{
+  nsCOMPtr<nsPIPluginInstancePeer> pp (do_QueryInterface(mPeer));
+  if (!pp)
+    return nsnull;
+
+  nsCOMPtr<nsIPluginInstanceOwner> owner;
+  pp->GetOwner(getter_AddRefs(owner));
+  if (!owner)
+    return NS_ERROR_FAILURE;
+
+  return owner->InvalidateRect(invalidRect);
+}
+
+NS_IMETHODIMP
+nsNPAPIPluginInstance::InvalidateRegion(nsPluginRegion invalidRegion)
+{
+  nsCOMPtr<nsPIPluginInstancePeer> pp (do_QueryInterface(mPeer));
+  if (!pp)
+    return nsnull;
+
+  nsCOMPtr<nsIPluginInstanceOwner> owner;
+  pp->GetOwner(getter_AddRefs(owner));
+  if (!owner)
+    return NS_ERROR_FAILURE;
+
+  return owner->InvalidateRegion(invalidRegion);
+}
+
+NS_IMETHODIMP
+nsNPAPIPluginInstance::ForceRedraw()
+{
+  nsCOMPtr<nsPIPluginInstancePeer> pp (do_QueryInterface(mPeer));
+  if (!pp)
+    return nsnull;
+
+  nsCOMPtr<nsIPluginInstanceOwner> owner;
+  pp->GetOwner(getter_AddRefs(owner));
+  if (!owner)
+    return NS_ERROR_FAILURE;
+
+  return owner->ForceRedraw();
+}
--- a/modules/plugin/base/src/nsPluginInstancePeer.cpp
+++ b/modules/plugin/base/src/nsPluginInstancePeer.cpp
@@ -72,21 +72,20 @@ nsPluginInstancePeerImpl::~nsPluginInsta
   if (nsnull != mMIMEType) {
     PR_Free((void *)mMIMEType);
     mMIMEType = nsnull;
   }
 }
 
 static NS_DEFINE_IID(kIPluginTagInfoIID, NS_IPLUGINTAGINFO_IID); 
 static NS_DEFINE_IID(kIPluginTagInfo2IID, NS_IPLUGINTAGINFO2_IID); 
-NS_IMPL_ISUPPORTS7(nsPluginInstancePeerImpl,
+NS_IMPL_ISUPPORTS6(nsPluginInstancePeerImpl,
                    nsIPluginInstancePeer,
                    nsIPluginInstancePeer2,
                    nsIPluginInstancePeer3,
-                   nsIWindowlessPluginInstancePeer,
                    nsIPluginTagInfo,
                    nsIPluginTagInfo2,
                    nsPIPluginInstancePeer)
 
 NS_IMETHODIMP
 nsPluginInstancePeerImpl::GetValue(nsPluginInstancePeerVariable variable,
                                    void *value)
 {
@@ -746,35 +745,8 @@ nsPluginInstancePeerImpl::SetOwner(nsIPl
 NS_IMETHODIMP
 nsPluginInstancePeerImpl::GetOwner(nsIPluginInstanceOwner **aOwner)
 {
   NS_ENSURE_ARG_POINTER(aOwner);
   *aOwner = mOwner;
   NS_IF_ADDREF(mOwner);
   return (mOwner) ? NS_OK : NS_ERROR_FAILURE;
 }
-
-NS_IMETHODIMP
-nsPluginInstancePeerImpl::InvalidateRect(nsPluginRect *invalidRect)
-{
-  if(!mOwner)
-    return NS_ERROR_FAILURE;
-
-  return mOwner->InvalidateRect(invalidRect);
-}
-
-NS_IMETHODIMP
-nsPluginInstancePeerImpl::InvalidateRegion(nsPluginRegion invalidRegion)
-{
-  if(!mOwner)
-    return NS_ERROR_FAILURE;
-
-  return mOwner->InvalidateRegion(invalidRegion);
-}
-
-NS_IMETHODIMP
-nsPluginInstancePeerImpl::ForceRedraw(void)
-{
-  if(!mOwner)
-    return NS_ERROR_FAILURE;
-
-  return mOwner->ForceRedraw();
-}
--- a/modules/plugin/base/src/nsPluginInstancePeer.h
+++ b/modules/plugin/base/src/nsPluginInstancePeer.h
@@ -34,36 +34,33 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef nsPluginInstancePeer_h_
 #define nsPluginInstancePeer_h_
 
 #include "nsIPluginInstancePeer2.h"
-#include "nsIWindowlessPlugInstPeer.h"
 #include "nsIPluginTagInfo2.h"
 #include "nsIPluginInstanceOwner.h"
 #include "nsPIPluginInstancePeer.h"
 
 #include "nsCOMPtr.h"
 
 class nsPluginInstancePeerImpl : public nsIPluginInstancePeer3,
-                                 public nsIWindowlessPluginInstancePeer,
                                  public nsIPluginTagInfo2,
                                  public nsPIPluginInstancePeer
 								
 {
 public:
   nsPluginInstancePeerImpl();
   virtual ~nsPluginInstancePeerImpl();
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSIPLUGININSTANCEPEER
-  NS_DECL_NSIWINDOWLESSPLUGININSTANCEPEER
   NS_DECL_NSIPLUGININSTANCEPEER2
   NS_DECL_NSIPLUGININSTANCEPEER3
   NS_DECL_NSIPLUGINTAGINFO
   NS_DECL_NSIPLUGINTAGINFO2
 
   //XXX Why isn't this ifdef'd like the class declaration?
   //nsIJVMPluginTagInfo interface
 
--- a/modules/plugin/base/src/nsPluginNativeWindowGtk2.cpp
+++ b/modules/plugin/base/src/nsPluginNativeWindowGtk2.cpp
@@ -169,27 +169,18 @@ nsPluginNativeWindowGtk2::plugin_composi
 
   /* We try to do our area invalidation here */
   nsPluginRect rect;
   rect.top = ev->area.x;
   rect.left = ev->area.y;
   rect.right = ev->area.x + ev->area.width;
   rect.bottom = ev->area.y + ev->area.height;
 
-  /* There might be a better way to do this? */
-  if (native_window->mPluginInstance) {
-    nsCOMPtr<nsIPluginInstancePeer> peer;
-    if (NS_SUCCEEDED(native_window->mPluginInstance->GetPeer(getter_AddRefs(peer))) && peer) {
-      nsCOMPtr<nsIWindowlessPluginInstancePeer> wpeer(do_QueryInterface(peer));
-      if (wpeer) {
-        // XXX nsRect & NPRect are structurally equivalent
-        wpeer->InvalidateRect(&rect);
-      }
-    }
-  }
+  if (native_window->mPluginInstance)
+    native_window->mPluginInstance->InvalidateRect(&rect);
 
   return GDK_FILTER_REMOVE;
 }
 #endif
 
 nsresult nsPluginNativeWindowGtk2::CallSetWindow(nsCOMPtr<nsIPluginInstance> &aPluginInstance)
 {
   if(aPluginInstance) {