Bug 1382077 part 1 - Have StyleSet::MediumFeaturesChanged return nsRestyleHint rather than a bool. r=heycam
☠☠ backed out by a34cb0f468bc ☠ ☠
authorXidorn Quan <me@upsuper.org>
Mon, 24 Jul 2017 11:27:08 +1000
changeset 421911 23c6326dd926bb60c59c684b6c6304e2cb8af035
parent 421910 5227744e2508312d6c92f122efc9d171c58c07bb
child 421912 972821835d487d5f416405764854092fddef6ed8
push id1517
push userjlorenzo@mozilla.com
push dateThu, 14 Sep 2017 16:50:54 +0000
treeherdermozilla-release@3b41fd564418 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam
bugs1382077
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 1382077 part 1 - Have StyleSet::MediumFeaturesChanged return nsRestyleHint rather than a bool. r=heycam MozReview-Commit-ID: 5g3mHU8pxXP
layout/base/nsPresContext.cpp
layout/style/ServoStyleSet.cpp
layout/style/ServoStyleSet.h
layout/style/StyleSetHandle.h
layout/style/StyleSetHandleInlines.h
layout/style/nsStyleSet.cpp
layout/style/nsStyleSet.h
--- a/layout/base/nsPresContext.cpp
+++ b/layout/base/nsPresContext.cpp
@@ -2112,18 +2112,19 @@ nsPresContext::MediaFeatureValuesChanged
 
 void
 nsPresContext::MediaFeatureValuesChanged(nsRestyleHint aRestyleHint,
                                          nsChangeHint aChangeHint)
 {
   mPendingMediaFeatureValuesChanged = false;
 
   // MediumFeaturesChanged updates the applied rules, so it always gets called.
-  if (mShell && mShell->StyleSet()->MediumFeaturesChanged()) {
-    aRestyleHint |= eRestyle_Subtree;
+  if (mShell) {
+    aRestyleHint |= mShell->
+      StyleSet()->MediumFeaturesChanged(mPendingViewportChange);
   }
 
   if (mPendingViewportChange &&
       (mUsesViewportUnits || mDocument->IsStyledByServo())) {
     // Rebuild all style data without rerunning selector matching.
     //
     // FIXME(emilio, bug 1328652): We don't set mUsesViewportUnits in stylo yet,
     // so assume the worst.
--- a/layout/style/ServoStyleSet.cpp
+++ b/layout/style/ServoStyleSet.cpp
@@ -108,20 +108,23 @@ ServoStyleSet::Shutdown()
 
 void
 ServoStyleSet::InvalidateStyleForCSSRuleChanges()
 {
   MOZ_ASSERT(StylistNeedsUpdate());
   mPresContext->RestyleManager()->AsServo()->PostRestyleEventForCSSRuleChanges();
 }
 
-bool
-ServoStyleSet::MediumFeaturesChanged() const
+nsRestyleHint
+ServoStyleSet::MediumFeaturesChanged(bool aViewportChanged) const
 {
-  return Servo_StyleSet_MediumFeaturesChanged(mRawSet.get());
+  if (Servo_StyleSet_MediumFeaturesChanged(mRawSet.get())) {
+    return eRestyle_Subtree;
+  }
+  return nsRestyleHint(0);
 }
 
 size_t
 ServoStyleSet::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
 {
   size_t n = aMallocSizeOf(this);
 
   if (mStyleRuleMap) {
--- a/layout/style/ServoStyleSet.h
+++ b/layout/style/ServoStyleSet.h
@@ -110,17 +110,17 @@ public:
     ForceAllStyleDirty();
   }
 
   bool StyleSheetsHaveChanged() const
   {
     return StylistNeedsUpdate();
   }
 
-  bool MediumFeaturesChanged() const;
+  nsRestyleHint MediumFeaturesChanged(bool aViewportChanged) const;
 
   void InvalidateStyleForCSSRuleChanges();
 
   size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
   const RawServoStyleSet* RawSet() const {
     return mRawSet.get();
   }
 
--- a/layout/style/StyleSetHandle.h
+++ b/layout/style/StyleSetHandle.h
@@ -155,17 +155,17 @@ public:
     inline StyleSheet* StyleSheetAt(SheetType aType, int32_t aIndex) const;
     inline void AppendAllXBLStyleSheets(nsTArray<StyleSheet*>& aArray) const;
     inline nsresult RemoveDocStyleSheet(StyleSheet* aSheet);
     inline nsresult AddDocStyleSheet(StyleSheet* aSheet, nsIDocument* aDocument);
     inline void RecordStyleSheetChange(StyleSheet* aSheet, StyleSheet::ChangeType);
     inline void RecordShadowStyleChange(mozilla::dom::ShadowRoot* aShadowRoot);
     inline bool StyleSheetsHaveChanged() const;
     inline void InvalidateStyleForCSSRuleChanges();
-    inline bool MediumFeaturesChanged();
+    inline nsRestyleHint MediumFeaturesChanged(bool aViewportChanged);
     inline already_AddRefed<nsStyleContext>
     ProbePseudoElementStyle(dom::Element* aParentElement,
                             mozilla::CSSPseudoElementType aType,
                             nsStyleContext* aParentContext);
     inline already_AddRefed<nsStyleContext>
     ProbePseudoElementStyle(dom::Element* aParentElement,
                             mozilla::CSSPseudoElementType aType,
                             nsStyleContext* aParentContext,
--- a/layout/style/StyleSetHandleInlines.h
+++ b/layout/style/StyleSetHandleInlines.h
@@ -251,20 +251,20 @@ StyleSetHandle::Ptr::RecordShadowStyleCh
   FORWARD(RecordShadowStyleChange, (aShadowRoot));
 }
 
 bool
 StyleSetHandle::Ptr::StyleSheetsHaveChanged() const
 {
   FORWARD(StyleSheetsHaveChanged, ());
 }
-bool
-StyleSetHandle::Ptr::MediumFeaturesChanged()
+nsRestyleHint
+StyleSetHandle::Ptr::MediumFeaturesChanged(bool aViewportChanged)
 {
-  FORWARD(MediumFeaturesChanged, ());
+  FORWARD(MediumFeaturesChanged, (aViewportChanged));
 }
 void
 StyleSetHandle::Ptr::InvalidateStyleForCSSRuleChanges()
 {
   FORWARD(InvalidateStyleForCSSRuleChanges, ());
 }
 
 // check whether there is ::before/::after style for an element
--- a/layout/style/nsStyleSet.cpp
+++ b/layout/style/nsStyleSet.cpp
@@ -2669,18 +2669,18 @@ nsStyleSet::HasAttributeDependentStyle(E
   if (!(data.mHint & eRestyle_Subtree)) {
     // No point keeping the list of selectors around if we are going to
     // restyle the whole subtree unconditionally.
     aRestyleHintDataResult = Move(data.mHintData);
   }
   return data.mHint;
 }
 
-bool
-nsStyleSet::MediumFeaturesChanged()
+nsRestyleHint
+nsStyleSet::MediumFeaturesChanged(bool aViewportChanged)
 {
   NS_ASSERTION(mBatching == 0, "rule processors out of date");
 
   // We can't use WalkRuleProcessors without a content node.
   nsPresContext* presContext = PresContext();
   bool stylesChanged = false;
   for (nsIStyleRuleProcessor* processor : mRuleProcessors) {
     if (!processor) {
@@ -2695,17 +2695,20 @@ nsStyleSet::MediumFeaturesChanged()
   }
 
   if (mBindingManager) {
     bool thisChanged = false;
     mBindingManager->MediumFeaturesChanged(presContext, &thisChanged);
     stylesChanged = stylesChanged || thisChanged;
   }
 
-  return stylesChanged;
+  if (stylesChanged) {
+    return eRestyle_Subtree;
+  }
+  return nsRestyleHint(0);
 }
 
 bool
 nsStyleSet::EnsureUniqueInnerOnCSSSheets()
 {
   AutoTArray<StyleSheet*, 32> queue;
   for (SheetType type : gCSSSheetTypes) {
     for (StyleSheet* sheet : mSheets[type]) {
--- a/layout/style/nsStyleSet.h
+++ b/layout/style/nsStyleSet.h
@@ -375,20 +375,20 @@ class nsStyleSet final
                                            int32_t        aModType,
                                            bool           aAttrHasChanged,
                                            const nsAttrValue* aOtherValue,
                                            mozilla::RestyleHintData&
                                              aRestyleHintDataResult);
 
   /*
    * Do any processing that needs to happen as a result of a change in
-   * the characteristics of the medium, and return whether style rules
-   * may have changed as a result.
+   * the characteristics of the medium, and return restyle hint needed
+   * for the change.
    */
-  bool MediumFeaturesChanged();
+  nsRestyleHint MediumFeaturesChanged(bool aViewportChanged);
 
   // APIs to manipulate the style sheet lists.  The sheets in each
   // list are stored with the most significant sheet last.
   nsresult AppendStyleSheet(mozilla::SheetType aType,
                             mozilla::CSSStyleSheet* aSheet);
   nsresult PrependStyleSheet(mozilla::SheetType aType,
                              mozilla::CSSStyleSheet* aSheet);
   nsresult RemoveStyleSheet(mozilla::SheetType aType,