From 07ccada8ceede8ab7775d7409ccc8f11e2e47b0e Mon Sep 17 00:00:00 2001 From: Norisz Fay Date: Fri, 8 Nov 2024 00:09:56 +0200 Subject: [PATCH] Backed out changeset 1445e1cfc71f (bug 1768921) for causing multiple failures CLOSED TREE --- dom/html/test/test_bug375003-2.html | 4 +- layout/generic/ScrollContainerFrame.cpp | 21 ++ layout/generic/crashtests/crashtests.list | 4 +- layout/generic/nsBlockFrame.cpp | 309 ++++++------------ layout/generic/nsBlockFrame.h | 14 +- layout/generic/nsLineBox.cpp | 35 +- layout/generic/nsLineBox.h | 16 - layout/reftests/bugs/458296-1c.html | 10 + layout/reftests/bugs/966992-1-ref.html | 16 +- layout/reftests/bugs/966992-1.html | 26 ++ layout/reftests/bugs/reftest.list | 1 + .../scrollable-horizontal-margin-ref.html | 6 +- .../scrollable-horizontal-margin.html | 6 +- .../position-sticky/padding-3-ref.html | 2 +- layout/tables/crashtests/crashtests.list | 4 +- .../inline-block-replaced-width-008.xht.ini | 3 + .../inline-replaced-width-009.xht.ini | 3 + .../content-visibility-090.html.ini | 3 - .../margin-block-end-scroll-area-001.html.ini | 2 - ...gonal-flow-with-inline-end-margin.html.ini | 3 + .../overflow-clip-margin-007.html.ini | 3 + .../overflow-clip-margin-012.html.ini | 3 + .../css-overflow/overflow-padding.html.ini | 5 + .../scrollable-overflow-padding.html.ini | 97 +++++- .../css/cssom-view/scrollWidthHeight.xht.ini | 6 + .../sizing-orthog-vlr-in-htb-008-ref.xht | 1 + .../sizing-orthog-vlr-in-htb-020-ref.xht | 1 + .../sizing-orthog-vrl-in-htb-008-ref.xht | 1 + .../sizing-orthog-vrl-in-htb-020-ref.xht | 1 + 29 files changed, 312 insertions(+), 294 deletions(-) create mode 100644 layout/reftests/bugs/458296-1c.html create mode 100644 testing/web-platform/meta/css/CSS2/normal-flow/inline-block-replaced-width-008.xht.ini create mode 100644 testing/web-platform/meta/css/CSS2/normal-flow/inline-replaced-width-009.xht.ini delete mode 100644 testing/web-platform/meta/css/css-contain/content-visibility/content-visibility-090.html.ini delete mode 100644 testing/web-platform/meta/css/css-overflow/margin-block-end-scroll-area-001.html.ini create mode 100644 testing/web-platform/meta/css/css-overflow/orthogonal-flow-with-inline-end-margin.html.ini create mode 100644 testing/web-platform/meta/css/css-overflow/overflow-clip-margin-007.html.ini create mode 100644 testing/web-platform/meta/css/css-overflow/overflow-clip-margin-012.html.ini create mode 100644 testing/web-platform/meta/css/css-overflow/overflow-padding.html.ini create mode 100644 testing/web-platform/meta/css/cssom-view/scrollWidthHeight.xht.ini diff --git a/dom/html/test/test_bug375003-2.html b/dom/html/test/test_bug375003-2.html index 0f8742d306f9..b8b985846ca5 100644 --- a/dom/html/test/test_bug375003-2.html +++ b/dom/html/test/test_bug375003-2.html @@ -67,8 +67,8 @@ function t3(id,c,o,s,pid) { function run_test() { // XXX how test clientWidth/clientHeight (the -1 below) in cross-platform manner // without hard-coding the scrollbar width? - t3('div1',[20,20,-1,-1],[10,10,200,160],[0,0,260,20],'body'); - t3('abs1',[20,20,-1,-1],[500,170,200,160],[0,0,260,20],'body'); + t3('div1',[20,20,-1,-1],[10,10,200,160],[0,0,230,20],'body'); + t3('abs1',[20,20,-1,-1],[500,170,200,160],[0,0,230,20],'body'); t3('table1',[0,0,306,306],[10,170,306,306],[0,0,306,306],'body'); t3('table2',[0,0,206,206],[0,0,206,206],[0,0,206,20],'table2parent'); t3('table3',[0,0,228,228],[0,0,228,228],[0,0,228,228],'table3parent'); diff --git a/layout/generic/ScrollContainerFrame.cpp b/layout/generic/ScrollContainerFrame.cpp index b03ebcfec4b2..41f275f50770 100644 --- a/layout/generic/ScrollContainerFrame.cpp +++ b/layout/generic/ScrollContainerFrame.cpp @@ -949,6 +949,27 @@ void ScrollContainerFrame::ReflowScrolledFrame(ScrollReflowInput& aState, // overflow area doesn't include the frame bounds. aMetrics->UnionOverflowAreasWithDesiredBounds(); + auto* disp = StyleDisplay(); + if (MOZ_UNLIKELY(disp->mOverflowClipBoxInline == + StyleOverflowClipBox::ContentBox)) { + // The scrolled frame is scrollable in the inline axis with + // `overflow-clip-box:content-box`. To prevent its content from being + // clipped at the scroll container's padding edges, we inflate its + // children's scrollable overflow area with its inline padding, and union + // its scrollable overflow area with its children's inflated scrollable + // overflow area. + OverflowAreas childOverflow; + mScrolledFrame->UnionChildOverflow(childOverflow); + nsRect childScrollableOverflow = childOverflow.ScrollableOverflow(); + + const LogicalMargin inlinePadding = + padding.ApplySkipSides(LogicalSides(wm, LogicalSides::BBoth)); + childScrollableOverflow.Inflate(inlinePadding.GetPhysicalMargin(wm)); + + nsRect& so = aMetrics->ScrollableOverflow(); + so = so.UnionEdges(childScrollableOverflow); + } + aState.mContentsOverflowAreas = aMetrics->mOverflowAreas; aState.mScrollbarGutterFromLastReflow = scrollbarGutter; aState.mReflowedContentsWithHScrollbar = aAssumeHScroll; diff --git a/layout/generic/crashtests/crashtests.list b/layout/generic/crashtests/crashtests.list index c3742bfcf27a..c2db73c81fbd 100644 --- a/layout/generic/crashtests/crashtests.list +++ b/layout/generic/crashtests/crashtests.list @@ -325,7 +325,7 @@ load 476241-1.html load 477731-1.html load 477928.html load 478131-1.html -load 478170-1.html # Big sizes +asserts(4) load 478170-1.html # Big sizes pref(layout.css.letter-spacing.model,2) load 478185-1.html load 478504.html asserts-if(!Android,0-1) load 479938-1.html # Bug 575011 @@ -631,7 +631,7 @@ load text-overflow-form-elements.html load text-overflow-iframe.html asserts(1-4) load 1225005.html # bug 682647 and bug 448083 load 1230378.xhtml -asserts(3) load 1231692-1.html +asserts(7) load 1231692-1.html load 1233191.html load 1233607.html load 1234701-1.html diff --git a/layout/generic/nsBlockFrame.cpp b/layout/generic/nsBlockFrame.cpp index 539fbc0f68ae..c18e687208fb 100644 --- a/layout/generic/nsBlockFrame.cpp +++ b/layout/generic/nsBlockFrame.cpp @@ -17,7 +17,6 @@ #include "mozilla/Baseline.h" #include "mozilla/ComputedStyle.h" #include "mozilla/DebugOnly.h" -#include "mozilla/Likely.h" #include "mozilla/Maybe.h" #include "mozilla/PresShell.h" #include "mozilla/ScrollContainerFrame.h" @@ -60,7 +59,6 @@ #include "mozilla/RestyleManager.h" #include "mozilla/ServoStyleSet.h" #include "nsFlexContainerFrame.h" -#include "nsTextControlFrame.h" #include "nsBidiPresUtils.h" @@ -262,11 +260,6 @@ static nscolor GetBackplateColor(nsIFrame* aFrame) { return NS_ComposeColors(backgroundColor, currentBackgroundColor); } -static nsRect GetNormalMarginRect(nsIFrame* aFrame) { - auto rect = aFrame->GetMarginRectRelativeToSelf(); - return rect + aFrame->GetNormalPosition(); -} - #ifdef DEBUG # include "nsBlockDebugFlags.h" @@ -429,6 +422,7 @@ NS_DECLARE_FRAME_PROPERTY_FRAMELIST(FloatsProperty) NS_DECLARE_FRAME_PROPERTY_FRAMELIST(PushedFloatsProperty) NS_DECLARE_FRAME_PROPERTY_FRAMELIST(OutsideMarkerProperty) NS_DECLARE_FRAME_PROPERTY_WITHOUT_DTOR(InsideMarkerProperty, nsIFrame) +NS_DECLARE_FRAME_PROPERTY_SMALL_VALUE(BlockEndEdgeOfChildrenProperty, nscoord) //---------------------------------------------------------------------- @@ -1705,7 +1699,9 @@ void nsBlockFrame::Reflow(nsPresContext* aPresContext, ReflowOutput& aMetrics, } aMetrics.SetOverflowAreasToDesiredBounds(); - ComputeOverflowAreas(aMetrics.mOverflowAreas, aReflowInput.mStyleDisplay); + ComputeOverflowAreas(aMetrics.mOverflowAreas, + trialState.mBlockEndEdgeOfChildren, + aReflowInput.mStyleDisplay); // Factor overflow container child bounds into the overflow area aMetrics.mOverflowAreas.UnionWith(trialState.mOcBounds); // Factor pushed float child bounds into the overflow area @@ -2384,6 +2380,13 @@ nscoord nsBlockFrame::ComputeFinalSize(const ReflowInput& aReflowInput, // Screen out negative block sizes --- can happen due to integer overflows :-( finalSize.BSize(wm) = std::max(0, finalSize.BSize(wm)); + + if (blockEndEdgeOfChildren != finalSize.BSize(wm) - borderPadding.BEnd(wm)) { + SetProperty(BlockEndEdgeOfChildrenProperty(), blockEndEdgeOfChildren); + } else { + RemoveProperty(BlockEndEdgeOfChildrenProperty()); + } + aMetrics.SetSize(wm, finalSize); return blockEndEdgeOfChildren; @@ -2460,7 +2463,69 @@ void nsBlockFrame::AlignContent(BlockReflowState& aState, } } +void nsBlockFrame::ConsiderBlockEndEdgeOfChildren( + OverflowAreas& aOverflowAreas, nscoord aBEndEdgeOfChildren, + const nsStyleDisplay* aDisplay) const { + const auto wm = GetWritingMode(); + + // Factor in the block-end edge of the children. Child frames will be added + // to the overflow area as we iterate through the lines, but their margins + // won't, so we need to account for block-end margins here. + // REVIEW: For now, we do this for both visual and scrollable area, + // although when we make scrollable overflow area not be a subset of + // visual, we can change this. + + if (Style()->GetPseudoType() == PseudoStyleType::scrolledContent) { + // If we are a scrolled inner frame, add our block-end padding to our + // children's block-end edge. + // + // Note: aBEndEdgeOfChildren already includes our own block-start padding + // because it is relative to our block-start edge of our border-box, which + // is the same as our padding-box here. + MOZ_ASSERT(GetLogicalUsedBorderAndPadding(wm) == GetLogicalUsedPadding(wm), + "A scrolled inner frame shouldn't have any border!"); + aBEndEdgeOfChildren += GetLogicalUsedPadding(wm).BEnd(wm); + } + + // XXX Currently, overflow areas are stored as physical rects, so we have + // to handle writing modes explicitly here. If we change overflow rects + // to be stored logically, this can be simplified again. + if (wm.IsVertical()) { + if (wm.IsVerticalLR()) { + for (const auto otype : AllOverflowTypes()) { + if (!(aDisplay->IsContainLayout() && + otype == OverflowType::Scrollable)) { + // Layout containment should force all overflow to be ink (visual) + // overflow, so if we're layout-contained, we only add our children's + // block-end edge to the ink (visual) overflow -- not to the + // scrollable overflow. + nsRect& o = aOverflowAreas.Overflow(otype); + o.width = std::max(o.XMost(), aBEndEdgeOfChildren) - o.x; + } + } + } else { + for (const auto otype : AllOverflowTypes()) { + if (!(aDisplay->IsContainLayout() && + otype == OverflowType::Scrollable)) { + nsRect& o = aOverflowAreas.Overflow(otype); + nscoord xmost = o.XMost(); + o.x = std::min(o.x, xmost - aBEndEdgeOfChildren); + o.width = xmost - o.x; + } + } + } + } else { + for (const auto otype : AllOverflowTypes()) { + if (!(aDisplay->IsContainLayout() && otype == OverflowType::Scrollable)) { + nsRect& o = aOverflowAreas.Overflow(otype); + o.height = std::max(o.YMost(), aBEndEdgeOfChildren) - o.y; + } + } + } +} + void nsBlockFrame::ComputeOverflowAreas(OverflowAreas& aOverflowAreas, + nscoord aBEndEdgeOfChildren, const nsStyleDisplay* aDisplay) const { // XXX_perf: This can be done incrementally. It is currently one of // the things that makes incremental reflow O(N^2). @@ -2473,57 +2538,22 @@ void nsBlockFrame::ComputeOverflowAreas(OverflowAreas& aOverflowAreas, // We rely here on our caller having called SetOverflowAreasToDesiredBounds(). nsRect frameBounds = aOverflowAreas.ScrollableOverflow(); - const auto wm = GetWritingMode(); - const auto borderPadding = - GetLogicalUsedBorderAndPadding(wm).GetPhysicalMargin(wm); - // Compute content-box by subtracting borderPadding off of frame rect. - // This gives us a reasonable starting-rect for the child-rect-unioning - // below, which we can then inflate by our padding (without needing to - // worry about having double-counted our padding or anything). - auto frameContentBounds = frameBounds; - frameContentBounds.Deflate(borderPadding); - // Margin rects (Zero-area rects included) of in-flow children (And floats, - // as discussed later) are unioned (starting with the scroller's own - // content-box), then inflated by the scroll container's padding... - auto inFlowChildBounds = frameContentBounds; - // ... While scrollable overflow rects contributed from further descendants - // (Regardless of if they're in-flow or out-of-flow) are unioned separately - // and their union does not get inflated by the scroll container's padding. - auto inFlowScrollableOverflow = frameContentBounds; - for (const auto& line : Lines()) { - aOverflowAreas.InkOverflow() = - aOverflowAreas.InkOverflow().Union(line.InkOverflowRect()); if (aDisplay->IsContainLayout()) { // If we have layout containment, we should only consider our child's // ink overflow, leaving the scrollable regions of the parent // unaffected. - // Note: Any overflow must be treated as ink overflow (As per - // https://drafts.csswg.org/css-contain/#containment-layout part 3). - // However, by unioning the children's ink overflow, we've already - // incorporated its scrollable overflow, since scrollable overflow - // is a subset of ink overflow. - continue; + // Note: scrollable overflow is a subset of ink overflow, + // so this has the same affect as unioning the child's visual and + // scrollable overflow with its parent's ink overflow. + nsRect childVisualRect = line.InkOverflowRect(); + OverflowAreas childVisualArea = OverflowAreas(childVisualRect, nsRect()); + aOverflowAreas.UnionWith(childVisualArea); + } else { + aOverflowAreas.UnionWith(line.GetOverflowAreas()); } - - auto lineInFlowChildBounds = line.GetInFlowChildBounds(); - if (lineInFlowChildBounds) { - inFlowChildBounds = inFlowChildBounds.UnionEdges(*lineInFlowChildBounds); - } - inFlowScrollableOverflow = - inFlowScrollableOverflow.Union(line.ScrollableOverflowRect()); } - if (Style()->GetPseudoType() == PseudoStyleType::scrolledContent) { - // Padding inflation only applies to scrolled containers. - const auto paddingInflatedOverflow = - ComputePaddingInflatedScrollableOverflow(inFlowChildBounds); - aOverflowAreas.UnionAllWith(paddingInflatedOverflow); - } - // Note: we're using UnionAllWith so as to maintain the invariant of - // ink overflow being a superset of scrollable overflow. - aOverflowAreas.UnionAllWith(inFlowScrollableOverflow); - // Factor an outside ::marker in; normally the ::marker will be factored // into the line-box's overflow areas. However, if the line is a block // line then it won't; if there are no lines, it won't. So just @@ -2533,6 +2563,8 @@ void nsBlockFrame::ComputeOverflowAreas(OverflowAreas& aOverflowAreas, aOverflowAreas.UnionAllWith(outsideMarker->GetRect()); } + ConsiderBlockEndEdgeOfChildren(aOverflowAreas, aBEndEdgeOfChildren, aDisplay); + if (!overflowClipAxes.isEmpty()) { aOverflowAreas.ApplyClipping(frameBounds, overflowClipAxes, overflowClipMargin); @@ -2545,113 +2577,12 @@ void nsBlockFrame::ComputeOverflowAreas(OverflowAreas& aOverflowAreas, #endif } -// Is this scrolled frame part of textarea? -// This assumes that the passed-in frame is a scrolled frame. -static bool IsScrolledFrameForTextArea(const nsIFrame* aFrame) { - MOZ_ASSERT(aFrame && aFrame->Style()->GetPseudoType() == - PseudoStyleType::scrolledContent, - "expecting a scrolled frame"); - // If we're `textarea`, our grandparent element must be the text control - // element that we can query. - const auto* parent = aFrame->GetParent(); - if (!parent) { - return false; - } - MOZ_ASSERT(parent->IsScrollContainerOrSubclass(), "Not a scrolled frame?"); - // `textarea` is guaranteed to have one of these pseudoelements: - // ::placeholder, the ::-moz-text-control-editing-root and the preview. - if (!parent->Style()->IsPseudoElement()) { - return false; - } - const auto* grandParent = parent->GetParent(); - if (!grandParent) { - return false; - } - const auto* textControlElement = - mozilla::TextControlElement::FromNodeOrNull(grandParent->GetContent()); - if (!textControlElement) { - return false; - } - return textControlElement->IsTextArea(); -} - -nsRect nsBlockFrame::ComputePaddingInflatedScrollableOverflow( - const nsRect& aInFlowChildBounds) const { - MOZ_ASSERT(Style()->GetPseudoType() == PseudoStyleType::scrolledContent, - "Expected scrolled frame"); - auto result = aInFlowChildBounds; - const auto wm = GetWritingMode(); - auto padding = GetLogicalUsedPadding(wm); - MOZ_ASSERT(GetLogicalUsedBorderAndPadding(wm) == padding, - "A scrolled inner frame shouldn't have any border!"); - // HACK(dshin): Reaching out and querying the type like this isn't ideal. - // However, we use `textarea` as a special case of a div, but based on - // web-platform-tests, different rules apply for it - namely, no inline - // padding inflation. See - // `textarea-padding-iend-overlaps-content-001.tentative.html`. - if (MOZ_UNLIKELY(IsScrolledFrameForTextArea(this))) { - padding.IStart(wm) = padding.IEnd(wm) = 0; - } - result.Inflate(padding.GetPhysicalMargin(wm)); - return result; -} - -Maybe nsBlockFrame::GetLineFrameInFlowBounds( - const nsLineBox& aLine, const nsIFrame& aLineChildFrame) const { - MOZ_ASSERT(aLineChildFrame.GetParent() == this, - "Line's frame doesn't belong to this block frame?"); - if (aLineChildFrame.IsPlaceholderFrame()) { - return Nothing{}; - } - if (aLine.IsInline()) { - return Some(aLineChildFrame.GetMarginRectRelativeToSelf() + - aLineChildFrame.GetNormalPosition()); - } - const auto wm = GetWritingMode(); - // Ensure we use the margin we actually carried out. - auto logicalMargin = aLineChildFrame.GetLogicalUsedMargin(wm); - logicalMargin.BEnd(wm) = aLine.GetCarriedOutBEndMargin().Get(); - - const auto linePoint = aLine.GetPhysicalBounds().TopLeft(); - // Special handling is required for boxes of zero block size, which carry - // out margin collapsing with themselves. We end up "rewinding" the line - // position after carrying out the block start margin. This is not reflected - // in the zero-sized frame's own frame-position. - const auto normalPosition = aLineChildFrame.GetLogicalSize(wm).BSize(wm) == 0 - ? linePoint - : aLineChildFrame.GetNormalPosition(); - const auto margin = logicalMargin.GetPhysicalMargin(wm).ApplySkipSides( - aLineChildFrame.GetSkipSides()); - auto rect = aLineChildFrame.GetRectRelativeToSelf(); - rect.Inflate(margin); - return Some(rect + normalPosition); -} - void nsBlockFrame::UnionChildOverflow(OverflowAreas& aOverflowAreas, bool aAsIfScrolled) { // We need to update the overflow areas of lines manually, as they // get cached and re-used otherwise. Lines aren't exposed as normal // frame children, so calling UnionChildOverflow alone will end up // using the old cached values. - const auto wm = GetWritingMode(); - const auto borderPadding = - GetLogicalUsedBorderAndPadding(wm).GetPhysicalMargin(wm); - // Overflow area computed here should agree with one computed in - // `ComputeOverflowAreas` (See bug 1800939 and bug 1800719). So the - // documentation in that function applies here as well. - const bool isScrolled = - Style()->GetPseudoType() == PseudoStyleType::scrolledContent; - - // Relying on aOverflowAreas having been set to frame border rect. - auto frameContentBounds = aOverflowAreas.ScrollableOverflow(); - frameContentBounds.Deflate(borderPadding); - // We need to take in-flow children's margin rect into account, and inflate - // it by the padding. - auto inFlowChildBounds = frameContentBounds; - auto inFlowScrollableOverflow = frameContentBounds; - - const auto inkOverflowOnly = StyleDisplay()->IsContainLayout(); - for (auto& line : Lines()) { nsRect bounds = line.GetPhysicalBounds(); OverflowAreas lineAreas(bounds, bounds); @@ -2659,46 +2590,20 @@ void nsBlockFrame::UnionChildOverflow(OverflowAreas& aOverflowAreas, int32_t n = line.GetChildCount(); for (nsIFrame* lineFrame = line.mFirstChild; n > 0; lineFrame = lineFrame->GetNextSibling(), --n) { - // Ensure this is called for each frame in the line ConsiderChildOverflow(lineAreas, lineFrame); - - if (inkOverflowOnly || !isScrolled) { - continue; - } - - if (auto lineFrameBounds = GetLineFrameInFlowBounds(line, *lineFrame)) { - inFlowChildBounds = inFlowChildBounds.UnionEdges(*lineFrameBounds); - } } // Consider the overflow areas of the floats attached to the line as well if (line.HasFloats()) { for (nsIFrame* f : line.Floats()) { ConsiderChildOverflow(lineAreas, f); - if (inkOverflowOnly || !isScrolled) { - continue; - } - inFlowChildBounds = - inFlowChildBounds.UnionEdges(GetNormalMarginRect(f)); } } line.SetOverflowAreas(lineAreas); - aOverflowAreas.InkOverflow() = - aOverflowAreas.InkOverflow().Union(lineAreas.InkOverflow()); - if (!inkOverflowOnly) { - inFlowScrollableOverflow = - inFlowScrollableOverflow.Union(lineAreas.ScrollableOverflow()); - } + aOverflowAreas.UnionWith(lineAreas); } - if (isScrolled) { - const auto paddingInflatedOverflow = - ComputePaddingInflatedScrollableOverflow(inFlowChildBounds); - aOverflowAreas.UnionAllWith(paddingInflatedOverflow); - } - aOverflowAreas.UnionAllWith(inFlowScrollableOverflow); - // Union with child frames, skipping the principal and float lists // since we already handled those using the line boxes. nsLayoutUtils::UnionChildOverflow( @@ -2707,6 +2612,14 @@ void nsBlockFrame::UnionChildOverflow(OverflowAreas& aOverflowAreas, } bool nsBlockFrame::ComputeCustomOverflow(OverflowAreas& aOverflowAreas) { + bool found; + nscoord blockEndEdgeOfChildren = + GetProperty(BlockEndEdgeOfChildrenProperty(), &found); + if (found) { + ConsiderBlockEndEdgeOfChildren(aOverflowAreas, blockEndEdgeOfChildren, + StyleDisplay()); + } + // Line cursor invariants depend on the overflow areas of the lines, so // we must clear the line cursor since those areas may have changed. ClearLineCursors(); @@ -4658,15 +4571,6 @@ void nsBlockFrame::ReflowBlockFrame(BlockReflowState& aState, } } - if (Style()->GetPseudoType() == PseudoStyleType::scrolledContent) { - auto lineFrameBounds = GetLineFrameInFlowBounds(*aLine, *frame); - MOZ_ASSERT(aLine->GetChildCount() == 1, - "More than one child in block line?"); - // Inline-line (i.e. Multiple frames in one line) handled in one of - // other callsites. - aLine->SetInFlowChildBounds(lineFrameBounds); - } - aLine->SetOverflowAreas(overflowAreas); if (*aKeepReflowGoing) { // Some of the child block fit @@ -5649,23 +5553,6 @@ bool nsBlockFrame::PlaceLine(BlockReflowState& aState, // might have moved frames around! OverflowAreas overflowAreas; aLineLayout.RelativePositionFrames(overflowAreas); - if (Style()->GetPseudoType() == PseudoStyleType::scrolledContent) { - Maybe inFlowBounds; - int32_t n = aLine->GetChildCount(); - for (nsIFrame* lineFrame = aLine->mFirstChild; n > 0; - lineFrame = lineFrame->GetNextSibling(), --n) { - auto lineFrameBounds = GetLineFrameInFlowBounds(*aLine, *lineFrame); - if (!lineFrameBounds) { - continue; - } - if (inFlowBounds) { - *inFlowBounds = inFlowBounds->UnionEdges(*lineFrameBounds); - } else { - inFlowBounds = Some(*lineFrameBounds); - } - } - aLine->SetInFlowChildBounds(inFlowBounds); - } aLine->SetOverflowAreas(overflowAreas); if (addedMarker) { aLineLayout.RemoveMarkerFrame(GetOutsideMarker()); @@ -5742,18 +5629,6 @@ bool nsBlockFrame::PlaceLine(BlockReflowState& aState, OverflowAreas lineOverflowAreas = aState.mFloatOverflowAreas; lineOverflowAreas.UnionWith(aLine->GetOverflowAreas()); aLine->SetOverflowAreas(lineOverflowAreas); - if (Style()->GetPseudoType() == PseudoStyleType::scrolledContent) { - auto itr = aLine->Floats().begin(); - // Guaranteed to have at least 1 element since `HasFloats()` is true. - auto floatRect = GetNormalMarginRect(*itr); - ++itr; - for (; itr != aLine->Floats().end(); ++itr) { - floatRect = floatRect.UnionEdges(GetNormalMarginRect(*itr)); - } - auto inFlowBounds = aLine->GetInFlowChildBounds(); - aLine->SetInFlowChildBounds( - Some(inFlowBounds ? inFlowBounds->UnionEdges(floatRect) : floatRect)); - } #ifdef NOISY_OVERFLOW_AREAS printf("%s: Line %p, InkOverflowRect=%s, ScrollableOverflowRect=%s\n", diff --git a/layout/generic/nsBlockFrame.h b/layout/generic/nsBlockFrame.h index 58bc1fe1ea77..031d541fe625 100644 --- a/layout/generic/nsBlockFrame.h +++ b/layout/generic/nsBlockFrame.h @@ -268,11 +268,6 @@ class nsBlockFrame : public nsContainerFrame { void CheckIntrinsicCacheAgainstShrinkWrapState(); - nsRect ComputePaddingInflatedScrollableOverflow( - const nsRect& aInFlowChildBounds) const; - Maybe GetLineFrameInFlowBounds(const nsLineBox& aLine, - const nsIFrame& aLineChildFrame) const; - template Maybe GetBaselineBOffset(LineIteratorType aStart, LineIteratorType aEnd, @@ -508,8 +503,17 @@ class nsBlockFrame : public nsContainerFrame { * children, and includes them into aOverflowAreas. */ void ComputeOverflowAreas(mozilla::OverflowAreas& aOverflowAreas, + nscoord aBEndEdgeOfChildren, const nsStyleDisplay* aDisplay) const; + /** + * Helper method for ComputeOverflowAreas(). Incorporates aBEndEdgeOfChildren + * into the aOverflowAreas. + */ + void ConsiderBlockEndEdgeOfChildren(mozilla::OverflowAreas& aOverflowAreas, + nscoord aBEndEdgeOfChildren, + const nsStyleDisplay* aDisplay) const; + /** * Add the frames in aFrameList to this block after aPrevSibling. * This block thinks in terms of lines, but the frame construction code diff --git a/layout/generic/nsLineBox.cpp b/layout/generic/nsLineBox.cpp index e3085a810a17..d3787edc5003 100644 --- a/layout/generic/nsLineBox.cpp +++ b/layout/generic/nsLineBox.cpp @@ -243,12 +243,6 @@ void nsLineBox::List(FILE* out, const char* aPrefix, nsIFrame::ConvertToString(vo, aFlags).c_str(), nsIFrame::ConvertToString(so, aFlags).c_str()); } - if (mData->mInFlowChildBounds) { - str += nsPrintfCString( - "in-flow-scr-overflow=%s ", - nsIFrame::ConvertToString(*mData->mInFlowChildBounds, aFlags) - .c_str()); - } } fprintf_stderr(out, "%s<\n", str.get()); @@ -456,10 +450,7 @@ bool nsLineBox::SetCarriedOutBEndMargin(CollapsingMargin aValue) { void nsLineBox::MaybeFreeData() { nsRect bounds = GetPhysicalBounds(); - // If we have space allocated for additional data but no additional data to - // represent, just delete it. - if (mData && mData->mOverflowAreas == OverflowAreas(bounds, bounds) && - !mData->mInFlowChildBounds) { + if (mData && mData->mOverflowAreas == OverflowAreas(bounds, bounds)) { if (IsInline()) { if (mInlineData->mFloats.IsEmpty()) { delete mInlineData; @@ -555,30 +546,6 @@ void nsLineBox::SetOverflowAreas(const OverflowAreas& aOverflowAreas) { } } -void nsLineBox::SetInFlowChildBounds(const Maybe& aInFlowChildBounds) { - if (aInFlowChildBounds) { - if (!mData) { - nsRect bounds = GetPhysicalBounds(); - if (IsInline()) { - mInlineData = new ExtraInlineData(bounds); - } else { - mBlockData = new ExtraBlockData(bounds); - } - } - mData->mInFlowChildBounds = aInFlowChildBounds; - } else if (mData) { - mData->mInFlowChildBounds = Nothing{}; - MaybeFreeData(); - } -} - -Maybe nsLineBox::GetInFlowChildBounds() const { - if (!mData) { - return Nothing{}; - } - return mData->mInFlowChildBounds; -} - //---------------------------------------------------------------------- Result nsLineIterator::GetLine( diff --git a/layout/generic/nsLineBox.h b/layout/generic/nsLineBox.h index 86d3ff47a07e..226f41393e60 100644 --- a/layout/generic/nsLineBox.h +++ b/layout/generic/nsLineBox.h @@ -306,10 +306,6 @@ class nsLineBox final : public nsLineLink { return GetOverflowArea(mozilla::OverflowType::Scrollable); } - // See comment on `mInFlowChildBounds`. - void SetInFlowChildBounds(const mozilla::Maybe& aInFlowChildBounds); - mozilla::Maybe GetInFlowChildBounds() const; - void SlideBy(nscoord aDBCoord, const nsSize& aContainerSize) { NS_ASSERTION( aContainerSize == mContainerSize || mContainerSize == nsSize(-1, -1), @@ -325,9 +321,6 @@ class nsLineBox final : public nsLineLink { for (const auto otype : mozilla::AllOverflowTypes()) { mData->mOverflowAreas.Overflow(otype) += physicalDelta; } - if (mData->mInFlowChildBounds) { - *mData->mInFlowChildBounds += physicalDelta; - } } } @@ -345,9 +338,6 @@ class nsLineBox final : public nsLineLink { for (const auto otype : mozilla::AllOverflowTypes()) { mData->mOverflowAreas.Overflow(otype) += physicalDelta; } - if (mData->mInFlowChildBounds) { - *mData->mInFlowChildBounds += physicalDelta; - } } return delta; } @@ -534,12 +524,6 @@ class nsLineBox final : public nsLineLink { explicit ExtraData(const nsRect& aBounds) : mOverflowAreas(aBounds, aBounds) {} mozilla::OverflowAreas mOverflowAreas; - // Union of the margin-boxes of our in-flow children (only children, - // *not* their descendants). This is part of a special contribution to - // the scrollable overflow of a scrolled block; as such, this is only - // emplaced if our block is a scrolled frame (and we have in-flow children, - // and floats, which are considered in-flow for scrollable overflow). - mozilla::Maybe mInFlowChildBounds; }; struct ExtraBlockData : public ExtraData { diff --git a/layout/reftests/bugs/458296-1c.html b/layout/reftests/bugs/458296-1c.html new file mode 100644 index 000000000000..98bbf4bdeee0 --- /dev/null +++ b/layout/reftests/bugs/458296-1c.html @@ -0,0 +1,10 @@ + + + +
+
+
+
+
+ + diff --git a/layout/reftests/bugs/966992-1-ref.html b/layout/reftests/bugs/966992-1-ref.html index 0a0058dcf846..7d9234fa839b 100644 --- a/layout/reftests/bugs/966992-1-ref.html +++ b/layout/reftests/bugs/966992-1-ref.html @@ -28,7 +28,7 @@ p { } .rel { position:relative; } .mask1 { position:absolute; width:20px; background:white; top:0; bottom:0; right:0; } -.mask2 { position:absolute; width:20px; background:white; top:0px; bottom:-15px; right:200px; z-index:99; } +.mask2 { position:absolute; width:20px; background:white; top:0px; bottom:-15px; right:220px; z-index:99; } .mask3 { position:absolute; width:20px; background:white; top:0; bottom:0; left:200px; } .mask4 { position:absolute; height:40px; background:white; top:4px; left:3px; width:210px; z-index:99; } .mask5 { position:absolute; height:40px; background:white; top:3px; right:3px; width:50px; } @@ -37,6 +37,20 @@ p { +
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

+
+ +
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+ +
+ +
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

+
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

+ +
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

+

diff --git a/layout/reftests/bugs/966992-1.html b/layout/reftests/bugs/966992-1.html index 44a84fa3afde..2038c613ed58 100644 --- a/layout/reftests/bugs/966992-1.html +++ b/layout/reftests/bugs/966992-1.html @@ -14,6 +14,19 @@ input { font-family: monospace; } +p { + position:absolute; + margin:0; + width:70%; + height: 1px; + background:magenta; +} +.rel p { width:200%; } +.block { + border:1px solid grey; height:50px; width:200px; padding:20px; + overflow:auto; overflow-clip-box:content-box; +} +.rel { position:relative; } .button { width:0px; padding:0 50px; overflow:hidden; } .pb { overflow-clip-box:padding-box; } .cb { overflow-clip-box:content-box; } @@ -21,6 +34,19 @@ input { +
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

+
+ +
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+
+ +
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

+
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

+ +
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

+
diff --git a/layout/reftests/bugs/reftest.list b/layout/reftests/bugs/reftest.list index e43e7eeebe12..b0b0c1179b90 100644 --- a/layout/reftests/bugs/reftest.list +++ b/layout/reftests/bugs/reftest.list @@ -1167,6 +1167,7 @@ fuzzy(0-10,0-8) == 456219-2.html 456219-2-ref.html == 457398-2.html 457398-2-ref.html == 458296-1a.html 458296-1-ref.html == 458296-1b.html 458296-1-ref.html +== 458296-1c.html 458296-1-ref.html == 458296-1d.html 458296-1-ref.html == 458487-1a.html 458487-1-ref.html == 458487-1b.html 458487-1-ref.html diff --git a/layout/reftests/margin-collapsing/scrollable-horizontal-margin-ref.html b/layout/reftests/margin-collapsing/scrollable-horizontal-margin-ref.html index 1ffd1f6f58b0..358c1f2bbc49 100644 --- a/layout/reftests/margin-collapsing/scrollable-horizontal-margin-ref.html +++ b/layout/reftests/margin-collapsing/scrollable-horizontal-margin-ref.html @@ -1,17 +1,17 @@ - Testcase for bug 1768921 + Testcase for bug 724352 diff --git a/layout/reftests/margin-collapsing/scrollable-horizontal-margin.html b/layout/reftests/margin-collapsing/scrollable-horizontal-margin.html index 9bd02800b002..5616b36fca54 100644 --- a/layout/reftests/margin-collapsing/scrollable-horizontal-margin.html +++ b/layout/reftests/margin-collapsing/scrollable-horizontal-margin.html @@ -1,15 +1,13 @@ - Testcase for bug 1768921 - + Testcase for bug 724352