From e65d961df7c881870554a69c5cf7e2e0ae7b3656 Mon Sep 17 00:00:00 2001 From: Ting-Yu Lin Date: Thu, 1 Aug 2019 00:03:22 +0000 Subject: [PATCH] Bug 1548100 Part 2 - Fix the block-size of the column-rule by consuming available block-size. r=dbaron After enabling column-span, ColumnSet becomes an anonymous child under ColumnSetWrapperFrame. It doesn't need to handle border and padding, containment, and non-auto block-size. ColumnSet's final block-size is simply the union of ::-moz-column-content frames' rects. However, we should extend ColumnSet's block-size to consume the available block-size if the ColumnSetWrapper's block-size is constrained so that the column rules are drawn to the block-end edge of the multicol container. Differential Revision: https://phabricator.services.mozilla.com/D39060 --HG-- rename : testing/web-platform/meta/css/css-multicol/multicol-breaking-000.html.ini => testing/web-platform/meta/css/css-multicol/multicol-rule-nested-balancing-001.html.ini rename : testing/web-platform/meta/css/css-multicol/multicol-breaking-000.html.ini => testing/web-platform/meta/css/css-multicol/multicol-rule-nested-balancing-002.html.ini rename : testing/web-platform/meta/css/css-multicol/multicol-breaking-000.html.ini => testing/web-platform/meta/css/css-multicol/multicol-span-all-rule-001.html.ini extra : moz-landing-system : lando --- layout/base/nsCSSFrameConstructor.cpp | 3 + layout/generic/nsBlockFrame.cpp | 2 + layout/generic/nsColumnSetFrame.cpp | 86 +++++++++++++------ layout/reftests/columns/reftest.list | 2 +- layout/reftests/w3c-css/failures.list | 3 +- layout/reftests/w3c-css/received/reftest.list | 2 +- .../multicol-breaking-000.html.ini | 1 - .../multicol-breaking-001.html.ini | 1 - .../multicol-breaking-004.html.ini | 1 - ...ulticol-breaking-nobackground-000.html.ini | 1 - ...ulticol-breaking-nobackground-001.html.ini | 1 - ...ulticol-rule-nested-balancing-001.html.ini | 2 + ...ulticol-rule-nested-balancing-002.html.ini | 2 + .../multicol-span-all-rule-001.html.ini | 2 + ...ulticol-rule-nested-balancing-001-ref.html | 43 ++++++++++ .../multicol-rule-nested-balancing-001.html | 41 +++++++++ ...ulticol-rule-nested-balancing-002-ref.html | 43 ++++++++++ .../multicol-rule-nested-balancing-002.html | 41 +++++++++ .../multicol-span-all-rule-001-ref.html | 36 ++++++++ .../multicol-span-all-rule-001.html | 45 ++++++++++ 20 files changed, 323 insertions(+), 35 deletions(-) create mode 100644 testing/web-platform/meta/css/css-multicol/multicol-rule-nested-balancing-001.html.ini create mode 100644 testing/web-platform/meta/css/css-multicol/multicol-rule-nested-balancing-002.html.ini create mode 100644 testing/web-platform/meta/css/css-multicol/multicol-span-all-rule-001.html.ini create mode 100644 testing/web-platform/tests/css/css-multicol/multicol-rule-nested-balancing-001-ref.html create mode 100644 testing/web-platform/tests/css/css-multicol/multicol-rule-nested-balancing-001.html create mode 100644 testing/web-platform/tests/css/css-multicol/multicol-rule-nested-balancing-002-ref.html create mode 100644 testing/web-platform/tests/css/css-multicol/multicol-rule-nested-balancing-002.html create mode 100644 testing/web-platform/tests/css/css-multicol/multicol-span-all-rule-001-ref.html create mode 100644 testing/web-platform/tests/css/css-multicol/multicol-span-all-rule-001.html diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index f7ef3f0626d4..2cff37a4f57b 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -10803,6 +10803,9 @@ void nsCSSFrameConstructor::FinishBuildingColumns( nsFrameList finalList; while (aColumnContentSiblings.NotEmpty()) { + // Tag every ColumnSet except the last one. + prevColumnSet->SetProperty(nsIFrame::HasColumnSpanSiblings(), true); + nsIFrame* f = aColumnContentSiblings.RemoveFirstChild(); if (f->IsColumnSpan()) { // Do nothing for column-span wrappers. Just move it to the final diff --git a/layout/generic/nsBlockFrame.cpp b/layout/generic/nsBlockFrame.cpp index fd63373fde09..06b1a0fdd440 100644 --- a/layout/generic/nsBlockFrame.cpp +++ b/layout/generic/nsBlockFrame.cpp @@ -3573,6 +3573,8 @@ void nsBlockFrame::ReflowBlockFrame(BlockReflowInput& aState, availSize.BSize(wm) -= aState.BorderPadding().BEnd(wm); } + // Bug 1569701: We need to use GetEffectiveComputedBSize() to get + // correct block-size if ColumnSetWrapper is fragmented. nscoord contentBSize = aState.mReflowInput.ComputedBSize(); if (aState.mReflowInput.ComputedMaxBSize() != NS_UNCONSTRAINEDSIZE) { contentBSize = diff --git a/layout/generic/nsColumnSetFrame.cpp b/layout/generic/nsColumnSetFrame.cpp index a6458a275f21..b64ea2b4dd9a 100644 --- a/layout/generic/nsColumnSetFrame.cpp +++ b/layout/generic/nsColumnSetFrame.cpp @@ -917,37 +917,71 @@ nsColumnSetFrame::ColumnBalanceData nsColumnSetFrame::ReflowChildren( contentSize.BSize(wm) = std::max(contentSize.BSize(wm), contentBEnd); mLastFrameStatus = aStatus; - // Apply computed and min/max values - if (aConfig.mComputedBSize != NS_UNCONSTRAINEDSIZE) { - if (aReflowInput.AvailableBSize() != NS_UNCONSTRAINEDSIZE) { + if (StaticPrefs::layout_css_column_span_enabled()) { + MOZ_ASSERT(borderPadding.IsAllZero(), + "Only our parent ColumnSetWrapper can have border and padding!"); + + if (computedSize.BSize(wm) != NS_UNCONSTRAINEDSIZE && + !GetProperty(nsIFrame::HasColumnSpanSiblings())) { + MOZ_ASSERT(aReflowInput.AvailableBSize() != NS_UNCONSTRAINEDSIZE, + "Available block-size should be constrained because it's " + "restricted by the computed block-size when our reflow input " + "is created in nsBlockFrame::ReflowBlockFrame()!"); + + // If a) our parent ColumnSetWrapper has constrained block-size + // (nsBlockFrame::ReflowBlockFrame() applies the block-size constraint + // when creating BlockReflowInput for ColumnSetFrame); and b) we are the + // sole ColumnSet or the last ColumnSet continuation split by column-spans + // in a ColumnSetWrapper, extend our block-size to consume the available + // block-size so that the column-rules are drawn to the content block-end + // edge of the multicol container. contentSize.BSize(wm) = - std::min(contentSize.BSize(wm), aConfig.mComputedBSize); - } else { - contentSize.BSize(wm) = aConfig.mComputedBSize; + std::max(contentSize.BSize(wm), aReflowInput.AvailableBSize()); + + // But don't consume more block-size than what is left in the + // ColumnSetWrapper. + // + // Bug 1569701: If we use the effective computed block-size of + // ColumnSetWrapper when creating BlockReflowInput for ColumnSet, the + // available block-size should always less than or equal to the effective + // computed block-size. This std::min() won't be needed. + contentSize.BSize(wm) = + std::min(contentSize.BSize(wm), computedSize.BSize(wm)); } - } else if (aReflowInput.mStyleDisplay->IsContainSize()) { - // If we are intrinsically sized, but are size contained, - // we need to behave as if we have no contents. Our BSize - // should be zero or minBSize if specified. - contentSize.BSize(wm) = aReflowInput.ApplyMinMaxBSize(0); } else { - // We add the "consumed" block-size back in so that we're applying - // constraints to the correct bSize value, then subtract it again - // after we've finished with the min/max calculation. This prevents us from - // having a last continuation that is smaller than the min bSize. but which - // has prev-in-flows, trigger a larger bSize than actually required. - contentSize.BSize(wm) = aReflowInput.ApplyMinMaxBSize( - contentSize.BSize(wm), aConfig.mConsumedBSize); - } - if (aReflowInput.ComputedISize() != NS_UNCONSTRAINEDSIZE) { - contentSize.ISize(wm) = aReflowInput.ComputedISize(); - } else { - contentSize.ISize(wm) = - aReflowInput.ApplyMinMaxISize(contentSize.ISize(wm)); + // Apply computed and min/max values + if (aConfig.mComputedBSize != NS_UNCONSTRAINEDSIZE) { + if (aReflowInput.AvailableBSize() != NS_UNCONSTRAINEDSIZE) { + contentSize.BSize(wm) = + std::min(contentSize.BSize(wm), aConfig.mComputedBSize); + } else { + contentSize.BSize(wm) = aConfig.mComputedBSize; + } + } else if (aReflowInput.mStyleDisplay->IsContainSize()) { + // If we are intrinsically sized, but are size contained, + // we need to behave as if we have no contents. Our BSize + // should be zero or minBSize if specified. + contentSize.BSize(wm) = aReflowInput.ApplyMinMaxBSize(0); + } else { + // We add the "consumed" block-size back in so that we're applying + // constraints to the correct bSize value, then subtract it again + // after we've finished with the min/max calculation. This prevents us + // from having a last continuation that is smaller than the min bSize. but + // which has prev-in-flows, trigger a larger bSize than actually required. + contentSize.BSize(wm) = aReflowInput.ApplyMinMaxBSize( + contentSize.BSize(wm), aConfig.mConsumedBSize); + } + if (aReflowInput.ComputedISize() != NS_UNCONSTRAINEDSIZE) { + contentSize.ISize(wm) = aReflowInput.ComputedISize(); + } else { + contentSize.ISize(wm) = + aReflowInput.ApplyMinMaxISize(contentSize.ISize(wm)); + } + + contentSize.ISize(wm) += borderPadding.IStartEnd(wm); + contentSize.BSize(wm) += borderPadding.BStartEnd(wm); } - contentSize.ISize(wm) += borderPadding.IStartEnd(wm); - contentSize.BSize(wm) += borderPadding.BStartEnd(wm); aDesiredSize.SetSize(wm, contentSize); aDesiredSize.mOverflowAreas = overflowRects; aDesiredSize.UnionOverflowAreasWithDesiredBounds(); diff --git a/layout/reftests/columns/reftest.list b/layout/reftests/columns/reftest.list index 1bbc35d37453..9df2c76b5b09 100644 --- a/layout/reftests/columns/reftest.list +++ b/layout/reftests/columns/reftest.list @@ -49,7 +49,7 @@ pref(layout.css.column-span.enabled,true) == first-line-first-letter.html first- # column-span enabled. These lines can be removed once the pref becomes # default-enabled (Bug 1426010). default-preferences pref(layout.css.column-span.enabled,true) -fails == min-width-2.html min-width-2-ref.html # Bug 1548100 +== min-width-2.html min-width-2-ref.html == column-balancing-nested-001.html column-balancing-nested-001-ref.html fails == zero-height-nondirty-reflow.html zero-height-nondirty-reflow-ref.html # bug 1565665 default-preferences diff --git a/layout/reftests/w3c-css/failures.list b/layout/reftests/w3c-css/failures.list index cb1fc41cf1da..a5cedccbbc13 100644 --- a/layout/reftests/w3c-css/failures.list +++ b/layout/reftests/w3c-css/failures.list @@ -260,8 +260,7 @@ css-multicol/multicol-rule-000.xht fuzzy-if(!OSX,0-135,0-1584) css-multicol/multicol-rule-001.xht fails-if(!OSX) random-if(OSX) css-multicol/multicol-rule-002.xht css-multicol/multicol-rule-003.xht -# Bug 1548100 -pref(layout.css.column-span.enabled,true) fails css-multicol/multicol-rule-004.xht +pref(layout.css.column-span.enabled,true) css-multicol/multicol-rule-004.xht css-multicol/multicol-rule-color-001.xht fuzzy(0-106,0-354) css-multicol/multicol-rule-dashed-000.xht fuzzy(0-106,0-354) css-multicol/multicol-rule-dotted-000.xht diff --git a/layout/reftests/w3c-css/received/reftest.list b/layout/reftests/w3c-css/received/reftest.list index 0b00b9176861..fae50ecf19fa 100644 --- a/layout/reftests/w3c-css/received/reftest.list +++ b/layout/reftests/w3c-css/received/reftest.list @@ -125,7 +125,7 @@ fuzzy-if(skiaContent,0-64,0-2) == css-multicol/multicol-reduce-000.xht css-multi fuzzy-if(!OSX,0-135,0-1584) == css-multicol/multicol-rule-001.xht css-multicol/multicol-rule-001-ref.xht fails-if(!OSX) random-if(OSX) == css-multicol/multicol-rule-002.xht css-multicol/multicol-rule-ref.xht == css-multicol/multicol-rule-003.xht css-multicol/multicol-rule-003-ref.xht -pref(layout.css.column-span.enabled,true) fails == css-multicol/multicol-rule-004.xht css-multicol/multicol-rule-004-ref.xht +pref(layout.css.column-span.enabled,true) == css-multicol/multicol-rule-004.xht css-multicol/multicol-rule-004-ref.xht == css-multicol/multicol-rule-color-001.xht css-multicol/multicol-rule-color-001-ref.xht == css-multicol/multicol-rule-color-inherit-001.xht css-multicol/multicol-rule-color-inherit-001-ref.xht == css-multicol/multicol-rule-color-inherit-002.xht css-multicol/multicol-rule-color-inherit-001-ref.xht diff --git a/testing/web-platform/meta/css/css-multicol/multicol-breaking-000.html.ini b/testing/web-platform/meta/css/css-multicol/multicol-breaking-000.html.ini index 158298e536a8..e29ee179f2f8 100644 --- a/testing/web-platform/meta/css/css-multicol/multicol-breaking-000.html.ini +++ b/testing/web-platform/meta/css/css-multicol/multicol-breaking-000.html.ini @@ -1,3 +1,2 @@ [multicol-breaking-000.html] prefs: [layout.css.column-span.enabled:true] - expected: FAIL diff --git a/testing/web-platform/meta/css/css-multicol/multicol-breaking-001.html.ini b/testing/web-platform/meta/css/css-multicol/multicol-breaking-001.html.ini index df2b00b9b1a9..ef86c088fcac 100644 --- a/testing/web-platform/meta/css/css-multicol/multicol-breaking-001.html.ini +++ b/testing/web-platform/meta/css/css-multicol/multicol-breaking-001.html.ini @@ -1,3 +1,2 @@ [multicol-breaking-001.html] prefs: [layout.css.column-span.enabled:true] - expected: FAIL diff --git a/testing/web-platform/meta/css/css-multicol/multicol-breaking-004.html.ini b/testing/web-platform/meta/css/css-multicol/multicol-breaking-004.html.ini index 15affb3ba664..cc211ed1f9c7 100644 --- a/testing/web-platform/meta/css/css-multicol/multicol-breaking-004.html.ini +++ b/testing/web-platform/meta/css/css-multicol/multicol-breaking-004.html.ini @@ -1,3 +1,2 @@ [multicol-breaking-004.html] prefs: [layout.css.column-span.enabled:true] - expected: FAIL diff --git a/testing/web-platform/meta/css/css-multicol/multicol-breaking-nobackground-000.html.ini b/testing/web-platform/meta/css/css-multicol/multicol-breaking-nobackground-000.html.ini index 0dd6fca71519..ae40d9a50d82 100644 --- a/testing/web-platform/meta/css/css-multicol/multicol-breaking-nobackground-000.html.ini +++ b/testing/web-platform/meta/css/css-multicol/multicol-breaking-nobackground-000.html.ini @@ -1,3 +1,2 @@ [multicol-breaking-nobackground-000.html] prefs: [layout.css.column-span.enabled:true] - expected: FAIL diff --git a/testing/web-platform/meta/css/css-multicol/multicol-breaking-nobackground-001.html.ini b/testing/web-platform/meta/css/css-multicol/multicol-breaking-nobackground-001.html.ini index 9433c5a38b27..e4e0da2da471 100644 --- a/testing/web-platform/meta/css/css-multicol/multicol-breaking-nobackground-001.html.ini +++ b/testing/web-platform/meta/css/css-multicol/multicol-breaking-nobackground-001.html.ini @@ -1,3 +1,2 @@ [multicol-breaking-nobackground-001.html] prefs: [layout.css.column-span.enabled:true] - expected: FAIL diff --git a/testing/web-platform/meta/css/css-multicol/multicol-rule-nested-balancing-001.html.ini b/testing/web-platform/meta/css/css-multicol/multicol-rule-nested-balancing-001.html.ini new file mode 100644 index 000000000000..4a5087857601 --- /dev/null +++ b/testing/web-platform/meta/css/css-multicol/multicol-rule-nested-balancing-001.html.ini @@ -0,0 +1,2 @@ +[multicol-rule-nested-balancing-001.html] + prefs: [layout.css.column-span.enabled:true] diff --git a/testing/web-platform/meta/css/css-multicol/multicol-rule-nested-balancing-002.html.ini b/testing/web-platform/meta/css/css-multicol/multicol-rule-nested-balancing-002.html.ini new file mode 100644 index 000000000000..d97742b28a6c --- /dev/null +++ b/testing/web-platform/meta/css/css-multicol/multicol-rule-nested-balancing-002.html.ini @@ -0,0 +1,2 @@ +[multicol-rule-nested-balancing-002.html] + prefs: [layout.css.column-span.enabled:true] diff --git a/testing/web-platform/meta/css/css-multicol/multicol-span-all-rule-001.html.ini b/testing/web-platform/meta/css/css-multicol/multicol-span-all-rule-001.html.ini new file mode 100644 index 000000000000..a426b568aa23 --- /dev/null +++ b/testing/web-platform/meta/css/css-multicol/multicol-span-all-rule-001.html.ini @@ -0,0 +1,2 @@ +[multicol-span-all-rule-001.html] + prefs: [layout.css.column-span.enabled:true] diff --git a/testing/web-platform/tests/css/css-multicol/multicol-rule-nested-balancing-001-ref.html b/testing/web-platform/tests/css/css-multicol/multicol-rule-nested-balancing-001-ref.html new file mode 100644 index 000000000000..29acc05a2223 --- /dev/null +++ b/testing/web-platform/tests/css/css-multicol/multicol-rule-nested-balancing-001-ref.html @@ -0,0 +1,43 @@ + + + + CSS Multi-column Layout Test Reference: Test the column rules' block-size with nested balancing multicol container + + + + + +
+
+
+
+
+
+
+
+ diff --git a/testing/web-platform/tests/css/css-multicol/multicol-rule-nested-balancing-001.html b/testing/web-platform/tests/css/css-multicol/multicol-rule-nested-balancing-001.html new file mode 100644 index 000000000000..0491bd37f1a6 --- /dev/null +++ b/testing/web-platform/tests/css/css-multicol/multicol-rule-nested-balancing-001.html @@ -0,0 +1,41 @@ + + + + CSS Multi-column Layout Test: Test the column rules' block-size with nested balancing multicol container + + + + + + + + + + +
+
+
+
+
+
+ diff --git a/testing/web-platform/tests/css/css-multicol/multicol-rule-nested-balancing-002-ref.html b/testing/web-platform/tests/css/css-multicol/multicol-rule-nested-balancing-002-ref.html new file mode 100644 index 000000000000..f55796617883 --- /dev/null +++ b/testing/web-platform/tests/css/css-multicol/multicol-rule-nested-balancing-002-ref.html @@ -0,0 +1,43 @@ + + + + CSS Multi-column Layout Test Reference: Test the column rules' block-size with nested balancing multicol container + + + + + +
+
+
+
+
+
+
+
+ diff --git a/testing/web-platform/tests/css/css-multicol/multicol-rule-nested-balancing-002.html b/testing/web-platform/tests/css/css-multicol/multicol-rule-nested-balancing-002.html new file mode 100644 index 000000000000..b38f90947a91 --- /dev/null +++ b/testing/web-platform/tests/css/css-multicol/multicol-rule-nested-balancing-002.html @@ -0,0 +1,41 @@ + + + + CSS Multi-column Layout Test: Test the column rules' block-size with nested balancing multicol container + + + + + + + + + + +
+
+
+
+
+
+ diff --git a/testing/web-platform/tests/css/css-multicol/multicol-span-all-rule-001-ref.html b/testing/web-platform/tests/css/css-multicol/multicol-span-all-rule-001-ref.html new file mode 100644 index 000000000000..0ab9ac553457 --- /dev/null +++ b/testing/web-platform/tests/css/css-multicol/multicol-span-all-rule-001-ref.html @@ -0,0 +1,36 @@ + + + + CSS Multi-column Layout Test: Test the column-rule's block-size + + + + + +
+
block1
+
column-span1
+
block2
+
column-span2
+
block3
+
+ diff --git a/testing/web-platform/tests/css/css-multicol/multicol-span-all-rule-001.html b/testing/web-platform/tests/css/css-multicol/multicol-span-all-rule-001.html new file mode 100644 index 000000000000..215aa5674097 --- /dev/null +++ b/testing/web-platform/tests/css/css-multicol/multicol-span-all-rule-001.html @@ -0,0 +1,45 @@ + + + + CSS Multi-column Layout Test: Test the column rule's block-size + + + + + + + + + + +
+ +
block1
+
column-span1
+
block2
+
column-span2
+ +
block3
+
+