Bug 1315632 - stylo: Leave old style on frames when nsChangeHint_ReconstructFrame was generated. r?emilio draft
authorCameron McCormack <cam@mcc.id.au>
Mon, 07 Nov 2016 18:15:32 +0800
changeset 434765 177c5f4c7a1775fccc0cfc72c06f1663075c8975
parent 434636 908557c762f798605a2f96e4c943791cbada1b50
child 536114 e258226a4f49fa912063909535c27e1c3f4307b8
push id34823
push userbmo:cam@mcc.id.au
push dateMon, 07 Nov 2016 10:16:00 +0000
reviewersemilio
bugs1315632
milestone52.0a1
Bug 1315632 - stylo: Leave old style on frames when nsChangeHint_ReconstructFrame was generated. r?emilio MozReview-Commit-ID: 4rtsOwwZFkS
layout/base/ServoRestyleManager.cpp
layout/reftests/bugs/1315632-1-ref.html
layout/reftests/bugs/1315632-1.html
layout/reftests/bugs/reftest-stylo.list
layout/reftests/bugs/reftest.list
--- a/layout/base/ServoRestyleManager.cpp
+++ b/layout/base/ServoRestyleManager.cpp
@@ -135,17 +135,21 @@ ServoRestyleManager::RecreateStyleContex
     // Add the new change hint to the list of elements to process if
     // we need to do any work.
     if (changeHint) {
       aChangeListToProcess.AppendChange(primaryFrame, element, changeHint);
     }
 
     // The frame reconstruction step (if needed) will ask for the descendants'
     // style correctly. If not needed, we're done too.
-    if (!primaryFrame) {
+    //
+    // Note that we must leave the old style on an existing frame that is
+    // about to be reframed, since some frame constructor code wants to
+    // inspect the old style to work out what to do.
+    if (!primaryFrame || (changeHint & nsChangeHint_ReconstructFrame)) {
       aContent->UnsetIsDirtyForServo();
       return;
     }
 
     // Hold the old style context alive, because it could become a dangling
     // pointer during the replacement. In practice it's not a huge deal (on
     // GetNextContinuationWithSameStyle the pointer is not dereferenced, only
     // compared), but better not playing with dangling pointers if not needed.
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/1315632-1-ref.html
@@ -0,0 +1,5 @@
+<!DOCTYPE html>
+<style>
+.y { color: green; }
+</style>
+<div class=y>hello</div>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/1315632-1.html
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<style>
+.x { position: absolute; color: red; }
+.y { color: green; }
+</style>
+<div class=x>hello</div>
+<script>
+document.body.offsetHeight;
+document.querySelector(".x").className = "y";
+document.body.offsetHeight;
+</script>
--- a/layout/reftests/bugs/reftest-stylo.list
+++ b/layout/reftests/bugs/reftest-stylo.list
@@ -2367,13 +2367,14 @@ random-if(!winWidget) == 1273154-1.html 
 # depends on Windows font
 random-if(!winWidget) == 1273154-2.html 1273154-2.html
 # depends on Windows font
 == 1274368-1.html 1274368-1.html
 == 1276161-1a.html 1276161-1a.html
 == 1276161-1b.html 1276161-1b.html
 == 1276161-1a.html 1276161-1a.html
 == 1275411-1.html 1275411-1.html
+== 1315632-1.html 1315632-1-ref.html
 
 HTTP == 652991-1a.html 652991-1a.html
 HTTP == 652991-1b.html 652991-1b.html
 HTTP == 652991-2.html 652991-2.html
 HTTP == 652991-3.html 652991-3.html
--- a/layout/reftests/bugs/reftest.list
+++ b/layout/reftests/bugs/reftest.list
@@ -1968,14 +1968,15 @@ random-if(!winWidget) == 1273154-2.html 
 == 1275411-1.html 1275411-1-ref.html
 == 1288255.html 1288255-ref.html
 fuzzy(8,1900) == 1291528.html 1291528-ref.html
 # Buttons in 2 pages have different position and the rendering result can be
 # different, but they should use the same button style and the background color
 # should be same.  |fuzzy()| here allows the difference in border, but not
 # background color.
 fuzzy(255,1000) skip-if(!cocoaWidget) == 1294102-1.html 1294102-1-ref.html
+== 1315632-1.html 1315632-1-ref.html
 
 HTTP == 652991-1a.html 652991-1-ref.html
 HTTP == 652991-1b.html 652991-1-ref.html
 HTTP == 652991-2.html 652991-2-ref.html
 HTTP == 652991-3.html 652991-3-ref.html
 HTTP == 652991-4.html 652991-4-ref.html