Bug 1359834 Part 2: Define a new nsChangeHint_ReflowHintsForFloatAreaChange hint and use it for float changes. draft
authorBrad Werth <bwerth@mozilla.com>
Fri, 14 Jul 2017 17:20:35 -0700
changeset 610053 14de01c074fcb1b7915ca110ba1230c836835c4a
parent 610052 c04d6a44e8a1bfbd954628c3e4a3c3d8019273ce
child 610054 f9999b665370b42d63ccd54ecfa117d71c78c070
push id68774
push userbwerth@mozilla.com
push dateMon, 17 Jul 2017 21:02:16 +0000
bugs1359834
milestone56.0a1
Bug 1359834 Part 2: Define a new nsChangeHint_ReflowHintsForFloatAreaChange hint and use it for float changes. MozReview-Commit-ID: 692GBiRUTab
layout/base/nsChangeHint.h
layout/style/nsStyleStruct.cpp
--- a/layout/base/nsChangeHint.h
+++ b/layout/base/nsChangeHint.h
@@ -422,16 +422,27 @@ static_assert(!(nsChangeHint_Hints_Alway
 // nsChangeHint_ClearAncestorIntrinsics (which is inline-axis specific), but we
 // do need to send it, to clear cached results from CSS Flex measuring reflows.
 #define nsChangeHint_ReflowHintsForBSizeChange            \
   nsChangeHint((nsChangeHint_AllReflowHints |             \
                 nsChangeHint_UpdateComputedBSize) &       \
                ~(nsChangeHint_ClearDescendantIntrinsics | \
                  nsChangeHint_NeedDirtyReflow))
 
+// * For changes to the float area of an already-floated element, we need all
+// reflow hints, but not the ones that apply to descendants.
+// Our descendants aren't impacted when our float area only changes
+// placement but not size/shape. (e.g. if we change which side we float to).
+// But our ancestors/siblings are potentially impacted, so we need to send
+// the non-descendant reflow hints.
+#define nsChangeHint_ReflowHintsForFloatAreaChange            \
+  nsChangeHint(nsChangeHint_AllReflowHints &              \
+               ~(nsChangeHint_ClearDescendantIntrinsics | \
+                 nsChangeHint_NeedDirtyReflow))
+
 #define NS_STYLE_HINT_REFLOW \
   nsChangeHint(NS_STYLE_HINT_VISUAL | nsChangeHint_AllReflowHints)
 
 #define nsChangeHint_Hints_CanIgnoreIfNotVisible   \
   nsChangeHint(NS_STYLE_HINT_VISUAL |              \
                nsChangeHint_NeutralChange |        \
                nsChangeHint_UpdateOpacityLayer |   \
                nsChangeHint_UpdateTransformLayer | \
--- a/layout/style/nsStyleStruct.cpp
+++ b/layout/style/nsStyleStruct.cpp
@@ -3522,20 +3522,18 @@ nsStyleDisplay::CalcDifference(const nsS
    * nsChangeHint_ReconstructFrame, PropagateScrollToViewport will be called.
    *
    * The scroll-behavior css property is not expected to change often (the
    * CSSOM-View DOM methods are likely to be used in those cases); however,
    * if this does become common perhaps a faster-path might be worth while.
    */
 
   if (mFloat != aNewData.mFloat) {
-    // Changing which side we float on doesn't affect descendants directly
-    hint |= nsChangeHint_AllReflowHints &
-            ~(nsChangeHint_ClearDescendantIntrinsics |
-              nsChangeHint_NeedDirtyReflow);
+    // Changing which side we're floating on (float:none was handled above).
+    hint |= nsChangeHint_ReflowHintsForFloatAreaChange;
   }
 
   if (mVerticalAlign != aNewData.mVerticalAlign) {
     // XXX Can this just be AllReflowHints + RepaintFrame, and be included in
     // the block below?
     hint |= NS_STYLE_HINT_REFLOW;
   }