Bug 1674302 Part 2 - Use StyleSizeOverrides to replace ComputeSizeFlag::UseAutoISize. r=dholbert

`UseAutoISize` flag is buggy when used on table flex items because it
never propagates to inner table frame.

Luckily, we can fix it by replacing the flag with StyleSizeOverrides
emplacing an 'auto' mStyleISize, because when computing the size, the
size overrides already propagates from table wrapper to inner table via
the following path:

  `nsTableWrapperFrame::ComputeSize()` [1] ->
  `nsTableWrapperFrame::ComputeAutoSize()` ->
  `nsTableWrapperFrame::InnerTableShrinkWrapISize()` ->
  `nsTableFrame::ComputeSize()`.

Part 3 is going to propagate the size overrides to inner table in
`nsTableWrapperFrame::CreateReflowInputForInnerTable()` during reflow.

This patch fixes the content size suggestion for table flex items.
Combining this patch with Part 3, we can fix those reftests in Part 4.

[1] In this patch, the table wrapper is still using nsContainerFrame's
ComputeSize(), but Part 3 is going to override it.

Differential Revision: https://phabricator.services.mozilla.com/D103438
This commit is contained in:
Ting-Yu Lin 2021-02-18 05:45:24 +00:00
Родитель 5c0047ddf2
Коммит cf926779e7
4 изменённых файлов: 7 добавлений и 15 удалений

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

@ -44,14 +44,6 @@ enum class ComputeSizeFlag : uint8_t {
*/
ShrinkWrap,
/**
* Set if we'd like to compute our 'auto' isize, regardless of our actual
* corresponding computed value. (e.g. to get an intrinsic isize for flex
* items when resolving automatic minimum size in the main axis during flexbox
* layout.)
*/
UseAutoISize,
/**
* Set if we'd like to compute our 'auto' bsize, regardless of our actual
* corresponding computed value. (e.g. to get an intrinsic bsize for flex

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

@ -989,7 +989,7 @@ LogicalSize nsContainerFrame::ComputeAutoSize(
const auto& styleISize = aSizeOverrides.mStyleISize
? *aSizeOverrides.mStyleISize
: StylePosition()->ISize(aWM);
if (styleISize.IsAuto() || aFlags.contains(ComputeSizeFlag::UseAutoISize)) {
if (styleISize.IsAuto()) {
result.ISize(aWM) =
ShrinkWidthToFit(aRenderingContext, availBased, aFlags);
}
@ -2419,8 +2419,7 @@ LogicalSize nsContainerFrame::ComputeSizeWithIntrinsicDimensions(
// a * (b / c) because of its reduced accuracy relative to a * b / c
// or (a * b) / c (which are equivalent).
const bool isAutoISize =
styleISize.IsAuto() || aFlags.contains(ComputeSizeFlag::UseAutoISize);
const bool isAutoISize = styleISize.IsAuto();
const bool isAutoBSize =
nsLayoutUtils::IsAutoBSize(styleBSize, aCBSize.BSize(aWM)) ||
aFlags.contains(ComputeSizeFlag::UseAutoBSize);

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

@ -1662,12 +1662,14 @@ void nsFlexContainerFrame::ResolveAutoFlexBasisAndMinSize(
const auto cbWM = aAxisTracker.GetWritingMode();
const auto itemWM = aFlexItem.GetWritingMode();
const nscoord availISize = 0; // for min-content size
StyleSizeOverrides sizeOverrides;
sizeOverrides.mStyleISize.emplace(StyleSize::Auto());
const auto sizeInItemWM = aFlexItem.Frame()->ComputeSize(
aItemReflowInput.mRenderingContext, itemWM,
aItemReflowInput.mContainingBlockSize, availISize,
aItemReflowInput.ComputedLogicalMargin(itemWM).Size(itemWM),
aItemReflowInput.ComputedLogicalBorderPadding(itemWM).Size(itemWM),
{}, {ComputeSizeFlag::UseAutoISize, ComputeSizeFlag::ShrinkWrap});
sizeOverrides, {ComputeSizeFlag::ShrinkWrap});
contentSizeSuggestion = aAxisTracker.MainComponent(
sizeInItemWM.mLogicalSize.ConvertTo(cbWM, itemWM));

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

@ -6099,8 +6099,7 @@ nsIFrame::SizeComputationResult nsIFrame::ComputeSize(
const auto aspectRatio = GetAspectRatio();
const bool isOrthogonal = aWM.IsOrthogonalTo(alignCB->GetWritingMode());
const bool isAutoISize =
styleISize.IsAuto() || aFlags.contains(ComputeSizeFlag::UseAutoISize);
const bool isAutoISize = styleISize.IsAuto();
// Compute inline-axis size
if (!isAutoISize) {
auto iSizeResult =
@ -6352,7 +6351,7 @@ LogicalSize nsIFrame::ComputeAutoSize(
const auto& styleISize = aSizeOverrides.mStyleISize
? *aSizeOverrides.mStyleISize
: StylePosition()->ISize(aWM);
if (styleISize.IsAuto() || aFlags.contains(ComputeSizeFlag::UseAutoISize)) {
if (styleISize.IsAuto()) {
nscoord availBased =
aAvailableISize - aMargin.ISize(aWM) - aBorderPadding.ISize(aWM);
result.ISize(aWM) = ShrinkWidthToFit(aRenderingContext, availBased, aFlags);