Bug 1373193 Part 2: Create and call a new UpdateStyleSheet method on ServoStyleSet when a ServoStyleSheet has its inner cloned. r=xidorn
authorBrad Werth <bwerth@mozilla.com>
Mon, 19 Jun 2017 10:47:13 -0700
changeset 365327 a2de41b74810e093e0517e83db7c297ec3663055
parent 365326 272a41ef0e3d64cc510424d0801142730302a0a4
child 365328 5bc9622943b1fa59f283579fc8ddfafbbcc31a51
push id91734
push userkwierso@gmail.com
push dateThu, 22 Jun 2017 01:05:37 +0000
treeherdermozilla-inbound@2576a0695305 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersxidorn
bugs1373193
milestone56.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 1373193 Part 2: Create and call a new UpdateStyleSheet method on ServoStyleSet when a ServoStyleSheet has its inner cloned. r=xidorn MozReview-Commit-ID: GKxnEiZvziS
layout/style/ServoBindingList.h
layout/style/ServoStyleSet.cpp
layout/style/ServoStyleSet.h
layout/style/StyleSheet.cpp
--- a/layout/style/ServoBindingList.h
+++ b/layout/style/ServoBindingList.h
@@ -71,16 +71,20 @@ SERVO_BINDING_FUNC(Servo_StyleSet_Prepen
 SERVO_BINDING_FUNC(Servo_StyleSet_RemoveStyleSheet, void,
                    RawServoStyleSetBorrowed set,
                    uint64_t unique_id)
 SERVO_BINDING_FUNC(Servo_StyleSet_InsertStyleSheetBefore, void,
                    RawServoStyleSetBorrowed set,
                    RawServoStyleSheetBorrowed sheet,
                    uint64_t unique_id,
                    uint64_t before_unique_id)
+SERVO_BINDING_FUNC(Servo_StyleSet_UpdateStyleSheet, void,
+                   RawServoStyleSetBorrowed set,
+                   RawServoStyleSheetBorrowed sheet,
+                   uint64_t unique_id)
 SERVO_BINDING_FUNC(Servo_StyleSet_FlushStyleSheets, void, RawServoStyleSetBorrowed set,
                    RawGeckoElementBorrowedOrNull doc_elem)
 SERVO_BINDING_FUNC(Servo_StyleSet_NoteStyleSheetsChanged, void,
                    RawServoStyleSetBorrowed set, bool author_style_disabled)
 SERVO_BINDING_FUNC(Servo_StyleSet_GetKeyframesForName, bool,
                    RawServoStyleSetBorrowed set,
                    const nsACString* property,
                    nsTimingFunctionBorrowed timing_function,
--- a/layout/style/ServoStyleSet.cpp
+++ b/layout/style/ServoStyleSet.cpp
@@ -826,16 +826,32 @@ ServoStyleSet::InsertStyleSheetBefore(Sh
                                           UniqueIDForSheet(aNewSheet),
                                           UniqueIDForSheet(aReferenceSheet));
     SetStylistStyleSheetsDirty();
   }
 
   return NS_OK;
 }
 
+void
+ServoStyleSet::UpdateStyleSheet(ServoStyleSheet* aSheet)
+{
+  MOZ_ASSERT(aSheet);
+
+  if (mRawSet) {
+    // Inform servo that the underlying raw sheet has changed.
+    Servo_StyleSet_UpdateStyleSheet(mRawSet.get(),
+                                    aSheet->RawSheet(),
+                                    UniqueIDForSheet(aSheet));
+    // No need to set the stylesheets as dirty, since this is only
+    // used to notify servo of a cloned raw sheet. It styles the
+    // same until the sheet is changed through other methods.
+  }
+}
+
 int32_t
 ServoStyleSet::SheetCount(SheetType aType) const
 {
   MOZ_ASSERT(nsStyleSet::IsCSSSheetType(aType));
   return mSheets[aType].Length();
 }
 
 ServoStyleSheet*
--- a/layout/style/ServoStyleSet.h
+++ b/layout/style/ServoStyleSet.h
@@ -241,16 +241,21 @@ public:
   nsresult PrependStyleSheet(SheetType aType, ServoStyleSheet* aSheet);
   nsresult RemoveStyleSheet(SheetType aType, ServoStyleSheet* aSheet);
   nsresult ReplaceSheets(SheetType aType,
                          const nsTArray<RefPtr<ServoStyleSheet>>& aNewSheets);
   nsresult InsertStyleSheetBefore(SheetType aType,
                                   ServoStyleSheet* aNewSheet,
                                   ServoStyleSheet* aReferenceSheet);
 
+  // Notify servo that the underlying raw sheet has changed, through cloning.
+  // This should only be called on a just-cloned sheet, because it does not
+  // mark the stylesheets as dirty either here or in servo.
+  void UpdateStyleSheet(ServoStyleSheet* aSheet);
+
   int32_t SheetCount(SheetType aType) const;
   ServoStyleSheet* StyleSheetAt(SheetType aType, int32_t aIndex) const;
 
   template<typename Func>
   void EnumerateStyleSheetArrays(Func aCallback) const {
     for (const auto& sheetArray : mSheets) {
       aCallback(sheetArray);
     }
--- a/layout/style/StyleSheet.cpp
+++ b/layout/style/StyleSheet.cpp
@@ -466,16 +466,20 @@ StyleSheet::EnsureUniqueInner()
   if (CSSStyleSheet* geckoSheet = GetAsGecko()) {
     geckoSheet->ClearRuleCascades();
   }
 
   // let our containing style sets know that if we call
   // nsPresContext::EnsureSafeToHandOutCSSRules we will need to restyle the
   // document
   for (StyleSetHandle& setHandle : mStyleSets) {
+    if (ServoStyleSet* servoSet = setHandle->GetAsServo()) {
+      MOZ_ASSERT(IsServo(), "Only servo sheets should be in servo stylesets.");
+      servoSet->UpdateStyleSheet(GetAsServo());
+    }
     setHandle->SetNeedsRestyleAfterEnsureUniqueInner();
   }
 }
 
 void
 StyleSheet::AppendAllChildSheets(nsTArray<StyleSheet*>& aArray)
 {
   for (StyleSheet* child = GetFirstChild(); child; child = child->mNext) {