From 5e8833a8810e97b8d096e3b2af68ca3c8f13cb39 Mon Sep 17 00:00:00 2001 From: Cristina Horotan Date: Wed, 8 Mar 2023 18:29:46 +0200 Subject: [PATCH] Backed out changeset 1e6c032825f1 (bug 1798810) for wpt failures at baseline-source-last-001.html CLOSED TREE --- layout/base/nsLayoutUtils.cpp | 41 +--------------- layout/base/nsLayoutUtils.h | 4 +- layout/generic/ColumnSetWrapperFrame.cpp | 47 ------------------- layout/generic/ColumnSetWrapperFrame.h | 8 ---- layout/generic/nsColumnSetFrame.cpp | 27 ----------- layout/generic/nsColumnSetFrame.h | 4 -- .../css/css-multicol/baseline-001.html.ini | 2 + .../css/css-multicol/baseline-002.html.ini | 2 + .../css/css-multicol/baseline-008.html.ini | 2 + 9 files changed, 9 insertions(+), 128 deletions(-) create mode 100644 testing/web-platform/meta/css/css-multicol/baseline-001.html.ini create mode 100644 testing/web-platform/meta/css/css-multicol/baseline-002.html.ini create mode 100644 testing/web-platform/meta/css/css-multicol/baseline-008.html.ini diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index c4bf3e817ee3..bbd1ab8dfb28 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -5838,7 +5838,8 @@ bool nsLayoutUtils::GetFirstLinePosition(WritingMode aWM, return false; } - if (fType == LayoutFrameType::FieldSet) { + if (fType == LayoutFrameType::FieldSet || + fType == LayoutFrameType::ColumnSet) { LinePosition kidPosition; nsIFrame* kid = aFrame->PrincipalChildList().FirstChild(); // If aFrame is fieldset, kid might be a legend frame here, but that's ok. @@ -5850,29 +5851,6 @@ bool nsLayoutUtils::GetFirstLinePosition(WritingMode aWM, return false; } - if (fType == LayoutFrameType::ColumnSet) { - // Note(dshin): This is basically the same as - // `nsColumnSetFrame::GetNaturalBaselineBOffset`, but with line start and - // end, all stored in `LinePosition`. Field value apart from baseline is - // used in one other place - // (`nsBlockFrame`) - if that goes away, this becomes a duplication that - // should be removed. - LinePosition kidPosition; - for (const auto* kid : aFrame->PrincipalChildList()) { - LinePosition position; - if (!GetFirstLinePosition(aWM, kid, &position)) { - continue; - } - if (position.mBaseline < kidPosition.mBaseline) { - kidPosition = position; - } - } - if (kidPosition.mBaseline != nscoord_MAX) { - *aResult = kidPosition; - return true; - } - } - // No baseline. return false; } @@ -5928,21 +5906,6 @@ bool nsLayoutUtils::GetLastLineBaseline(WritingMode aWM, const nsIFrame* aFrame, *aResult = std::clamp(*aResult, 0, maxBaseline); return true; } - - // No need to duplicate the baseline logic (Unlike `GetFirstLinePosition`, - // we don't need to return any other value apart from baseline), just defer - // to `GetNaturalBaselineBOffset`. Technically, we could do this at - // `ColumnSetWrapperFrame` level, but this keeps it symmetric to - // `GetFirstLinePosition`. - if (aFrame->IsColumnSetFrame()) { - const auto baseline = - aFrame->GetNaturalBaselineBOffset(aWM, BaselineSharingGroup::Last); - if (!baseline) { - return false; - } - *aResult = aFrame->BSize(aWM) - *baseline; - return true; - } // No baseline. return false; } diff --git a/layout/base/nsLayoutUtils.h b/layout/base/nsLayoutUtils.h index c4b7bc243e20..90aeb5407d50 100644 --- a/layout/base/nsLayoutUtils.h +++ b/layout/base/nsLayoutUtils.h @@ -1754,9 +1754,7 @@ class nsLayoutUtils { * Otherwise returns false. */ struct LinePosition { - nscoord mBStart{nscoord_MAX}; - nscoord mBaseline{nscoord_MAX}; - nscoord mBEnd{nscoord_MAX}; + nscoord mBStart, mBaseline, mBEnd; LinePosition operator+(nscoord aOffset) const { LinePosition result; diff --git a/layout/generic/ColumnSetWrapperFrame.cpp b/layout/generic/ColumnSetWrapperFrame.cpp index de2bfcd9ddb2..543ea1bcb894 100644 --- a/layout/generic/ColumnSetWrapperFrame.cpp +++ b/layout/generic/ColumnSetWrapperFrame.cpp @@ -232,53 +232,6 @@ nscoord ColumnSetWrapperFrame::GetPrefISize(gfxContext* aRenderingContext) { return iSize; } -template -Maybe ColumnSetWrapperFrame::GetBaselineBOffset( - Iterator aStart, Iterator aEnd, WritingMode aWM, - BaselineSharingGroup aBaselineGroup) const { - // Either forward iterator + first baseline, or reverse iterator + last - // baseline - MOZ_ASSERT((*aStart == PrincipalChildList().FirstChild() && - aBaselineGroup == BaselineSharingGroup::First) || - (*aStart == PrincipalChildList().LastChild() && - aBaselineGroup == BaselineSharingGroup::Last), - "Iterator direction must match baseline sharing group."); - if (StyleDisplay()->IsContainLayout()) { - return Nothing{}; - } - - // Start from start/end of principal child list, and use the first valid - // baseline. - for (auto itr = aStart; itr != aEnd; ++itr) { - const nsIFrame* kid = *itr; - auto kidBaseline = kid->GetNaturalBaselineBOffset(aWM, aBaselineGroup); - if (!kidBaseline) { - continue; - } - // Baseline is offset from the kid's rectangle, so find the offset to the - // kid's rectangle. - LogicalRect kidRect{aWM, kid->GetLogicalNormalPosition(aWM, GetSize()), - kid->GetLogicalSize(aWM)}; - if (aBaselineGroup == BaselineSharingGroup::First) { - *kidBaseline += kidRect.BStart(aWM); - } else { - *kidBaseline += (GetLogicalSize().BSize(aWM) - kidRect.BEnd(aWM)); - } - return kidBaseline; - } - return Nothing{}; -} - -Maybe ColumnSetWrapperFrame::GetNaturalBaselineBOffset( - WritingMode aWM, BaselineSharingGroup aBaselineGroup) const { - if (aBaselineGroup == BaselineSharingGroup::First) { - return GetBaselineBOffset(PrincipalChildList().cbegin(), - PrincipalChildList().cend(), aWM, aBaselineGroup); - } - return GetBaselineBOffset(PrincipalChildList().crbegin(), - PrincipalChildList().crend(), aWM, aBaselineGroup); -} - #ifdef DEBUG /* static */ diff --git a/layout/generic/ColumnSetWrapperFrame.h b/layout/generic/ColumnSetWrapperFrame.h index 0ee2b0b4eb1e..4c5228483108 100644 --- a/layout/generic/ColumnSetWrapperFrame.h +++ b/layout/generic/ColumnSetWrapperFrame.h @@ -59,9 +59,6 @@ class ColumnSetWrapperFrame final : public nsBlockFrame { nscoord GetPrefISize(gfxContext* aRenderingContext) override; - Maybe GetNaturalBaselineBOffset( - WritingMode aWM, BaselineSharingGroup aBaselineGroup) const override; - private: explicit ColumnSetWrapperFrame(ComputedStyle* aStyle, nsPresContext* aPresContext); @@ -74,11 +71,6 @@ class ColumnSetWrapperFrame final : public nsBlockFrame { // its descendants. bool mFinishedBuildingColumns = false; #endif - - template - Maybe GetBaselineBOffset(Iterator aStart, Iterator aEnd, - WritingMode aWM, - BaselineSharingGroup aBaselineGroup) const; }; } // namespace mozilla diff --git a/layout/generic/nsColumnSetFrame.cpp b/layout/generic/nsColumnSetFrame.cpp index 2e24500af32a..4371494f6494 100644 --- a/layout/generic/nsColumnSetFrame.cpp +++ b/layout/generic/nsColumnSetFrame.cpp @@ -15,7 +15,6 @@ #include "mozilla/ToString.h" #include "nsCSSRendering.h" #include "nsDisplayList.h" -#include "nsIFrameInlines.h" #include "nsLayoutUtils.h" using namespace mozilla; @@ -1296,32 +1295,6 @@ void nsColumnSetFrame::AppendDirectlyOwnedAnonBoxes( aResult.AppendElement(OwnedAnonBox(column)); } -Maybe nsColumnSetFrame::GetNaturalBaselineBOffset( - WritingMode aWM, BaselineSharingGroup aBaselineGroup) const { - Maybe result; - for (const auto* kid : mFrames) { - auto kidBaseline = kid->GetNaturalBaselineBOffset(aWM, aBaselineGroup); - if (!kidBaseline) { - continue; - } - // The kid frame may not necessarily be aligned with the columnset frame. - LogicalRect kidRect{aWM, kid->GetLogicalNormalPosition(aWM, GetSize()), - kid->GetLogicalSize(aWM)}; - if (aBaselineGroup == BaselineSharingGroup::First) { - *kidBaseline += kidRect.BStart(aWM); - } else { - *kidBaseline += (GetLogicalSize().BSize(aWM) - kidRect.BEnd(aWM)); - } - // Take the smallest of the baselines (i.e. Closest to border-block-start - // for `BaselineSharingGroup::First`, border-block-end for - // `BaselineSharingGroup::Last`) - if (!result || *kidBaseline < *result) { - result = kidBaseline; - } - } - return result; -} - #ifdef DEBUG void nsColumnSetFrame::SetInitialChildList(ChildListID aListID, nsFrameList&& aChildList) { diff --git a/layout/generic/nsColumnSetFrame.h b/layout/generic/nsColumnSetFrame.h index 210d2401fa20..70a7ceef9373 100644 --- a/layout/generic/nsColumnSetFrame.h +++ b/layout/generic/nsColumnSetFrame.h @@ -74,10 +74,6 @@ class nsColumnSetFrame final : public nsContainerFrame { gfxContext* aCtx, const nsRect& aDirtyRect, const nsPoint& aPt); - Maybe GetNaturalBaselineBOffset( - mozilla::WritingMode aWM, - BaselineSharingGroup aBaselineGroup) const override; - protected: nscoord mLastBalanceBSize; nsReflowStatus mLastFrameStatus; diff --git a/testing/web-platform/meta/css/css-multicol/baseline-001.html.ini b/testing/web-platform/meta/css/css-multicol/baseline-001.html.ini new file mode 100644 index 000000000000..a190c9ea8cad --- /dev/null +++ b/testing/web-platform/meta/css/css-multicol/baseline-001.html.ini @@ -0,0 +1,2 @@ +[baseline-001.html] + expected: FAIL diff --git a/testing/web-platform/meta/css/css-multicol/baseline-002.html.ini b/testing/web-platform/meta/css/css-multicol/baseline-002.html.ini new file mode 100644 index 000000000000..b17980873888 --- /dev/null +++ b/testing/web-platform/meta/css/css-multicol/baseline-002.html.ini @@ -0,0 +1,2 @@ +[baseline-002.html] + expected: FAIL diff --git a/testing/web-platform/meta/css/css-multicol/baseline-008.html.ini b/testing/web-platform/meta/css/css-multicol/baseline-008.html.ini new file mode 100644 index 000000000000..4dc88ac74508 --- /dev/null +++ b/testing/web-platform/meta/css/css-multicol/baseline-008.html.ini @@ -0,0 +1,2 @@ +[baseline-008.html] + expected: FAIL