Bug 1167389 - Make FileList::mParent a smart pointer, and declare it to the cycle collector. r=ehsan

This commit is contained in:
Michael Layzell 2015-07-07 06:38:00 -04:00
parent 25c21aef08
commit 724e72569c
4 changed files with 5 additions and 23 deletions

View File

@ -1235,7 +1235,7 @@ BlobImplTemporaryBlob::GetInternalStream(nsIInputStream** aStream,
////////////////////////////////////////////////////////////////////////////
// FileList implementation
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(FileList, mFiles)
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(FileList, mFiles, mParent)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(FileList)
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY

View File

@ -989,11 +989,6 @@ public:
return mParent;
}
void Disconnect()
{
mParent = nullptr;
}
bool Append(File *aFile) { return mFiles.AppendElement(aFile); }
bool Remove(uint32_t aIndex) {
@ -1040,7 +1035,7 @@ public:
private:
nsTArray<nsRefPtr<File>> mFiles;
nsISupports *mParent;
nsCOMPtr<nsISupports> mParent;
};
} // dom namespace

View File

@ -36,10 +36,7 @@ NS_IMPL_CYCLE_COLLECTION_CLASS(DataTransfer)
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(DataTransfer)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mParent)
if (tmp->mFiles) {
tmp->mFiles->Disconnect();
NS_IMPL_CYCLE_COLLECTION_UNLINK(mFiles)
}
NS_IMPL_CYCLE_COLLECTION_UNLINK(mFiles)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mDragTarget)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mDragImage)
NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
@ -139,11 +136,7 @@ DataTransfer::DataTransfer(nsISupports* aParent,
}
DataTransfer::~DataTransfer()
{
if (mFiles) {
mFiles->Disconnect();
}
}
{}
// static
already_AddRefed<DataTransfer>

View File

@ -879,9 +879,6 @@ HTMLInputElement::HTMLInputElement(already_AddRefed<mozilla::dom::NodeInfo>& aNo
HTMLInputElement::~HTMLInputElement()
{
if (mFileList) {
mFileList->Disconnect();
}
if (mNumberControlSpinnerIsSpinning) {
StopNumberControlSpinnerSpin();
}
@ -936,10 +933,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(HTMLInputElement,
NS_IMPL_CYCLE_COLLECTION_UNLINK(mValidity)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mControllers)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mFiles)
if (tmp->mFileList) {
tmp->mFileList->Disconnect();
tmp->mFileList = nullptr;
}
NS_IMPL_CYCLE_COLLECTION_UNLINK(mFileList)
if (tmp->IsSingleLineTextControl(false)) {
tmp->mInputData.mState->Unlink();
}