Use NS_IMPL_ISUPPPORTS macros where possible. b=387211 r=neil sr=dbaron a19=pavlov
authormats.palmgren@bredband.net
Tue, 07 Aug 2007 08:18:36 -0700
changeset 4345 64126303f4880cc91c65161b31cfdea8d9d9ae5b
parent 4344 5d8169c239b58f8090cf8f4ef1c83f4e52f6012c
child 4346 ce499b2c7abab80909dee316e7dbd58a68eda0fd
push idunknown
push userunknown
push dateunknown
reviewersneil, dbaron
bugs387211
milestone1.9a8pre
Use NS_IMPL_ISUPPPORTS macros where possible. b=387211 r=neil sr=dbaron a19=pavlov
content/html/content/src/nsFormSubmission.cpp
layout/generic/nsSelection.cpp
layout/xul/base/src/nsMenuBoxObject.cpp
widget/src/beos/nsDeviceContextSpecB.cpp
widget/src/cocoa/nsDragService.h
widget/src/cocoa/nsDragService.mm
widget/src/gtk2/nsDragService.cpp
widget/src/os2/nsDeviceContextSpecOS2.cpp
widget/src/os2/nsDragService.cpp
widget/src/photon/nsDragService.cpp
widget/src/photon/nsDragService.h
widget/src/windows/nsWindow.cpp
widget/src/windows/nsWindow.h
widget/src/xpwidgets/nsBaseClipboard.cpp
widget/src/xpwidgets/nsBaseDragService.cpp
widget/src/xpwidgets/nsHTMLFormatConverter.cpp
--- a/content/html/content/src/nsFormSubmission.cpp
+++ b/content/html/content/src/nsFormSubmission.cpp
@@ -266,18 +266,16 @@ public:
     : nsFormSubmission(aCharset, aEncoder, aFormProcessor, aBidiOptions),
       mMethod(aMethod)
   {
   }
   virtual ~nsFSURLEncoded()
   {
   }
 
-  NS_DECL_ISUPPORTS_INHERITED
-
   // nsIFormSubmission
   virtual nsresult AddNameValuePair(nsIDOMHTMLElement* aSource,
                                     const nsAString& aName,
                                     const nsAString& aValue);
   virtual nsresult AddNameFilePair(nsIDOMHTMLElement* aSource,
                                    const nsAString& aName,
                                    const nsAString& aFilename,
                                    nsIInputStream* aStream,
@@ -315,20 +313,16 @@ private:
 
   /** The query string so far (the part after the ?) */
   nsCString mQueryString;
 
   /** Whether or not we have warned about a file control not being submitted */
   PRBool mWarnedFileControl;
 };
 
-NS_IMPL_RELEASE_INHERITED(nsFSURLEncoded, nsFormSubmission)
-NS_IMPL_ADDREF_INHERITED(nsFSURLEncoded, nsFormSubmission)
-NS_IMPL_QUERY_INTERFACE_INHERITED0(nsFSURLEncoded, nsFormSubmission)
-
 nsresult
 nsFSURLEncoded::AddNameValuePair(nsIDOMHTMLElement* aSource,
                                  const nsAString& aName,
                                  const nsAString& aValue)
 {
   //
   // Check if there is an input type=file so that we can warn
   //
@@ -606,18 +600,16 @@ public:
    * @param aBidiOptions the BIDI options flags for the current pres context
    */
   nsFSMultipartFormData(const nsACString& aCharset,
                         nsISaveAsCharset* aEncoder,
                         nsIFormProcessor* aFormProcessor,
                         PRInt32 aBidiOptions);
   virtual ~nsFSMultipartFormData() { }
  
-  NS_DECL_ISUPPORTS_INHERITED
-
   // nsIFormSubmission
   virtual nsresult AddNameValuePair(nsIDOMHTMLElement* aSource,
                                     const nsAString& aName,
                                     const nsAString& aValue);
   virtual nsresult AddNameFilePair(nsIDOMHTMLElement* aSource,
                                    const nsAString& aName,
                                    const nsAString& aFilename,
                                    nsIInputStream* aStream,
@@ -687,20 +679,16 @@ private:
   /**
    * The boundary string to use after each "part" (the boundary that marks the
    * end of a value).  This is computed randomly and is different for each
    * submission.
    */
   nsCString mBoundary;
 };
 
-NS_IMPL_RELEASE_INHERITED(nsFSMultipartFormData, nsFormSubmission)
-NS_IMPL_ADDREF_INHERITED(nsFSMultipartFormData, nsFormSubmission)
-NS_IMPL_QUERY_INTERFACE_INHERITED0(nsFSMultipartFormData, nsFormSubmission)
-
 //
 // Constructor
 //
 nsFSMultipartFormData::nsFSMultipartFormData(const nsACString& aCharset,
                                              nsISaveAsCharset* aEncoder,
                                              nsIFormProcessor* aFormProcessor,
                                              PRInt32 aBidiOptions)
     : nsFormSubmission(aCharset, aEncoder, aFormProcessor, aBidiOptions)
@@ -932,18 +920,16 @@ public:
                 PRInt32 aBidiOptions)
     : nsFormSubmission(aCharset, aEncoder, aFormProcessor, aBidiOptions)
   {
   }
   virtual ~nsFSTextPlain()
   {
   }
 
