Bug 1367568 part 1: Create reusable macros that represent our change hints for tweaks to CSS width or height (ISize/BSize). r?bz
This patch doesn't affect behavior at all; it's simply moving code (and
moving/extending some associated code comments).
MozReview-Commit-ID: JiX53R9e9GW
--- a/layout/base/nsChangeHint.h
+++ b/layout/base/nsChangeHint.h
@@ -384,16 +384,49 @@ static_assert(!(nsChangeHint_Hints_Alway
nsChangeHint(nsChangeHint_RepaintFrame | nsChangeHint_SyncFrameView | \
nsChangeHint_SchedulePaint)
#define nsChangeHint_AllReflowHints \
nsChangeHint(nsChangeHint_NeedReflow | \
nsChangeHint_ReflowChangesSizeOrPosition|\
nsChangeHint_ClearAncestorIntrinsics | \
nsChangeHint_ClearDescendantIntrinsics | \
nsChangeHint_NeedDirtyReflow)
+
+// Below are the change hints that we send for ISize & BSize changes.
+// Each is similar to nsChangeHint_AllReflowHints with a few changes.
+
+// * For an ISize change, we send nsChangeHint_AllReflowHints, with two bits
+// excluded: nsChangeHint_ClearDescendantIntrinsics (because an ancestor's
+// inline-size change can't affect descendant intrinsic sizes), and
+// nsChangeHint_NeedDirtyReflow (because ISize changes don't need to *force*
+// all descendants to reflow).
+#define nsChangeHint_ReflowHintsForISizeChange \
+ nsChangeHint(nsChangeHint_AllReflowHints & \
+ ~(nsChangeHint_ClearDescendantIntrinsics | \
+ nsChangeHint_NeedDirtyReflow))
+
+// * For a BSize change, we send almost the same hints as for ISize changes,
+// with one extra: nsChangeHint_UpdateComputedBSize. We need this hint because
+// BSize changes CAN affect descendant intrinsic sizes, due to replaced
+// elements with percentage BSizes in descendants which also have percentage
+// BSizes. nsChangeHint_UpdateComputedBSize clears intrinsic sizes for frames
+// that have such replaced elements. (We could instead send
+// nsChangeHint_ClearDescendantIntrinsics, but that's broader than we need.)
+//
+// NOTE: You might think that BSize changes could exclude
+// nsChangeHint_ClearAncestorIntrinsics (which is inline-axis specific), but we
+// do need to send it, to clear cached results from CSS Flex measuring reflows.
+//
+// XXXdholbert The next patch rewrites this hint to be similar to the ISize one.
+#define nsChangeHint_ReflowHintsForBSizeChange \
+ nsChangeHint(nsChangeHint_NeedReflow | \
+ nsChangeHint_UpdateComputedBSize | \
+ nsChangeHint_ReflowChangesSizeOrPosition | \
+ nsChangeHint_ClearAncestorIntrinsics)
+
#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
@@ -1638,38 +1638,21 @@ nsStylePosition::CalcDifference(const ns
// nsStyleContext::CalcStyleDifference, which can lead to incorrect
// style data.
// It doesn't matter whether we're looking at the old or new
// visibility struct, since a change between vertical and horizontal
// writing-mode will cause a reframe, and it's easier to pass the old.
if (aOldStyleVisibility) {
bool isVertical = WritingMode(aOldStyleVisibility).IsVertical();
if (isVertical ? widthChanged : heightChanged) {
- // Block-size changes can affect descendant intrinsic sizes due to
- // replaced elements with percentage bsizes in descendants which
- // also have percentage bsizes. This is handled via
- // nsChangeHint_UpdateComputedBSize which clears intrinsic sizes
- // for frames that have such replaced elements.
- //
- // We need to use nsChangeHint_ClearAncestorIntrinsics for
- // block-size changes so we clear results of cached CSS Flex
- // measuring reflows.
- hint |= nsChangeHint_NeedReflow |
- nsChangeHint_UpdateComputedBSize |
- nsChangeHint_ReflowChangesSizeOrPosition |
- nsChangeHint_ClearAncestorIntrinsics;
+ hint |= nsChangeHint_ReflowHintsForBSizeChange;
}
if (isVertical ? heightChanged : widthChanged) {
- // None of our inline-size differences can affect descendant
- // intrinsic sizes and none of them need to force children to
- // reflow.
- hint |= nsChangeHint_AllReflowHints &
- ~(nsChangeHint_ClearDescendantIntrinsics |
- nsChangeHint_NeedDirtyReflow);
+ hint |= nsChangeHint_ReflowHintsForISizeChange;
}
} else {
if (widthChanged || heightChanged) {
hint |= nsChangeHint_NeutralChange;
}
}
// If any of the offsets have changed, then return the respective hints