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

This commit is contained in:
dbaron%fas.harvard.edu 2002-01-06 18:37:27 +00:00
Родитель 561311a8b2
Коммит 6ef5940320
26 изменённых файлов: 47 добавлений и 172 удалений

Просмотреть файл

@ -62,8 +62,8 @@ static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
nscoord nsDeviceContextBeOS::mDpi = 96; nscoord nsDeviceContextBeOS::mDpi = 96;
nsDeviceContextBeOS::nsDeviceContextBeOS() nsDeviceContextBeOS::nsDeviceContextBeOS()
: DeviceContextImpl()
{ {
NS_INIT_REFCNT();
mTwipsToPixels = 1.0; mTwipsToPixels = 1.0;
mPixelsToTwips = 1.0; mPixelsToTwips = 1.0;
mDepth = 0 ; mDepth = 0 ;

Просмотреть файл

@ -119,9 +119,8 @@ nscoord nsDeviceContextGTK::mDpi = 96;
static nsSystemFontsGTK *gSystemFonts = nsnull; static nsSystemFontsGTK *gSystemFonts = nsnull;
nsDeviceContextGTK::nsDeviceContextGTK() nsDeviceContextGTK::nsDeviceContextGTK()
: DeviceContextImpl()
{ {
NS_INIT_REFCNT();
mTwipsToPixels = 1.0; mTwipsToPixels = 1.0;
mPixelsToTwips = 1.0; mPixelsToTwips = 1.0;
mDepth = 0 ; mDepth = 0 ;

Просмотреть файл

@ -78,10 +78,10 @@ PRUint32 nsDeviceContextMac::sNumberOfScreens = 0;
* @update 12/9/98 dwc * @update 12/9/98 dwc
*/ */
nsDeviceContextMac :: nsDeviceContextMac() nsDeviceContextMac :: nsDeviceContextMac()
: mSurface(nsnull), mOldPort(nsnull) : DeviceContextImpl(),
mSurface(nsnull),
mOldPort(nsnull)
{ {
NS_INIT_REFCNT();
} }
/** --------------------------------------------------- /** ---------------------------------------------------

Просмотреть файл

@ -59,9 +59,9 @@ nscoord nsDeviceContextPh::mDpi = 96;
static nsHashtable* mFontLoadCache = nsnull; static nsHashtable* mFontLoadCache = nsnull;
nsDeviceContextPh :: nsDeviceContextPh( ) { nsDeviceContextPh :: nsDeviceContextPh( )
NS_INIT_REFCNT(); : DeviceContextImpl()
{
mTwipsToPixels = 1.0; mTwipsToPixels = 1.0;
mPixelsToTwips = 1.0; mPixelsToTwips = 1.0;
mDepth = 0 ; mDepth = 0 ;

Просмотреть файл

@ -51,8 +51,8 @@ static NS_DEFINE_IID(kIDeviceContextSpecPSIID, NS_IDEVICE_CONTEXT_SPEC_PS_IID);
* @update 12/21/98 dwc * @update 12/21/98 dwc
*/ */
nsDeviceContextPS :: nsDeviceContextPS() nsDeviceContextPS :: nsDeviceContextPS()
: DeviceContextImpl()
{ {
NS_INIT_REFCNT();
mSpec = nsnull; mSpec = nsnull;
mParentDeviceContext = nsnull; mParentDeviceContext = nsnull;
} }

Просмотреть файл

@ -53,6 +53,8 @@ class nsIDeviceContextSpecPS : public nsISupports
{ {
public: public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IDEVICE_CONTEXT_SPEC_PS_IID)
/* /*
* If PR_TRUE, print to printer * If PR_TRUE, print to printer
* @update * @update

Просмотреть файл

@ -1638,8 +1638,7 @@ PRBool
nsPostScriptObj::InitUnixPrinterProps() nsPostScriptObj::InitUnixPrinterProps()
{ {
nsCOMPtr<nsIPersistentProperties> printerprops_tmp; nsCOMPtr<nsIPersistentProperties> printerprops_tmp;
nsAutoString propertyURL; const char propertyURL[] = "resource:/res/unixpsfonts.properties";
propertyURL.Assign(NS_LITERAL_STRING("resource:/res/unixpsfonts.properties"));
nsCOMPtr<nsIURI> uri; nsCOMPtr<nsIURI> uri;
NS_ENSURE_SUCCESS(NS_NewURI(getter_AddRefs(uri), propertyURL), PR_FALSE); NS_ENSURE_SUCCESS(NS_NewURI(getter_AddRefs(uri), propertyURL), PR_FALSE);
nsCOMPtr<nsIInputStream> in; nsCOMPtr<nsIInputStream> in;

Просмотреть файл

@ -69,8 +69,8 @@ static NS_DEFINE_CID(kPrefCID,NS_PREF_CID);
nscoord nsDeviceContextQT::mDpi = 96; nscoord nsDeviceContextQT::mDpi = 96;
nsDeviceContextQT::nsDeviceContextQT() nsDeviceContextQT::nsDeviceContextQT()
: DeviceContextImpl()
{ {
NS_INIT_REFCNT();
mTwipsToPixels = 1.0; mTwipsToPixels = 1.0;
mPixelsToTwips = 1.0; mPixelsToTwips = 1.0;
mDepth = 0 ; mDepth = 0 ;

Просмотреть файл

@ -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 #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 #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, static nsresult DisplayXPDialog(nsIPrintSettings* aPS,

Просмотреть файл

@ -447,7 +447,7 @@ nsClipboard::GetNativeClipboardData(nsITransferable * aTransferable,
nsXPIDLCString flavorStr; nsXPIDLCString flavorStr;
currentFlavor->ToString ( getter_Copies(flavorStr) ); currentFlavor->ToString ( getter_Copies(flavorStr) );
if (DoConvert(flavorStr, selectionAtom)) { if (DoConvert(flavorStr, selectionAtom)) {
foundFlavor = nsCAutoString(flavorStr); foundFlavor = flavorStr;
foundData = PR_TRUE; foundData = PR_TRUE;
break; break;
} }

Просмотреть файл

@ -1063,7 +1063,7 @@ nsAppShell::HandleEnterEvent(XEvent *event, nsWidget *aWidget)
// make sure this is in focus. This will do until I rewrite all the // make sure this is in focus. This will do until I rewrite all the
// focus routines. KenF // focus routines. KenF
aWidget->SetFocus(PR_FALSE); aWidget->SetFocus();
NS_ADDREF(aWidget); NS_ADDREF(aWidget);
aWidget->DispatchWindowEvent(enterEvent); aWidget->DispatchWindowEvent(enterEvent);

Просмотреть файл

@ -37,12 +37,8 @@
#include "nsButton.h" #include "nsButton.h"
NS_IMPL_ADDREF(nsButton) nsButton::nsButton() : nsWidget()
NS_IMPL_RELEASE(nsButton)
nsButton::nsButton() : nsWidget() , nsIButton()
{ {
NS_INIT_REFCNT();
mName.Assign(NS_LITERAL_STRING("nsButton")); mName.Assign(NS_LITERAL_STRING("nsButton"));
} }
@ -50,21 +46,7 @@ nsButton::~nsButton()
{ {
} }
nsresult nsButton::QueryInterface(const nsIID& aIID, void** aInstancePtr) NS_IMPL_ISUPPORTS_INHERITED1(nsButton, nsWidget, nsIButton)
{
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_METHOD nsButton::SetLabel (const nsString &aText) NS_METHOD nsButton::SetLabel (const nsString &aText)
{ {

Просмотреть файл

@ -48,10 +48,7 @@ class nsButton : public nsWidget,
nsButton(); nsButton();
virtual ~nsButton(); virtual ~nsButton();
// from nsISupports NS_DECL_ISUPPORTS_INHERITED
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr);
NS_IMETHOD_(nsrefcnt) AddRef(void);
NS_IMETHOD_(nsrefcnt) Release(void);
// from nsIButton // from nsIButton
NS_IMETHOD SetLabel(const nsString& aText); NS_IMETHOD SetLabel(const nsString& aText);

Просмотреть файл

@ -37,33 +37,17 @@
#include "nsCheckButton.h" #include "nsCheckButton.h"
NS_IMPL_ADDREF(nsCheckButton) nsCheckButton::nsCheckButton()
NS_IMPL_RELEASE(nsCheckButton) : nsWidget(),
mState(PR_FALSE)
nsCheckButton::nsCheckButton() : nsWidget() , nsICheckButton(),
mState(PR_FALSE)
{ {
NS_INIT_REFCNT();
} }
nsCheckButton::~nsCheckButton() nsCheckButton::~nsCheckButton()
{ {
} }
nsresult nsCheckButton::QueryInterface(const nsIID& aIID, void** aInstancePtr) NS_IMPL_ISUPPORTS_INHERITED1(nsCheckButton, nsWidget, nsICheckButton)
{
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_METHOD nsCheckButton::SetState(const PRBool aState) NS_METHOD nsCheckButton::SetState(const PRBool aState)
{ {

Просмотреть файл

@ -50,10 +50,7 @@ public:
nsCheckButton(); nsCheckButton();
virtual ~nsCheckButton(); virtual ~nsCheckButton();
// nsISupports NS_DECL_ISUPPORTS_INHERITED
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr);
NS_IMETHOD_(nsrefcnt) AddRef(void);
NS_IMETHOD_(nsrefcnt) Release(void);
// nsICheckButton part // nsICheckButton part
NS_IMETHOD SetLabel(const nsString &aText); NS_IMETHOD SetLabel(const nsString &aText);

Просмотреть файл

@ -83,10 +83,10 @@ Display *nsClipboard::sDisplay;
#define DEBUG_CLIPBOARD #define DEBUG_CLIPBOARD
#endif #endif
NS_IMPL_ISUPPORTS1(nsClipboard, nsIClipboard); NS_IMPL_ISUPPORTS1(nsClipboard, nsIClipboard)
nsClipboard::nsClipboard() { nsClipboard::nsClipboard() {
NS_INIT_REFCNT(); NS_INIT_ISUPPORTS();
sDisplay = xxlib_rgb_get_display(nsAppShell::GetXlibRgbHandle()); sDisplay = xxlib_rgb_get_display(nsAppShell::GetXlibRgbHandle());

Просмотреть файл

@ -37,6 +37,10 @@
#include "xlibrgb.h" #include "xlibrgb.h"
NS_IMPL_ISUPPORTS_INHERITED1(nsDragService,
nsBaseDragService,
nsIDragSessionXlib)
/* drag bitmaps */ /* drag bitmaps */
static const unsigned char drag_bitmap[] = { static const unsigned char drag_bitmap[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 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, 0x7c, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 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; nsWidget *nsDragService::sWidget = nsnull;
Window nsDragService::sWindow; Window nsDragService::sWindow;
XlibRgbHandle *nsDragService::sXlibRgbHandle; XlibRgbHandle *nsDragService::sXlibRgbHandle;

Просмотреть файл

@ -37,12 +37,8 @@
#include "nsLabel.h" #include "nsLabel.h"
NS_IMPL_ADDREF(nsLabel) nsLabel::nsLabel() : nsWidget()
NS_IMPL_RELEASE(nsLabel)
nsLabel::nsLabel() : nsWidget(), nsILabel()
{ {
NS_INIT_REFCNT();
} }
NS_METHOD nsLabel::PreCreateWidget(nsWidgetInitData *aInitData) NS_METHOD nsLabel::PreCreateWidget(nsWidgetInitData *aInitData)
@ -54,19 +50,7 @@ nsLabel::~nsLabel()
{ {
} }
nsresult nsLabel::QueryInterface(const nsIID& aIID, void** aInstancePtr) NS_IMPL_ISUPPORTS_INHERITED1(nsLabel, nsWidget, nsILabel)
{
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_METHOD nsLabel::SetAlignment(nsLabelAlignment aAlignment) NS_METHOD nsLabel::SetAlignment(nsLabelAlignment aAlignment)
{ {

Просмотреть файл

@ -53,10 +53,7 @@ public:
nsLabel(); nsLabel();
virtual ~nsLabel(); virtual ~nsLabel();
// nsISupports NS_DECL_ISUPPORTS_INHERITED
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr);
NS_IMETHOD_(nsrefcnt) AddRef(void);
NS_IMETHOD_(nsrefcnt) Release(void);
// nsILabel part // nsILabel part
NS_IMETHOD SetLabel(const nsString &aText); NS_IMETHOD SetLabel(const nsString &aText);

Просмотреть файл

@ -45,13 +45,13 @@
NS_IMPL_ADDREF_INHERITED(nsScrollbar, nsWidget) NS_IMPL_ADDREF_INHERITED(nsScrollbar, nsWidget)
NS_IMPL_RELEASE_INHERITED(nsScrollbar, nsWidget) NS_IMPL_RELEASE_INHERITED(nsScrollbar, nsWidget)
// XXX not INHERITED?
NS_IMPL_QUERY_INTERFACE2(nsScrollbar, nsIScrollbar, nsIWidget) NS_IMPL_QUERY_INTERFACE2(nsScrollbar, nsIScrollbar, nsIWidget)
PRLogModuleInfo *XlibScrollbarLM = PR_NewLogModule("XlibScrollbar"); PRLogModuleInfo *XlibScrollbarLM = PR_NewLogModule("XlibScrollbar");
nsScrollbar::nsScrollbar(PRBool aIsVertical) : nsWidget(), nsIScrollbar() nsScrollbar::nsScrollbar(PRBool aIsVertical) : nsWidget()
{ {
NS_INIT_REFCNT();
mMaxRange = 0; mMaxRange = 0;
mPosition = 0; mPosition = 0;
mThumbSize = 0; mThumbSize = 0;

Просмотреть файл

@ -49,10 +49,7 @@ public:
nsScrollbar(PRBool aIsVertical); nsScrollbar(PRBool aIsVertical);
virtual ~nsScrollbar(); virtual ~nsScrollbar();
// nsISupports NS_DECL_ISUPPORTS_INHERITED
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr);
NS_IMETHOD_(nsrefcnt) AddRef(void);
NS_IMETHOD_(nsrefcnt) Release(void);
// Override some of the native widget methods for scrollbars // Override some of the native widget methods for scrollbars
PRBool OnResize (nsSizeEvent &event); PRBool OnResize (nsSizeEvent &event);

Просмотреть файл

@ -37,12 +37,8 @@
#include "nsTextWidget.h" #include "nsTextWidget.h"
NS_IMPL_ADDREF(nsTextWidget)
NS_IMPL_RELEASE(nsTextWidget)
nsTextWidget::nsTextWidget() : nsTextHelper() nsTextWidget::nsTextWidget() : nsTextHelper()
{ {
NS_INIT_REFCNT();
mName.Assign(NS_LITERAL_STRING("nsTextWidget")); mName.Assign(NS_LITERAL_STRING("nsTextWidget"));
} }
@ -50,19 +46,7 @@ nsTextWidget::~nsTextWidget()
{ {
} }
nsresult nsTextWidget::QueryInterface(const nsIID& aIID, void** aInstancePtr) NS_IMPL_ISUPPORTS_INHERITED1(nsTextWidget, nsWidget, nsITextWidget)
{
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_METHOD nsTextWidget::Paint(nsIRenderingContext& aRenderingContext, NS_METHOD nsTextWidget::Paint(nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect) const nsRect& aDirtyRect)

Просмотреть файл

@ -49,10 +49,7 @@ public:
nsTextWidget(); nsTextWidget();
virtual ~nsTextWidget(); virtual ~nsTextWidget();
// nsISupports NS_DECL_ISUPPORTS_INHERITED
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr);
NS_IMETHOD_(nsrefcnt) AddRef(void);
NS_IMETHOD_(nsrefcnt) Release(void);
NS_IMETHOD Paint(nsIRenderingContext& aRenderingContext, NS_IMETHOD Paint(nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect); const nsRect& aDirtyRect);

Просмотреть файл

@ -47,7 +47,7 @@ static PRUintn gToolkitTLSIndex = 0;
nsToolkit::nsToolkit() nsToolkit::nsToolkit()
{ {
NS_INIT_REFCNT(); NS_INIT_ISUPPORTS();
mGC = nsnull; mGC = nsnull;
mDisplay = xxlib_rgb_get_display(nsAppShell::GetXlibRgbHandle()); mDisplay = xxlib_rgb_get_display(nsAppShell::GetXlibRgbHandle());
} }

Просмотреть файл

@ -103,7 +103,7 @@ public:
PRBool aRepaint); PRBool aRepaint);
NS_IMETHOD Enable(PRBool bState); 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 SetName(const char * aName);
NS_IMETHOD SetBackgroundColor(const nscolor &aColor); NS_IMETHOD SetBackgroundColor(const nscolor &aColor);
virtual nsIFontMetrics* GetFont(void); virtual nsIFontMetrics* GetFont(void);

Просмотреть файл

@ -206,7 +206,6 @@ NS_IMPL_ISUPPORTS_INHERITED0(nsWindow, nsWidget)
nsWindow::nsWindow() : nsWidget() nsWindow::nsWindow() : nsWidget()
{ {
NS_INIT_REFCNT();
mName.Assign(NS_LITERAL_STRING("nsWindow")); mName.Assign(NS_LITERAL_STRING("nsWindow"));
mBackground = NS_RGB(255, 255, 255); mBackground = NS_RGB(255, 255, 255);
mBackgroundPixel = xxlib_rgb_xpixel_from_rgb(mXlibRgbHandle, mBackground); mBackgroundPixel = xxlib_rgb_xpixel_from_rgb(mXlibRgbHandle, mBackground);