Bug 1490012 - Don't flush on the parent document if we already have a pres context. r=xidorn
authorEmilio Cobos Álvarez <emilio@crisal.io>
Tue, 11 Sep 2018 19:48:44 +0200
changeset 436026 b499d1183c996ce044961ecf5cd67b139b095427
parent 436025 cc1f16ecff46b5daf37154f5d84592e54663bca4
child 436027 e5c0d34d8fdf1152de53a09421679f71a2fb7a0d
push id34625
push userdvarga@mozilla.com
push dateThu, 13 Sep 2018 02:31:40 +0000
treeherdermozilla-central@51e9e9660b3e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersxidorn
bugs1490012, 1458816
milestone64.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 1490012 - Don't flush on the parent document if we already have a pres context. r=xidorn I think conceptually we should flush layout instead of frames and do it unconditionally, but everyone agrees on not doing that, and it can be really slow, so will raise it to the CSSWG and get this spec'd. See the test-case in bug 1458816, which tracks that. I don't want to uplift this, but I think it's worth landing. Differential Revision: https://phabricator.services.mozilla.com/D5562
layout/style/MediaQueryList.cpp
--- a/layout/style/MediaQueryList.cpp
+++ b/layout/style/MediaQueryList.cpp
@@ -132,27 +132,31 @@ void
 MediaQueryList::RecomputeMatches()
 {
   mMatches = false;
 
   if (!mDocument) {
     return;
   }
 
-  if (mDocument->GetParentDocument()) {
+  // FIXME(emilio, bug 1490401): We shouldn't need a pres context to evaluate
+  // media queries.
+  nsPresContext* presContext = mDocument->GetPresContext();
+  if (!presContext && mDocument->GetParentDocument()) {
     // Flush frames on the parent so our prescontext will get
-    // recreated as needed.
+    // created if needed.
     mDocument->GetParentDocument()->FlushPendingNotifications(FlushType::Frames);
     // That might have killed our document, so recheck that.
     if (!mDocument) {
       return;
     }
+
+    presContext = mDocument->GetPresContext();
   }
 
-  nsPresContext* presContext = mDocument->GetPresContext();
   if (!presContext) {
     // XXXbz What's the right behavior here?  Spec doesn't say.
     return;
   }
 
   mMatches = mMediaList->Matches(presContext);
   mMatchesValid = true;
 }