зеркало из https://github.com/mozilla/pjs.git
Begin deCOMtamination of central objects by adding inline getters to get from one object to another. b=208190 r=roc sr=bzbarsky
This commit is contained in:
Родитель
32d7da59d5
Коммит
815131809e
|
@ -150,12 +150,16 @@ public:
|
|||
NS_IMETHOD AllocateStackMemory(size_t aSize, void** aResult) = 0;
|
||||
|
||||
NS_IMETHOD GetDocument(nsIDocument** aResult) = 0;
|
||||
nsIDocument* GetDocument() { return mDocument; }
|
||||
|
||||
NS_IMETHOD GetPresContext(nsIPresContext** aResult) = 0;
|
||||
nsIPresContext* GetPresContext() { return mPresContext; }
|
||||
|
||||
NS_IMETHOD GetViewManager(nsIViewManager** aResult) = 0;
|
||||
nsIViewManager* GetViewManager() { return mViewManager; }
|
||||
|
||||
NS_IMETHOD GetStyleSet(nsIStyleSet** aResult) = 0;
|
||||
nsIStyleSet* GetStyleSet() { return mStyleSet; }
|
||||
|
||||
NS_IMETHOD GetActiveAlternateStyleSheet(nsString& aSheetTitle) = 0;
|
||||
|
||||
|
@ -609,6 +613,17 @@ public:
|
|||
NS_IMETHOD BidiStyleChangeReflow(void) = 0;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
// IMPORTANT: The ownership implicit in the following member variables
|
||||
// has been explicitly checked. If you add any members to this class,
|
||||
// please make the ownership explicit (pinkerton, scc).
|
||||
|
||||
// these are the same Document and PresContext owned by the DocViewer.
|
||||
// we must share ownership.
|
||||
nsIDocument* mDocument; // [STRONG]
|
||||
nsIPresContext* mPresContext; // [STRONG]
|
||||
nsIStyleSet* mStyleSet; // [STRONG]
|
||||
nsIViewManager* mViewManager; // [WEAK] docViewer owns it so I don't have to
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -211,8 +211,10 @@ nsPresContext::~nsPresContext()
|
|||
NS_PRECONDITION(!mShell, "Presshell forgot to clear our mShell pointer");
|
||||
SetShell(nsnull);
|
||||
|
||||
if (mEventManager)
|
||||
if (mEventManager) {
|
||||
mEventManager->SetPresContext(nsnull); // unclear if this is needed, but can't hurt
|
||||
NS_RELEASE(mEventManager);
|
||||
}
|
||||
|
||||
// Unregister preference callbacks
|
||||
if (mPrefs) {
|
||||
|
@ -232,6 +234,8 @@ nsPresContext::~nsPresContext()
|
|||
delete mBidiUtils;
|
||||
}
|
||||
#endif // IBMBIDI
|
||||
|
||||
NS_IF_RELEASE(mDeviceContext);
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS2(nsPresContext, nsIPresContext, nsIObserver)
|
||||
|
@ -618,7 +622,8 @@ nsPresContext::Init(nsIDeviceContext* aDeviceContext)
|
|||
{
|
||||
NS_ASSERTION(!(mInitialized == PR_TRUE), "attempt to reinit pres context");
|
||||
|
||||
mDeviceContext = dont_QueryInterface(aDeviceContext);
|
||||
mDeviceContext = aDeviceContext;
|
||||
NS_IF_ADDREF(mDeviceContext);
|
||||
|
||||
mLangService = do_GetService(NS_LANGUAGEATOMSERVICE_CONTRACTID);
|
||||
mPrefs = do_GetService(NS_PREF_CONTRACTID);
|
||||
|
@ -1497,24 +1502,30 @@ nsPresContext::GetContainer(nsISupports** aResult)
|
|||
return CallQueryReferent(mContainer.get(), aResult);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPresContext::GetEventStateManager(nsIEventStateManager** aManager)
|
||||
nsIEventStateManager*
|
||||
nsIPresContext::GetEventStateManager()
|
||||
{
|
||||
NS_PRECONDITION(aManager, "null ptr");
|
||||
|
||||
if (!mEventManager) {
|
||||
nsresult rv;
|
||||
mEventManager = do_CreateInstance(kEventStateManagerCID,&rv);
|
||||
nsresult rv = CallCreateInstance(kEventStateManagerCID, &mEventManager);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
//Not refcnted, set null in destructor
|
||||
mEventManager->SetPresContext(this);
|
||||
}
|
||||
return mEventManager;
|
||||
}
|
||||
|
||||
*aManager = mEventManager;
|
||||
NS_IF_ADDREF(*aManager);
|
||||
NS_IMETHODIMP
|
||||
nsPresContext::GetEventStateManager(nsIEventStateManager** aManager)
|
||||
{
|
||||
NS_PRECONDITION(aManager, "null ptr");
|
||||
|
||||
*aManager = GetEventStateManager();
|
||||
if (!*aManager)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(*aManager);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#include "nsIRequest.h"
|
||||
#include "nsCompatibility.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIPresShell.h"
|
||||
#ifdef IBMBIDI
|
||||
class nsBidiPresUtils;
|
||||
#endif // IBMBIDI
|
||||
|
@ -131,6 +132,11 @@ public:
|
|||
* Get the PresentationShell that this context is bound to.
|
||||
*/
|
||||
NS_IMETHOD GetShell(nsIPresShell** aResult) = 0;
|
||||
nsIPresShell* GetPresShell() { return mShell; }
|
||||
|
||||
nsIDocument* GetDocument() { return GetPresShell()->GetDocument(); }
|
||||
nsIViewManager* GetViewManager() { return GetPresShell()->GetViewManager(); }
|
||||
nsIStyleSet* GetStyleSet() { return GetPresShell()->GetStyleSet(); }
|
||||
|
||||
/**
|
||||
* Access compatibility mode for this context
|
||||
|
@ -393,10 +399,12 @@ public:
|
|||
*/
|
||||
NS_IMETHOD GetScaledPixelsToTwips(float* aScale) const = 0;
|
||||
|
||||
//be sure to Relase() after you are done with the Get()
|
||||
NS_IMETHOD GetDeviceContext(nsIDeviceContext** aResult) const = 0;
|
||||
nsIDeviceContext* GetDeviceContext() { return mDeviceContext; }
|
||||
|
||||
NS_IMETHOD GetEventStateManager(nsIEventStateManager** aManager) = 0;
|
||||
nsIEventStateManager* GetEventStateManager();
|
||||
|
||||
NS_IMETHOD GetLanguage(nsILanguageAtom** aLanguage) = 0;
|
||||
|
||||
/**
|
||||
|
@ -546,6 +554,20 @@ public:
|
|||
NS_IMETHOD CountReflows(const char * aName, PRUint32 aType, nsIFrame * aFrame) = 0;
|
||||
NS_IMETHOD PaintCount(const char * aName, nsIRenderingContext* aRendingContext, nsIFrame * aFrame, PRUint32 aColor) = 0;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
// IMPORTANT: The ownership implicit in the following member variables
|
||||
// has been explicitly checked. If you add any members to this class,
|
||||
// please make the ownership explicit (pinkerton, scc).
|
||||
|
||||
nsIPresShell* mShell; // [WEAK]
|
||||
nsIDeviceContext* mDeviceContext; // [STRONG] could be weak, but
|
||||
// better safe than sorry.
|
||||
// Cannot reintroduce cycles
|
||||
// since there is no dependency
|
||||
// from gfx back to layout.
|
||||
nsIEventStateManager* mEventManager; // [STRONG]
|
||||
|
||||
};
|
||||
|
||||
// Bit values for StartLoadImage's aImageStatus
|
||||
|
|
|
@ -1294,18 +1294,7 @@ protected:
|
|||
|
||||
nsresult GetSelectionForCopy(nsISelection** outSelection);
|
||||
|
||||
// IMPORTANT: The ownership implicit in the following member variables has been
|
||||
// explicitly checked and set using nsCOMPtr for owning pointers and raw COM interface
|
||||
// pointers for weak (ie, non owning) references. If you add any members to this
|
||||
// class, please make the ownership explicit (pinkerton, scc).
|
||||
|
||||
// these are the same Document and PresContext owned by the DocViewer.
|
||||
// we must share ownership.
|
||||
nsCOMPtr<nsIDocument> mDocument;
|
||||
nsCOMPtr<nsIPresContext> mPresContext;
|
||||
nsCOMPtr<nsIStyleSet> mStyleSet;
|
||||
nsICSSStyleSheet* mPrefStyleSheet; // mStyleSet owns it but we maintaina ref, may be null
|
||||
nsIViewManager* mViewManager; // [WEAK] docViewer owns it so I don't have to
|
||||
PRUint32 mUpdateCount;
|
||||
// normal reflow commands
|
||||
nsVoidArray mReflowCommands;
|
||||
|
@ -1613,6 +1602,9 @@ PresShell::~PresShell()
|
|||
|
||||
// if we allocated any stack memory free it.
|
||||
FreeDynamicStack();
|
||||
|
||||
NS_IF_RELEASE(mPresContext);
|
||||
NS_IF_RELEASE(mDocument);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1638,7 +1630,8 @@ PresShell::Init(nsIDocument* aDocument,
|
|||
return NS_ERROR_ALREADY_INITIALIZED;
|
||||
}
|
||||
|
||||
mDocument = dont_QueryInterface(aDocument);
|
||||
mDocument = aDocument;
|
||||
NS_ADDREF(mDocument);
|
||||
mViewManager = aViewManager;
|
||||
|
||||
// The document viewer owns both view manager and pres shell.
|
||||
|
@ -1646,9 +1639,11 @@ PresShell::Init(nsIDocument* aDocument,
|
|||
|
||||
// Bind the context to the presentation shell.
|
||||
mPresContext = aPresContext;
|
||||
NS_ADDREF(mPresContext);
|
||||
aPresContext->SetShell(this);
|
||||
|
||||
mStyleSet = aStyleSet;
|
||||
NS_IF_ADDREF(mStyleSet);
|
||||
|
||||
// Set the compatibility mode after attaching the pres context and
|
||||
// style set, but before creating any frames.
|
||||
|
@ -1837,7 +1832,7 @@ PresShell::Destroy()
|
|||
|
||||
// Let the style set do its cleanup.
|
||||
mStyleSet->Shutdown(mPresContext);
|
||||
mStyleSet = nsnull;
|
||||
NS_RELEASE(mStyleSet);
|
||||
|
||||
// We hold a reference to the pres context, and it holds a weak link back
|
||||
// to us. To avoid the pres context having a dangling reference, set its
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#include "nsIRequest.h"
|
||||
#include "nsCompatibility.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIPresShell.h"
|
||||
#ifdef IBMBIDI
|
||||
class nsBidiPresUtils;
|
||||
#endif // IBMBIDI
|
||||
|
@ -131,6 +132,11 @@ public:
|
|||
* Get the PresentationShell that this context is bound to.
|
||||
*/
|
||||
NS_IMETHOD GetShell(nsIPresShell** aResult) = 0;
|
||||
nsIPresShell* GetPresShell() { return mShell; }
|
||||
|
||||
nsIDocument* GetDocument() { return GetPresShell()->GetDocument(); }
|
||||
nsIViewManager* GetViewManager() { return GetPresShell()->GetViewManager(); }
|
||||
nsIStyleSet* GetStyleSet() { return GetPresShell()->GetStyleSet(); }
|
||||
|
||||
/**
|
||||
* Access compatibility mode for this context
|
||||
|
@ -393,10 +399,12 @@ public:
|
|||
*/
|
||||
NS_IMETHOD GetScaledPixelsToTwips(float* aScale) const = 0;
|
||||
|
||||
//be sure to Relase() after you are done with the Get()
|
||||
NS_IMETHOD GetDeviceContext(nsIDeviceContext** aResult) const = 0;
|
||||
nsIDeviceContext* GetDeviceContext() { return mDeviceContext; }
|
||||
|
||||
NS_IMETHOD GetEventStateManager(nsIEventStateManager** aManager) = 0;
|
||||
nsIEventStateManager* GetEventStateManager();
|
||||
|
||||
NS_IMETHOD GetLanguage(nsILanguageAtom** aLanguage) = 0;
|
||||
|
||||
/**
|
||||
|
@ -546,6 +554,20 @@ public:
|
|||
NS_IMETHOD CountReflows(const char * aName, PRUint32 aType, nsIFrame * aFrame) = 0;
|
||||
NS_IMETHOD PaintCount(const char * aName, nsIRenderingContext* aRendingContext, nsIFrame * aFrame, PRUint32 aColor) = 0;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
// IMPORTANT: The ownership implicit in the following member variables
|
||||
// has been explicitly checked. If you add any members to this class,
|
||||
// please make the ownership explicit (pinkerton, scc).
|
||||
|
||||
nsIPresShell* mShell; // [WEAK]
|
||||
nsIDeviceContext* mDeviceContext; // [STRONG] could be weak, but
|
||||
// better safe than sorry.
|
||||
// Cannot reintroduce cycles
|
||||
// since there is no dependency
|
||||
// from gfx back to layout.
|
||||
nsIEventStateManager* mEventManager; // [STRONG]
|
||||
|
||||
};
|
||||
|
||||
// Bit values for StartLoadImage's aImageStatus
|
||||
|
|
|
@ -150,12 +150,16 @@ public:
|
|||
NS_IMETHOD AllocateStackMemory(size_t aSize, void** aResult) = 0;
|
||||
|
||||
NS_IMETHOD GetDocument(nsIDocument** aResult) = 0;
|
||||
nsIDocument* GetDocument() { return mDocument; }
|
||||
|
||||
NS_IMETHOD GetPresContext(nsIPresContext** aResult) = 0;
|
||||
nsIPresContext* GetPresContext() { return mPresContext; }
|
||||
|
||||
NS_IMETHOD GetViewManager(nsIViewManager** aResult) = 0;
|
||||
nsIViewManager* GetViewManager() { return mViewManager; }
|
||||
|
||||
NS_IMETHOD GetStyleSet(nsIStyleSet** aResult) = 0;
|
||||
nsIStyleSet* GetStyleSet() { return mStyleSet; }
|
||||
|
||||
NS_IMETHOD GetActiveAlternateStyleSheet(nsString& aSheetTitle) = 0;
|
||||
|
||||
|
@ -609,6 +613,17 @@ public:
|
|||
NS_IMETHOD BidiStyleChangeReflow(void) = 0;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
// IMPORTANT: The ownership implicit in the following member variables
|
||||
// has been explicitly checked. If you add any members to this class,
|
||||
// please make the ownership explicit (pinkerton, scc).
|
||||
|
||||
// these are the same Document and PresContext owned by the DocViewer.
|
||||
// we must share ownership.
|
||||
nsIDocument* mDocument; // [STRONG]
|
||||
nsIPresContext* mPresContext; // [STRONG]
|
||||
nsIStyleSet* mStyleSet; // [STRONG]
|
||||
nsIViewManager* mViewManager; // [WEAK] docViewer owns it so I don't have to
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#include "nsIRequest.h"
|
||||
#include "nsCompatibility.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIPresShell.h"
|
||||
#ifdef IBMBIDI
|
||||
class nsBidiPresUtils;
|
||||
#endif // IBMBIDI
|
||||
|
@ -131,6 +132,11 @@ public:
|
|||
* Get the PresentationShell that this context is bound to.
|
||||
*/
|
||||
NS_IMETHOD GetShell(nsIPresShell** aResult) = 0;
|
||||
nsIPresShell* GetPresShell() { return mShell; }
|
||||
|
||||
nsIDocument* GetDocument() { return GetPresShell()->GetDocument(); }
|
||||
nsIViewManager* GetViewManager() { return GetPresShell()->GetViewManager(); }
|
||||
nsIStyleSet* GetStyleSet() { return GetPresShell()->GetStyleSet(); }
|
||||
|
||||
/**
|
||||
* Access compatibility mode for this context
|
||||
|
@ -393,10 +399,12 @@ public:
|
|||
*/
|
||||
NS_IMETHOD GetScaledPixelsToTwips(float* aScale) const = 0;
|
||||
|
||||
//be sure to Relase() after you are done with the Get()
|
||||
NS_IMETHOD GetDeviceContext(nsIDeviceContext** aResult) const = 0;
|
||||
nsIDeviceContext* GetDeviceContext() { return mDeviceContext; }
|
||||
|
||||
NS_IMETHOD GetEventStateManager(nsIEventStateManager** aManager) = 0;
|
||||
nsIEventStateManager* GetEventStateManager();
|
||||
|
||||
NS_IMETHOD GetLanguage(nsILanguageAtom** aLanguage) = 0;
|
||||
|
||||
/**
|
||||
|
@ -546,6 +554,20 @@ public:
|
|||
NS_IMETHOD CountReflows(const char * aName, PRUint32 aType, nsIFrame * aFrame) = 0;
|
||||
NS_IMETHOD PaintCount(const char * aName, nsIRenderingContext* aRendingContext, nsIFrame * aFrame, PRUint32 aColor) = 0;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
// IMPORTANT: The ownership implicit in the following member variables
|
||||
// has been explicitly checked. If you add any members to this class,
|
||||
// please make the ownership explicit (pinkerton, scc).
|
||||
|
||||
nsIPresShell* mShell; // [WEAK]
|
||||
nsIDeviceContext* mDeviceContext; // [STRONG] could be weak, but
|
||||
// better safe than sorry.
|
||||
// Cannot reintroduce cycles
|
||||
// since there is no dependency
|
||||
// from gfx back to layout.
|
||||
nsIEventStateManager* mEventManager; // [STRONG]
|
||||
|
||||
};
|
||||
|
||||
// Bit values for StartLoadImage's aImageStatus
|
||||
|
|
|
@ -211,8 +211,10 @@ nsPresContext::~nsPresContext()
|
|||
NS_PRECONDITION(!mShell, "Presshell forgot to clear our mShell pointer");
|
||||
SetShell(nsnull);
|
||||
|
||||
if (mEventManager)
|
||||
if (mEventManager) {
|
||||
mEventManager->SetPresContext(nsnull); // unclear if this is needed, but can't hurt
|
||||
NS_RELEASE(mEventManager);
|
||||
}
|
||||
|
||||
// Unregister preference callbacks
|
||||
if (mPrefs) {
|
||||
|
@ -232,6 +234,8 @@ nsPresContext::~nsPresContext()
|
|||
delete mBidiUtils;
|
||||
}
|
||||
#endif // IBMBIDI
|
||||
|
||||
NS_IF_RELEASE(mDeviceContext);
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS2(nsPresContext, nsIPresContext, nsIObserver)
|
||||
|
@ -618,7 +622,8 @@ nsPresContext::Init(nsIDeviceContext* aDeviceContext)
|
|||
{
|
||||
NS_ASSERTION(!(mInitialized == PR_TRUE), "attempt to reinit pres context");
|
||||
|
||||
mDeviceContext = dont_QueryInterface(aDeviceContext);
|
||||
mDeviceContext = aDeviceContext;
|
||||
NS_IF_ADDREF(mDeviceContext);
|
||||
|
||||
mLangService = do_GetService(NS_LANGUAGEATOMSERVICE_CONTRACTID);
|
||||
mPrefs = do_GetService(NS_PREF_CONTRACTID);
|
||||
|
@ -1497,24 +1502,30 @@ nsPresContext::GetContainer(nsISupports** aResult)
|
|||
return CallQueryReferent(mContainer.get(), aResult);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPresContext::GetEventStateManager(nsIEventStateManager** aManager)
|
||||
nsIEventStateManager*
|
||||
nsIPresContext::GetEventStateManager()
|
||||
{
|
||||
NS_PRECONDITION(aManager, "null ptr");
|
||||
|
||||
if (!mEventManager) {
|
||||
nsresult rv;
|
||||
mEventManager = do_CreateInstance(kEventStateManagerCID,&rv);
|
||||
nsresult rv = CallCreateInstance(kEventStateManagerCID, &mEventManager);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
//Not refcnted, set null in destructor
|
||||
mEventManager->SetPresContext(this);
|
||||
}
|
||||
return mEventManager;
|
||||
}
|
||||
|
||||
*aManager = mEventManager;
|
||||
NS_IF_ADDREF(*aManager);
|
||||
NS_IMETHODIMP
|
||||
nsPresContext::GetEventStateManager(nsIEventStateManager** aManager)
|
||||
{
|
||||
NS_PRECONDITION(aManager, "null ptr");
|
||||
|
||||
*aManager = GetEventStateManager();
|
||||
if (!*aManager)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(*aManager);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -155,6 +155,9 @@ public:
|
|||
NS_IMETHOD GetScaledPixelsToTwips(float* aScale) const;
|
||||
NS_IMETHOD GetDeviceContext(nsIDeviceContext** aResult) const;
|
||||
NS_IMETHOD GetEventStateManager(nsIEventStateManager** aManager);
|
||||
nsIEventStateManager* GetEventStateManager() {
|
||||
return nsIPresContext::GetEventStateManager();
|
||||
}
|
||||
NS_IMETHOD GetLanguage(nsILanguageAtom** aLanguage);
|
||||
NS_IMETHOD GetLanguageSpecificTransformType(
|
||||
nsLanguageSpecificTransformType* aType);
|
||||
|
@ -208,16 +211,8 @@ protected:
|
|||
nsPresContext();
|
||||
virtual ~nsPresContext();
|
||||
|
||||
// IMPORTANT: The ownership implicit in the following member variables has been
|
||||
// explicitly checked and set using nsCOMPtr for owning pointers and raw COM interface
|
||||
// pointers for weak (ie, non owning) references. If you add any members to this
|
||||
// class, please make the ownership explicit (pinkerton, scc).
|
||||
|
||||
nsIPresShell* mShell; // [WEAK]
|
||||
nsCOMPtr<nsIPref> mPrefs;
|
||||
nsRect mVisibleArea;
|
||||
nsCOMPtr<nsIDeviceContext> mDeviceContext; // could be weak, but better safe than sorry. Cannot reintroduce cycles
|
||||
// since there is no dependency from gfx back to layout.
|
||||
nsCOMPtr<nsILanguageAtomService> mLangService;
|
||||
nsCOMPtr<nsILanguageAtom> mLanguage;
|
||||
nsLanguageSpecificTransformType mLanguageSpecificTransformType;
|
||||
|
@ -257,7 +252,6 @@ protected:
|
|||
|
||||
nsSupportsHashtable mImageLoaders;
|
||||
|
||||
nsCOMPtr<nsIEventStateManager> mEventManager;
|
||||
nsCOMPtr<nsIURI> mBaseURL;
|
||||
|
||||
nsCompatibility mCompatibilityMode;
|
||||
|
|
|
@ -1294,18 +1294,7 @@ protected:
|
|||
|
||||
nsresult GetSelectionForCopy(nsISelection** outSelection);
|
||||
|
||||
// IMPORTANT: The ownership implicit in the following member variables has been
|
||||
// explicitly checked and set using nsCOMPtr for owning pointers and raw COM interface
|
||||
// pointers for weak (ie, non owning) references. If you add any members to this
|
||||
// class, please make the ownership explicit (pinkerton, scc).
|
||||
|
||||
// these are the same Document and PresContext owned by the DocViewer.
|
||||
// we must share ownership.
|
||||
nsCOMPtr<nsIDocument> mDocument;
|
||||
nsCOMPtr<nsIPresContext> mPresContext;
|
||||
nsCOMPtr<nsIStyleSet> mStyleSet;
|
||||
nsICSSStyleSheet* mPrefStyleSheet; // mStyleSet owns it but we maintaina ref, may be null
|
||||
nsIViewManager* mViewManager; // [WEAK] docViewer owns it so I don't have to
|
||||
PRUint32 mUpdateCount;
|
||||
// normal reflow commands
|
||||
nsVoidArray mReflowCommands;
|
||||
|
@ -1613,6 +1602,9 @@ PresShell::~PresShell()
|
|||
|
||||
// if we allocated any stack memory free it.
|
||||
FreeDynamicStack();
|
||||
|
||||
NS_IF_RELEASE(mPresContext);
|
||||
NS_IF_RELEASE(mDocument);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1638,7 +1630,8 @@ PresShell::Init(nsIDocument* aDocument,
|
|||
return NS_ERROR_ALREADY_INITIALIZED;
|
||||
}
|
||||
|
||||
mDocument = dont_QueryInterface(aDocument);
|
||||
mDocument = aDocument;
|
||||
NS_ADDREF(mDocument);
|
||||
mViewManager = aViewManager;
|
||||
|
||||
// The document viewer owns both view manager and pres shell.
|
||||
|
@ -1646,9 +1639,11 @@ PresShell::Init(nsIDocument* aDocument,
|
|||
|
||||
// Bind the context to the presentation shell.
|
||||
mPresContext = aPresContext;
|
||||
NS_ADDREF(mPresContext);
|
||||
aPresContext->SetShell(this);
|
||||
|
||||
mStyleSet = aStyleSet;
|
||||
NS_IF_ADDREF(mStyleSet);
|
||||
|
||||
// Set the compatibility mode after attaching the pres context and
|
||||
// style set, but before creating any frames.
|
||||
|
@ -1837,7 +1832,7 @@ PresShell::Destroy()
|
|||
|
||||
// Let the style set do its cleanup.
|
||||
mStyleSet->Shutdown(mPresContext);
|
||||
mStyleSet = nsnull;
|
||||
NS_RELEASE(mStyleSet);
|
||||
|
||||
// We hold a reference to the pres context, and it holds a weak link back
|
||||
// to us. To avoid the pres context having a dangling reference, set its
|
||||
|
|
Загрузка…
Ссылка в новой задаче