Bug 1222226 - Don't return eRestyleResult_StopWithStyleChange if the old style context is shared. r=dbaron, a=lizzard
authorCameron McCormack <cam@mcc.id.au>
Sun, 08 Nov 2015 11:06:14 +1100
changeset 296689 5ff2e264e7ff
parent 296688 7d24cb4584fc
child 296690 9576cf65c2b5
push id5290
push usercbook@mozilla.com
push date2015-11-11 09:57 +0000
treeherdermozilla-beta@5ff2e264e7ff [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdbaron, lizzard
bugs1222226
milestone43.0
Bug 1222226 - Don't return eRestyleResult_StopWithStyleChange if the old style context is shared. r=dbaron, a=lizzard
layout/base/RestyleManager.cpp
layout/reftests/bugs/1222226-1-ref.html
layout/reftests/bugs/1222226-1.html
layout/reftests/bugs/reftest.list
--- a/layout/base/RestyleManager.cpp
+++ b/layout/base/RestyleManager.cpp
@@ -3965,16 +3965,25 @@ ElementRestyler::RestyleSelf(nsIFrame* a
   if (newContext != oldContext) {
     if (oldContext->IsShared()) {
       // If the old style context was shared, then we can't return
       // eRestyleResult_Stop and patch its parent to point to the
       // new parent style context, as that change might not be valid
       // for the other frames sharing the style context.
       LOG_RESTYLE_CONTINUE("the old style context is shared");
       result = eRestyleResult_Continue;
+
+      // It's not safe to return eRestyleResult_StopWithStyleChange,
+      // as even though we might not have cached structs for inherited
+      // properties on oldContext (and thus our samePointerStructs
+      // check later will look OK), oldContext and newContext might
+      // represent different inherited style data, and some of the
+      // elements currently sharing oldContext might need to keep it
+      // rather than get restyled to use newContext.
+      canStopWithStyleChange = false;
     }
 
     // Look at some details of the new style context to see if it would
     // be safe to stop restyling, if we discover it has the same style
     // data as the old style context.
     ComputeRestyleResultFromNewContext(aSelf, newContext,
                                        result, canStopWithStyleChange);
 
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/1222226-1-ref.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<style>
+.red { color: red; }
+</style>
+<div>
+  <span id="s1">test</span><br />
+  <span id="s2" class=red>test</span><br />
+  <span id="s3" class=red>test</span><br />
+  <span id="s4">test</span><br />
+</div>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/1222226-1.html
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<style>
+.red { color: red; }
+</style>
+<script>
+document.onreadystatechange = function() {
+  if (document.readyState == "complete") {
+    var arr = ["s2","s3"];
+    arr.forEach(function(n) {
+      document.getElementById(n).className = "red";
+    });
+  }
+};
+</script>
+<div>
+  <span id="s1">test</span><br />
+  <span id="s2">test</span><br />
+  <span id="s3">test</span><br />
+  <span id="s4">test</span><br />
+</div>
--- a/layout/reftests/bugs/reftest.list
+++ b/layout/reftests/bugs/reftest.list
@@ -1934,8 +1934,9 @@ fuzzy(1,74) fuzzy-if(gtkWidget,6,79) == 
 == 1190635-1.html 1190635-1-ref.html
 == 1202512-1.html 1202512-1-ref.html
 == 1202512-2.html 1202512-2-ref.html
 != 1207326-1.html about:blank
 == 1209994-1.html 1209994-1-ref.html
 == 1209994-2.html 1209994-2-ref.html
 == 1209994-3.html 1209994-3-ref.html
 == 1209994-4.html 1209994-4-ref.html
+== 1222226-1.html 1222226-1-ref.html