From 415340d3d5d810886b818d869efce925e09a4d6e Mon Sep 17 00:00:00 2001 From: Timothy Nikkel Date: Sat, 8 Aug 2020 07:07:46 +0000 Subject: [PATCH] Bug 1656802. In LayoutScrollbars move the calculation of the scrollbar rects to the first thing in the function. r=emilio There is no dependency in this code as far as I can tell. The next patch needs the scrollbar rects for the scroll corner calculation. Differential Revision: https://phabricator.services.mozilla.com/D85705 --- layout/generic/nsGfxScrollFrame.cpp | 122 ++++++++++++++-------------- 1 file changed, 61 insertions(+), 61 deletions(-) diff --git a/layout/generic/nsGfxScrollFrame.cpp b/layout/generic/nsGfxScrollFrame.cpp index 6b38c80647de..285ca8fb24a1 100644 --- a/layout/generic/nsGfxScrollFrame.cpp +++ b/layout/generic/nsGfxScrollFrame.cpp @@ -6519,67 +6519,6 @@ void ScrollFrameHelper::LayoutScrollbars(nsBoxLayoutState& aState, mOuter, false, &compositionSize); } - // place the scrollcorner - if (mScrollCornerBox || mResizerBox) { - MOZ_ASSERT(!mScrollCornerBox || mScrollCornerBox->IsXULBoxFrame(), - "Must be a box frame!"); - - nsRect r(0, 0, 0, 0); - if (aContentArea.x != mScrollPort.x || scrollbarOnLeft) { - // scrollbar (if any) on left - r.x = aContentArea.x; - r.width = mScrollPort.x - aContentArea.x; - NS_ASSERTION(r.width >= 0, "Scroll area should be inside client rect"); - } else { - // scrollbar (if any) on right - r.width = aContentArea.XMost() - mScrollPort.XMost(); - r.x = aContentArea.XMost() - r.width; - NS_ASSERTION(r.width >= 0, "Scroll area should be inside client rect"); - } - if (aContentArea.y != mScrollPort.y) { - NS_ERROR("top scrollbars not supported"); - } else { - // scrollbar (if any) on bottom - r.height = aContentArea.YMost() - mScrollPort.YMost(); - r.y = aContentArea.YMost() - r.height; - NS_ASSERTION(r.height >= 0, "Scroll area should be inside client rect"); - } - - if (mScrollCornerBox) { - nsBoxFrame::LayoutChildAt(aState, mScrollCornerBox, r); - } - - if (hasResizer) { - // if a resizer is present, get its size. Assume a default size of 15 - // pixels. - nscoord defaultSize = nsPresContext::CSSPixelsToAppUnits(15); - nsSize resizerMinSize = mResizerBox->GetXULMinSize(aState); - - nscoord vScrollbarWidth = - mVScrollbarBox ? mVScrollbarBox->GetXULPrefSize(aState).width - : defaultSize; - r.width = - std::max(std::max(r.width, vScrollbarWidth), resizerMinSize.width); - if (aContentArea.x == mScrollPort.x && !scrollbarOnLeft) { - r.x = aContentArea.XMost() - r.width; - } - - nscoord hScrollbarHeight = - mHScrollbarBox ? mHScrollbarBox->GetXULPrefSize(aState).height - : defaultSize; - r.height = - std::max(std::max(r.height, hScrollbarHeight), resizerMinSize.height); - if (aContentArea.y == mScrollPort.y) { - r.y = aContentArea.YMost() - r.height; - } - - nsBoxFrame::LayoutChildAt(aState, mResizerBox, r); - } else if (mResizerBox) { - // otherwise lay out the resizer with an empty rectangle - nsBoxFrame::LayoutChildAt(aState, mResizerBox, nsRect()); - } - } - nsPresContext* presContext = mScrolledFrame->PresContext(); nsRect vRect; if (mVScrollbarBox) { @@ -6654,6 +6593,67 @@ void ScrollFrameHelper::LayoutScrollbars(nsBoxLayoutState& aState, ScrollDirection::eHorizontal); } + // place the scrollcorner + if (mScrollCornerBox || mResizerBox) { + MOZ_ASSERT(!mScrollCornerBox || mScrollCornerBox->IsXULBoxFrame(), + "Must be a box frame!"); + + nsRect r(0, 0, 0, 0); + if (aContentArea.x != mScrollPort.x || scrollbarOnLeft) { + // scrollbar (if any) on left + r.x = aContentArea.x; + r.width = mScrollPort.x - aContentArea.x; + NS_ASSERTION(r.width >= 0, "Scroll area should be inside client rect"); + } else { + // scrollbar (if any) on right + r.width = aContentArea.XMost() - mScrollPort.XMost(); + r.x = aContentArea.XMost() - r.width; + NS_ASSERTION(r.width >= 0, "Scroll area should be inside client rect"); + } + if (aContentArea.y != mScrollPort.y) { + NS_ERROR("top scrollbars not supported"); + } else { + // scrollbar (if any) on bottom + r.height = aContentArea.YMost() - mScrollPort.YMost(); + r.y = aContentArea.YMost() - r.height; + NS_ASSERTION(r.height >= 0, "Scroll area should be inside client rect"); + } + + if (mScrollCornerBox) { + nsBoxFrame::LayoutChildAt(aState, mScrollCornerBox, r); + } + + if (hasResizer) { + // if a resizer is present, get its size. Assume a default size of 15 + // pixels. + nscoord defaultSize = nsPresContext::CSSPixelsToAppUnits(15); + nsSize resizerMinSize = mResizerBox->GetXULMinSize(aState); + + nscoord vScrollbarWidth = + mVScrollbarBox ? mVScrollbarBox->GetXULPrefSize(aState).width + : defaultSize; + r.width = + std::max(std::max(r.width, vScrollbarWidth), resizerMinSize.width); + if (aContentArea.x == mScrollPort.x && !scrollbarOnLeft) { + r.x = aContentArea.XMost() - r.width; + } + + nscoord hScrollbarHeight = + mHScrollbarBox ? mHScrollbarBox->GetXULPrefSize(aState).height + : defaultSize; + r.height = + std::max(std::max(r.height, hScrollbarHeight), resizerMinSize.height); + if (aContentArea.y == mScrollPort.y) { + r.y = aContentArea.YMost() - r.height; + } + + nsBoxFrame::LayoutChildAt(aState, mResizerBox, r); + } else if (mResizerBox) { + // otherwise lay out the resizer with an empty rectangle + nsBoxFrame::LayoutChildAt(aState, mResizerBox, nsRect()); + } + } + if (!LookAndFeel::GetInt(LookAndFeel::IntID::AllowOverlayScrollbarsOverlap)) { AdjustOverlappingScrollbars(vRect, hRect); }