Bug 1661874 Part 3 - Reverse the meaning of skipIncremental and rename it. r=heycam

I feel skipIncremental is hard to reasoning. It's easier to list all the
possible reasons that the child needs to be reflowed again.

Differential Revision: https://phabricator.services.mozilla.com/D88699
This commit is contained in:
Ting-Yu Lin 2020-08-31 03:45:23 +00:00
Родитель be1519920a
Коммит 7ffc02eb41
1 изменённых файлов: 29 добавлений и 25 удалений

Просмотреть файл

@ -561,20 +561,25 @@ nsColumnSetFrame::ColumnBalanceData nsColumnSetFrame::ReflowChildren(
aUnboundedLastColumn && colData.mColCount == aConfig.mUsedColCount && aUnboundedLastColumn && colData.mColCount == aConfig.mUsedColCount &&
aConfig.mIsBalancing; aConfig.mIsBalancing;
// Try to skip reflowing the child. We can't skip if the child is dirty. We // We need to reflow the child (column) ...
// also can't skip if the next column is dirty, because the next column's bool reflowChild =
// first line(s) might be pullable back to this column. We can't skip if // if we are told to do so;
// it's the last child because we need to obtain the bottom margin. We can't aReflowInput.ShouldReflowAllKids() ||
// skip if this is the last column and we're supposed to assign unbounded // if the child is dirty;
// block-size to it, because that could change the available block-size from child->IsSubtreeDirty() ||
// the last time we reflowed it and we should try to pull all the // if it's the last child because we need to obtain the block-end
// content from its next sibling. (Note that it might be the last // margin;
// column, but not be the last child because the desired number of columns !child->GetNextSibling() ||
// has changed.) // if the next column is dirty, because the next column's first line(s)
bool skipIncremental = // might be pullable back to this column;
!aReflowInput.ShouldReflowAllKids() && !child->IsSubtreeDirty() && child->GetNextSibling()->IsSubtreeDirty() ||
child->GetNextSibling() && !isMeasuringFeasibleContentBSize && // if this is the last column and we are supposed to assign unbounded
!child->GetNextSibling()->IsSubtreeDirty(); // block-size to it, because that could change the available block-size
// from the last time we reflowed it and we should try to pull all the
// content from its next sibling (Note that it might be the last column,
// but not be the last child because the desired number of columns has
// changed.)
isMeasuringFeasibleContentBSize;
// If column-fill is auto (not the default), then we might need to // If column-fill is auto (not the default), then we might need to
// move content between columns for any change in column block-size. // move content between columns for any change in column block-size.
@ -582,13 +587,13 @@ nsColumnSetFrame::ColumnBalanceData nsColumnSetFrame::ReflowChildren(
// The same is true if we have a non-'auto' computed block-size. // The same is true if we have a non-'auto' computed block-size.
// //
// FIXME: It's not clear to me why it's *ever* valid to have // FIXME: It's not clear to me why it's *ever* valid to have
// skipIncremental be true when changingBSize is true, since it // reflowChild be false when changingBSize is true, since it
// seems like a child broken over multiple columns might need to // seems like a child broken over multiple columns might need to
// change the size of the fragment in each column. // change the size of the fragment in each column.
if (skipIncremental && changingBSize && if (!reflowChild && changingBSize &&
(StyleColumn()->mColumnFill == StyleColumnFill::Auto || (StyleColumn()->mColumnFill == StyleColumnFill::Auto ||
computedBSize != NS_UNCONSTRAINEDSIZE)) { computedBSize != NS_UNCONSTRAINEDSIZE)) {
skipIncremental = false; reflowChild = true;
} }
// If we need to pull up content from the prev-in-flow then this is not just // If we need to pull up content from the prev-in-flow then this is not just
// a block-size shrink. The prev in flow will have set the dirty bit. // a block-size shrink. The prev in flow will have set the dirty bit.
@ -598,22 +603,22 @@ nsColumnSetFrame::ColumnBalanceData nsColumnSetFrame::ReflowChildren(
// doesn't care about the available block-size boundary, but if so, too bad, // doesn't care about the available block-size boundary, but if so, too bad,
// this optimization is defeated.) We want scrollable overflow here since // this optimization is defeated.) We want scrollable overflow here since
// this is a calculation that affects layout. // this is a calculation that affects layout.
if (skipIncremental && shrinkingBSize) { if (!reflowChild && shrinkingBSize) {
switch (wm.GetBlockDir()) { switch (wm.GetBlockDir()) {
case WritingMode::eBlockTB: case WritingMode::eBlockTB:
if (child->ScrollableOverflowRect().YMost() > aConfig.mColBSize) { if (child->ScrollableOverflowRect().YMost() > aConfig.mColBSize) {
skipIncremental = false; reflowChild = true;
} }
break; break;
case WritingMode::eBlockLR: case WritingMode::eBlockLR:
if (child->ScrollableOverflowRect().XMost() > aConfig.mColBSize) { if (child->ScrollableOverflowRect().XMost() > aConfig.mColBSize) {
skipIncremental = false; reflowChild = true;
} }
break; break;
case WritingMode::eBlockRL: case WritingMode::eBlockRL:
// XXX not sure how to handle this, so for now just don't attempt // XXX not sure how to handle this, so for now just don't attempt
// the optimization // the optimization
skipIncremental = false; reflowChild = true;
break; break;
default: default:
MOZ_ASSERT_UNREACHABLE("unknown block direction"); MOZ_ASSERT_UNREACHABLE("unknown block direction");
@ -622,7 +627,7 @@ nsColumnSetFrame::ColumnBalanceData nsColumnSetFrame::ReflowChildren(
} }
nscoord childContentBEnd = 0; nscoord childContentBEnd = 0;
if (!reflowNext && skipIncremental) { if (!reflowNext && !reflowChild) {
// This child does not need to be reflowed, but we may need to move it // This child does not need to be reflowed, but we may need to move it
MoveChildTo(child, childOrigin, wm, containerSize); MoveChildTo(child, childOrigin, wm, containerSize);
@ -640,9 +645,8 @@ nsColumnSetFrame::ColumnBalanceData nsColumnSetFrame::ReflowChildren(
} }
childContentBEnd = nsLayoutUtils::CalculateContentBEnd(wm, child); childContentBEnd = nsLayoutUtils::CalculateContentBEnd(wm, child);
COLUMN_SET_LOG("%s: Skipping child #%d %p (incremental %d): status=%s", COLUMN_SET_LOG("%s: Skipping child #%d %p: status=%s", __func__,
__func__, colData.mColCount, child, skipIncremental, colData.mColCount, child, ToString(aStatus).c_str());
ToString(aStatus).c_str());
} else { } else {
LogicalSize availSize(wm, aConfig.mColISize, aConfig.mColBSize); LogicalSize availSize(wm, aConfig.mColISize, aConfig.mColBSize);
if (isMeasuringFeasibleContentBSize) { if (isMeasuringFeasibleContentBSize) {