Bug 1190635 - Don't early-return for an mHeight change, since width changes can add extra change hints. r=heycam, a=ritu
authorRobert O'Callahan <robert@ocallahan.org>
Tue, 04 Aug 2015 16:41:50 +1200
changeset 281802 d26b3266a147c88db6946b2831c48df869e92d3c
parent 281801 92a911aecda1d2cc23f7b0d7e51c72d6b8527811
child 281803 f57b52fa0a5843cbd837177aef5e2c6b503c3906
push id4932
push userjlund@mozilla.com
push dateMon, 10 Aug 2015 18:23:06 +0000
treeherdermozilla-beta@6dd5a4f5f745 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam, ritu
bugs1190635
milestone41.0a2
Bug 1190635 - Don't early-return for an mHeight change, since width changes can add extra change hints. r=heycam, a=ritu Don't return early for an mWidth change either.
layout/reftests/bugs/1190635-1-ref.html
layout/reftests/bugs/1190635-1.html
layout/reftests/bugs/reftest.list
layout/style/nsStyleStruct.cpp
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/1190635-1-ref.html
@@ -0,0 +1,9 @@
+<!DOCTYPE HTML>
+<body style="width:500px; border:2px solid black;">
+<div style="width:300px; height:300px; background:yellow; float:left;"></div>
+<div style="width:300px; height:400px;">
+  <span style="display:inline-block; outline:3px solid cyan">
+    <span style="display:inline-block; width:300px; height:100px; outline:5px solid red" id="d"></span>
+  </span>
+</div>
+</body>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/1190635-1.html
@@ -0,0 +1,17 @@
+<!DOCTYPE HTML>
+<html class="reftest-wait">
+<body style="width:500px; border:2px solid black;">
+<div style="width:300px; height:300px; background:yellow; float:left;"></div>
+<div style="width:300px; height:400px;">
+  <span style="display:inline-block; outline:3px solid cyan">
+    <span style="display:inline-block; width:0; height:0; outline:5px solid red" id="d"></span>
+  </span>
+</div>
+<script>
+window.addEventListener("MozReftestInvalidate", function() {
+  d.style.width = "300px";
+  d.style.height = "100px";
+  document.documentElement.removeAttribute("class");
+});
+</script>
+</body>
--- a/layout/reftests/bugs/reftest.list
+++ b/layout/reftests/bugs/reftest.list
@@ -1923,8 +1923,9 @@ skip-if(!B2G) fuzzy-if(B2G,101,887) == 1
 skip-if(B2G||Mulet) == 1150021-1.xul 1150021-1-ref.xul
 == 1151145-1.html 1151145-1-ref.html
 == 1151306-1.html 1151306-1-ref.html
 == 1153845-1.html 1153845-1-ref.html
 == 1155828-1.html 1155828-1-ref.html
 == 1156129-1.html 1156129-1-ref.html
 == 1169331-1.html 1169331-1-ref.html
 fuzzy(1,74) == 1174332-1.html 1174332-1-ref.html
+== 1190635-1.html 1190635-1-ref.html
--- a/layout/style/nsStyleStruct.cpp
+++ b/layout/style/nsStyleStruct.cpp
@@ -1595,47 +1595,44 @@ nsChangeHint nsStylePosition::CalcDiffer
 
   if (mHeight != aOther.mHeight ||
       mMinHeight != aOther.mMinHeight ||
       mMaxHeight != aOther.mMaxHeight) {
     // Height changes can affect descendant intrinsic sizes due to replaced
     // elements with percentage heights in descendants which also have
     // percentage heights. This is handled via nsChangeHint_UpdateComputedBSize
     // which clears intrinsic sizes for frames that have such replaced elements.
-    return NS_CombineHint(hint, nsChangeHint_NeedReflow |
+    NS_UpdateHint(hint, nsChangeHint_NeedReflow |
         nsChangeHint_UpdateComputedBSize |
         nsChangeHint_ReflowChangesSizeOrPosition);
   }
 
   if (mWidth != aOther.mWidth ||
       mMinWidth != aOther.mMinWidth ||
       mMaxWidth != aOther.mMaxWidth) {
     // None of our width differences can affect descendant intrinsic
     // sizes and none of them need to force children to reflow.
-    return
-      NS_CombineHint(hint,
-                     NS_SubtractHint(nsChangeHint_AllReflowHints,
-                                     NS_CombineHint(nsChangeHint_ClearDescendantIntrinsics,
-                                                    nsChangeHint_NeedDirtyReflow)));
+    NS_UpdateHint(hint, NS_SubtractHint(nsChangeHint_AllReflowHints,
+                                        NS_CombineHint(nsChangeHint_ClearDescendantIntrinsics,
+                                                       nsChangeHint_NeedDirtyReflow)));
   }
 
-  // If width and height have not changed, but any of the offsets have changed,
-  // then return the respective hints so that we would hopefully be able to
-  // avoid reflowing.
+  // If any of the offsets have changed, then return the respective hints
+  // so that we would hopefully be able to avoid reflowing.
   // Note that it is possible that we'll need to reflow when processing
   // restyles, but we don't have enough information to make a good decision
   // right now.
   // Don't try to handle changes between "auto" and non-auto efficiently;
   // that's tricky to do and will hardly ever be able to avoid a reflow.
   if (mOffset != aOther.mOffset) {
     if (IsAutonessEqual(mOffset, aOther.mOffset)) {
       NS_UpdateHint(hint, nsChangeHint(nsChangeHint_RecomputePosition |
                                        nsChangeHint_UpdateParentOverflow));
     } else {
-      return NS_CombineHint(hint, nsChangeHint_AllReflowHints);
+      NS_UpdateHint(hint, nsChangeHint_AllReflowHints);
     }
   }
   return hint;
 }
 
 /* static */ bool
 nsStylePosition::WidthCoordDependsOnContainer(const nsStyleCoord &aCoord)
 {