-  NS_DECL_ISUPPORTS_INHERITED
-
   // nsIFormSubmission
   virtual nsresult AddNameValuePair(nsIDOMHTMLElement* aSource,
                                     const nsAString& aName,
                                     const nsAString& aValue);
   virtual nsresult AddNameFilePair(nsIDOMHTMLElement* aSource,
                                    const nsAString& aName,
                                    const nsAString& aFilename,
                                    nsIInputStream* aStream,
@@ -960,20 +946,16 @@ protected:
   {
     return PR_FALSE;
   }
 
 private:
   nsString mBody;
 };
 
-NS_IMPL_RELEASE_INHERITED(nsFSTextPlain, nsFormSubmission)
-NS_IMPL_ADDREF_INHERITED(nsFSTextPlain, nsFormSubmission)
-NS_IMPL_QUERY_INTERFACE_INHERITED0(nsFSTextPlain, nsFormSubmission)
-
 nsresult
 nsFSTextPlain::AddNameValuePair(nsIDOMHTMLElement* aSource,
                                 const nsAString& aName,
                                 const nsAString& aValue)
 {
   //
   // Let external code process (and possibly change) value
   //
--- a/layout/generic/nsSelection.cpp
+++ b/layout/generic/nsSelection.cpp
@@ -564,34 +564,28 @@ private:
   nsTypedSelection *mSelection;
   nsPresContext *mPresContext;
   nsPoint mPoint;
   nsCOMPtr<nsITimer> mTimer;
   nsCOMPtr<nsIContent> mContent;
   PRUint32 mDelay;
 };
 
-NS_IMPL_ADDREF(nsAutoScrollTimer)
-NS_IMPL_RELEASE(nsAutoScrollTimer)
-NS_IMPL_QUERY_INTERFACE1(nsAutoScrollTimer, nsITimerCallback)
-
-nsresult NS_NewSelection(nsFrameSelection **aFrameSelection);
+NS_IMPL_ISUPPORTS1(nsAutoScrollTimer, nsITimerCallback)
 
 nsresult NS_NewSelection(nsFrameSelection **aFrameSelection)
 {
   nsFrameSelection *rlist = new nsFrameSelection;
   if (!rlist)
     return NS_ERROR_OUT_OF_MEMORY;
   *aFrameSelection = rlist;
   NS_ADDREF(rlist);
   return NS_OK;
 }
 
