Backed out changeset 972821835d48 (bug 1382077)
authorCarsten "Tomcat" Book <cbook@mozilla.com>
Tue, 25 Jul 2017 12:17:16 +0200
changeset 419515 d173f12089ac56c3ae080aa4af5cba357ba0d56d
parent 419514 a95f9f156785bccde08b9718d23e153eaad5932f
child 419516 a34cb0f468bce65e7b8e7eae1c86bcbd4529fa10
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1382077
milestone56.0a1
backs out972821835d487d5f416405764854092fddef6ed8
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
Backed out changeset 972821835d48 (bug 1382077)
layout/base/nsPresContext.cpp
layout/base/nsPresContext.h
layout/style/ServoStyleSet.cpp
layout/style/nsRuleNode.cpp
layout/style/nsStyleSet.cpp
layout/style/nsStyleSet.h
--- a/layout/base/nsPresContext.cpp
+++ b/layout/base/nsPresContext.cpp
@@ -269,16 +269,17 @@ nsPresContext::nsPresContext(nsIDocument
     mPendingThemeChanged(false),
     mPendingUIResolutionChanged(false),
     mPendingMediaFeatureValuesChanged(false),
     mPrefChangePendingNeedsReflow(false),
     mIsEmulatingMedia(false),
     mIsGlyph(false),
     mUsesRootEMUnits(false),
     mUsesExChUnits(false),
+    mUsesViewportUnits(false),
     mPendingViewportChange(false),
     mCounterStylesDirty(true),
     mPostedFlushCounterStyles(false),
     mSuppressResizeReflow(false),
     mIsVisual(false),
     mFireAfterPaintEvents(false),
     mIsChrome(false),
     mIsChromeOriginImage(false),
@@ -2053,19 +2054,17 @@ nsPresContext::RebuildAllStyleData(nsCha
 {
   if (!mShell) {
     // We must have been torn down. Nothing to do here.
     return;
   }
 
   mUsesRootEMUnits = false;
   mUsesExChUnits = false;
-  if (nsStyleSet* styleSet = mShell->StyleSet()->GetAsGecko()) {
-    styleSet->SetUsesViewportUnits(false);
-  }
+  mUsesViewportUnits = false;
   mDocument->RebuildUserFontSet();
   RebuildCounterStyles();
 
   RestyleManager()->RebuildAllStyleData(aExtraHint, aRestyleHint);
 }
 
 void
 nsPresContext::PostRebuildAllStyleDataEvent(nsChangeHint aExtraHint,
@@ -2118,16 +2117,28 @@ nsPresContext::MediaFeatureValuesChanged
   mPendingMediaFeatureValuesChanged = false;
 
   // MediumFeaturesChanged updates the applied rules, so it always gets called.
   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.
+    //
+    // Also, in this case we don't need to do a rebuild of the style data, only
+    // post a restyle.
+    aRestyleHint |= eRestyle_ForceDescendants;
+  }
+
   if (aRestyleHint || aChangeHint) {
     RebuildAllStyleData(aChangeHint, aRestyleHint);
   }
 
   mPendingViewportChange = false;
 
   if (mDocument->IsBeingUsedAsImage()) {
     MOZ_ASSERT(mDocument->MediaQueryLists().isEmpty());
--- a/layout/base/nsPresContext.h
+++ b/layout/base/nsPresContext.h
@@ -1148,16 +1148,24 @@ public:
   bool UsesExChUnits() const {
     return mUsesExChUnits;
   }
 
   void SetUsesExChUnits(bool aValue) {
     mUsesExChUnits = aValue;
   }
 
+  bool UsesViewportUnits() const {
+    return mUsesViewportUnits;
+  }
+
+  void SetUsesViewportUnits(bool aValue) {
+    mUsesViewportUnits = aValue;
+  }
+
   // true if there are OMTA transition updates for the current document which
   // have been throttled, and therefore some style information may not be up
   // to date
   bool ExistThrottledUpdates() const {
     return mExistThrottledUpdates;
   }
 
   void SetExistThrottledUpdates(bool aExistThrottledUpdates) {
@@ -1454,16 +1462,18 @@ protected:
 
   // Are we currently drawing an SVG glyph?
   unsigned              mIsGlyph : 1;
 
   // Does the associated document use root-em (rem) units?
   unsigned              mUsesRootEMUnits : 1;
   // Does the associated document use ex or ch units?
   unsigned              mUsesExChUnits : 1;
+  // Does the associated document use viewport units (vw/vh/vmin/vmax)?
+  unsigned              mUsesViewportUnits : 1;
 
   // Has there been a change to the viewport's dimensions?
   unsigned              mPendingViewportChange : 1;
 
   // Is the current mCounterStyleManager valid?
   unsigned              mCounterStylesDirty : 1;
   // Do we currently have an event posted to call FlushCounterStyles?
   unsigned              mPostedFlushCounterStyles: 1;
--- a/layout/style/ServoStyleSet.cpp
+++ b/layout/style/ServoStyleSet.cpp
@@ -114,23 +114,16 @@ ServoStyleSet::InvalidateStyleForCSSRule
 }
 
 nsRestyleHint
 ServoStyleSet::MediumFeaturesChanged(bool aViewportChanged) const
 {
   if (Servo_StyleSet_MediumFeaturesChanged(mRawSet.get())) {
     return eRestyle_Subtree;
   }
-  if (aViewportChanged) {
-    // Rebuild all style data without rerunning selector matching.
-    //
-    // FIXME(emilio, bug 1328652): We don't set mUsesViewportUnits in stylo yet,
-    // so assume the worst.
-    return eRestyle_ForceDescendants;
-  }
   return nsRestyleHint(0);
 }
 
 size_t
 ServoStyleSet::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
 {
   size_t n = aMallocSizeOf(this);
 
--- a/layout/style/nsRuleNode.cpp
+++ b/layout/style/nsRuleNode.cpp
@@ -466,24 +466,20 @@ nsRuleNode::ApplyMinFontSize(nsStyleFont
       fontSize = aMinFontSize;
     }
   }
   aFont->mFont.size = fontSize;
 }
 
 static nsSize CalcViewportUnitsScale(nsPresContext* aPresContext)
 {
-  // The caller is making use of viewport units, so notify the style set
+  // The caller is making use of viewport units, so notify the pres context
   // that it will need to rebuild the rule tree if the size of the viewport
   // changes.
-  // It is possible for this to be called on a Servo-styled document,from
-  // media query evaluation outside stylesheets.
-  if (nsStyleSet* styleSet = aPresContext->StyleSet()->GetAsGecko()) {
-    styleSet->SetUsesViewportUnits(true);
-  }
+  aPresContext->SetUsesViewportUnits(true);
 
   // The default (when we have 'overflow: auto' on the root element, or
   // trivially for 'overflow: hidden' since we never have scrollbars in that
   // case) is to define the scale of the viewport units without considering
   // scrollbars.
   nsSize viewportSize(aPresContext->GetVisibleArea().Size());
 
   // Check for 'overflow: scroll' styles on the root scroll frame. If we find
--- a/layout/style/nsStyleSet.cpp
+++ b/layout/style/nsStyleSet.cpp
@@ -214,17 +214,16 @@ nsStyleSet::nsStyleSet()
     mBatching(0),
     mStylesHaveChanged(0),
     mInShutdown(false),
     mInGC(false),
     mAuthorStyleDisabled(false),
     mInReconstruct(false),
     mInitFontFeatureValuesLookup(true),
     mNeedsRestyleAfterEnsureUniqueInner(false),
-    mUsesViewportUnits(false),
     mDirty(0),
     mRootStyleContextCount(0),
 #ifdef DEBUG
     mOldRootNode(nullptr),
 #endif
     mUnusedRuleNodeCount(0)
 {
 }
@@ -2699,20 +2698,16 @@ nsStyleSet::MediumFeaturesChanged(bool a
     bool thisChanged = false;
     mBindingManager->MediumFeaturesChanged(presContext, &thisChanged);
     stylesChanged = stylesChanged || thisChanged;
   }
 
   if (stylesChanged) {
     return eRestyle_Subtree;
   }
-  if (aViewportChanged && mUsesViewportUnits) {
-    // Rebuild all style data without rerunning selector matching.
-    return eRestyle_ForceDescendants;
-  }
   return nsRestyleHint(0);
 }
 
 bool
 nsStyleSet::EnsureUniqueInnerOnCSSSheets()
 {
   AutoTArray<StyleSheet*, 32> queue;
   for (SheetType type : gCSSSheetTypes) {
--- a/layout/style/nsStyleSet.h
+++ b/layout/style/nsStyleSet.h
@@ -486,20 +486,16 @@ class nsStyleSet final
   // to drop any nsCSSSelector pointers it has.
   void ClearSelectors();
 
   // Returns whether aSheetType represents a level of the cascade that uses
   // CSSStyleSheets.  See gCSSSheetTypes in nsStyleSet.cpp for the list
   // of CSS sheet types.
   static bool IsCSSSheetType(mozilla::SheetType aSheetType);
 
-  void SetUsesViewportUnits(bool aValue) {
-    mUsesViewportUnits = aValue;
-  }
-
 private:
   nsStyleSet(const nsStyleSet& aCopy) = delete;
   nsStyleSet& operator=(const nsStyleSet& aCopy) = delete;
 
   // Free all the rules with reference-count zero. This continues iterating
   // over the free list until it is empty, which allows immediate collection
   // of nodes whose reference-count drops to zero during the destruction of
   // a child node. This allows the collection of entire trees at once, since
@@ -632,18 +628,16 @@ private:
   // in mStylesHaveChanged.
   unsigned mStylesHaveChanged : 1;
   unsigned mInShutdown : 1;
   unsigned mInGC : 1;
   unsigned mAuthorStyleDisabled: 1;
   unsigned mInReconstruct : 1;
   unsigned mInitFontFeatureValuesLookup : 1;
   unsigned mNeedsRestyleAfterEnsureUniqueInner : 1;
-  // Does the associated document use viewport units (vw/vh/vmin/vmax)?
-  unsigned mUsesViewportUnits : 1;
   unsigned mDirty : int(mozilla::SheetType::Count);  // one bit per sheet type
 
   uint32_t mRootStyleContextCount;
 
 #ifdef DEBUG
   // In debug builds, we stash a weak pointer here to the old root during
   // reconstruction. During GC, we check for this pointer, and null it out
   // when we encounter it. This allows us to assert that the old root (and