Bug 1661356 - Change nsLayoutUtils::ComputeScrollMetadata() to take a scrollport size instead of a scrollport rect. r=kats

No one meaningfully uses the scrollport rect's origin, so there's no
point in having callers compute it.

Differential Revision: https://phabricator.services.mozilla.com/D88337
This commit is contained in:
Botond Ballo 2020-08-27 01:40:19 +00:00
Родитель a7a45c51db
Коммит 9be0302277
4 изменённых файлов: 12 добавлений и 18 удалений

Просмотреть файл

@ -9209,7 +9209,7 @@ bool nsLayoutUtils::CanScrollOriginClobberApz(ScrollOrigin aScrollOrigin) {
ScrollMetadata nsLayoutUtils::ComputeScrollMetadata(
nsIFrame* aForFrame, nsIFrame* aScrollFrame, nsIContent* aContent,
const nsIFrame* aReferenceFrame, LayerManager* aLayerManager,
ViewID aScrollParentId, const nsRect& aViewport,
ViewID aScrollParentId, const nsSize& aScrollPortSize,
const Maybe<nsRect>& aClipRect, bool aIsRootContent,
const Maybe<ContainerLayerParameters>& aContainerParameters) {
nsPresContext* presContext = aForFrame->PresContext();
@ -9218,7 +9218,8 @@ ScrollMetadata nsLayoutUtils::ComputeScrollMetadata(
PresShell* presShell = presContext->GetPresShell();
ScrollMetadata metadata;
FrameMetrics& metrics = metadata.GetMetrics();
metrics.SetLayoutViewport(CSSRect::FromAppUnits(aViewport));
metrics.SetLayoutViewport(
CSSRect(CSSPoint(), CSSSize::FromAppUnits(aScrollPortSize)));
nsIDocShell* docShell = presContext->GetDocShell();
BrowsingContext* bc = docShell ? docShell->GetBrowsingContext() : nullptr;
@ -9640,16 +9641,16 @@ Maybe<ScrollMetadata> nsLayoutUtils::GetRootMetadata(
if (addMetrics || ensureMetricsForRootId) {
bool isRootContent = presContext->IsRootContentDocumentCrossProcess();
nsRect viewport(aBuilder->ToReferenceFrame(frame), frame->GetSize());
nsSize scrollPortSize = frame->GetSize();
if (isRootContent && rootScrollFrame) {
nsIScrollableFrame* scrollableFrame =
rootScrollFrame->GetScrollTargetFrame();
viewport.SizeTo(scrollableFrame->GetScrollPortRect().Size());
scrollPortSize = scrollableFrame->GetScrollPortRect().Size();
}
return Some(nsLayoutUtils::ComputeScrollMetadata(
frame, rootScrollFrame, content, aBuilder->FindReferenceFrameFor(frame),
aLayerManager, ScrollableLayerGuid::NULL_SCROLL_ID, viewport, Nothing(),
isRootContent, Some(aContainerParameters)));
aLayerManager, ScrollableLayerGuid::NULL_SCROLL_ID, scrollPortSize,
Nothing(), isRootContent, Some(aContainerParameters)));
}
return Nothing();

Просмотреть файл

@ -2903,7 +2903,7 @@ class nsLayoutUtils {
nsIFrame* aForFrame, nsIFrame* aScrollFrame, nsIContent* aContent,
const nsIFrame* aReferenceFrame,
mozilla::layers::LayerManager* aLayerManager, ViewID aScrollParentId,
const nsRect& aViewport, const mozilla::Maybe<nsRect>& aClipRect,
const nsSize& aScrollPortSize, const mozilla::Maybe<nsRect>& aClipRect,
bool aIsRoot,
const mozilla::Maybe<ContainerLayerParameters>& aContainerParameters);

Просмотреть файл

@ -4307,9 +4307,6 @@ Maybe<ScrollMetadata> ScrollFrameHelper::ComputeScrollMetadata(
return Nothing();
}
nsPoint toReferenceFrame =
mOuter->GetOffsetToCrossDoc(aContainerReferenceFrame);
Maybe<nsRect> parentLayerClip;
if (aClip && mAddClipRectToLayer) {
parentLayerClip = Some(aClip->GetClipRect());
@ -4320,11 +4317,9 @@ Maybe<ScrollMetadata> ScrollFrameHelper::ComputeScrollMetadata(
MOZ_ASSERT(mScrolledFrame->GetContent());
nsRect scrollport = mScrollPort + toReferenceFrame;
return Some(nsLayoutUtils::ComputeScrollMetadata(
mScrolledFrame, mOuter, mOuter->GetContent(), aContainerReferenceFrame,
aLayerManager, mScrollParentID, scrollport, parentLayerClip,
aLayerManager, mScrollParentID, mScrollPort.Size(), parentLayerClip,
isRootContent, aParameters));
}

Просмотреть файл

@ -38,6 +38,7 @@
#include "mozilla/ViewportUtils.h"
#include "nsCSSRendering.h"
#include "nsCSSRenderingGradients.h"
#include "nsRefreshDriver.h"
#include "nsRegion.h"
#include "nsStyleStructInlines.h"
#include "nsStyleTransformMatrix.h"
@ -7091,13 +7092,10 @@ LayerState nsDisplayScrollInfoLayer::GetLayerState(
UniquePtr<ScrollMetadata> nsDisplayScrollInfoLayer::ComputeScrollMetadata(
LayerManager* aLayerManager,
const ContainerLayerParameters& aContainerParameters) {
nsRect viewport = mScrollFrame->GetRect() - mScrollFrame->GetPosition() +
mScrollFrame->GetOffsetToCrossDoc(ReferenceFrame());
ScrollMetadata metadata = nsLayoutUtils::ComputeScrollMetadata(
mScrolledFrame, mScrollFrame, mScrollFrame->GetContent(),
ReferenceFrame(), aLayerManager, mScrollParentId, viewport, Nothing(),
false, Some(aContainerParameters));
ReferenceFrame(), aLayerManager, mScrollParentId, mScrollFrame->GetSize(),
Nothing(), false, Some(aContainerParameters));
metadata.GetMetrics().SetIsScrollInfoLayer(true);
nsIScrollableFrame* scrollableFrame = mScrollFrame->GetScrollTargetFrame();
if (scrollableFrame) {