-nsresult NS_NewDomSelection(nsISelection **aDomSelection);
-
 nsresult NS_NewDomSelection(nsISelection **aDomSelection)
 {
   nsTypedSelection *rlist = new nsTypedSelection;
   if (!rlist)
     return NS_ERROR_OUT_OF_MEMORY;
   *aDomSelection = (nsISelection *)rlist;
   NS_ADDREF(rlist);
   return NS_OK;
--- a/layout/xul/base/src/nsMenuBoxObject.cpp
+++ b/layout/xul/base/src/nsMenuBoxObject.cpp
@@ -40,57 +40,37 @@
 #include "nsBoxObject.h"
 #include "nsIPresShell.h"
 #include "nsIFrame.h"
 #include "nsGUIEvent.h"
 #include "nsIDOMNSUIEvent.h"
 #include "nsMenuBarListener.h"
 #include "nsMenuFrame.h"
 #include "nsMenuPopupFrame.h"
-#include "nsPopupSetFrame.h"
 
 class nsMenuBoxObject : public nsIMenuBoxObject, public nsBoxObject
 {
 public:
-  NS_DECL_ISUPPORTS
+  NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_NSIMENUBOXOBJECT
 
   nsMenuBoxObject();
   virtual ~nsMenuBoxObject();
-  
-protected:
 };
 
-/* Implementation file */
-NS_IMPL_ADDREF(nsMenuBoxObject)
-NS_IMPL_RELEASE(nsMenuBoxObject)
-
-NS_IMETHODIMP 
-nsMenuBoxObject::QueryInterface(REFNSIID iid, void** aResult)
-{
-  NS_PRECONDITION(aResult, "null out param");
-
-  if (iid.Equals(NS_GET_IID(nsIMenuBoxObject))) {
-    *aResult = static_cast<nsIMenuBoxObject*>(this);
-    NS_ADDREF(this);
-    return NS_OK;
-  }
-
-  return nsBoxObject::QueryInterface(iid, aResult);
-}
-  
 nsMenuBoxObject::nsMenuBoxObject()
 {
 }
 
 nsMenuBoxObject::~nsMenuBoxObject()
 {
-  /* destructor code */
 }
 
+NS_IMPL_ISUPPORTS_INHERITED1(nsMenuBoxObject, nsBoxObject, nsIMenuBoxObject)
+
 /* void openMenu (in boolean openFlag); */
 NS_IMETHODIMP nsMenuBoxObject::OpenMenu(PRBool aOpenFlag)
 {
   nsXULPopupManager* pm = nsXULPopupManager::GetInstance();
   if (pm) {
     nsIFrame* frame = GetFrame(PR_FALSE);
     if (frame) {
       if (aOpenFlag) {
--- a/widget/src/beos/nsDeviceContextSpecB.cpp
+++ b/widget/src/beos/nsDeviceContextSpecB.cpp
@@ -74,68 +74,26 @@ protected:
 
 };
 //---------------
 // static members
 GlobalPrinters GlobalPrinters::mGlobalPrinters;
 nsStringArray* GlobalPrinters::mGlobalPrinterList = nsnull;
 int            GlobalPrinters::mGlobalNumPrinters = 0;
 
-/** -------------------------------------------------------
- *  Construct the nsDeviceContextSpecBeOS
- *  @update   dc 12/02/98
- */
-nsDeviceContextSpecBeOS :: nsDeviceContextSpecBeOS()
+nsDeviceContextSpecBeOS::nsDeviceContextSpecBeOS()
 {
 }
 
-/** -------------------------------------------------------
- *  Destroy the nsDeviceContextSpecBeOS
- *  @update   dc 2/15/98
- */
-nsDeviceContextSpecBeOS :: ~nsDeviceContextSpecBeOS()
+nsDeviceContextSpecBeOS::~nsDeviceContextSpecBeOS()
 {
 } 
  
-static NS_DEFINE_IID(kIDeviceContextSpecIID, NS_IDEVICE_CONTEXT_SPEC_IID); 
- 
-#if 0 
 NS_IMPL_ISUPPORTS1(nsDeviceContextSpecBeOS, nsIDeviceContextSpec)
-#endif 
- 
-NS_IMETHODIMP nsDeviceContextSpecBeOS :: QueryInterface(REFNSIID aIID, void** aInstancePtr) 
-{ 
-  NS_PRECONDITION(aInstancePtr, "null out param");
-
-  if (aIID.Equals(kIDeviceContextSpecIID)) 
-  { 
-    nsIDeviceContextSpec* tmp = this; 
-    *aInstancePtr = (void*) tmp; 
-    NS_ADDREF_THIS(); 
-    return NS_OK; 
-  } 
  
-  static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
-
-  if (aIID.Equals(kISupportsIID)) 
-  { 
-    nsIDeviceContextSpec* tmp = this; 
-    nsISupports* tmp2 = tmp; 
-    *aInstancePtr = (void*) tmp2; 
-    NS_ADDREF_THIS(); 
-    return NS_OK; 
-  } 
- 
-  *aInstancePtr = nsnull;
-  return NS_ERROR_NO_INTERFACE;
-} 
- 
-NS_IMPL_ADDREF(nsDeviceContextSpecBeOS)
-NS_IMPL_RELEASE(nsDeviceContextSpecBeOS)
-
 /** -------------------------------------------------------
  *  Initialize the nsDeviceContextSpecBeOS
  *  @update   dc 2/15/98
  *  @update   syd 3/2/99
  */
 NS_IMETHODIMP nsDeviceContextSpecBeOS::Init(nsIWidget *aWidget,
                                             nsIPrintSettings* aPS,
                                             PRBool aIsPrintPreview)
--- a/widget/src/cocoa/nsDragService.h
+++ b/widget/src/cocoa/nsDragService.h
@@ -56,19 +56,16 @@ extern PRLogModuleInfo* sCocoaLog;
 extern NSString* const kWildcardPboardType;
 
 class nsDragService : public nsBaseDragService
 {
 public:
   nsDragService();
   virtual ~nsDragService();
 
-  // nsISupports
-  NS_DECL_ISUPPORTS_INHERITED
-
   // nsIDragService
   NS_IMETHOD InvokeDragSession(nsIDOMNode *aDOMNode, nsISupportsArray * anArrayTransferables,
                                nsIScriptableRegion * aRegion, PRUint32 aActionType);
   NS_IMETHOD EndDragSession(PRBool aDoneDrag);
 
   // nsIDragSession
   NS_IMETHOD GetData(nsITransferable * aTransferable, PRUint32 aItemIndex);
   NS_IMETHOD IsDataFlavorSupported(const char *aDataFlavor, PRBool *_retval);
--- a/widget/src/cocoa/nsDragService.mm
+++ b/widget/src/cocoa/nsDragService.mm
@@ -70,33 +70,25 @@ extern NSView* globalDragView;
 extern NSEvent* globalDragEvent;
 
 // This global makes the transferable array available to Cocoa's promised
 // file destination callback.
 nsISupportsArray *gDraggedTransferables = nsnull;
 
 NSString* const kWildcardPboardType = @"MozillaWildcard";
 
-NS_IMPL_ADDREF_INHERITED(nsDragService, nsBaseDragService)
-NS_IMPL_RELEASE_INHERITED(nsDragService, nsBaseDragService)
-NS_IMPL_QUERY_INTERFACE2(nsDragService, nsIDragService, nsIDragSession)
-
-
 nsDragService::nsDragService()
 {
-
 }
 
 
 nsDragService::~nsDragService()
 {
-
 }
 
-
 static nsresult SetUpDragClipboard(nsISupportsArray* aTransferableArray)
 {
   if (!aTransferableArray)
     return NS_ERROR_FAILURE;
 
   PRUint32 count = 0;
   aTransferableArray->Count(&count);
 
--- a/widget/src/gtk2/nsDragService.cpp
+++ b/widget/src/gtk2/nsDragService.cpp
@@ -45,41 +45,32 @@
 #include "nsIObserverService.h"
 #include "nsWidgetsCID.h"
 #include "nsWindow.h"
 #include "nsIServiceManager.h"
 #include "nsXPCOM.h"
 #include "nsISupportsPrimitives.h"
 #include "prlog.h"
 #include "nsVoidArray.h"
-#include "nsXPIDLString.h"
 #include "nsPrimitiveHelpers.h"
 #include "prtime.h"
 #include "prthread.h"
 #include <gtk/gtkinvisible.h>
 #include <gdk/gdkx.h>
 #include "nsCRT.h"
 
 #include "gfxASurface.h"
 #include "nsImageToPixbuf.h"
 
 static PRLogModuleInfo *sDragLm = NULL;
 
 static const char gMimeListType[] = "application/x-moz-internal-item-list";
 static const char gMozUrlType[] = "_NETSCAPE_URL";
 static const char gTextUriListType[] = "text/uri-list";
 
-NS_IMPL_ADDREF_INHERITED(nsDragService, nsBaseDragService)
-NS_IMPL_RELEASE_INHERITED(nsDragService, nsBaseDragService)
-NS_IMPL_QUERY_INTERFACE4(nsDragService,
-                         nsIDragService,
-                         nsIDragSession,
-                         nsIDragSessionGTK,
-                         nsIObserver)
-
 static void
 invisibleSourceDragEnd(GtkWidget        *aWidget,
                        GdkDragContext   *aContext,
                        gpointer          aData);
 
 static void
 invisibleSourceDragDataGet(GtkWidget        *aWidget,
                            GdkDragContext   *aContext,
@@ -121,16 +112,19 @@ nsDragService::nsDragService()
     mTargetDragDataLen = 0;
 }
 
 nsDragService::~nsDragService()
 {
     PR_LOG(sDragLm, PR_LOG_DEBUG, ("nsDragService::~nsDragService"));
 }
 
+NS_IMPL_ISUPPORTS_INHERITED2(nsDragService, nsBaseDragService,
+                             nsIDragSessionGTK, nsIObserver)
+
 // nsIObserver
 
 NS_IMETHODIMP
 nsDragService::Observe(nsISupports *aSubject, const char *aTopic,
                        const PRUnichar *aData)
 {
   if (!nsCRT::strcmp(aTopic, "quit-application")) {
     PR_LOG(sDragLm, PR_LOG_DEBUG,
--- a/widget/src/os2/nsDeviceContextSpecOS2.cpp
+++ b/widget/src/os2/nsDeviceContextSpecOS2.cpp
@@ -1,8 +1,9 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* ***** 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/
  *
@@ -85,36 +86,28 @@ protected:
 };
 //---------------
 // static members
 GlobalPrinters GlobalPrinters::mGlobalPrinters;
 nsStringArray* GlobalPrinters::mGlobalPrinterList = nsnull;
 ULONG          GlobalPrinters::mGlobalNumPrinters = 0;
 //---------------
 
-/** -------------------------------------------------------
- *  Construct the nsDeviceContextSpecOS2
- *  @update   dc 12/02/98
- */
-nsDeviceContextSpecOS2 :: nsDeviceContextSpecOS2()
+nsDeviceContextSpecOS2::nsDeviceContextSpecOS2()
+  : mQueue(nsnull)
 {
-  mQueue = nsnull;
 }
 
-/** -------------------------------------------------------
- *  Destroy the nsDeviceContextSpecOS2
- *  @update   dc 2/15/98
- */
-nsDeviceContextSpecOS2 :: ~nsDeviceContextSpecOS2()
+nsDeviceContextSpecOS2::~nsDeviceContextSpecOS2()
 {
-  if( mQueue)
-     PrnClosePrinter( mQueue);
+  if (mQueue)
+    PrnClosePrinter(mQueue);
 }
 
-static NS_DEFINE_IID(kIDeviceContextSpecIID, NS_IDEVICE_CONTEXT_SPEC_IID);
+NS_IMPL_ISUPPORTS1(nsDeviceContextSpecOS2, nsIDeviceContextSpec)
 
 void SetupDevModeFromSettings(ULONG printer, nsIPrintSettings* aPrintSettings)
 {
   if (aPrintSettings) {
     int bufferSize = 3 * sizeof(DJP_ITEM);
     PBYTE pDJP_Buffer = new BYTE[bufferSize];
     memset(pDJP_Buffer, 0, bufferSize);
     PDJP_ITEM pDJP = (PDJP_ITEM) pDJP_Buffer;
@@ -214,46 +207,16 @@ nsresult nsDeviceContextSpecOS2::SetPrin
     }
   }
   
   delete [] pDJP_Buffer;
   DevCloseDC(hdc);  
   return NS_OK;
 }
 
-NS_IMETHODIMP nsDeviceContextSpecOS2 :: QueryInterface(REFNSIID aIID, void** aInstancePtr)
-{
-  NS_PRECONDITION(aInstancePtr, "null out param");
-
-  if (aIID.Equals(kIDeviceContextSpecIID))
-  {
-    nsIDeviceContextSpec* tmp = this;
-    *aInstancePtr = (void*) tmp;
-    NS_ADDREF_THIS();
-    return NS_OK;
-  }
-
-  static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
-
-  if (aIID.Equals(kISupportsIID))
-  {
-    nsIDeviceContextSpec* tmp = this;
-    nsISupports* tmp2 = tmp;
-    *aInstancePtr = (void*) tmp2;
-    NS_ADDREF_THIS();
-    return NS_OK;
-  }
-
-  *aInstancePtr = nsnull;
-  return NS_ERROR_NO_INTERFACE;
-}
-
-NS_IMPL_ADDREF(nsDeviceContextSpecOS2)
-NS_IMPL_RELEASE(nsDeviceContextSpecOS2)
-
 NS_IMETHODIMP nsDeviceContextSpecOS2::Init(nsIWidget *aWidget,
                                            nsIPrintSettings* aPS,
                                            PRBool aIsPrintPreview)
 {
   nsresult rv = NS_ERROR_FAILURE;
 
   mPrintSettings = aPS;
   NS_ASSERTION(aPS, "Must have a PrintSettings!");
--- a/widget/src/os2/nsDragService.cpp
+++ b/widget/src/os2/nsDragService.cpp
@@ -51,21 +51,16 @@
 #include "nsNetUtil.h"
 #include "nsOS2Uni.h"
 #include "nsdefs.h"
 #include "wdgtos2rc.h"
 #include "nsILocalFileOS2.h"
 #include "nsIDocument.h"
 #include "nsGUIEvent.h"
 
-NS_IMPL_ADDREF_INHERITED(nsDragService, nsBaseDragService)
-NS_IMPL_RELEASE_INHERITED(nsDragService, nsBaseDragService)
-NS_IMPL_QUERY_INTERFACE3(nsDragService, nsIDragService, nsIDragSession, \
-                         nsIDragSessionOS2)
-
 // --------------------------------------------------------------------------
 // Local defines
 
 // undocumented(?)
 #ifndef DC_PREPAREITEM
   #define DC_PREPAREITEM  0x0040
 #endif
 
@@ -130,16 +125,18 @@ nsDragService::~nsDragService()
   WinDestroyWindow(mDragWnd);
 
   for (int i = 0; i < IDC_DNDCOUNT; i++) {
     WinDestroyPointer(gPtrArray[i]);
     gPtrArray[i] = 0;
   }
 }
 
+NS_IMPL_ISUPPORTS_INHERITED1(nsDragService, nsBaseDragService, nsIDragSessionOS2)
+
 // --------------------------------------------------------------------------
 
 NS_IMETHODIMP nsDragService::InvokeDragSession(nsIDOMNode *aDOMNode,
                                             nsISupportsArray *aTransferables, 
                                             nsIScriptableRegion *aRegion,
                                             PRUint32 aActionType)
 {
   if (mDoingDrag)
--- a/widget/src/photon/nsDragService.cpp
+++ b/widget/src/photon/nsDragService.cpp
@@ -42,45 +42,31 @@
 #include "nsIRegion.h"
 #include "nsISupportsPrimitives.h"
 #include "nsPrimitiveHelpers.h"
 #include "nsCOMPtr.h"
 #include "nsXPIDLString.h"
 
 #include "nsWidgetsCID.h"
 
-NS_IMPL_ADDREF_INHERITED(nsDragService, nsBaseDragService)
-NS_IMPL_RELEASE_INHERITED(nsDragService, nsBaseDragService)
-NS_IMPL_QUERY_INTERFACE2(nsDragService, nsIDragService, nsIDragSession)
-
 char *nsDragService::mDndEvent = NULL;
 int nsDragService::mDndEventLen;
 
 #define kMimeCustom			"text/_moz_htmlcontext"
 
-//-------------------------------------------------------------------------
-//
-// DragService constructor
-//
-//-------------------------------------------------------------------------
 nsDragService::nsDragService()
 {
   mDndWidget = nsnull;
   mDndEvent = nsnull;
 	mNativeCtrl = nsnull;
 	mRawData = nsnull;
 	mFlavourStr = nsnull;
 	mTransportFile = nsnull;
 }
 
-//-------------------------------------------------------------------------
-//
-// DragService destructor
-//
-//-------------------------------------------------------------------------
 nsDragService::~nsDragService()
 {
 	if( mNativeCtrl ) PtReleaseTransportCtrl( mNativeCtrl );
 	if( mFlavourStr ) free( mFlavourStr );
 	if( mTransportFile ) {
 		unlink( mTransportFile );
 		free( mTransportFile );
 		}
--- a/widget/src/photon/nsDragService.h
+++ b/widget/src/photon/nsDragService.h
@@ -50,18 +50,16 @@
 
 class nsDragService : public nsBaseDragService
 {
 
 public:
   nsDragService();
   virtual ~nsDragService();
   
-  NS_DECL_ISUPPORTS_INHERITED
-
 	/* photon dependent stuff */
   NS_IMETHOD SetNativeDndData( PtWidget_t * widget, PhEvent_t *event );
 
 
   // nsIDragService
   NS_IMETHOD InvokeDragSession (nsIDOMNode *aDOMNode, nsISupportsArray * anArrayTransferables,
                                 nsIScriptableRegion * aRegion, PRUint32 aActionType);
 
--- a/widget/src/windows/nsWindow.cpp
+++ b/widget/src/windows/nsWindow.cpp
@@ -749,36 +749,16 @@ void nsWindow::GlobalMsgWindowProc(HWND 
     break;
   }
 }
 
 // End of the methods to dispatch global messages
 
 //-------------------------------------------------------------------------
 //
-// nsISupport stuff
-//
-//-------------------------------------------------------------------------
-NS_IMPL_ADDREF(nsWindow)
-NS_IMPL_RELEASE(nsWindow)
-NS_IMETHODIMP
-nsWindow::QueryInterface(const nsIID& aIID, void** aInstancePtr)
-{
-  NS_PRECONDITION(aInstancePtr, "null out param");
-
-  if (aIID.Equals(NS_GET_IID(nsIKBStateControl))) {
-    *aInstancePtr = static_cast<nsIKBStateControl*>(this);
-    NS_ADDREF(static_cast<nsBaseWidget*>(this));
-    return NS_OK;
-  }
-
-  return nsBaseWidget::QueryInterface(aIID,aInstancePtr);
-}
-//-------------------------------------------------------------------------
-//
 // nsWindow constructor
 //
 //-------------------------------------------------------------------------
 #ifdef ACCESSIBILITY
 nsWindow::nsWindow() : nsBaseWidget()
 #else
 nsWindow::nsWindow() : nsBaseWidget()
 #endif
@@ -914,16 +894,17 @@ nsWindow::~nsWindow()
 
     NS_IF_RELEASE(gCursorImgContainer);
   }
 
   NS_IF_RELEASE(mNativeDragTarget);
 
 }
 
+NS_IMPL_ISUPPORTS_INHERITED1(nsWindow, nsBaseWidget, nsIKBStateControl)
 
 NS_METHOD nsWindow::CaptureMouse(PRBool aCapture)
 {
   if (!nsToolkit::gMouseTrailer) {
     NS_ERROR("nsWindow::CaptureMouse called after nsToolkit destroyed");
     return NS_OK;
   }
 
--- a/widget/src/windows/nsWindow.h
+++ b/widget/src/windows/nsWindow.h
@@ -115,20 +115,17 @@ const LPCSTR kClassNameDialog         = 
 class nsWindow : public nsSwitchToUIThread,
                  public nsBaseWidget,
                  public nsIKBStateControl
 {
 public:
   nsWindow();
   virtual ~nsWindow();
 
-  // nsISupports
-  NS_IMETHOD_(nsrefcnt) AddRef(void);
-  NS_IMETHOD_(nsrefcnt) Release(void);
-  NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr);
+  NS_DECL_ISUPPORTS_INHERITED
 
   // nsIWidget interface
   NS_IMETHOD              Create(nsIWidget *aParent,
                                  const nsRect &aRect,
                                  EVENT_CALLBACK aHandleEventFunction,
                                  nsIDeviceContext *aContext,
                                  nsIAppShell *aAppShell = nsnull,
                                  nsIToolkit *aToolkit = nsnull,
--- a/widget/src/xpwidgets/nsBaseClipboard.cpp
+++ b/widget/src/xpwidgets/nsBaseClipboard.cpp
@@ -33,54 +33,36 @@
  * 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 "nsBaseClipboard.h"
 
 #include "nsIClipboardOwner.h"
-#include "nsString.h"
-
-#include "nsIWidget.h"
-#include "nsIComponentManager.h"
 #include "nsCOMPtr.h"
 #include "nsXPCOM.h"
 #include "nsISupportsPrimitives.h"
 
 
-NS_IMPL_ADDREF(nsBaseClipboard)
-NS_IMPL_RELEASE(nsBaseClipboard)
-NS_IMPL_QUERY_INTERFACE1(nsBaseClipboard, nsIClipboard)
-
-
-//-------------------------------------------------------------------------
-//
-// nsBaseClipboard constructor
-//
-//-------------------------------------------------------------------------
 nsBaseClipboard::nsBaseClipboard()
 {
   mClipboardOwner          = nsnull;
   mTransferable            = nsnull;
   mIgnoreEmptyNotification = PR_FALSE;
 
 }
 
-//-------------------------------------------------------------------------
-//
-// nsBaseClipboard destructor
-//
-//-------------------------------------------------------------------------
 nsBaseClipboard::~nsBaseClipboard()
 {
   EmptyClipboard(kSelectionClipboard);
   EmptyClipboard(kGlobalClipboard);
 }
 
+NS_IMPL_ISUPPORTS1(nsBaseClipboard, nsIClipboard)
 
 /**
   * Sets the transferable object
   *
   */
 NS_IMETHODIMP nsBaseClipboard::SetData(nsITransferable * aTransferable, nsIClipboardOwner * anOwner,
                                         PRInt32 aWhichClipboard)
 {
@@ -125,21 +107,16 @@ NS_IMETHODIMP nsBaseClipboard::GetData(n
     return NS_ERROR_FAILURE;
 
   if ( aTransferable )
     return GetNativeClipboardData(aTransferable, aWhichClipboard);
 
   return NS_ERROR_FAILURE;
 }
 
-
-/**
-  * 
-  *
-  */
 NS_IMETHODIMP nsBaseClipboard::EmptyClipboard(PRInt32 aWhichClipboard)
 {
   PRBool selectClipPresent;
   SupportsSelectionClipboard(&selectClipPresent);
   if ( !selectClipPresent && aWhichClipboard != kGlobalClipboard )
     return NS_ERROR_FAILURE;
 
   if (mIgnoreEmptyNotification)
@@ -150,27 +127,23 @@ NS_IMETHODIMP nsBaseClipboard::EmptyClip
     NS_RELEASE(mClipboardOwner);
   }
 
   NS_IF_RELEASE(mTransferable);
 
   return NS_OK;
 }
 
-
-/**
-  * 
-  *
-  */
 NS_IMETHODIMP
-nsBaseClipboard :: HasDataMatchingFlavors ( nsISupportsArray* aFlavorList, PRInt32 aWhichClipboard, PRBool * outResult ) 
+nsBaseClipboard::HasDataMatchingFlavors(nsISupportsArray* aFlavorList,
+                                        PRInt32 aWhichClipboard,
+                                        PRBool* outResult) 
 {
   *outResult = PR_TRUE;  // say we always do.
   return NS_OK;
 }
 
-
 NS_IMETHODIMP
-nsBaseClipboard :: SupportsSelectionClipboard ( PRBool *_retval )
+nsBaseClipboard::SupportsSelectionClipboard(PRBool* _retval)
 {
   *_retval = PR_FALSE;   // we don't support the selection clipboard by default.
   return NS_OK;
 }
--- a/widget/src/xpwidgets/nsBaseDragService.cpp
+++ b/widget/src/xpwidgets/nsBaseDragService.cpp
@@ -74,42 +74,28 @@
 #ifdef MOZ_CAIRO_GFX
 #include "gfxContext.h"
 #include "gfxImageSurface.h"
 
 #endif
 
 #define DRAGIMAGES_PREF "nglayout.enable_drag_images"
 
-NS_IMPL_ADDREF(nsBaseDragService)
-NS_IMPL_RELEASE(nsBaseDragService)
-NS_IMPL_QUERY_INTERFACE2(nsBaseDragService, nsIDragService, nsIDragSession)
-
-
-//-------------------------------------------------------------------------
-//
-// DragService constructor
-//
-//-------------------------------------------------------------------------
 nsBaseDragService::nsBaseDragService()
   : mCanDrop(PR_FALSE), mDoingDrag(PR_FALSE), mHasImage(PR_FALSE),
     mDragAction(DRAGDROP_ACTION_NONE), mTargetSize(0,0),
     mImageX(0), mImageY(0), mScreenX(-1), mScreenY(-1)
 {
 }
 
-//-------------------------------------------------------------------------
-//
-// DragService destructor
-//
-//-------------------------------------------------------------------------
 nsBaseDragService::~nsBaseDragService()
 {
 }
 
+NS_IMPL_ISUPPORTS2(nsBaseDragService, nsIDragService, nsIDragSession)
 
 //---------------------------------------------------------
 NS_IMETHODIMP
 nsBaseDragService::SetCanDrop(PRBool aCanDrop)
 {
   mCanDrop = aCanDrop;
   return NS_OK;
 }
--- a/widget/src/xpwidgets/nsHTMLFormatConverter.cpp
+++ b/widget/src/xpwidgets/nsHTMLFormatConverter.cpp
@@ -31,65 +31,47 @@
  * 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 "nsString.h"
+#include "nsHTMLFormatConverter.h"
+
 #include "nsCRT.h"
 #include "nsISupportsArray.h"
 #include "nsIComponentManager.h"
 #include "nsCOMPtr.h"
 #include "nsXPCOM.h"
 #include "nsISupportsPrimitives.h"
-#include "nsXPIDLString.h"
 
 #include "nsITransferable.h" // for mime defs, this is BAD
 
 // HTML convertor stuff
 #include "nsIParser.h"
 #include "nsIDTD.h"
 #include "nsParserCIID.h"
 #include "nsIContentSink.h"
-
-#include "nsString.h"
-#include "nsWidgetsCID.h"
-#include "nsHTMLFormatConverter.h"
 #include "nsPrimitiveHelpers.h"
 #include "nsIDocumentEncoder.h"
 #include "nsIHTMLToTextSink.h"
 
 static NS_DEFINE_CID(kCParserCID, NS_PARSER_CID);
 
-NS_IMPL_ADDREF(nsHTMLFormatConverter)
-NS_IMPL_RELEASE(nsHTMLFormatConverter)
-NS_IMPL_QUERY_INTERFACE1(nsHTMLFormatConverter, nsIFormatConverter)
-
-
-//-------------------------------------------------------------------------
-//
-// HTMLFormatConverter constructor
-//
-//-------------------------------------------------------------------------
 nsHTMLFormatConverter::nsHTMLFormatConverter()
 {
 }
 
-//-------------------------------------------------------------------------
-//
-// HTMLFormatConverter destructor
-//
-//-------------------------------------------------------------------------
 nsHTMLFormatConverter::~nsHTMLFormatConverter()
 {
 }
 
+NS_IMPL_ISUPPORTS1(nsHTMLFormatConverter, nsIFormatConverter)
 
 //
 // GetInputDataFlavors
 //
 // Creates a new list and returns the list of all the flavors this converter
 // knows how to import. In this case, it's just HTML.
 //
 // Flavors (strings) are wrapped in a primitive object so that JavaScript can
@@ -314,20 +296,16 @@ nsHTMLFormatConverter::ConvertFromHTMLTo
   parser->SetContentSink(sink);
 
   parser->Parse(aFromStr, 0, NS_LITERAL_CSTRING("text/html"), PR_TRUE, eDTDMode_fragment);
   
   return NS_OK;
 } // ConvertFromHTMLToUnicode
 
 
-/**
-  * 
-  *
-  */
 NS_IMETHODIMP
 nsHTMLFormatConverter::ConvertFromHTMLToAOLMail(const nsAutoString & aFromStr,
                                                 nsAutoString & aToStr)
 {
   aToStr.AssignLiteral("<HTML>");
   aToStr.Append(aFromStr);
   aToStr.AppendLiteral("</HTML>");