Bug 1089417 patch 10 - Make CloneMQCacheKey clone the mPreviousCacheKey, to fix bug 1089417 for multiple rebuilds of the rule cascade in sequence. r=heycam
authorL. David Baron <dbaron@dbaron.org>
Mon, 19 Jan 2015 00:49:56 -0800
changeset 224479 1e26b3a0731cdd3ed6360c135d5b068dfa2db189
parent 224478 f86a9dfe3be5ef62d5a716451b8ef8e4b4c15785
child 224480 856679a135f2017c8fd1af9694491f91ecb190dc
push id28131
push usercbook@mozilla.com
push dateMon, 19 Jan 2015 15:10:25 +0000
treeherdermozilla-central@f8e4fdb89a05 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam
bugs1089417
milestone38.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 1089417 patch 10 - Make CloneMQCacheKey clone the mPreviousCacheKey, to fix bug 1089417 for multiple rebuilds of the rule cascade in sequence. r=heycam I confirmed that this patch fixes the mochitest.
layout/style/nsCSSRuleProcessor.cpp
layout/style/test/test_bug1089417.html
--- a/layout/style/nsCSSRuleProcessor.cpp
+++ b/layout/style/nsCSSRuleProcessor.cpp
@@ -2920,18 +2920,34 @@ nsCSSRuleProcessor::MediumFeaturesChange
   }
 
   return false;
 }
 
 UniquePtr<nsMediaQueryResultCacheKey>
 nsCSSRuleProcessor::CloneMQCacheKey()
 {
+  MOZ_ASSERT(!(mRuleCascades && mPreviousCacheKey));
+
   RuleCascadeData* c = mRuleCascades;
-  if (!c || !c->mCacheKey.HasFeatureConditions()) {
+  if (!c) {
+    // We might have an mPreviousCacheKey.  It already comes from a call
+    // to CloneMQCacheKey, so don't bother checking
+    // HasFeatureConditions().
+    if (mPreviousCacheKey) {
+      NS_ASSERTION(mPreviousCacheKey->HasFeatureConditions(),
+                   "we shouldn't have a previous cache key unless it has "
+                   "feature conditions");
+      return MakeUnique<nsMediaQueryResultCacheKey>(*mPreviousCacheKey);
+    }
+
+    return UniquePtr<nsMediaQueryResultCacheKey>();
+  }
+
+  if (!c->mCacheKey.HasFeatureConditions()) {
     return UniquePtr<nsMediaQueryResultCacheKey>();
   }
 
   return MakeUnique<nsMediaQueryResultCacheKey>(c->mCacheKey);
 }
 
 /* virtual */ size_t
 nsCSSRuleProcessor::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const
--- a/layout/style/test/test_bug1089417.html
+++ b/layout/style/test/test_bug1089417.html
@@ -23,17 +23,17 @@ https://bugzilla.mozilla.org/show_bug.cg
     fdoc.getElementById("s").disabled = false;
     is(fwin.getComputedStyle(fdoc.documentElement).backgroundColor,
        "rgb(0, 128, 0)",
        "media query change should have restyled");
 
     f.height = "200";
     fdoc.getElementById("s").disabled = true;
     fdoc.getElementById("s").disabled = false;
-    todo_is(fwin.getComputedStyle(fdoc.documentElement).backgroundColor,
+    is(fwin.getComputedStyle(fdoc.documentElement).backgroundColor,
        "rgb(255, 0, 0)",
        "media query change should have restyled");
     SimpleTest.finish();
   }
 
   </script>
 </head>
 <body onload="run()">