From 785de1f5f1ebd475b8273a3f1a209f476157e7b0 Mon Sep 17 00:00:00 2001 From: "dbaron%fas.harvard.edu" Date: Sun, 6 Jan 2002 18:37:27 +0000 Subject: [PATCH] Remove duplicate initialization of nsDeviceContext reference count by derived class constructor (which is dangerous since it could be incremented during the base class constructor). Various other cleanup, mostly in xlib port. b=111088 r=rbs sr=jag git-svn-id: svn://10.0.0.236/trunk@111451 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/gfx/src/beos/nsDeviceContextBeOS.cpp | 2 +- mozilla/gfx/src/gtk/nsDeviceContextGTK.cpp | 3 +- mozilla/gfx/src/mac/nsDeviceContextMac.cpp | 6 +- mozilla/gfx/src/photon/nsDeviceContextPh.cpp | 6 +- mozilla/gfx/src/ps/nsDeviceContextPS.cpp | 2 +- mozilla/gfx/src/ps/nsIDeviceContextSpecPS.h | 2 + mozilla/gfx/src/ps/nsPostScriptObj.cpp | 3 +- mozilla/gfx/src/qt/nsDeviceContextQT.cpp | 2 +- .../gfx/src/xlib/nsDeviceContextSpecXlib.cpp | 59 +++---------------- mozilla/widget/src/gtk/nsClipboard.cpp | 2 +- mozilla/widget/src/xlib/nsAppShell.cpp | 2 +- mozilla/widget/src/xlib/nsButton.cpp | 22 +------ mozilla/widget/src/xlib/nsButton.h | 5 +- mozilla/widget/src/xlib/nsCheckButton.cpp | 24 ++------ mozilla/widget/src/xlib/nsCheckButton.h | 5 +- mozilla/widget/src/xlib/nsClipboard.cpp | 4 +- mozilla/widget/src/xlib/nsDragService.cpp | 8 +-- mozilla/widget/src/xlib/nsLabel.cpp | 20 +------ mozilla/widget/src/xlib/nsLabel.h | 5 +- mozilla/widget/src/xlib/nsScrollBar.cpp | 4 +- mozilla/widget/src/xlib/nsScrollBar.h | 5 +- mozilla/widget/src/xlib/nsTextWidget.cpp | 18 +----- mozilla/widget/src/xlib/nsTextWidget.h | 5 +- mozilla/widget/src/xlib/nsToolkit.cpp | 2 +- mozilla/widget/src/xlib/nsWidget.h | 2 +- mozilla/widget/src/xlib/nsWindow.cpp | 1 - 26 files changed, 47 insertions(+), 172 deletions(-) diff --git a/mozilla/gfx/src/beos/nsDeviceContextBeOS.cpp b/mozilla/gfx/src/beos/nsDeviceContextBeOS.cpp index ccb91441a4a..c0e14846d58 100644 --- a/mozilla/gfx/src/beos/nsDeviceContextBeOS.cpp +++ b/mozilla/gfx/src/beos/nsDeviceContextBeOS.cpp @@ -62,8 +62,8 @@ static NS_DEFINE_CID(kPrefCID, NS_PREF_CID); nscoord nsDeviceContextBeOS::mDpi = 96; nsDeviceContextBeOS::nsDeviceContextBeOS() + : DeviceContextImpl() { - NS_INIT_REFCNT(); mTwipsToPixels = 1.0; mPixelsToTwips = 1.0; mDepth = 0 ; diff --git a/mozilla/gfx/src/gtk/nsDeviceContextGTK.cpp b/mozilla/gfx/src/gtk/nsDeviceContextGTK.cpp index 282502ec92c..2d0097d82b4 100644 --- a/mozilla/gfx/src/gtk/nsDeviceContextGTK.cpp +++ b/mozilla/gfx/src/gtk/nsDeviceContextGTK.cpp @@ -119,9 +119,8 @@ nscoord nsDeviceContextGTK::mDpi = 96; static nsSystemFontsGTK *gSystemFonts = nsnull; nsDeviceContextGTK::nsDeviceContextGTK() + : DeviceContextImpl() { - NS_INIT_REFCNT(); - mTwipsToPixels = 1.0; mPixelsToTwips = 1.0; mDepth = 0 ; diff --git a/mozilla/gfx/src/mac/nsDeviceContextMac.cpp b/mozilla/gfx/src/mac/nsDeviceContextMac.cpp index bd8102bb219..7e141faa9ed 100644 --- a/mozilla/gfx/src/mac/nsDeviceContextMac.cpp +++ b/mozilla/gfx/src/mac/nsDeviceContextMac.cpp @@ -78,10 +78,10 @@ PRUint32 nsDeviceContextMac::sNumberOfScreens = 0; * @update 12/9/98 dwc */ nsDeviceContextMac :: nsDeviceContextMac() - : mSurface(nsnull), mOldPort(nsnull) + : DeviceContextImpl(), + mSurface(nsnull), + mOldPort(nsnull) { - NS_INIT_REFCNT(); - } /** --------------------------------------------------- diff --git a/mozilla/gfx/src/photon/nsDeviceContextPh.cpp b/mozilla/gfx/src/photon/nsDeviceContextPh.cpp index e340dc4463b..deb44c7bb85 100644 --- a/mozilla/gfx/src/photon/nsDeviceContextPh.cpp +++ b/mozilla/gfx/src/photon/nsDeviceContextPh.cpp @@ -59,9 +59,9 @@ nscoord nsDeviceContextPh::mDpi = 96; static nsHashtable* mFontLoadCache = nsnull; -nsDeviceContextPh :: nsDeviceContextPh( ) { - NS_INIT_REFCNT(); - +nsDeviceContextPh :: nsDeviceContextPh( ) + : DeviceContextImpl() + { mTwipsToPixels = 1.0; mPixelsToTwips = 1.0; mDepth = 0 ; diff --git a/mozilla/gfx/src/ps/nsDeviceContextPS.cpp b/mozilla/gfx/src/ps/nsDeviceContextPS.cpp index e4dfc535faf..c21d93f34c3 100644 --- a/mozilla/gfx/src/ps/nsDeviceContextPS.cpp +++ b/mozilla/gfx/src/ps/nsDeviceContextPS.cpp @@ -51,8 +51,8 @@ static NS_DEFINE_IID(kIDeviceContextSpecPSIID, NS_IDEVICE_CONTEXT_SPEC_PS_IID); * @update 12/21/98 dwc */ nsDeviceContextPS :: nsDeviceContextPS() + : DeviceContextImpl() { - NS_INIT_REFCNT(); mSpec = nsnull; mParentDeviceContext = nsnull; } diff --git a/mozilla/gfx/src/ps/nsIDeviceContextSpecPS.h b/mozilla/gfx/src/ps/nsIDeviceContextSpecPS.h index 1eb07f17ac4..6aa5ba06841 100644 --- a/mozilla/gfx/src/ps/nsIDeviceContextSpecPS.h +++ b/mozilla/gfx/src/ps/nsIDeviceContextSpecPS.h @@ -53,6 +53,8 @@ class nsIDeviceContextSpecPS : public nsISupports { public: + NS_DEFINE_STATIC_IID_ACCESSOR(NS_IDEVICE_CONTEXT_SPEC_PS_IID) + /* * If PR_TRUE, print to printer * @update diff --git a/mozilla/gfx/src/ps/nsPostScriptObj.cpp b/mozilla/gfx/src/ps/nsPostScriptObj.cpp index 4a194d33634..d0d4df17694 100644 --- a/mozilla/gfx/src/ps/nsPostScriptObj.cpp +++ b/mozilla/gfx/src/ps/nsPostScriptObj.cpp @@ -1638,8 +1638,7 @@ PRBool nsPostScriptObj::InitUnixPrinterProps() { nsCOMPtr printerprops_tmp; - nsAutoString propertyURL; - propertyURL.Assign(NS_LITERAL_STRING("resource:/res/unixpsfonts.properties")); + const char propertyURL[] = "resource:/res/unixpsfonts.properties"; nsCOMPtr uri; NS_ENSURE_SUCCESS(NS_NewURI(getter_AddRefs(uri), propertyURL), PR_FALSE); nsCOMPtr in; diff --git a/mozilla/gfx/src/qt/nsDeviceContextQT.cpp b/mozilla/gfx/src/qt/nsDeviceContextQT.cpp index d295c07b1aa..580548a278a 100644 --- a/mozilla/gfx/src/qt/nsDeviceContextQT.cpp +++ b/mozilla/gfx/src/qt/nsDeviceContextQT.cpp @@ -69,8 +69,8 @@ static NS_DEFINE_CID(kPrefCID,NS_PREF_CID); nscoord nsDeviceContextQT::mDpi = 96; nsDeviceContextQT::nsDeviceContextQT() + : DeviceContextImpl() { - NS_INIT_REFCNT(); mTwipsToPixels = 1.0; mPixelsToTwips = 1.0; mDepth = 0 ; diff --git a/mozilla/gfx/src/xlib/nsDeviceContextSpecXlib.cpp b/mozilla/gfx/src/xlib/nsDeviceContextSpecXlib.cpp index 263179e29dd..e60a6638673 100644 --- a/mozilla/gfx/src/xlib/nsDeviceContextSpecXlib.cpp +++ b/mozilla/gfx/src/xlib/nsDeviceContextSpecXlib.cpp @@ -97,60 +97,17 @@ nsDeviceContextSpecXlib::~nsDeviceContextSpecXlib() { } -static NS_DEFINE_IID(kIDeviceContextSpecIID, NS_IDEVICE_CONTEXT_SPEC_IID); -static NS_DEFINE_IID(kIDeviceContextSpecPSIID, NS_IDEVICE_CONTEXT_SPEC_PS_IID); #ifdef USE_XPRINT -static NS_DEFINE_IID(kIDeviceContextSpecXPIID, NS_IDEVICE_CONTEXT_SPEC_XP_IID); +NS_IMPL_ISUPPORTS3(nsDeviceContextSpecXlib, + nsIDeviceContextSpec, + nsIDeviceContextSpecPS, + nsIDeviceContextSpecXp) +#else +NS_IMPL_ISUPPORTS2(nsDeviceContextSpecXlib, + nsIDeviceContextSpec, + nsIDeviceContextSpecPS) #endif -NS_IMETHODIMP nsDeviceContextSpecXlib::QueryInterface(REFNSIID aIID, void **aInstancePtr) -{ - if (nsnull == aInstancePtr) - return NS_ERROR_NULL_POINTER; - - if (aIID.Equals(kIDeviceContextSpecIID)) - { - nsIDeviceContextSpec *tmp = this; - *aInstancePtr = (void *) tmp; - NS_ADDREF_THIS(); - return NS_OK; - } - - if (aIID.Equals(kIDeviceContextSpecPSIID)) - { - nsIDeviceContextSpecPS *tmp = this; - *aInstancePtr = (void *) tmp; - NS_ADDREF_THIS(); - return NS_OK; - } - -#ifdef USE_XPRINT - if (aIID.Equals(kIDeviceContextSpecXPIID)) - { - nsIDeviceContextSpecXp *tmp = this; - *aInstancePtr = (void*) tmp; - NS_ADDREF_THIS(); - return NS_OK; - } -#endif /* USE_XPRINT */ - - 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; - } - - return NS_NOINTERFACE; -} - -NS_IMPL_ADDREF(nsDeviceContextSpecXlib) -NS_IMPL_RELEASE(nsDeviceContextSpecXlib) - /** ------------------------------------------------------- */ static nsresult DisplayXPDialog(nsIPrintSettings* aPS, diff --git a/mozilla/widget/src/gtk/nsClipboard.cpp b/mozilla/widget/src/gtk/nsClipboard.cpp index 872cfd50fb3..ca4d8baa21c 100644 --- a/mozilla/widget/src/gtk/nsClipboard.cpp +++ b/mozilla/widget/src/gtk/nsClipboard.cpp @@ -447,7 +447,7 @@ nsClipboard::GetNativeClipboardData(nsITransferable * aTransferable, nsXPIDLCString flavorStr; currentFlavor->ToString ( getter_Copies(flavorStr) ); if (DoConvert(flavorStr, selectionAtom)) { - foundFlavor = nsCAutoString(flavorStr); + foundFlavor = flavorStr; foundData = PR_TRUE; break; } diff --git a/mozilla/widget/src/xlib/nsAppShell.cpp b/mozilla/widget/src/xlib/nsAppShell.cpp index 360e10352eb..85e5a2bef62 100644 --- a/mozilla/widget/src/xlib/nsAppShell.cpp +++ b/mozilla/widget/src/xlib/nsAppShell.cpp @@ -1063,7 +1063,7 @@ nsAppShell::HandleEnterEvent(XEvent *event, nsWidget *aWidget) // make sure this is in focus. This will do until I rewrite all the // focus routines. KenF - aWidget->SetFocus(PR_FALSE); + aWidget->SetFocus(); NS_ADDREF(aWidget); aWidget->DispatchWindowEvent(enterEvent); diff --git a/mozilla/widget/src/xlib/nsButton.cpp b/mozilla/widget/src/xlib/nsButton.cpp index 3dafbcd17cc..5205cb7de36 100644 --- a/mozilla/widget/src/xlib/nsButton.cpp +++ b/mozilla/widget/src/xlib/nsButton.cpp @@ -37,12 +37,8 @@ #include "nsButton.h" -NS_IMPL_ADDREF(nsButton) -NS_IMPL_RELEASE(nsButton) - -nsButton::nsButton() : nsWidget() , nsIButton() +nsButton::nsButton() : nsWidget() { - NS_INIT_REFCNT(); mName.Assign(NS_LITERAL_STRING("nsButton")); } @@ -50,21 +46,7 @@ nsButton::~nsButton() { } -nsresult nsButton::QueryInterface(const nsIID& aIID, void** aInstancePtr) -{ - if (NULL == aInstancePtr) { - return NS_ERROR_NULL_POINTER; - } - - static NS_DEFINE_IID(kIButton, NS_IBUTTON_IID); - if (aIID.Equals(kIButton)) { - *aInstancePtr = (void*) ((nsIButton*)this); - NS_ADDREF_THIS(); - return NS_OK; - } - - return nsWidget::QueryInterface(aIID,aInstancePtr); -} +NS_IMPL_ISUPPORTS_INHERITED1(nsButton, nsWidget, nsIButton) NS_METHOD nsButton::SetLabel (const nsString &aText) { diff --git a/mozilla/widget/src/xlib/nsButton.h b/mozilla/widget/src/xlib/nsButton.h index 291447ad709..df8918f5a5f 100644 --- a/mozilla/widget/src/xlib/nsButton.h +++ b/mozilla/widget/src/xlib/nsButton.h @@ -48,10 +48,7 @@ class nsButton : public nsWidget, nsButton(); virtual ~nsButton(); - // from nsISupports - NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr); - NS_IMETHOD_(nsrefcnt) AddRef(void); - NS_IMETHOD_(nsrefcnt) Release(void); + NS_DECL_ISUPPORTS_INHERITED // from nsIButton NS_IMETHOD SetLabel(const nsString& aText); diff --git a/mozilla/widget/src/xlib/nsCheckButton.cpp b/mozilla/widget/src/xlib/nsCheckButton.cpp index 697ed60df6a..2d1b80757c5 100644 --- a/mozilla/widget/src/xlib/nsCheckButton.cpp +++ b/mozilla/widget/src/xlib/nsCheckButton.cpp @@ -37,33 +37,17 @@ #include "nsCheckButton.h" -NS_IMPL_ADDREF(nsCheckButton) -NS_IMPL_RELEASE(nsCheckButton) - -nsCheckButton::nsCheckButton() : nsWidget() , nsICheckButton(), - mState(PR_FALSE) +nsCheckButton::nsCheckButton() + : nsWidget(), + mState(PR_FALSE) { - NS_INIT_REFCNT(); } nsCheckButton::~nsCheckButton() { } -nsresult nsCheckButton::QueryInterface(const nsIID& aIID, void** aInstancePtr) -{ - if (NULL == aInstancePtr) { - return NS_ERROR_NULL_POINTER; - } - - static NS_DEFINE_IID(kICheckButtonIID, NS_ICHECKBUTTON_IID); - if (aIID.Equals(kICheckButtonIID)) { - *aInstancePtr = (void*) ((nsICheckButton*)this); - NS_ADDREF_THIS(); - return NS_OK; - } - return nsWidget::QueryInterface(aIID,aInstancePtr); -} +NS_IMPL_ISUPPORTS_INHERITED1(nsCheckButton, nsWidget, nsICheckButton) NS_METHOD nsCheckButton::SetState(const PRBool aState) { diff --git a/mozilla/widget/src/xlib/nsCheckButton.h b/mozilla/widget/src/xlib/nsCheckButton.h index e0e2e90d3d9..ab1eb22649e 100644 --- a/mozilla/widget/src/xlib/nsCheckButton.h +++ b/mozilla/widget/src/xlib/nsCheckButton.h @@ -50,10 +50,7 @@ public: nsCheckButton(); virtual ~nsCheckButton(); - // nsISupports - NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr); - NS_IMETHOD_(nsrefcnt) AddRef(void); - NS_IMETHOD_(nsrefcnt) Release(void); + NS_DECL_ISUPPORTS_INHERITED // nsICheckButton part NS_IMETHOD SetLabel(const nsString &aText); diff --git a/mozilla/widget/src/xlib/nsClipboard.cpp b/mozilla/widget/src/xlib/nsClipboard.cpp index b30436e65df..b2c3ea6e501 100644 --- a/mozilla/widget/src/xlib/nsClipboard.cpp +++ b/mozilla/widget/src/xlib/nsClipboard.cpp @@ -83,10 +83,10 @@ Display *nsClipboard::sDisplay; #define DEBUG_CLIPBOARD #endif -NS_IMPL_ISUPPORTS1(nsClipboard, nsIClipboard); +NS_IMPL_ISUPPORTS1(nsClipboard, nsIClipboard) nsClipboard::nsClipboard() { - NS_INIT_REFCNT(); + NS_INIT_ISUPPORTS(); sDisplay = xxlib_rgb_get_display(nsAppShell::GetXlibRgbHandle()); diff --git a/mozilla/widget/src/xlib/nsDragService.cpp b/mozilla/widget/src/xlib/nsDragService.cpp index 76af2475fe7..61c89136ca7 100644 --- a/mozilla/widget/src/xlib/nsDragService.cpp +++ b/mozilla/widget/src/xlib/nsDragService.cpp @@ -37,6 +37,10 @@ #include "xlibrgb.h" +NS_IMPL_ISUPPORTS_INHERITED1(nsDragService, + nsBaseDragService, + nsIDragSessionXlib) + /* drag bitmaps */ static const unsigned char drag_bitmap[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, @@ -64,10 +68,6 @@ static const unsigned char drag_mask[] = { 0x00, 0x7c, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; -NS_IMPL_ADDREF_INHERITED(nsDragService, nsBaseDragService) -NS_IMPL_RELEASE_INHERITED(nsDragService, nsBaseDragService) -NS_IMPL_QUERY_INTERFACE3(nsDragService, nsIDragService, nsIDragSession, nsIDragSessionXlib) - nsWidget *nsDragService::sWidget = nsnull; Window nsDragService::sWindow; XlibRgbHandle *nsDragService::sXlibRgbHandle; diff --git a/mozilla/widget/src/xlib/nsLabel.cpp b/mozilla/widget/src/xlib/nsLabel.cpp index b782fa6731e..e41dc10c62a 100644 --- a/mozilla/widget/src/xlib/nsLabel.cpp +++ b/mozilla/widget/src/xlib/nsLabel.cpp @@ -37,12 +37,8 @@ #include "nsLabel.h" -NS_IMPL_ADDREF(nsLabel) -NS_IMPL_RELEASE(nsLabel) - -nsLabel::nsLabel() : nsWidget(), nsILabel() +nsLabel::nsLabel() : nsWidget() { - NS_INIT_REFCNT(); } NS_METHOD nsLabel::PreCreateWidget(nsWidgetInitData *aInitData) @@ -54,19 +50,7 @@ nsLabel::~nsLabel() { } -nsresult nsLabel::QueryInterface(const nsIID& aIID, void** aInstancePtr) -{ - nsresult result = nsWidget::QueryInterface(aIID, aInstancePtr); - - static NS_DEFINE_IID(kILabelIID, NS_ILABEL_IID); - if (result == NS_NOINTERFACE && aIID.Equals(kILabelIID)) { - *aInstancePtr = (void*) ((nsILabel*)this); - NS_ADDREF_THIS(); - result = NS_OK; - } - - return result; -} +NS_IMPL_ISUPPORTS_INHERITED1(nsLabel, nsWidget, nsILabel) NS_METHOD nsLabel::SetAlignment(nsLabelAlignment aAlignment) { diff --git a/mozilla/widget/src/xlib/nsLabel.h b/mozilla/widget/src/xlib/nsLabel.h index 4c664bb84ec..b0969a295a0 100644 --- a/mozilla/widget/src/xlib/nsLabel.h +++ b/mozilla/widget/src/xlib/nsLabel.h @@ -53,10 +53,7 @@ public: nsLabel(); virtual ~nsLabel(); - // nsISupports - NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr); - NS_IMETHOD_(nsrefcnt) AddRef(void); - NS_IMETHOD_(nsrefcnt) Release(void); + NS_DECL_ISUPPORTS_INHERITED // nsILabel part NS_IMETHOD SetLabel(const nsString &aText); diff --git a/mozilla/widget/src/xlib/nsScrollBar.cpp b/mozilla/widget/src/xlib/nsScrollBar.cpp index 679ecaf7b1c..8900e269b5d 100644 --- a/mozilla/widget/src/xlib/nsScrollBar.cpp +++ b/mozilla/widget/src/xlib/nsScrollBar.cpp @@ -45,13 +45,13 @@ NS_IMPL_ADDREF_INHERITED(nsScrollbar, nsWidget) NS_IMPL_RELEASE_INHERITED(nsScrollbar, nsWidget) + // XXX not INHERITED? NS_IMPL_QUERY_INTERFACE2(nsScrollbar, nsIScrollbar, nsIWidget) PRLogModuleInfo *XlibScrollbarLM = PR_NewLogModule("XlibScrollbar"); -nsScrollbar::nsScrollbar(PRBool aIsVertical) : nsWidget(), nsIScrollbar() +nsScrollbar::nsScrollbar(PRBool aIsVertical) : nsWidget() { - NS_INIT_REFCNT(); mMaxRange = 0; mPosition = 0; mThumbSize = 0; diff --git a/mozilla/widget/src/xlib/nsScrollBar.h b/mozilla/widget/src/xlib/nsScrollBar.h index e78c06da621..75b4537e772 100644 --- a/mozilla/widget/src/xlib/nsScrollBar.h +++ b/mozilla/widget/src/xlib/nsScrollBar.h @@ -49,10 +49,7 @@ public: nsScrollbar(PRBool aIsVertical); virtual ~nsScrollbar(); - // nsISupports - NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr); - NS_IMETHOD_(nsrefcnt) AddRef(void); - NS_IMETHOD_(nsrefcnt) Release(void); + NS_DECL_ISUPPORTS_INHERITED // Override some of the native widget methods for scrollbars PRBool OnResize (nsSizeEvent &event); diff --git a/mozilla/widget/src/xlib/nsTextWidget.cpp b/mozilla/widget/src/xlib/nsTextWidget.cpp index 881ee0cd598..685ae16f4f6 100644 --- a/mozilla/widget/src/xlib/nsTextWidget.cpp +++ b/mozilla/widget/src/xlib/nsTextWidget.cpp @@ -37,12 +37,8 @@ #include "nsTextWidget.h" -NS_IMPL_ADDREF(nsTextWidget) -NS_IMPL_RELEASE(nsTextWidget) - nsTextWidget::nsTextWidget() : nsTextHelper() { - NS_INIT_REFCNT(); mName.Assign(NS_LITERAL_STRING("nsTextWidget")); } @@ -50,19 +46,7 @@ nsTextWidget::~nsTextWidget() { } -nsresult nsTextWidget::QueryInterface(const nsIID& aIID, void** aInstancePtr) -{ - nsresult result = nsWidget::QueryInterface(aIID, aInstancePtr); - - static NS_DEFINE_IID(kInsTextWidgetIID, NS_ITEXTWIDGET_IID); - if (result == NS_NOINTERFACE && aIID.Equals(kInsTextWidgetIID)) { - *aInstancePtr = (void*) ((nsITextWidget*)this); - NS_ADDREF_THIS(); - result = NS_OK; - } - - return result; -} +NS_IMPL_ISUPPORTS_INHERITED1(nsTextWidget, nsWidget, nsITextWidget) NS_METHOD nsTextWidget::Paint(nsIRenderingContext& aRenderingContext, const nsRect& aDirtyRect) diff --git a/mozilla/widget/src/xlib/nsTextWidget.h b/mozilla/widget/src/xlib/nsTextWidget.h index 39029bf9d9a..6c10107f4a1 100644 --- a/mozilla/widget/src/xlib/nsTextWidget.h +++ b/mozilla/widget/src/xlib/nsTextWidget.h @@ -49,10 +49,7 @@ public: nsTextWidget(); virtual ~nsTextWidget(); - // nsISupports - NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr); - NS_IMETHOD_(nsrefcnt) AddRef(void); - NS_IMETHOD_(nsrefcnt) Release(void); + NS_DECL_ISUPPORTS_INHERITED NS_IMETHOD Paint(nsIRenderingContext& aRenderingContext, const nsRect& aDirtyRect); diff --git a/mozilla/widget/src/xlib/nsToolkit.cpp b/mozilla/widget/src/xlib/nsToolkit.cpp index 8d0c0ced4af..74f89cdb9ef 100644 --- a/mozilla/widget/src/xlib/nsToolkit.cpp +++ b/mozilla/widget/src/xlib/nsToolkit.cpp @@ -47,7 +47,7 @@ static PRUintn gToolkitTLSIndex = 0; nsToolkit::nsToolkit() { - NS_INIT_REFCNT(); + NS_INIT_ISUPPORTS(); mGC = nsnull; mDisplay = xxlib_rgb_get_display(nsAppShell::GetXlibRgbHandle()); } diff --git a/mozilla/widget/src/xlib/nsWidget.h b/mozilla/widget/src/xlib/nsWidget.h index b1d3f48650c..6f43b016078 100644 --- a/mozilla/widget/src/xlib/nsWidget.h +++ b/mozilla/widget/src/xlib/nsWidget.h @@ -103,7 +103,7 @@ public: PRBool aRepaint); NS_IMETHOD Enable(PRBool bState); - NS_IMETHOD SetFocus(PRBool aRaise); + NS_IMETHOD SetFocus(PRBool aRaise = PR_FALSE); NS_IMETHOD SetName(const char * aName); NS_IMETHOD SetBackgroundColor(const nscolor &aColor); virtual nsIFontMetrics* GetFont(void); diff --git a/mozilla/widget/src/xlib/nsWindow.cpp b/mozilla/widget/src/xlib/nsWindow.cpp index 01a8f4c3454..d2edcb8fcdd 100644 --- a/mozilla/widget/src/xlib/nsWindow.cpp +++ b/mozilla/widget/src/xlib/nsWindow.cpp @@ -206,7 +206,6 @@ NS_IMPL_ISUPPORTS_INHERITED0(nsWindow, nsWidget) nsWindow::nsWindow() : nsWidget() { - NS_INIT_REFCNT(); mName.Assign(NS_LITERAL_STRING("nsWindow")); mBackground = NS_RGB(255, 255, 255); mBackgroundPixel = xxlib_rgb_xpixel_from_rgb(mXlibRgbHandle, mBackground);