Bug 1499961 - Indicate position-change reflow hint when RecomputePosition() bails out - r=dbaron,heycam
authorGerald Squelart <gsquelart@mozilla.com>
Wed, 14 Nov 2018 10:16:01 +0000
changeset 502609 26666002fbe333b0aaaafce1f7c1658728084b77
parent 502608 4e0347c2ced99ed5c69278509584fe5c3a88c0ca
child 502610 22c78747446daa0df05d532497b941d996f07548
push id10290
push userffxbld-merge
push dateMon, 03 Dec 2018 16:23:23 +0000
treeherdermozilla-beta@700bed2445e6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdbaron, heycam
bugs1499961
milestone65.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 1499961 - Indicate position-change reflow hint when RecomputePosition() bails out - r=dbaron,heycam If a frame cannot be repositioned, the reflow request should hint at the position change, so that if that frame is a reflow root, the next reflow won't just start from there and not set the new position. Updated incorrect comment about nsChangeHint_ReflowChangesSizeOrPosition always requiring nsChangeHint_ClearAncestorIntrinsics. Differential Revision: https://phabricator.services.mozilla.com/D9065
layout/base/RestyleManager.cpp
layout/base/nsChangeHint.h
--- a/layout/base/RestyleManager.cpp
+++ b/layout/base/RestyleManager.cpp
@@ -726,26 +726,30 @@ RecomputePosition(nsIFrame* aFrame)
     return true;
   }
 
   // Don't process position changes on frames which have views or the ones which
   // have a view somewhere in their descendants, because the corresponding view
   // needs to be repositioned properly as well.
   if (aFrame->HasView() ||
       (aFrame->GetStateBits() & NS_FRAME_HAS_CHILD_WITH_VIEW)) {
-    StyleChangeReflow(aFrame, nsChangeHint_NeedReflow);
+    StyleChangeReflow(aFrame,
+                      nsChangeHint_NeedReflow |
+                      nsChangeHint_ReflowChangesSizeOrPosition);
     return false;
   }
 
   // Flexbox and Grid layout supports CSS Align and the optimizations below
   // don't support that yet.
   if (aFrame->HasAnyStateBits(NS_FRAME_OUT_OF_FLOW)) {
     nsIFrame* ph = aFrame->GetPlaceholderFrame();
     if (ph && ph->HasAnyStateBits(PLACEHOLDER_STATICPOS_NEEDS_CSSALIGN)) {
-      StyleChangeReflow(aFrame, nsChangeHint_NeedReflow);
+      StyleChangeReflow(aFrame,
+                        nsChangeHint_NeedReflow |
+                        nsChangeHint_ReflowChangesSizeOrPosition);
       return false;
     }
   }
 
   aFrame->SchedulePaint();
 
   // For relative positioning, we can simply update the frame rect
   if (display->IsRelativelyPositionedStyle()) {
@@ -900,17 +904,19 @@ RecomputePosition(nsIFrame* aFrame)
                 parentBorder.top + reflowInput.ComputedPhysicalOffsets().top +
                 reflowInput.ComputedPhysicalMargin().top);
     aFrame->SetPosition(pos);
 
     return true;
   }
 
   // Fall back to a reflow
-  StyleChangeReflow(aFrame, nsChangeHint_NeedReflow);
+  StyleChangeReflow(aFrame,
+                    nsChangeHint_NeedReflow |
+                    nsChangeHint_ReflowChangesSizeOrPosition);
   return false;
 }
 
 static bool
 HasBoxAncestor(nsIFrame* aFrame)
 {
   for (nsIFrame* f = aFrame; f; f = f->GetParent()) {
     if (f->IsXULBoxFrame()) {
--- a/layout/base/nsChangeHint.h
+++ b/layout/base/nsChangeHint.h
@@ -180,18 +180,18 @@ enum nsChangeHint : uint32_t {
   /**
    * This will cause rendering observers to be invalidated.
    */
   nsChangeHint_InvalidateRenderingObservers = 1 << 22,
 
   /**
    * Indicates that the reflow changes the size or position of the
    * element, and thus the reflow must start from at least the frame's
-   * parent.  Must be not be set without also setting nsChangeHint_NeedReflow
-   * and nsChangeHint_ClearAncestorIntrinsics.
+   * parent.  Must be not be set without also setting nsChangeHint_NeedReflow.
+   * And consider adding nsChangeHint_ClearAncestorIntrinsics if needed.
    */
   nsChangeHint_ReflowChangesSizeOrPosition = 1 << 23,
 
   /**
    * Indicates that the style changes the computed BSize --- e.g. 'height'.
    * Must not be set without also setting nsChangeHint_NeedReflow.
    */
   nsChangeHint_UpdateComputedBSize = 1 << 24,