зеркало из https://github.com/mozilla/pjs.git
Memory leak fixes, bug fixes, general cleanup....
This commit is contained in:
Родитель
8bd77bb700
Коммит
b4a00eaa88
|
@ -150,22 +150,23 @@ nsCalXMLContentSink::nsCalXMLContentSink() : nsIHTMLContentSink()
|
|||
nsCalXMLContentSink::~nsCalXMLContentSink()
|
||||
{
|
||||
|
||||
if (mOrphanCanvasList != nsnull) {
|
||||
if (mOrphanCanvasList != nsnull)
|
||||
{
|
||||
|
||||
nsIIterator * iterator;
|
||||
nsIIterator * iterator;
|
||||
|
||||
mOrphanCanvasList->CreateIterator(&iterator);
|
||||
iterator->Init();
|
||||
mOrphanCanvasList->CreateIterator(&iterator);
|
||||
iterator->Init();
|
||||
|
||||
nsIXPFCCanvas * item;
|
||||
|
||||
while(!(iterator->IsDone()))
|
||||
{
|
||||
item = (nsIXPFCCanvas *) iterator->CurrentItem();
|
||||
NS_RELEASE(item);
|
||||
iterator->Next();
|
||||
}
|
||||
NS_RELEASE(iterator);
|
||||
while(!(iterator->IsDone()))
|
||||
{
|
||||
item = (nsIXPFCCanvas *) iterator->CurrentItem();
|
||||
NS_RELEASE(item);
|
||||
iterator->Next();
|
||||
}
|
||||
NS_RELEASE(iterator);
|
||||
|
||||
mOrphanCanvasList->RemoveAll();
|
||||
NS_RELEASE(mOrphanCanvasList);
|
||||
|
@ -175,10 +176,28 @@ nsCalXMLContentSink::~nsCalXMLContentSink()
|
|||
NS_RELEASE(mTimeContextList);
|
||||
NS_RELEASE(mCanvasStack);
|
||||
|
||||
if (mControlList != nsnull) {
|
||||
if (mControlList != nsnull)
|
||||
{
|
||||
|
||||
nsIIterator * iterator;
|
||||
|
||||
mControlList->CreateIterator(&iterator);
|
||||
iterator->Init();
|
||||
|
||||
ControlListEntry * item;
|
||||
|
||||
while(!(iterator->IsDone()))
|
||||
{
|
||||
item = (ControlListEntry *) iterator->CurrentItem();
|
||||
delete item;
|
||||
iterator->Next();
|
||||
}
|
||||
NS_RELEASE(iterator);
|
||||
|
||||
mControlList->RemoveAll();
|
||||
NS_RELEASE(mControlList);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(nsCalXMLContentSink)
|
||||
|
@ -289,6 +308,7 @@ NS_IMETHODIMP nsCalXMLContentSink::OpenContainer(const nsIParserNode& aNode)
|
|||
NS_RELEASE(root);
|
||||
}
|
||||
|
||||
NS_RELEASE(object);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -330,9 +350,7 @@ NS_IMETHODIMP nsCalXMLContentSink::ConsumeAttributes(const nsIParserNode& aNode,
|
|||
*/
|
||||
|
||||
if (control == PR_TRUE)
|
||||
{
|
||||
mControlList->Append(new ControlListEntry(&aObject, scontrol));
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -341,11 +359,7 @@ NS_IMETHODIMP nsCalXMLContentSink::ConsumeAttributes(const nsIParserNode& aNode,
|
|||
NS_IMETHODIMP nsCalXMLContentSink::CloseContainer(const nsIParserNode& aNode)
|
||||
{
|
||||
nsIXPFCCanvas * canvas = (nsIXPFCCanvas *)mCanvasStack->Pop();
|
||||
|
||||
#if 0
|
||||
NS_IF_RELEASE(canvas);
|
||||
#endif
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -382,7 +396,10 @@ NS_IMETHODIMP nsCalXMLContentSink::AddToHierarchy(nsIXMLParserObject& aObject, P
|
|||
}
|
||||
|
||||
if (aPush == PR_TRUE)
|
||||
{
|
||||
mCanvasStack->Push(canvas);
|
||||
NS_ADDREF(canvas);
|
||||
}
|
||||
|
||||
NS_RELEASE(canvas);
|
||||
|
||||
|
@ -542,6 +559,7 @@ NS_IMETHODIMP nsCalXMLContentSink::AddCtx(const nsIParserNode& aNode)
|
|||
ApplyContext(root, context);
|
||||
|
||||
NS_RELEASE(root);
|
||||
NS_RELEASE(context);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -696,8 +714,9 @@ NS_IMETHODIMP nsCalXMLContentSink::AddControl(const nsIParserNode& aNode)
|
|||
NS_RELEASE(object);
|
||||
}
|
||||
|
||||
mOrphanCanvasList->Remove(child);
|
||||
NS_RELEASE(child);
|
||||
if (NS_OK == (mOrphanCanvasList->Remove(child)))
|
||||
NS_RELEASE(child);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -977,6 +996,7 @@ NS_IMETHODIMP nsCalXMLContentSink::DidBuildModel(PRInt32 aQualityLevel)
|
|||
NS_RELEASE(msubject);
|
||||
}
|
||||
}
|
||||
NS_RELEASE(observer);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1070,5 +1090,6 @@ nsIXPFCCanvas * nsCalXMLContentSink::CanvasFromName(nsString& aName)
|
|||
nsresult nsCalXMLContentSink::SetRootCanvas(nsIXPFCCanvas * aCanvas)
|
||||
{
|
||||
mCanvasStack->Push(aCanvas);
|
||||
NS_ADDREF(aCanvas);
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -188,6 +188,8 @@ nsIXPFCCanvas * nsCalMultiDayViewCanvas :: AddDayViewCanvas()
|
|||
|
||||
parent = canvas;
|
||||
|
||||
NS_RELEASE(canvas);
|
||||
|
||||
/*
|
||||
* Add the Header Time Canvas
|
||||
*/
|
||||
|
@ -213,6 +215,8 @@ nsIXPFCCanvas * nsCalMultiDayViewCanvas :: AddDayViewCanvas()
|
|||
canvas->SetMinimumSize(nsSize(25,25));
|
||||
canvas->SetMaximumSize(nsSize(25,25));
|
||||
|
||||
NS_RELEASE(canvas);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -240,6 +244,8 @@ nsIXPFCCanvas * nsCalMultiDayViewCanvas :: AddDayViewCanvas()
|
|||
else
|
||||
((nsBoxLayout *)(canvas->GetLayout()))->SetLayoutAlignment(eLayoutAlignment_horizontal);
|
||||
|
||||
NS_RELEASE(canvas);
|
||||
|
||||
/*
|
||||
* Add the status View Canvas
|
||||
*/
|
||||
|
@ -263,6 +269,8 @@ nsIXPFCCanvas * nsCalMultiDayViewCanvas :: AddDayViewCanvas()
|
|||
canvas->SetMinimumSize(nsSize(25,25));
|
||||
canvas->SetMaximumSize(nsSize(25,25));
|
||||
|
||||
NS_RELEASE(canvas);
|
||||
|
||||
}
|
||||
|
||||
return (parent);
|
||||
|
@ -443,6 +451,8 @@ nsEventStatus nsCalMultiDayViewCanvas::Action(nsIXPFCCommand * aCommand)
|
|||
iterator->Next();
|
||||
}
|
||||
|
||||
NS_RELEASE(iterator);
|
||||
|
||||
Layout();
|
||||
|
||||
nsRect bounds;
|
||||
|
@ -559,13 +569,16 @@ nsresult nsCalMultiDayViewCanvas :: SetMultiDayLayout(nsLayoutAlignment aLayoutA
|
|||
iterator2->Next();
|
||||
|
||||
}
|
||||
|
||||
NS_RELEASE(iterator2);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
iterator->Next();
|
||||
}
|
||||
|
||||
NS_IF_RELEASE(iterator);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -633,9 +646,13 @@ nsresult nsCalMultiDayViewCanvas :: SetTimeContext(nsICalTimeContext * aContext)
|
|||
|
||||
}
|
||||
|
||||
NS_RELEASE(iterator2);
|
||||
|
||||
index++;
|
||||
iterator->Next();
|
||||
}
|
||||
|
||||
NS_RELEASE(iterator);
|
||||
|
||||
return (nsCalMultiViewCanvas :: SetTimeContext(aContext));
|
||||
}
|
||||
|
|
|
@ -329,6 +329,9 @@ nsresult nsCalTimebarCanvas :: SetChildTimeContext(nsCalTimebarCanvas * aCanvas,
|
|||
|
||||
nsServiceManager::ReleaseService(kCXPFCObserverManagerCID, om);
|
||||
|
||||
NS_RELEASE(context_subject);
|
||||
NS_RELEASE(context_observer);
|
||||
|
||||
/*
|
||||
* TODO: Add the increment here for the appropriate period
|
||||
*/
|
||||
|
@ -338,6 +341,8 @@ nsresult nsCalTimebarCanvas :: SetChildTimeContext(nsCalTimebarCanvas * aCanvas,
|
|||
|
||||
context->AddPeriod(nsCalPeriodFormat_kDay,increment);
|
||||
|
||||
NS_RELEASE(context);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#define nsCalContextController_h___
|
||||
|
||||
#include "nsICalContextController.h"
|
||||
#include "nsXPFCCanvas.h"
|
||||
#include "nsCalCanvas.h"
|
||||
|
||||
#include "nsIXPFCSubject.h"
|
||||
#include "nsIXPFCCommand.h"
|
||||
|
@ -30,7 +30,7 @@
|
|||
|
||||
class nsCalContextController : public nsICalContextController,
|
||||
public nsIXPFCSubject,
|
||||
public nsXPFCCanvas
|
||||
public nsCalCanvas
|
||||
{
|
||||
public:
|
||||
nsCalContextController(nsISupports * aOuter);
|
||||
|
|
|
@ -41,7 +41,7 @@ static NS_DEFINE_IID(kCXPFCSubjectIID, NS_IXPFC_SUBJECT_IID);
|
|||
|
||||
#define kNotFound -1
|
||||
|
||||
nsCalContextController :: nsCalContextController(nsISupports * aOuter) : nsXPFCCanvas(aOuter)
|
||||
nsCalContextController :: nsCalContextController(nsISupports * aOuter) : nsCalCanvas(aOuter)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
|
||||
|
@ -86,7 +86,7 @@ nsresult nsCalContextController::QueryInterface(REFNSIID aIID, void** aInstanceP
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
return (nsXPFCCanvas::QueryInterface(aIID, aInstancePtr));
|
||||
return (nsCalCanvas::QueryInterface(aIID, aInstancePtr));
|
||||
|
||||
}
|
||||
|
||||
|
@ -124,7 +124,7 @@ nsresult nsCalContextController :: Init()
|
|||
mDuration->SetMinute(0);
|
||||
mDuration->SetSecond(0);
|
||||
|
||||
return (nsXPFCCanvas::Init());
|
||||
return (nsCalCanvas::Init());
|
||||
}
|
||||
|
||||
nsresult nsCalContextController :: Attach(nsIXPFCObserver * aObserver)
|
||||
|
@ -240,5 +240,5 @@ nsresult nsCalContextController :: SetParameter(nsString& aKey, nsString& aValue
|
|||
}
|
||||
|
||||
|
||||
return (nsXPFCCanvas::SetParameter(aKey, aValue));
|
||||
return (nsCalCanvas::SetParameter(aKey, aValue));
|
||||
}
|
||||
|
|
|
@ -98,7 +98,6 @@ nsCalMonthContextController :: nsCalMonthContextController(nsISupports* outer) :
|
|||
m_HighlightBGColor = NS_RGB(255,0,0);
|
||||
m_ActionDateList = nsnull;
|
||||
SetDefaults();
|
||||
Init();
|
||||
}
|
||||
|
||||
nsCalMonthContextController :: ~nsCalMonthContextController()
|
||||
|
@ -106,6 +105,12 @@ nsCalMonthContextController :: ~nsCalMonthContextController()
|
|||
if (m_pDates != 0)
|
||||
delete m_pDates;
|
||||
|
||||
if (nsnull != m_pValidPosMap)
|
||||
PR_Free(m_pValidPosMap);
|
||||
|
||||
if (nsnull != m_pStartTimeMap)
|
||||
PR_Free(m_pStartTimeMap);
|
||||
|
||||
NS_IF_RELEASE(m_ActionDateList);
|
||||
|
||||
}
|
||||
|
@ -140,16 +145,27 @@ NS_IMPL_RELEASE(nsCalMonthContextController)
|
|||
|
||||
nsresult nsCalMonthContextController :: Init()
|
||||
{
|
||||
m_pDates = new JulianPtrArray();
|
||||
if (nsnull == m_pDates)
|
||||
m_pDates = new JulianPtrArray();
|
||||
|
||||
/*
|
||||
* Create the Interactive date list array
|
||||
*/
|
||||
static NS_DEFINE_IID(kCVectorCID, NS_VECTOR_CID);
|
||||
nsresult res = nsRepository::CreateInstance(kCVectorCID, nsnull, kCVectorCID, (void **)&m_ActionDateList);
|
||||
if (NS_OK != res)
|
||||
return res ;
|
||||
m_ActionDateList->Init();
|
||||
|
||||
if (nsnull == m_ActionDateList)
|
||||
{
|
||||
static NS_DEFINE_IID(kCVectorCID, NS_VECTOR_CID);
|
||||
|
||||
nsresult res = nsRepository::CreateInstance(kCVectorCID,
|
||||
nsnull,
|
||||
kCVectorCID,
|
||||
(void **)&m_ActionDateList);
|
||||
|
||||
if (NS_OK != res)
|
||||
return res ;
|
||||
|
||||
m_ActionDateList->Init();
|
||||
}
|
||||
|
||||
nsFont font(m_sFontName /*"Arial"*/, NS_FONT_STYLE_NORMAL,
|
||||
NS_FONT_VARIANT_NORMAL,
|
||||
|
|
|
@ -68,7 +68,6 @@ static NS_DEFINE_IID(kIViewIID, NS_IVIEW_IID);
|
|||
static NS_DEFINE_IID(kViewCID, NS_VIEW_CID);
|
||||
static NS_DEFINE_IID(kCViewCID, NS_VIEW_CID);
|
||||
|
||||
|
||||
nsXPFCCanvas :: nsXPFCCanvas(nsISupports* outer) :
|
||||
mFont("Times",
|
||||
NS_FONT_STYLE_NORMAL,
|
||||
|
@ -144,7 +143,81 @@ nsXPFCCanvas :: ~nsXPFCCanvas()
|
|||
|
||||
}
|
||||
|
||||
NS_IMPL_AGGREGATED(nsXPFCCanvas)
|
||||
NS_IMETHODIMP
|
||||
nsXPFCCanvas::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
||||
{
|
||||
/* try our own interfaces first before delegating to outer */
|
||||
nsresult rslt = AggregatedQueryInterface(aIID, aInstancePtr);
|
||||
if (rslt != NS_OK && fOuter)
|
||||
return fOuter->QueryInterface(aIID, aInstancePtr);
|
||||
else
|
||||
return rslt;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(nsrefcnt)
|
||||
nsXPFCCanvas::AddRef(void)
|
||||
{
|
||||
++mRefCnt; /* keep track of our refcount as well as outer's */
|
||||
if (fOuter)
|
||||
return NS_ADDREF(fOuter);
|
||||
else
|
||||
return mRefCnt;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(nsrefcnt)
|
||||
nsXPFCCanvas::Release(void)
|
||||
{
|
||||
if (fOuter) {
|
||||
nsISupports* outer = fOuter; /* in case we release ourself */
|
||||
nsIOuter* outerIntf;
|
||||
static NS_DEFINE_IID(kIOuterIID, NS_IOUTER_IID);
|
||||
if (mRefCnt == 1 &&
|
||||
outer->QueryInterface(kIOuterIID,
|
||||
(void**)&outerIntf) == NS_OK) {
|
||||
outerIntf->ReleaseInner(GetInner());
|
||||
outerIntf->Release();
|
||||
}
|
||||
else
|
||||
--mRefCnt; /* keep track of our refcount as well as outer's */
|
||||
return outer->Release();
|
||||
}
|
||||
else {
|
||||
if (--mRefCnt == 0) {
|
||||
delete this;
|
||||
return 0;
|
||||
}
|
||||
return mRefCnt;
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXPFCCanvas::Internal::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
||||
{
|
||||
nsXPFCCanvas* agg = (nsXPFCCanvas*)((char*)(this) - offsetof(nsXPFCCanvas, fAggregated));
|
||||
return agg->AggregatedQueryInterface(aIID, aInstancePtr);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(nsrefcnt)
|
||||
nsXPFCCanvas::Internal::AddRef(void)
|
||||
{
|
||||
nsXPFCCanvas* agg = (nsXPFCCanvas*)((char*)(this) - offsetof(nsXPFCCanvas, fAggregated));
|
||||
return ++agg->mRefCnt;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(nsrefcnt)
|
||||
nsXPFCCanvas::Internal::Release(void)
|
||||
{
|
||||
nsXPFCCanvas* agg = (nsXPFCCanvas*)((char*)(this) - offsetof(nsXPFCCanvas, fAggregated));
|
||||
if (--agg->mRefCnt == 0) {
|
||||
delete agg;
|
||||
return 0;
|
||||
}
|
||||
return agg->mRefCnt;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
nsresult nsXPFCCanvas::AggregatedQueryInterface(const nsIID &aIID,
|
||||
void** aInstancePtr)
|
||||
|
@ -940,7 +1013,7 @@ nsEventStatus nsXPFCCanvas :: OnResize(nscoord aX, nscoord aY, nscoord aWidth, n
|
|||
bounds.x = 0;
|
||||
bounds.y = 0;
|
||||
|
||||
gXPFCToolkit->GetViewManager()->UpdateView(mView, bounds, NS_VMREFRESH_AUTO_DOUBLE_BUFFER | NS_VMREFRESH_NO_SYNC) ;
|
||||
if (gXPFCToolkit) gXPFCToolkit->GetViewManager()->UpdateView(mView, bounds, NS_VMREFRESH_AUTO_DOUBLE_BUFFER | NS_VMREFRESH_NO_SYNC) ;
|
||||
}
|
||||
|
||||
mLayout->Layout();
|
||||
|
@ -1032,11 +1105,17 @@ void nsXPFCCanvas :: RemoveChildCanvas(nsIXPFCCanvas * aChildCanvas)
|
|||
|
||||
void nsXPFCCanvas :: Reparent(nsIXPFCCanvas * aParentCanvas)
|
||||
{
|
||||
nsIXPFCCanvas * me = this;
|
||||
|
||||
NS_ADDREF(me);
|
||||
|
||||
if (GetParent() != nsnull)
|
||||
GetParent()->RemoveChildCanvas(this);
|
||||
|
||||
aParentCanvas->AddChildCanvas(this);
|
||||
|
||||
NS_RELEASE(me);
|
||||
|
||||
return ;
|
||||
}
|
||||
|
||||
|
@ -1395,7 +1474,7 @@ nsEventStatus nsXPFCCanvas :: HandleEvent(nsGUIEvent *aEvent)
|
|||
canvas->mView->GetBounds(bounds);
|
||||
bounds.x = 0;
|
||||
bounds.y = 0;
|
||||
gXPFCToolkit->GetViewManager()->UpdateView(canvas->mView, bounds, NS_VMREFRESH_AUTO_DOUBLE_BUFFER | NS_VMREFRESH_NO_SYNC) ;
|
||||
if (gXPFCToolkit) gXPFCToolkit->GetViewManager()->UpdateView(canvas->mView, bounds, NS_VMREFRESH_AUTO_DOUBLE_BUFFER | NS_VMREFRESH_NO_SYNC) ;
|
||||
}
|
||||
|
||||
iterator->Next();
|
||||
|
@ -2028,7 +2107,7 @@ nsEventStatus nsXPFCCanvas::Action(nsIXPFCCommand * aCommand)
|
|||
bounds.x = 0;
|
||||
bounds.y = 0;
|
||||
|
||||
gXPFCToolkit->GetViewManager()->UpdateView(GetView(), bounds, NS_VMREFRESH_AUTO_DOUBLE_BUFFER | NS_VMREFRESH_NO_SYNC);
|
||||
if (gXPFCToolkit) gXPFCToolkit->GetViewManager()->UpdateView(GetView(), bounds, NS_VMREFRESH_AUTO_DOUBLE_BUFFER | NS_VMREFRESH_NO_SYNC);
|
||||
|
||||
|
||||
}
|
||||
|
@ -2268,7 +2347,7 @@ void nsXPFCCanvas::Notify(nsIImageRequest *aImageRequest,
|
|||
bounds.x = 0;
|
||||
bounds.y = 0;
|
||||
aImageRequest->RemoveObserver((nsIImageRequestObserver*)this);
|
||||
gXPFCToolkit->GetViewManager()->UpdateView(GetView(), bounds, NS_VMREFRESH_AUTO_DOUBLE_BUFFER | NS_VMREFRESH_NO_SYNC);
|
||||
if (gXPFCToolkit) gXPFCToolkit->GetViewManager()->UpdateView(GetView(), bounds, NS_VMREFRESH_AUTO_DOUBLE_BUFFER | NS_VMREFRESH_NO_SYNC);
|
||||
}
|
||||
return ;
|
||||
}
|
||||
|
|
|
@ -81,6 +81,9 @@ private:
|
|||
public:
|
||||
NS_IMETHOD_(PRBool) IsContainer(const nsIParserNode& aNode);
|
||||
|
||||
private:
|
||||
NS_IMETHOD PushComponent(nsISupports* aComponent);
|
||||
|
||||
|
||||
private:
|
||||
nsIWebViewerContainer * mViewerContainer ;
|
||||
|
|
|
@ -356,9 +356,7 @@ NS_IMETHODIMP nsXPFCXMLContentSink::OpenContainer(const nsIParserNode& aNode)
|
|||
NS_IF_RELEASE(canvas);
|
||||
}
|
||||
|
||||
// XXX: Really need this for all states
|
||||
if (mState == XPFC_PARSING_STATE_MENUBAR || mState == XPFC_PARSING_STATE_TOOLBAR)
|
||||
NS_RELEASE(object);
|
||||
NS_RELEASE(object);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -385,10 +383,7 @@ NS_IMETHODIMP nsXPFCXMLContentSink::CloseContainer(const nsIParserNode& aNode)
|
|||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
NS_IF_RELEASE(container);
|
||||
#endif
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -453,9 +448,7 @@ NS_IMETHODIMP nsXPFCXMLContentSink::AddLeaf(const nsIParserNode& aNode)
|
|||
|
||||
}
|
||||
|
||||
// XXX: Really need this for all states
|
||||
if (mState == XPFC_PARSING_STATE_MENUBAR || mState == XPFC_PARSING_STATE_TOOLBAR)
|
||||
NS_RELEASE(object);
|
||||
NS_RELEASE(object);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -804,7 +797,7 @@ NS_IMETHODIMP nsXPFCXMLContentSink::AddToHierarchy(nsIXMLParserObject& aObject,
|
|||
|
||||
|
||||
if (aPush == PR_TRUE)
|
||||
mXPFCStack->Push(child_canvas);
|
||||
PushComponent(child_canvas);
|
||||
|
||||
NS_IF_RELEASE(child_canvas);
|
||||
NS_IF_RELEASE(container);
|
||||
|
@ -875,7 +868,7 @@ NS_IMETHODIMP nsXPFCXMLContentSink::AddToHierarchy(nsIXMLParserObject& aObject,
|
|||
}
|
||||
|
||||
if (aPush == PR_TRUE)
|
||||
mXPFCStack->Push(container);
|
||||
PushComponent(container);
|
||||
|
||||
|
||||
container->Release();
|
||||
|
@ -896,7 +889,7 @@ NS_IMETHODIMP nsXPFCXMLContentSink::AddToHierarchy(nsIXMLParserObject& aObject,
|
|||
//mViewerContainer->GetToolbarManager()->AddDialog(container);
|
||||
|
||||
if (aPush == PR_TRUE)
|
||||
mXPFCStack->Push(container);
|
||||
PushComponent(container);
|
||||
|
||||
} else {
|
||||
|
||||
|
@ -912,14 +905,13 @@ NS_IMETHODIMP nsXPFCXMLContentSink::AddToHierarchy(nsIXMLParserObject& aObject,
|
|||
if (NS_OK == res)
|
||||
{
|
||||
parent_canvas->AddChildCanvas(child_canvas);
|
||||
|
||||
//NS_RELEASE(parent_canvas);
|
||||
NS_RELEASE(parent_canvas);
|
||||
}
|
||||
|
||||
if (aPush == PR_TRUE)
|
||||
mXPFCStack->Push(child_canvas);
|
||||
PushComponent(child_canvas);
|
||||
|
||||
//NS_RELEASE(child_canvas);
|
||||
NS_RELEASE(child_canvas);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -936,18 +928,13 @@ NS_IMETHODIMP nsXPFCXMLContentSink::AddToHierarchy(nsIXMLParserObject& aObject,
|
|||
|
||||
parent = (nsIXPFCCanvas *) mXPFCStack->Top();
|
||||
|
||||
if (parent == nsnull)
|
||||
{
|
||||
if (aPush == PR_TRUE)
|
||||
mXPFCStack->Push(container);
|
||||
|
||||
} else {
|
||||
|
||||
if (parent != nsnull)
|
||||
parent->AddChildCanvas(container);
|
||||
|
||||
if (aPush == PR_TRUE)
|
||||
mXPFCStack->Push(container);
|
||||
}
|
||||
if (aPush == PR_TRUE)
|
||||
PushComponent(container);
|
||||
|
||||
NS_RELEASE(container);
|
||||
|
||||
return NS_OK;
|
||||
|
||||
|
@ -962,6 +949,13 @@ NS_IMETHODIMP nsXPFCXMLContentSink::AddToHierarchy(nsIXMLParserObject& aObject,
|
|||
|
||||
nsresult nsXPFCXMLContentSink::SetRootCanvas(nsIXPFCCanvas * aCanvas)
|
||||
{
|
||||
mXPFCStack->Push(aCanvas);
|
||||
PushComponent(aCanvas);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsXPFCXMLContentSink::PushComponent(nsISupports* aComponent)
|
||||
{
|
||||
mXPFCStack->Push(aComponent);
|
||||
NS_ADDREF(aComponent);
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -1,202 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "nsVector.h"
|
||||
#include "nsVectorIterator.h"
|
||||
#include "nsxpfcCIID.h"
|
||||
#include "nsxpfcutil.h"
|
||||
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kCVectorCID, NS_VECTOR_CID);
|
||||
|
||||
nsVector :: nsVector()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
|
||||
mVoidArray = nsnull ;
|
||||
}
|
||||
|
||||
nsVector :: ~nsVector()
|
||||
{
|
||||
DeleteIfObject(mVoidArray) ;
|
||||
}
|
||||
|
||||
NS_IMPL_QUERY_INTERFACE(nsVector, kCVectorCID)
|
||||
NS_IMPL_ADDREF(nsVector)
|
||||
NS_IMPL_RELEASE(nsVector)
|
||||
|
||||
nsresult nsVector :: Init()
|
||||
{
|
||||
mVoidArray = NewObject(nsVoidArray) ;
|
||||
|
||||
return NS_OK ;
|
||||
}
|
||||
|
||||
PRUint32 nsVector :: Count()
|
||||
{
|
||||
return mVoidArray->Count() ;
|
||||
}
|
||||
|
||||
PRBool nsVector :: Empty()
|
||||
{
|
||||
return (Count() ? PR_TRUE : PR_FALSE) ;
|
||||
}
|
||||
|
||||
PRBool nsVector :: Contains(nsComponent aComponent)
|
||||
{
|
||||
if (IndexOf(aComponent))
|
||||
return PR_TRUE ;
|
||||
else
|
||||
return PR_FALSE ;
|
||||
}
|
||||
|
||||
PRUint32 nsVector :: IndexOf(nsComponent aComponent)
|
||||
{
|
||||
return (mVoidArray->IndexOf(aComponent)) ;
|
||||
}
|
||||
|
||||
nsComponent nsVector :: ElementAt(PRUint32 aIndex)
|
||||
{
|
||||
return (mVoidArray->ElementAt(aIndex)) ; ;
|
||||
}
|
||||
|
||||
/*
|
||||
* Inserts an element into the list in a sorted fashion.
|
||||
* @param newElement the element to insert
|
||||
* @param compare the sorting function
|
||||
* @param bAllowDups if TRUE-> insert duplicates into the list, if FALSE-> don't insert duplicates in the list
|
||||
* @returns -1 means that the element existed and that dupliates were not allowed, so it was not inserted.
|
||||
* 0 means the element was inserted, no problems
|
||||
* 1 means the element was not inserted because of an internal error
|
||||
*/
|
||||
PRInt32 nsVector::InsertBinary(nsComponent newElement, nsVectorCompareProc aCompareFn, PRBool bAllowDups)
|
||||
{
|
||||
PRInt32 iCurrent = 0;
|
||||
PRInt32 iLeft = 0;
|
||||
PRInt32 iRight = Count() - 1;
|
||||
PRInt32 iCompare = 0;
|
||||
|
||||
while (iLeft <= iRight)
|
||||
{
|
||||
iCurrent = (iLeft + iRight) / 2;
|
||||
void* pCurrent = ElementAt(iCurrent);
|
||||
iCompare = aCompareFn(&pCurrent, &newElement);
|
||||
if (iCompare == 0)
|
||||
{
|
||||
if (0 == bAllowDups)
|
||||
return -1;
|
||||
else
|
||||
break;
|
||||
}
|
||||
else if (iCompare > 0)
|
||||
iRight = iCurrent - 1;
|
||||
else
|
||||
iLeft = iCurrent + 1;
|
||||
}
|
||||
|
||||
if (iCompare < 0)
|
||||
iCurrent += 1;
|
||||
if (PR_TRUE == mVoidArray->InsertElementAt(newElement, iCurrent))
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
nsresult nsVector :: Insert(PRUint32 aIndex, nsComponent aComponent)
|
||||
{
|
||||
nsresult res = NS_OK;
|
||||
|
||||
if (PR_TRUE == mVoidArray->InsertElementAt(aComponent, aIndex))
|
||||
return NS_OK ;
|
||||
|
||||
// XXX What to return here
|
||||
return res ;
|
||||
}
|
||||
|
||||
nsresult nsVector :: Append(nsComponent aComponent)
|
||||
{
|
||||
nsresult res = NS_OK;
|
||||
|
||||
if (PR_TRUE == mVoidArray->AppendElement(aComponent))
|
||||
return NS_OK ;
|
||||
|
||||
// XXX What to return here
|
||||
return res ;
|
||||
}
|
||||
|
||||
nsresult nsVector :: Remove(nsComponent aComponent)
|
||||
{
|
||||
nsresult res = NS_OK;
|
||||
|
||||
if (PR_TRUE == mVoidArray->RemoveElement(aComponent))
|
||||
return NS_OK ;
|
||||
|
||||
// XXX What to return here
|
||||
return res ;
|
||||
}
|
||||
|
||||
nsresult nsVector :: RemoveAll()
|
||||
{
|
||||
mVoidArray->Clear();
|
||||
|
||||
return NS_OK ;
|
||||
}
|
||||
|
||||
nsresult nsVector :: RemoveAt(PRUint32 aIndex)
|
||||
{
|
||||
nsresult res = NS_OK;
|
||||
|
||||
if (PR_TRUE == mVoidArray->RemoveElementAt(aIndex))
|
||||
return NS_OK ;
|
||||
|
||||
// XXX What to return here
|
||||
return res ;
|
||||
}
|
||||
|
||||
nsresult nsVector :: CreateIterator(nsIIterator ** aIterator)
|
||||
{
|
||||
static NS_DEFINE_IID(kCVectorIteratorCID, NS_VECTOR_ITERATOR_CID);
|
||||
|
||||
nsresult res ;
|
||||
|
||||
#ifdef NS_WIN32
|
||||
#define XPFC_DLL "xpfc10.dll"
|
||||
#else
|
||||
#define XPFC_DLL "libxpfc10.so"
|
||||
#endif
|
||||
|
||||
nsRepository::RegisterFactory(kCVectorIteratorCID, XPFC_DLL, PR_FALSE, PR_FALSE);
|
||||
|
||||
nsVectorIterator * aVectorIterator ;
|
||||
|
||||
*aIterator = nsnull;
|
||||
|
||||
res = nsRepository::CreateInstance(kCVectorIteratorCID,
|
||||
nsnull,
|
||||
kCVectorIteratorCID,
|
||||
(void **)&aVectorIterator);
|
||||
|
||||
if (NS_OK != res)
|
||||
return res ;
|
||||
|
||||
aVectorIterator->Init(this);
|
||||
|
||||
*aIterator = (nsIIterator *) aVectorIterator;
|
||||
|
||||
return res ;
|
||||
}
|
||||
|
Загрузка…
Ссылка в новой задаче