зеркало из https://github.com/mozilla/pjs.git
Ref count fixes, fix widget test app.
This commit is contained in:
Родитель
42ea687ae9
Коммит
c53b9ebd29
|
@ -58,6 +58,7 @@ CPPSRCS= \
|
|||
nsWidgetFactory.cpp \
|
||||
nsWindow.cpp \
|
||||
nsXtEventHandler.cpp \
|
||||
nsLookAndFeel.cpp \
|
||||
nsToolkit.cpp
|
||||
|
||||
CPP_OBJS= \
|
||||
|
|
|
@ -89,6 +89,7 @@ void nsAppShell::Exit()
|
|||
//-------------------------------------------------------------------------
|
||||
nsAppShell::nsAppShell()
|
||||
{
|
||||
mRefCnt = 0;
|
||||
mDispatchListener = 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -34,10 +34,11 @@
|
|||
#include "nsFileWidget.h"
|
||||
#include "nsListBox.h"
|
||||
#include "nsComboBox.h"
|
||||
#include "nsLookAndFeel.h"
|
||||
|
||||
static NS_DEFINE_IID(kCWindow, NS_WINDOW_CID);
|
||||
static NS_DEFINE_IID(kCChild, NS_CHILD_CID);
|
||||
static NS_DEFINE_IID(kCAppShell, NS_APPSHELL_CID);
|
||||
static NS_DEFINE_IID(kCAppShellCID, NS_APPSHELL_CID);
|
||||
static NS_DEFINE_IID(kCHorzScrollbarCID, NS_HORZSCROLLBAR_CID);
|
||||
static NS_DEFINE_IID(kCVertScrollbarCID, NS_VERTSCROLLBAR_CID);
|
||||
static NS_DEFINE_IID(kCCheckButtonCID, NS_CHECKBUTTON_CID);
|
||||
|
@ -48,6 +49,7 @@ static NS_DEFINE_IID(kCFileWidgetCID, NS_FILEWIDGET_CID);
|
|||
static NS_DEFINE_IID(kCButtonCID, NS_BUTTON_CID);
|
||||
static NS_DEFINE_IID(kCListBoxCID, NS_LISTBOX_CID);
|
||||
static NS_DEFINE_IID(kCComboBoxCID, NS_COMBOBOX_CID);
|
||||
static NS_DEFINE_IID(kCLookAndFeelCID, NS_LOOKANDFEEL_CID);
|
||||
|
||||
|
||||
static NS_DEFINE_IID(kIWidget, NS_IWIDGET_IID);
|
||||
|
@ -177,34 +179,39 @@ nsresult nsWidgetFactory::CreateInstance(nsISupports *aOuter,
|
|||
else if (mClassID.Equals(kCChild)) {
|
||||
inst = new ChildWindow(aOuter);
|
||||
}
|
||||
|
||||
else if (aIID.Equals(kIAppShellIID)) {
|
||||
nsIAppShell *appInst = (nsIAppShell*)new nsAppShell();
|
||||
if (appInst == NULL) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
nsresult res = appInst->QueryInterface(aIID, aResult);
|
||||
if (res != NS_OK) {
|
||||
delete appInst ;
|
||||
}
|
||||
return res;
|
||||
else if (mClassID.Equals(kCLookAndFeelCID)) {
|
||||
nsLookAndFeel *laf = new nsLookAndFeel(aOuter);
|
||||
if (laf == NULL) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
nsresult res = laf->QueryInterface(aIID, aResult);
|
||||
if (res != NS_OK) {
|
||||
delete laf;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
if (inst == NULL) {
|
||||
else if (mClassID.Equals(kCAppShellCID)) {
|
||||
nsAppShell *appInst = new nsAppShell();
|
||||
if (appInst == NULL) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
nsresult res = appInst->QueryInterface(aIID, aResult);
|
||||
if (res != NS_OK) {
|
||||
delete appInst;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
if (inst == NULL) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
|
||||
nsresult res = inst->QueryObject(aIID, aResult);
|
||||
|
||||
|
||||
nsresult res = inst->QueryObject(aIID, aResult);
|
||||
|
||||
if (res != NS_OK) {
|
||||
delete inst ;
|
||||
}
|
||||
else {
|
||||
NS_RELEASE(inst);
|
||||
}
|
||||
|
||||
return res;
|
||||
if (res != NS_OK) {
|
||||
delete inst;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
nsresult nsWidgetFactory::LockFactory(PRBool aLock)
|
||||
|
|
|
@ -188,7 +188,7 @@ nsWindow::nsWindow(nsISupports *aOuter):
|
|||
mOuter = aOuter;
|
||||
else
|
||||
mOuter = &mInner;
|
||||
mRefCnt = 1;
|
||||
mRefCnt = 0;
|
||||
|
||||
mGC = nsnull ;
|
||||
mShown = PR_FALSE;
|
||||
|
@ -928,12 +928,18 @@ void* nsWindow::GetNativeData(PRUint32 aDataType)
|
|||
case NS_NATIVE_WIDGET:
|
||||
return (void*)(mWidget);
|
||||
case NS_NATIVE_GRAPHIC:
|
||||
// We Cache a Read-Only Shared GC in the Toolkit. If we don't
|
||||
// have one ourselves (because it needs to be writeable) grab the
|
||||
// the shared GC
|
||||
if (nsnull == mGC)
|
||||
return (((nsToolkit *)mToolkit)->GetSharedGC());
|
||||
return ((void*)mGC);
|
||||
{
|
||||
void *res = NULL;
|
||||
// We Cache a Read-Only Shared GC in the Toolkit. If we don't
|
||||
// have one ourselves (because it needs to be writeable) grab the
|
||||
// the shared GC
|
||||
if (nsnull == mGC)
|
||||
res = (void *)((nsToolkit *)mToolkit)->GetSharedGC();
|
||||
else
|
||||
res = (void *)mGC;
|
||||
NS_ASSERTION(res, "Unable to return GC");
|
||||
return res;
|
||||
}
|
||||
case NS_NATIVE_COLORMAP:
|
||||
default:
|
||||
break;
|
||||
|
@ -1213,9 +1219,9 @@ PRBool nsWindow::OnPaint(nsPaintEvent &event)
|
|||
kRenderingContextIID,
|
||||
(void **)&event.renderingContext))
|
||||
{
|
||||
event.renderingContext->Init(mContext, this);
|
||||
result = DispatchEvent(&event);
|
||||
NS_RELEASE(event.renderingContext);
|
||||
event.renderingContext->Init(mContext, this);
|
||||
result = DispatchEvent(&event);
|
||||
NS_RELEASE(event.renderingContext);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -1,115 +0,0 @@
|
|||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH=../../..
|
||||
|
||||
include $(DEPTH)/config/config.mk
|
||||
|
||||
CPPSRCS = \
|
||||
main.cpp \
|
||||
nsWidgetTest.cpp \
|
||||
$(NULL)
|
||||
|
||||
INCLUDES+= -I$(PUBLIC)/raptor -I$(PUBLIC)/xpcom -I$(PUBLIC)/shell
|
||||
|
||||
DIRS =
|
||||
|
||||
OBJS = $(CPPSRCS:.cpp=.o)
|
||||
|
||||
EX_LIBS = \
|
||||
$(DIST)/bin/libraptorbase.so \
|
||||
$(DIST)/bin/libpng.so \
|
||||
$(DIST)/bin/libpref.so \
|
||||
$(DIST)/bin/libraptorbase.so \
|
||||
$(DIST)/bin/libwidgetunix.so \
|
||||
$(DIST)/bin/libraptorgfx.so \
|
||||
$(DIST)/bin/libgfxunix.so \
|
||||
$(DIST)/bin/libraptorhtml.so \
|
||||
$(DIST)/bin/libgmbaseunix.so \
|
||||
$(DIST)/bin/libraptorhtml.so \
|
||||
$(DIST)/bin/libraptorhtmlpars.so \
|
||||
$(DIST)/bin/libraptorview.so \
|
||||
$(DIST)/bin/libreg.so \
|
||||
$(DIST)/bin/libabouturl.so \
|
||||
$(DIST)/bin/libfileurl.so \
|
||||
$(DIST)/bin/libftpurl.so \
|
||||
$(DIST)/bin/libgophurl.so \
|
||||
$(DIST)/bin/libhttpurl.so \
|
||||
$(DIST)/bin/libimg.so \
|
||||
$(DIST)/bin/libjpeg.so \
|
||||
$(DIST)/bin/libjs.so \
|
||||
$(DIST)/bin/libjsdom.so \
|
||||
$(DIST)/bin/libjsj.so \
|
||||
$(DIST)/bin/libmimetype.so \
|
||||
$(DIST)/bin/libmsgc21.so \
|
||||
$(DIST)/bin/libnetcache.so \
|
||||
$(DIST)/bin/libnetcnvts.so \
|
||||
$(DIST)/bin/libnetlib.so \
|
||||
$(DIST)/bin/libnetutil.so \
|
||||
$(DIST)/bin/libnetwork.so \
|
||||
$(DIST)/bin/libnspr21.so \
|
||||
$(DIST)/bin/libplc21.so \
|
||||
$(DIST)/bin/libplds21.so \
|
||||
$(DIST)/bin/libraptorwebwidget.so \
|
||||
$(DIST)/bin/libreg.so \
|
||||
$(DIST)/bin/libremoturl.so \
|
||||
$(DIST)/bin/libsecfree.so \
|
||||
$(DIST)/bin/libstubnj.so \
|
||||
$(DIST)/bin/libstubsj.so \
|
||||
$(DIST)/bin/libtestdynamic.so \
|
||||
$(DIST)/bin/libutil.so \
|
||||
$(DIST)/bin/libxp.so \
|
||||
$(DIST)/bin/libxpcom.so \
|
||||
$(DIST)/bin/libzlib.so \
|
||||
$(DIST)/bin/libutil.so \
|
||||
$(DIST)/bin/libxp.so \
|
||||
$(DIST)/bin/libxpcom.so \
|
||||
$(DIST)/bin/libzlib.so \
|
||||
$(NULL)
|
||||
|
||||
ifeq ($(OS_ARCH),Linux)
|
||||
EX_LIBS += \
|
||||
$(DIST)/bin/libpwcac.so \
|
||||
$(DIST)/bin/libdbm.so \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
PROG = widget
|
||||
|
||||
TARGETS = $(OBJDIR)/$(PROG)
|
||||
|
||||
include $(DEPTH)/config/rules.mk
|
||||
|
||||
$(OBJDIR)/%.o: %.cpp
|
||||
@$(MAKE_OBJDIR)
|
||||
$(CCC) -o $@ $(CFLAGS) -c $*.cpp
|
||||
|
||||
$(OBJDIR)/$(PROG): $(EX_LIBS)
|
||||
@$(MAKE_OBJDIR)
|
||||
ifeq ($(OS_ARCH),Linux)
|
||||
$(CCC) -rdynamic -o $@ $(OBJDIR)/main.o $(OBJDIR)/nsWidgetTest.o $(LDFLAGS) $(EX_LIBS) $(OS_LIBS) -L/usr/X11R6/lib -lXm -lXt -lX11 -lXp -lXext
|
||||
else
|
||||
$(CCC) -o $@ $@.o -woff 84,85 $(LDFLAGS) $(OBJDIR)/nsWidgetTest.o $(EX_LIBS) $(OS_LIBS) -lXm -lXt -lX11
|
||||
endif
|
||||
|
||||
install:: $(TARGETS)
|
||||
$(INSTALL) $(OBJDIR)/$(PROG) $(DIST)/bin
|
||||
|
||||
clobber::
|
||||
rm -f $(DIST)/bin/$(PROG)
|
||||
|
||||
|
|
@ -890,6 +890,7 @@ nsEventStatus PR_CALLBACK HandleEvent(nsGUIEvent *aEvent)
|
|||
break;
|
||||
|
||||
case NS_PAINT:
|
||||
#ifndef XP_UNIX
|
||||
// paint the background
|
||||
if (aEvent->widget == window) {
|
||||
nsIRenderingContext *drawCtx = ((nsPaintEvent*)aEvent)->renderingContext;
|
||||
|
@ -898,6 +899,7 @@ nsEventStatus PR_CALLBACK HandleEvent(nsGUIEvent *aEvent)
|
|||
|
||||
return nsEventStatus_eIgnore;
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
|
||||
case NS_DESTROY:
|
||||
|
@ -1159,14 +1161,6 @@ nsresult WidgetTest(int *argc, char **argv)
|
|||
static NS_DEFINE_IID(kDeviceContextCID, NS_DEVICE_CONTEXT_CID);
|
||||
static NS_DEFINE_IID(kDeviceContextIID, NS_IDEVICE_CONTEXT_IID);
|
||||
|
||||
res = NSRepository::CreateInstance(kDeviceContextCID, nsnull, kDeviceContextIID, (void **)&deviceContext);
|
||||
|
||||
if (NS_OK == res)
|
||||
{
|
||||
deviceContext->Init(nsnull);
|
||||
NS_ADDREF(deviceContext);
|
||||
}
|
||||
|
||||
//
|
||||
// create the main window
|
||||
//
|
||||
|
@ -1179,6 +1173,17 @@ nsresult WidgetTest(int *argc, char **argv)
|
|||
window->Show(PR_TRUE);
|
||||
window->SetBackgroundColor(NS_RGB(196, 196, 196));
|
||||
|
||||
//
|
||||
// Create Device Context based on main window
|
||||
//
|
||||
res = NSRepository::CreateInstance(kDeviceContextCID, nsnull, kDeviceContextIID, (void **)&deviceContext);
|
||||
|
||||
if (NS_OK == res)
|
||||
{
|
||||
deviceContext->Init(window->GetNativeData(NS_NATIVE_WIDGET));
|
||||
NS_ADDREF(deviceContext);
|
||||
}
|
||||
|
||||
#ifdef XP_PC
|
||||
tooltipWindow = createTooltipWindow(window, "INSERT <tooltip> here", 0, 0, 150, 0);
|
||||
tooltipWindow->Show(PR_FALSE);
|
||||
|
|
Загрузка…
Ссылка в новой задаче