Bug 185236 part 2. Make sure to remove our SheetLoadData from mPostedEvents before calling SheetComplete on it, so that checking for pending loads from inside SheetComplete will work correctly. r=peterv
authorBoris Zbarsky <bzbarsky@mit.edu>
Mon, 26 Sep 2011 17:26:05 -0400
changeset 78925 465554cdfbcc1785afd3804b7ba711add1ecdd32
parent 78924 bb87ceae27a5d682c2f28450300e31438d95d096
child 78926 2c05e937de5d8eb6002eb74e8b4a6f30cc303887
push id78
push userclegnitto@mozilla.com
push dateFri, 16 Dec 2011 17:32:24 +0000
treeherdermozilla-release@79d24e644fdd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspeterv
bugs185236
milestone9.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 185236 part 2. Make sure to remove our SheetLoadData from mPostedEvents before calling SheetComplete on it, so that checking for pending loads from inside SheetComplete will work correctly. r=peterv
layout/style/Loader.cpp
layout/style/Loader.h
--- a/layout/style/Loader.cpp
+++ b/layout/style/Loader.cpp
@@ -2173,25 +2173,29 @@ Loader::PostLoadEvent(nsIURI* aURI,
 
 void
 Loader::HandleLoadEvent(SheetLoadData* aEvent)
 {
   // XXXbz can't assert this yet.... May not have an observer because
   // we're unblocking the parser
   // NS_ASSERTION(aEvent->mObserver, "Must have observer");
   NS_ASSERTION(aEvent->mSheet, "Must have sheet");
+
+  // Very important: this needs to come before the SheetComplete call
+  // below, so that HasPendingLoads() will test true as needed under
+  // notifications we send from that SheetComplete call.
+  mPostedEvents.RemoveElement(aEvent);
+
   if (!aEvent->mIsCancelled) {
     // SheetComplete will call Release(), so give it a reference to do
     // that with.
     NS_ADDREF(aEvent);
     SheetComplete(aEvent, NS_OK);
   }
 
-  mPostedEvents.RemoveElement(aEvent);
-
   if (mDocument) {
     mDocument->UnblockOnload(PR_TRUE);
   }
 }
 
 static PLDHashOperator
 StopLoadingSheetCallback(URIAndPrincipalHashKey* aKey,
                          SheetLoadData*& aData,
--- a/layout/style/Loader.h
+++ b/layout/style/Loader.h
@@ -467,16 +467,17 @@ private:
   // some.  Allocate some storage, what the hell.
   nsAutoTArray<SheetLoadData*, 8> mParsingDatas;
 
   // The array of posted stylesheet loaded events (SheetLoadDatas) we have.
   // Note that these are rare.
   LoadDataArray     mPostedEvents;
 
   // Our array of "global" observers
+  // XXXbz these are strong refs; should we be cycle collecting CSS loaders?
   nsTObserverArray<nsCOMPtr<nsICSSLoaderObserver> > mObservers;
 
   // the load data needs access to the document...
   nsIDocument*      mDocument;  // the document we live for
 
   // Refcounting
   nsAutoRefCnt      mRefCnt;
   NS_DECL_OWNINGTHREAD