зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1648500 - Use the composition size when positioning scrollbars. r=tnikkel
When positioning overlay scrollbars, the code was previously taking the visual viewport size and scaling it back up to the composition size using the resolution. This works because overlay scrollbars don't take up any space, and so the visual viewport size is exactly equal to the composition size divided by the resolution. However, it's simpler to just use the composition size because we can get that easily enough. And this fixes the scrollbar positioning on the very first reflow, before the visual viewport has been set on the presShell. Eventually this might make it easier to do this for non-overlay scrollbars as well, since those do take up layout space, and can't be positioned using the "VV size multiplied by resolution" quantity, as that doesn't exactly equal the composition size. Differential Revision: https://phabricator.services.mozilla.com/D81277
This commit is contained in:
Родитель
9768f4f2ba
Коммит
a3752f3581
|
@ -6290,18 +6290,14 @@ void ScrollFrameHelper::LayoutScrollbars(nsBoxLayoutState& aState,
|
|||
const nsRect& aOldScrollArea) {
|
||||
NS_ASSERTION(!mSuppressScrollbarUpdate, "This should have been suppressed");
|
||||
|
||||
PresShell* presShell = mOuter->PresShell();
|
||||
|
||||
bool hasResizer = HasResizer();
|
||||
bool scrollbarOnLeft = !IsScrollbarOnRight();
|
||||
bool overlayScrollBarsWithZoom = UsesOverlayScrollbars() && mIsRoot &&
|
||||
presShell->IsVisualViewportSizeSet();
|
||||
bool overlayScrollBarsOnRoot = UsesOverlayScrollbars() && mIsRoot;
|
||||
|
||||
nsSize scrollPortClampingSize = mScrollPort.Size();
|
||||
double res = 1.0;
|
||||
if (overlayScrollBarsWithZoom) {
|
||||
scrollPortClampingSize = presShell->GetVisualViewportSize();
|
||||
res = presShell->GetCumulativeResolution();
|
||||
nsSize compositionSize = mScrollPort.Size();
|
||||
if (overlayScrollBarsOnRoot) {
|
||||
compositionSize = nsLayoutUtils::CalculateCompositionSizeForFrame(
|
||||
mOuter, false, &compositionSize);
|
||||
}
|
||||
|
||||
// place the scrollcorner
|
||||
|
@ -6370,14 +6366,12 @@ void ScrollFrameHelper::LayoutScrollbars(nsBoxLayoutState& aState,
|
|||
if (mVScrollbarBox) {
|
||||
MOZ_ASSERT(mVScrollbarBox->IsXULBoxFrame(), "Must be a box frame!");
|
||||
vRect = mScrollPort;
|
||||
if (overlayScrollBarsWithZoom) {
|
||||
vRect.height = NSToCoordRound(res * scrollPortClampingSize.height);
|
||||
if (overlayScrollBarsOnRoot) {
|
||||
vRect.height = compositionSize.height;
|
||||
}
|
||||
vRect.width = aContentArea.width - mScrollPort.width;
|
||||
vRect.x = scrollbarOnLeft
|
||||
? aContentArea.x
|
||||
: mScrollPort.x +
|
||||
NSToCoordRound(res * scrollPortClampingSize.width);
|
||||
vRect.x = scrollbarOnLeft ? aContentArea.x
|
||||
: mScrollPort.x + compositionSize.width;
|
||||
if (mHasVerticalScrollbar) {
|
||||
nsMargin margin;
|
||||
mVScrollbarBox->GetXULMargin(margin);
|
||||
|
@ -6391,12 +6385,11 @@ void ScrollFrameHelper::LayoutScrollbars(nsBoxLayoutState& aState,
|
|||
if (mHScrollbarBox) {
|
||||
MOZ_ASSERT(mHScrollbarBox->IsXULBoxFrame(), "Must be a box frame!");
|
||||
hRect = mScrollPort;
|
||||
if (overlayScrollBarsWithZoom) {
|
||||
hRect.width = NSToCoordRound(res * scrollPortClampingSize.width);
|
||||
if (overlayScrollBarsOnRoot) {
|
||||
hRect.width = compositionSize.width;
|
||||
}
|
||||
hRect.height = aContentArea.height - mScrollPort.height;
|
||||
hRect.y =
|
||||
mScrollPort.y + NSToCoordRound(res * scrollPortClampingSize.height);
|
||||
hRect.y = mScrollPort.y + compositionSize.height;
|
||||
if (mHasHorizontalScrollbar) {
|
||||
nsMargin margin;
|
||||
mHScrollbarBox->GetXULMargin(margin);
|
||||
|
|
Загрузка…
Ссылка в новой задаче