Bug 1363572 Part 2: Change ServoStyleSet to use uint64_t for entry unique IDs. draft
authorBrad Werth <bwerth@mozilla.com>
Wed, 10 May 2017 11:20:57 -0700
changeset 577073 a7b1d9d5139735c67266ff58dfb45c0a9a60896c
parent 576982 1e2fe13035e13b7b4001ade3b48f226957cef5fc
child 577074 6469bf51d69da1877b5b9d7f1e8c7852cd0b5fac
push id58593
push userbwerth@mozilla.com
push dateFri, 12 May 2017 19:49:54 +0000
bugs1363572
milestone55.0a1
Bug 1363572 Part 2: Change ServoStyleSet to use uint64_t for entry unique IDs. MozReview-Commit-ID: 50whQ71j4B5
layout/style/ServoBindingList.h
layout/style/ServoStyleSet.cpp
layout/style/ServoStyleSet.h
--- a/layout/style/ServoBindingList.h
+++ b/layout/style/ServoBindingList.h
@@ -47,29 +47,29 @@ SERVO_BINDING_FUNC(Servo_StyleSheet_GetR
                    RawServoStyleSheetBorrowed sheet)
 SERVO_BINDING_FUNC(Servo_StyleSet_Init, RawServoStyleSetOwned, RawGeckoPresContextOwned pres_context)
 SERVO_BINDING_FUNC(Servo_StyleSet_RebuildData, void,
                    RawServoStyleSetBorrowed set)
 SERVO_BINDING_FUNC(Servo_StyleSet_Drop, void, RawServoStyleSetOwned set)
 SERVO_BINDING_FUNC(Servo_StyleSet_AppendStyleSheet, void,
                    RawServoStyleSetBorrowed set,
                    RawServoStyleSheetBorrowed sheet,
-                   uint32_t unique_id)
+                   uint64_t unique_id)
 SERVO_BINDING_FUNC(Servo_StyleSet_PrependStyleSheet, void,
                    RawServoStyleSetBorrowed set,
                    RawServoStyleSheetBorrowed sheet,
-                   uint32_t unique_id)
+                   uint64_t unique_id)
 SERVO_BINDING_FUNC(Servo_StyleSet_RemoveStyleSheet, void,
                    RawServoStyleSetBorrowed set,
-                   uint32_t unique_id)
+                   uint64_t unique_id)
 SERVO_BINDING_FUNC(Servo_StyleSet_InsertStyleSheetBefore, void,
                    RawServoStyleSetBorrowed set,
                    RawServoStyleSheetBorrowed sheet,
-                   uint32_t unique_id,
-                   uint32_t before_unique_id)
+                   uint64_t unique_id,
+                   uint64_t before_unique_id)
 SERVO_BINDING_FUNC(Servo_StyleSet_FlushStyleSheets, void, RawServoStyleSetBorrowed set)
 SERVO_BINDING_FUNC(Servo_StyleSet_NoteStyleSheetsChanged, void,
                    RawServoStyleSetBorrowed set, bool author_style_disabled)
 SERVO_BINDING_FUNC(Servo_StyleSet_FillKeyframesForName, bool,
                    RawServoStyleSetBorrowed set,
                    const nsACString* property,
                    nsTimingFunctionBorrowed timing_function,
                    ServoComputedValuesBorrowed computed_values,
--- a/layout/style/ServoStyleSet.cpp
+++ b/layout/style/ServoStyleSet.cpp
@@ -570,18 +570,18 @@ ServoStyleSet::AppendStyleSheet(SheetTyp
   MOZ_ASSERT(aSheet);
   MOZ_ASSERT(aSheet->IsApplicable());
   MOZ_ASSERT(nsStyleSet::IsCSSSheetType(aType));
   MOZ_ASSERT(aSheet->RawSheet(), "Raw sheet should be in place before insertion.");
 
   // If we were already tracking aSheet, the newUniqueID will be the same
   // as the oldUniqueID. In that case, Servo will remove aSheet from its
   // original position as part of the call to Servo_StyleSet_AppendStyleSheet.
-  uint32_t oldUniqueID = RemoveSheetOfType(aType, aSheet);
-  uint32_t newUniqueID = AppendSheetOfType(aType, aSheet, oldUniqueID);
+  uint64_t oldUniqueID = RemoveSheetOfType(aType, aSheet);
+  uint64_t newUniqueID = AppendSheetOfType(aType, aSheet, oldUniqueID);
 
   if (mRawSet) {
     // Maintain a mirrored list of sheets on the servo side.
     Servo_StyleSet_AppendStyleSheet(mRawSet.get(),
                                     aSheet->RawSheet(),
                                     newUniqueID);
     mStylistMayNeedRebuild = true;
   }
@@ -596,18 +596,18 @@ ServoStyleSet::PrependStyleSheet(SheetTy
   MOZ_ASSERT(aSheet);
   MOZ_ASSERT(aSheet->IsApplicable());
   MOZ_ASSERT(nsStyleSet::IsCSSSheetType(aType));
   MOZ_ASSERT(aSheet->RawSheet(), "Raw sheet should be in place before insertion.");
 
   // If we were already tracking aSheet, the newUniqueID will be the same
   // as the oldUniqueID. In that case, Servo will remove aSheet from its
   // original position as part of the call to Servo_StyleSet_PrependStyleSheet.
-  uint32_t oldUniqueID = RemoveSheetOfType(aType, aSheet);
-  uint32_t newUniqueID = PrependSheetOfType(aType, aSheet, oldUniqueID);
+  uint64_t oldUniqueID = RemoveSheetOfType(aType, aSheet);
+  uint64_t newUniqueID = PrependSheetOfType(aType, aSheet, oldUniqueID);
 
   if (mRawSet) {
     // Maintain a mirrored list of sheets on the servo side.
     Servo_StyleSet_PrependStyleSheet(mRawSet.get(),
                                      aSheet->RawSheet(),
                                      newUniqueID);
     mStylistMayNeedRebuild = true;
   }
@@ -617,17 +617,17 @@ ServoStyleSet::PrependStyleSheet(SheetTy
 
 nsresult
 ServoStyleSet::RemoveStyleSheet(SheetType aType,
                                 ServoStyleSheet* aSheet)
 {
   MOZ_ASSERT(aSheet);
   MOZ_ASSERT(nsStyleSet::IsCSSSheetType(aType));
 
-  uint32_t uniqueID = RemoveSheetOfType(aType, aSheet);
+  uint64_t uniqueID = RemoveSheetOfType(aType, aSheet);
   if (mRawSet && uniqueID) {
     // Maintain a mirrored list of sheets on the servo side.
     Servo_StyleSet_RemoveStyleSheet(mRawSet.get(), uniqueID);
     mStylistMayNeedRebuild = true;
   }
 
   return NS_OK;
 }
@@ -648,17 +648,17 @@ ServoStyleSet::ReplaceSheets(SheetType a
     for (const Entry& entry : mEntries[aType]) {
       Servo_StyleSet_RemoveStyleSheet(mRawSet.get(), entry.uniqueID);
     }
   }
   mEntries[aType].Clear();
 
   // Add in all the new sheets.
   for (auto& sheet : aNewSheets) {
-    uint32_t uniqueID = AppendSheetOfType(aType, sheet);
+    uint64_t uniqueID = AppendSheetOfType(aType, sheet);
     if (mRawSet) {
       MOZ_ASSERT(sheet->RawSheet(), "Raw sheet should be in place before replacement.");
       Servo_StyleSet_AppendStyleSheet(mRawSet.get(),
                                       sheet->RawSheet(),
                                       uniqueID);
     }
   }
 
@@ -672,26 +672,26 @@ ServoStyleSet::InsertStyleSheetBefore(Sh
 {
   MOZ_ASSERT(aNewSheet);
   MOZ_ASSERT(aReferenceSheet);
   MOZ_ASSERT(aNewSheet->IsApplicable());
   MOZ_ASSERT(aNewSheet != aReferenceSheet, "Can't place sheet before itself.");
   MOZ_ASSERT(aNewSheet->RawSheet(), "Raw sheet should be in place before insertion.");
   MOZ_ASSERT(aReferenceSheet->RawSheet(), "Reference sheet should have a raw sheet.");
 
-  uint32_t beforeUniqueID = FindSheetOfType(aType, aReferenceSheet);
+  uint64_t beforeUniqueID = FindSheetOfType(aType, aReferenceSheet);
   if (beforeUniqueID == 0) {
     return NS_ERROR_INVALID_ARG;
   }
 
   // If we were already tracking aNewSheet, the newUniqueID will be the same
   // as the oldUniqueID. In that case, Servo will remove aNewSheet from its
   // original position as part of the call to Servo_StyleSet_InsertStyleSheetBefore.
-  uint32_t oldUniqueID = RemoveSheetOfType(aType, aNewSheet);
-  uint32_t newUniqueID = InsertSheetOfType(aType,
+  uint64_t oldUniqueID = RemoveSheetOfType(aType, aNewSheet);
+  uint64_t newUniqueID = InsertSheetOfType(aType,
                                            aNewSheet,
                                            beforeUniqueID,
                                            oldUniqueID);
 
   if (mRawSet) {
     // Maintain a mirrored list of sheets on the servo side.
     Servo_StyleSet_InsertStyleSheetBefore(mRawSet.get(),
                                           aNewSheet->RawSheet(),
@@ -728,40 +728,40 @@ nsresult
 ServoStyleSet::AddDocStyleSheet(ServoStyleSheet* aSheet,
                                 nsIDocument* aDocument)
 {
   MOZ_ASSERT(aSheet->IsApplicable());
   MOZ_ASSERT(aSheet->RawSheet(), "Raw sheet should be in place by this point.");
 
   RefPtr<StyleSheet> strong(aSheet);
 
-  uint32_t oldUniqueID = RemoveSheetOfType(SheetType::Doc, aSheet);
+  uint64_t oldUniqueID = RemoveSheetOfType(SheetType::Doc, aSheet);
 
   size_t index =
     aDocument->FindDocStyleSheetInsertionPoint(mEntries[SheetType::Doc], aSheet);
 
   if (index < mEntries[SheetType::Doc].Length()) {
     // This case is insert before.
-    uint32_t beforeUniqueID = mEntries[SheetType::Doc][index].uniqueID;
-    uint32_t newUniqueID = InsertSheetOfType(SheetType::Doc,
+    uint64_t beforeUniqueID = mEntries[SheetType::Doc][index].uniqueID;
+    uint64_t newUniqueID = InsertSheetOfType(SheetType::Doc,
                                              aSheet,
                                              beforeUniqueID,
                                              oldUniqueID);
 
     if (mRawSet) {
       // Maintain a mirrored list of sheets on the servo side.
       Servo_StyleSet_InsertStyleSheetBefore(mRawSet.get(),
                                             aSheet->RawSheet(),
                                             newUniqueID,
                                             beforeUniqueID);
       mStylistMayNeedRebuild = true;
     }
   } else {
     // This case is append.
-    uint32_t newUniqueID = AppendSheetOfType(SheetType::Doc,
+    uint64_t newUniqueID = AppendSheetOfType(SheetType::Doc,
                                              aSheet,
                                              oldUniqueID);
 
     if (mRawSet) {
       // Maintain a mirrored list of sheets on the servo side.
       Servo_StyleSet_AppendStyleSheet(mRawSet.get(),
                                       aSheet->RawSheet(),
                                       newUniqueID);
@@ -1068,74 +1068,74 @@ ServoStyleSet::ResolveForDeclarations(
 void
 ServoStyleSet::RebuildStylist()
 {
   MOZ_ASSERT(mStylistMayNeedRebuild);
   Servo_StyleSet_FlushStyleSheets(mRawSet.get());
   mStylistMayNeedRebuild = false;
 }
 
-uint32_t
+uint64_t
 ServoStyleSet::FindSheetOfType(SheetType aType,
                                ServoStyleSheet* aSheet)
 {
   for (const auto& entry : mEntries[aType]) {
     if (entry.sheet == aSheet) {
       return entry.uniqueID;
     }
   }
   return 0;
 }
 
-uint32_t
+uint64_t
 ServoStyleSet::PrependSheetOfType(SheetType aType,
                                   ServoStyleSheet* aSheet,
-                                  uint32_t aReuseUniqueID)
+                                  uint64_t aReuseUniqueID)
 {
   Entry* entry = mEntries[aType].InsertElementAt(0);
   entry->uniqueID = aReuseUniqueID ? aReuseUniqueID : ++mUniqueIDCounter;
   entry->sheet = aSheet;
   return entry->uniqueID;
 }
 
-uint32_t
+uint64_t
 ServoStyleSet::AppendSheetOfType(SheetType aType,
                                  ServoStyleSheet* aSheet,
-                                 uint32_t aReuseUniqueID)
+                                 uint64_t aReuseUniqueID)
 {
   Entry* entry = mEntries[aType].AppendElement();
   entry->uniqueID = aReuseUniqueID ? aReuseUniqueID : ++mUniqueIDCounter;
   entry->sheet = aSheet;
   return entry->uniqueID;
 }
 
-uint32_t
+uint64_t
 ServoStyleSet::InsertSheetOfType(SheetType aType,
                                  ServoStyleSheet* aSheet,
-                                 uint32_t aBeforeUniqueID,
-                                 uint32_t aReuseUniqueID)
+                                 uint64_t aBeforeUniqueID,
+                                 uint64_t aReuseUniqueID)
 {
   for (uint32_t i = 0; i < mEntries[aType].Length(); ++i) {
     if (mEntries[aType][i].uniqueID == aBeforeUniqueID) {
       Entry* entry = mEntries[aType].InsertElementAt(i);
       entry->uniqueID = aReuseUniqueID ? aReuseUniqueID : ++mUniqueIDCounter;
       entry->sheet = aSheet;
       return entry->uniqueID;
     }
   }
   return 0;
 }
 
-uint32_t
+uint64_t
 ServoStyleSet::RemoveSheetOfType(SheetType aType,
                                  ServoStyleSheet* aSheet)
 {
   for (uint32_t i = 0; i < mEntries[aType].Length(); ++i) {
     if (mEntries[aType][i].sheet == aSheet) {
-      uint32_t uniqueID = mEntries[aType][i].uniqueID;
+      uint64_t uniqueID = mEntries[aType][i].uniqueID;
       mEntries[aType].RemoveElementAt(i);
       return uniqueID;
     }
   }
   return 0;
 }
 
 void
--- a/layout/style/ServoStyleSet.h
+++ b/layout/style/ServoStyleSet.h
@@ -435,49 +435,49 @@ private:
     }
   }
 
   already_AddRefed<ServoComputedValues> ResolveStyleLazily(dom::Element* aElement,
                                                            nsIAtom* aPseudoTag);
 
   void RunPostTraversalTasks();
 
-  uint32_t FindSheetOfType(SheetType aType,
+  uint64_t FindSheetOfType(SheetType aType,
                            ServoStyleSheet* aSheet);
 
-  uint32_t PrependSheetOfType(SheetType aType,
+  uint64_t PrependSheetOfType(SheetType aType,
                               ServoStyleSheet* aSheet,
-                              uint32_t aReuseUniqueID = 0);
+                              uint64_t aReuseUniqueID = 0);
 
-  uint32_t AppendSheetOfType(SheetType aType,
+  uint64_t AppendSheetOfType(SheetType aType,
                              ServoStyleSheet* aSheet,
-                             uint32_t aReuseUniqueID = 0);
+                             uint64_t aReuseUniqueID = 0);
 
-  uint32_t InsertSheetOfType(SheetType aType,
+  uint64_t InsertSheetOfType(SheetType aType,
                              ServoStyleSheet* aSheet,
-                             uint32_t aBeforeUniqueID,
-                             uint32_t aReuseUniqueID = 0);
+                             uint64_t aBeforeUniqueID,
+                             uint64_t aReuseUniqueID = 0);
 
-  uint32_t RemoveSheetOfType(SheetType aType,
+  uint64_t RemoveSheetOfType(SheetType aType,
                              ServoStyleSheet* aSheet);
 
   struct Entry {
-    uint32_t uniqueID;
+    uint64_t uniqueID;
     RefPtr<ServoStyleSheet> sheet;
 
     // Provide a cast operator to simplify calling
     // nsIDocument::FindDocStyleSheetInsertionPoint.
     operator ServoStyleSheet*() const { return sheet; }
   };
 
   nsPresContext* mPresContext;
   UniquePtr<RawServoStyleSet> mRawSet;
   EnumeratedArray<SheetType, SheetType::Count,
                   nsTArray<Entry>> mEntries;
-  uint32_t mUniqueIDCounter;
+  uint64_t mUniqueIDCounter;
   bool mAllowResolveStaleStyles;
   bool mAuthorStyleDisabled;
   bool mStylistMayNeedRebuild;
 
   // Stores pointers to our cached style contexts for non-inheriting anonymous
   // boxes.
   EnumeratedArray<nsCSSAnonBoxes::NonInheriting,
                   nsCSSAnonBoxes::NonInheriting::_Count,