Backout glazman's fix for bug 107567, pending investigation
on why it causes the tinderbox Leak count to go up. a=beard@netscape.com,jj@netscape.com git-svn-id: svn://10.0.0.236/trunk@106834 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -312,6 +312,8 @@ public:
|
||||
nsVoidArray mPendingDocSheets; // loaded sheet waiting for doc insertion
|
||||
nsVoidArray mPendingAlternateSheets; // alternates waiting for load to start
|
||||
|
||||
nsHashtable mSheetMapTable; // map to insertion index arrays
|
||||
|
||||
// @charset support
|
||||
nsString mCharset; // the charset we are using
|
||||
|
||||
@@ -484,6 +486,13 @@ static PRBool PR_CALLBACK DeleteLoadData(void* aData, void* aClosure)
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
static PRBool PR_CALLBACK DeleteSheetMap(nsHashKey* aKey, void* aData, void* aClosure)
|
||||
{
|
||||
nsAutoVoidArray* map = (nsAutoVoidArray*)aData;
|
||||
delete map;
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
CSSLoaderImpl::~CSSLoaderImpl(void)
|
||||
{
|
||||
if (mLoadingSheets.Count() > 0) {
|
||||
@@ -494,6 +503,7 @@ CSSLoaderImpl::~CSSLoaderImpl(void)
|
||||
mLoadingSheets.Enumerate(DeleteHashLoadData);
|
||||
mPendingDocSheets.EnumerateForwards(DeletePendingData, nsnull);
|
||||
mPendingAlternateSheets.EnumerateForwards(DeleteLoadData, nsnull);
|
||||
mSheetMapTable.Enumerate(DeleteSheetMap);
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(CSSLoaderImpl, nsICSSLoader)
|
||||
@@ -1109,7 +1119,7 @@ CSSLoaderImpl::InsertSheetInDoc(nsICSSStyleSheet* aSheet, PRInt32 aDocIndex,
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
if (aElement) {
|
||||
if (nsnull != aElement) {
|
||||
nsIDOMNode* domNode = nsnull;
|
||||
if (NS_SUCCEEDED(aElement->QueryInterface(NS_GET_IID(nsIDOMNode), (void**)&domNode))) {
|
||||
aSheet->SetOwningNode(domNode);
|
||||
@@ -1128,11 +1138,37 @@ CSSLoaderImpl::InsertSheetInDoc(nsICSSStyleSheet* aSheet, PRInt32 aDocIndex,
|
||||
aSheet->GetTitle(title);
|
||||
aSheet->SetEnabled(! IsAlternate(title));
|
||||
|
||||
mDocument->InsertStyleSheetAt(aSheet, aDocIndex, aNotify);
|
||||
if (aObserver) {
|
||||
aObserver->StyleSheetLoaded(aSheet, aNotify);
|
||||
nsVoidKey key(mDocument);
|
||||
nsAutoVoidArray* sheetMap = (nsAutoVoidArray*)mSheetMapTable.Get(&key);
|
||||
if (! sheetMap) {
|
||||
sheetMap = new nsAutoVoidArray();
|
||||
if (sheetMap) {
|
||||
mSheetMapTable.Put(&key, sheetMap);
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
|
||||
if (sheetMap) {
|
||||
PRInt32 insertIndex = sheetMap->Count();
|
||||
PRBool insertedSheet = PR_FALSE;
|
||||
while (0 <= --insertIndex) {
|
||||
PRInt32 targetIndex = NS_PTR_TO_INT32(sheetMap->ElementAt(insertIndex));
|
||||
if (targetIndex < aDocIndex) {
|
||||
mDocument->InsertStyleSheetAt(aSheet, insertIndex + 1, aNotify);
|
||||
sheetMap->InsertElementAt((void*)aDocIndex, insertIndex + 1);
|
||||
insertedSheet = PR_TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!insertedSheet) { // didn't insert yet
|
||||
mDocument->InsertStyleSheetAt(aSheet, 0, aNotify);
|
||||
sheetMap->InsertElementAt((void*)aDocIndex, 0);
|
||||
}
|
||||
if (nsnull != aObserver) {
|
||||
aObserver->StyleSheetLoaded(aSheet, aNotify);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
nsresult
|
||||
@@ -1143,8 +1179,33 @@ CSSLoaderImpl::InsertChildSheet(nsICSSStyleSheet* aSheet, nsICSSStyleSheet* aPar
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
aParentSheet->InsertStyleSheetAt(aSheet, aIndex);
|
||||
return NS_OK;
|
||||
nsVoidKey key(aParentSheet);
|
||||
nsAutoVoidArray* sheetMap = (nsAutoVoidArray*)mSheetMapTable.Get(&key);
|
||||
if (! sheetMap) {
|
||||
sheetMap = new nsAutoVoidArray();
|
||||
if (sheetMap) {
|
||||
mSheetMapTable.Put(&key, sheetMap);
|
||||
}
|
||||
}
|
||||
|
||||
if (sheetMap) {
|
||||
PRInt32 insertIndex = sheetMap->Count();
|
||||
while (0 <= --insertIndex) {
|
||||
PRInt32 targetIndex = NS_PTR_TO_INT32(sheetMap->ElementAt(insertIndex));
|
||||
if (targetIndex < aIndex) {
|
||||
aParentSheet->InsertStyleSheetAt(aSheet, insertIndex + 1);
|
||||
sheetMap->InsertElementAt((void*)aIndex, insertIndex + 1);
|
||||
aSheet = nsnull;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (nsnull != aSheet) { // didn't insert yet
|
||||
aParentSheet->InsertStyleSheetAt(aSheet, 0);
|
||||
sheetMap->InsertElementAt((void*)aIndex, 0);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
||||
Reference in New Issue
Block a user