@@ -270,9 +270,15 @@ static nscolor GetBackplateColor(nsIFrame* aFrame) {
270
270
return NS_ComposeColors(backgroundColor, currentBackgroundColor);
271
271
}
272
272
273
- static nsRect GetNormalMarginRect (nsIFrame* aFrame) {
274
- auto rect = aFrame->GetMarginRectRelativeToSelf ();
275
- return rect + aFrame->GetNormalPosition ();
273
+ static nsRect GetNormalMarginRect (const nsIFrame& aFrame,
274
+ bool aIncludePositiveMargins = true ) {
275
+ nsMargin m = aFrame.GetUsedMargin ().ApplySkipSides (aFrame.GetSkipSides ());
276
+ if (!aIncludePositiveMargins) {
277
+ m.EnsureAtMost (nsMargin ());
278
+ }
279
+ auto rect = aFrame.GetRectRelativeToSelf ();
280
+ rect.Inflate (m);
281
+ return rect + aFrame.GetNormalPosition ();
276
282
}
277
283
278
284
#ifdef DEBUG
@@ -2600,7 +2606,7 @@ nsRect nsBlockFrame::ComputePaddingInflatedScrollableOverflow(
2600
2606
2601
2607
Maybe<nsRect> nsBlockFrame::GetLineFrameInFlowBounds (
2602
2608
const nsLineBox& aLine, const nsIFrame& aLineChildFrame,
2603
- bool aConsiderMargins ) const {
2609
+ bool aConsiderPositiveMargins ) const {
2604
2610
MOZ_ASSERT (aLineChildFrame.GetParent () == this ,
2605
2611
" Line's frame doesn't belong to this block frame?" );
2606
2612
// Line participants are considered in-flow for content within the line
@@ -2612,9 +2618,7 @@ Maybe<nsRect> nsBlockFrame::GetLineFrameInFlowBounds(
2612
2618
return Nothing{};
2613
2619
}
2614
2620
if (aLine.IsInline ()) {
2615
- auto rect = aConsiderMargins ? aLineChildFrame.GetMarginRectRelativeToSelf ()
2616
- : aLineChildFrame.GetRectRelativeToSelf ();
2617
- return Some (rect + aLineChildFrame.GetNormalPosition ());
2621
+ return Some (GetNormalMarginRect (aLineChildFrame, aConsiderPositiveMargins));
2618
2622
}
2619
2623
const auto wm = GetWritingMode ();
2620
2624
auto rect = aLineChildFrame.GetRectRelativeToSelf ();
@@ -2626,14 +2630,19 @@ Maybe<nsRect> nsBlockFrame::GetLineFrameInFlowBounds(
2626
2630
const auto normalPosition = aLineChildFrame.GetLogicalSize (wm).BSize (wm) == 0
2627
2631
? linePoint
2628
2632
: aLineChildFrame.GetNormalPosition ();
2629
- if (aConsiderMargins) {
2630
- // Ensure we use the margin we actually carried out.
2633
+ // Ensure we use the margin we actually carried out.
2634
+ nsMargin margin;
2635
+ if (aConsiderPositiveMargins) {
2631
2636
auto logicalMargin = aLineChildFrame.GetLogicalUsedMargin (wm);
2632
2637
logicalMargin.BEnd (wm) = aLine.GetCarriedOutBEndMargin ().Get ();
2633
- const auto margin = logicalMargin.GetPhysicalMargin (wm).ApplySkipSides (
2638
+ margin = logicalMargin.GetPhysicalMargin (wm).ApplySkipSides (
2639
+ aLineChildFrame.GetSkipSides ());
2640
+ } else {
2641
+ margin = aLineChildFrame.GetUsedMargin ().ApplySkipSides (
2634
2642
aLineChildFrame.GetSkipSides ());
2635
- rect. Inflate (margin );
2643
+ margin. EnsureAtMost ( nsMargin () );
2636
2644
}
2645
+ rect.Inflate (margin);
2637
2646
return Some (rect + normalPosition);
2638
2647
}
2639
2648
@@ -2653,7 +2662,7 @@ void nsBlockFrame::UnionChildOverflow(OverflowAreas& aOverflowAreas,
2653
2662
// happen only for overflow: visible), so that we don't incorrectly account
2654
2663
// for margins that otherwise collapse through, see bug 1936156. Note that
2655
2664
// ::-moz-scrolled-content is always a BFC (see `AnonymousBoxIsBFC`).
2656
- const bool considerMarginsForInFlowChildBounds =
2665
+ const bool considerPositiveMarginsForInFlowChildBounds =
2657
2666
isScrolled && HasAnyStateBits (NS_BLOCK_BFC);
2658
2667
2659
2668
// Relying on aOverflowAreas having been set to frame border rect (if
@@ -2686,7 +2695,7 @@ void nsBlockFrame::UnionChildOverflow(OverflowAreas& aOverflowAreas,
2686
2695
}
2687
2696
2688
2697
if (auto lineFrameBounds = GetLineFrameInFlowBounds (
2689
- line, *lineFrame, considerMarginsForInFlowChildBounds )) {
2698
+ line, *lineFrame, considerPositiveMarginsForInFlowChildBounds )) {
2690
2699
inFlowChildBounds = inFlowChildBounds.UnionEdges (*lineFrameBounds);
2691
2700
}
2692
2701
}
@@ -2698,9 +2707,8 @@ void nsBlockFrame::UnionChildOverflow(OverflowAreas& aOverflowAreas,
2698
2707
if (inkOverflowOnly || !isScrolled) {
2699
2708
continue ;
2700
2709
}
2701
- auto rect = considerMarginsForInFlowChildBounds
2702
- ? GetNormalMarginRect (f)
2703
- : f->GetRectRelativeToSelf () + f->GetNormalPosition ();
2710
+ auto rect = GetNormalMarginRect (
2711
+ *f, considerPositiveMarginsForInFlowChildBounds);
2704
2712
inFlowChildBounds = inFlowChildBounds.UnionEdges (rect);
2705
2713
}
2706
2714
}
@@ -5774,12 +5782,11 @@ bool nsBlockFrame::PlaceLine(BlockReflowState& aState,
5774
5782
lineOverflowAreas.UnionWith (aLine->GetOverflowAreas ());
5775
5783
aLine->SetOverflowAreas (lineOverflowAreas);
5776
5784
if (Style ()->GetPseudoType () == PseudoStyleType::scrolledContent) {
5777
- auto itr = aLine->Floats (). begin ( );
5785
+ Span< const nsIFrame* const > floats ( aLine->Floats ());
5778
5786
// Guaranteed to have at least 1 element since `HasFloats()` is true.
5779
- auto floatRect = GetNormalMarginRect (*itr);
5780
- ++itr;
5781
- for (; itr != aLine->Floats ().end (); ++itr) {
5782
- floatRect = floatRect.UnionEdges (GetNormalMarginRect (*itr));
5787
+ auto floatRect = GetNormalMarginRect (*floats[0 ]);
5788
+ for (const nsIFrame* f : floats.From (1 )) {
5789
+ floatRect = floatRect.UnionEdges (GetNormalMarginRect (*f));
5783
5790
}
5784
5791
auto inFlowBounds = aLine->GetInFlowChildBounds ();
5785
5792
aLine->SetInFlowChildBounds (
0 commit comments