Bug 1352968 part 4 - Change the direction of child stylesheet list. r=heycam
authorXidorn Quan <me@upsuper.org>
Tue, 30 May 2017 11:10:25 +1000
changeset 409274 28676da16b1613c4b7e36b7012fd8d46d7905291
parent 409273 58cf5a6058fc71ae6fe588efed561f27c8f023c8
child 409275 afe344d438168a0b7ce4bb2a50e679712f7c77e7
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam
bugs1352968
milestone55.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 1352968 part 4 - Change the direction of child stylesheet list. r=heycam It seems no one actually care about the order of the list, and the order is completely meaningless if the script insert new @import rules. Changing the order makes inserting faster, and make it easier for later patch to get the latest inserted child sheet. MozReview-Commit-ID: 72eKqVoPbZ7
layout/style/Loader.cpp
layout/style/StyleSheet.cpp
layout/style/StyleSheet.h
--- a/layout/style/Loader.cpp
+++ b/layout/style/Loader.cpp
@@ -1417,17 +1417,17 @@ Loader::InsertChildSheet(StyleSheet* aSh
     // cloned off of top-level sheets which were disabled
     aSheet->AsGecko()->SetEnabled(true);
     aGeckoParentRule->SetSheet(aSheet->AsGecko()); // This sets the ownerRule on the sheet
   } else {
     if (!aSheet->AsServo()->RawSheet()) {
       aSheet->AsServo()->SetSheetForImport(aServoChildSheet);
     }
   }
-  aParentSheet->AppendStyleSheet(aSheet);
+  aParentSheet->PrependStyleSheet(aSheet);
 
   LOG(("  Inserting into parent sheet"));
   return NS_OK;
 }
 
 /**
  * LoadSheet handles the actual load of a sheet.  If the load is
  * supposed to be synchronous it just opens a channel synchronously
--- a/layout/style/StyleSheet.cpp
+++ b/layout/style/StyleSheet.cpp
@@ -690,26 +690,23 @@ StyleSheet::SetAssociatedDocument(nsIDoc
 
 void
 StyleSheet::ClearAssociatedDocument()
 {
   SetAssociatedDocument(nullptr, NotOwnedByDocument);
 }
 
 void
-StyleSheet::AppendStyleSheet(StyleSheet* aSheet)
+StyleSheet::PrependStyleSheet(StyleSheet* aSheet)
 {
   NS_PRECONDITION(nullptr != aSheet, "null arg");
 
   WillDirty();
-  RefPtr<StyleSheet>* tail = &SheetInfo().mFirstChild;
-  while (*tail) {
-    tail = &(*tail)->mNext;
-  }
-  *tail = aSheet;
+  aSheet->mNext = SheetInfo().mFirstChild;
+  SheetInfo().mFirstChild = aSheet;
 
   // This is not reference counted. Our parent tells us when
   // it's going away.
   aSheet->mParent = this;
   aSheet->SetAssociatedDocument(mDocument, mDocumentAssociationMode);
   DidDirty();
 }
 
--- a/layout/style/StyleSheet.h
+++ b/layout/style/StyleSheet.h
@@ -162,17 +162,17 @@ public:
   nsINode* GetOwnerNode() const { return mOwningNode; }
   inline StyleSheet* GetParentSheet() const { return mParent; }
 
   void SetOwnerRule(dom::CSSImportRule* aOwnerRule) {
     mOwnerRule = aOwnerRule; /* Not ref counted */
   }
   dom::CSSImportRule* GetOwnerRule() const { return mOwnerRule; }
 
-  void AppendStyleSheet(StyleSheet* aSheet);
+  void PrependStyleSheet(StyleSheet* aSheet);
 
   StyleSheet* GetFirstChild() const;
 
   // Principal() never returns a null pointer.
   inline nsIPrincipal* Principal() const;
   /**
    * SetPrincipal should be called on all sheets before parsing into them.
    * This can only be called once with a non-null principal.  Calling this with