mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
[Bug 774751] Use nsRefPtr in nsIDocument r=bz
This commit is contained in:
parent
88371b030a
commit
b6548ad674
@ -19,7 +19,6 @@
|
||||
#include "nsTObserverArray.h"
|
||||
#include "nsTHashtable.h"
|
||||
#include "nsHashKeys.h"
|
||||
#include "nsNodeInfoManager.h"
|
||||
#include "nsIVariant.h"
|
||||
#include "nsIObserver.h"
|
||||
#include "nsGkAtoms.h"
|
||||
@ -126,28 +125,9 @@ public:
|
||||
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
|
||||
|
||||
#ifdef MOZILLA_INTERNAL_API
|
||||
nsIDocument()
|
||||
: nsINode(nsnull),
|
||||
mCharacterSet(NS_LITERAL_CSTRING("ISO-8859-1")),
|
||||
mNodeInfoManager(nsnull),
|
||||
mCompatMode(eCompatibility_FullStandards),
|
||||
mIsInitialDocumentInWindow(false),
|
||||
mMayStartLayout(true),
|
||||
mVisible(true),
|
||||
mRemovedFromDocShell(false),
|
||||
// mAllowDNSPrefetch starts true, so that we can always reliably && it
|
||||
// with various values that might disable it. Since we never prefetch
|
||||
// unless we get a window, and in that case the docshell value will get
|
||||
// &&-ed in, this is safe.
|
||||
mAllowDNSPrefetch(true),
|
||||
mIsBeingUsedAsImage(false),
|
||||
mHasLinksToUpdate(false),
|
||||
mPartID(0)
|
||||
{
|
||||
SetInDocument();
|
||||
}
|
||||
nsIDocument();
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* Let the document know that we're starting to load data into it.
|
||||
* @param aCommand The parser command. Must not be null.
|
||||
@ -1683,14 +1663,7 @@ private:
|
||||
PRUint64 mWarnedAbout;
|
||||
|
||||
protected:
|
||||
~nsIDocument()
|
||||
{
|
||||
// XXX The cleanup of mNodeInfoManager (calling DropDocumentReference and
|
||||
// releasing it) happens in the nsDocument destructor. We'd prefer to
|
||||
// do it here but nsNodeInfoManager is a concrete class that we don't
|
||||
// want to expose to users of the nsIDocument API outside of Gecko.
|
||||
}
|
||||
|
||||
~nsIDocument();
|
||||
nsPropertyTable* GetExtraPropertyTable(PRUint16 aCategory);
|
||||
|
||||
// Never ever call this. Only call GetWindow!
|
||||
@ -1747,11 +1720,9 @@ protected:
|
||||
// A reference to the element last returned from GetRootElement().
|
||||
mozilla::dom::Element* mCachedRootElement;
|
||||
|
||||
// We'd like these to be nsRefPtrs, but that'd require us to include
|
||||
// additional headers that we don't want to expose.
|
||||
// The cleanup is handled by the nsDocument destructor.
|
||||
// We hold a strong reference to mNodeInfoManager through mNodeInfo
|
||||
nsNodeInfoManager* mNodeInfoManager; // [STRONG]
|
||||
mozilla::css::Loader* mCSSLoader; // [STRONG]
|
||||
nsRefPtr<mozilla::css::Loader> mCSSLoader;
|
||||
nsHTMLStyleSheet* mAttrStyleSheet;
|
||||
|
||||
// The set of all object, embed, applet, video and audio elements for
|
||||
@ -1759,7 +1730,7 @@ protected:
|
||||
// These are non-owning pointers, the elements are responsible for removing
|
||||
// themselves when they go away.
|
||||
nsAutoPtr<nsTHashtable<nsPtrHashKey<nsIContent> > > mFreezableElements;
|
||||
|
||||
|
||||
// The set of all links that need their status resolved. Links must add themselves
|
||||
// to this set by calling RegisterPendingLinkUpdate when added to a document and must
|
||||
// remove themselves by calling UnregisterPendingLinkUpdate when removed from a document.
|
||||
|
@ -1494,9 +1494,29 @@ nsDOMImplementation::CreateHTMLDocument(const nsAString& aTitle,
|
||||
// ==================================================================
|
||||
// =
|
||||
// ==================================================================
|
||||
nsIDocument::nsIDocument()
|
||||
: nsINode(nsnull),
|
||||
mCharacterSet(NS_LITERAL_CSTRING("ISO-8859-1")),
|
||||
mNodeInfoManager(nsnull),
|
||||
mCompatMode(eCompatibility_FullStandards),
|
||||
mIsInitialDocumentInWindow(false),
|
||||
mMayStartLayout(true),
|
||||
mVisible(true),
|
||||
mRemovedFromDocShell(false),
|
||||
// mAllowDNSPrefetch starts true, so that we can always reliably && it
|
||||
// with various values that might disable it. Since we never prefetch
|
||||
// unless we get a window, and in that case the docshell value will get
|
||||
// &&-ed in, this is safe.
|
||||
mAllowDNSPrefetch(true),
|
||||
mIsBeingUsedAsImage(false),
|
||||
mHasLinksToUpdate(false),
|
||||
mPartID(0)
|
||||
{
|
||||
SetInDocument();
|
||||
}
|
||||
|
||||
// NOTE! nsDocument::operator new() zeroes out all members, so don't
|
||||
// bother initializing members to 0.
|
||||
// NOTE! nsDocument::operator new() zeroes out all members, so don't
|
||||
// bother initializing members to 0.
|
||||
|
||||
nsDocument::nsDocument(const char* aContentType)
|
||||
: nsIDocument()
|
||||
@ -1504,7 +1524,7 @@ nsDocument::nsDocument(const char* aContentType)
|
||||
, mVisibilityState(eHidden)
|
||||
{
|
||||
SetContentTypeInternal(nsDependentCString(aContentType));
|
||||
|
||||
|
||||
#ifdef PR_LOGGING
|
||||
if (!gDocumentLeakPRLog)
|
||||
gDocumentLeakPRLog = PR_NewLogModule("DocumentLeak");
|
||||
@ -1519,7 +1539,7 @@ nsDocument::nsDocument(const char* aContentType)
|
||||
|
||||
// Start out mLastStyleSheetSet as null, per spec
|
||||
SetDOMStringToNull(mLastStyleSheetSet);
|
||||
|
||||
|
||||
mLinksToUpdate.Init();
|
||||
}
|
||||
|
||||
@ -1532,6 +1552,14 @@ ClearAllBoxObjects(nsIContent* aKey, nsPIBoxObject* aBoxObject, void* aUserArg)
|
||||
return PL_DHASH_NEXT;
|
||||
}
|
||||
|
||||
nsIDocument::~nsIDocument()
|
||||
{
|
||||
if (mNodeInfoManager) {
|
||||
mNodeInfoManager->DropDocumentReference();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
nsDocument::~nsDocument()
|
||||
{
|
||||
#ifdef PR_LOGGING
|
||||
@ -1613,12 +1641,6 @@ nsDocument::~nsDocument()
|
||||
if (mCSSLoader) {
|
||||
// Could be null here if Init() failed
|
||||
mCSSLoader->DropDocumentReference();
|
||||
NS_RELEASE(mCSSLoader);
|
||||
}
|
||||
|
||||
// XXX Ideally we'd do this cleanup in the nsIDocument destructor.
|
||||
if (mNodeInfoManager) {
|
||||
mNodeInfoManager->DropDocumentReference();
|
||||
}
|
||||
|
||||
delete mHeaderData;
|
||||
@ -1910,7 +1932,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsDocument)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMARRAY(mPreloadingImages)
|
||||
|
||||
|
||||
|
||||
if (tmp->mBoxObjectTable) {
|
||||
tmp->mBoxObjectTable->EnumerateRead(ClearAllBoxObjects, nsnull);
|
||||
delete tmp->mBoxObjectTable;
|
||||
@ -1931,7 +1953,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsDocument)
|
||||
tmp->mFrameRequestCallbacks.Clear();
|
||||
|
||||
tmp->mRadioGroups.Clear();
|
||||
|
||||
|
||||
// nsDocument has a pretty complex destructor, so we're going to
|
||||
// assume that *most* cycles you actually want to break somewhere
|
||||
// else, and not unlink an awful lot here.
|
||||
@ -1943,7 +1965,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsDocument)
|
||||
}
|
||||
|
||||
tmp->mPendingTitleChangeEvent.Revoke();
|
||||
|
||||
|
||||
tmp->mInUnlinkOrDeletion = false;
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
|
||||
@ -1961,7 +1983,6 @@ nsDocument::Init()
|
||||
|
||||
// Force initialization.
|
||||
nsINode::nsSlots* slots = GetSlots();
|
||||
NS_ENSURE_TRUE(slots,NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
// Prepend self as mutation-observer whether we need it or not (some
|
||||
// subclasses currently do, other don't). This is because the code in
|
||||
@ -1972,17 +1993,11 @@ nsDocument::Init()
|
||||
|
||||
|
||||
mOnloadBlocker = new nsOnloadBlocker();
|
||||
NS_ENSURE_TRUE(mOnloadBlocker, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
mCSSLoader = new mozilla::css::Loader(this);
|
||||
NS_ENSURE_TRUE(mCSSLoader, NS_ERROR_OUT_OF_MEMORY);
|
||||
NS_ADDREF(mCSSLoader);
|
||||
// Assume we're not quirky, until we know otherwise
|
||||
mCSSLoader->SetCompatibilityMode(eCompatibility_FullStandards);
|
||||
|
||||
mNodeInfoManager = new nsNodeInfoManager();
|
||||
NS_ENSURE_TRUE(mNodeInfoManager, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
nsresult rv = mNodeInfoManager->Init(this);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
@ -1995,7 +2010,6 @@ nsDocument::Init()
|
||||
NS_ASSERTION(OwnerDoc() == this, "Our nodeinfo is busted!");
|
||||
|
||||
mScriptLoader = new nsScriptLoader(this);
|
||||
NS_ENSURE_TRUE(mScriptLoader, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
mImageTracker.Init();
|
||||
mPlugins.Init();
|
||||
@ -2003,7 +2017,7 @@ nsDocument::Init()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
nsIDocument::DeleteAllProperties()
|
||||
{
|
||||
for (PRUint32 i = 0; i < GetPropertyTableCount(); ++i) {
|
||||
|
Loading…
Reference in New Issue
Block a user