зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1617427 - Refactor to extract helper method; no functional changes. r=tnikkel
Differential Revision: https://phabricator.services.mozilla.com/D66420 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
7a871da043
Коммит
f81f55c129
|
@ -3846,6 +3846,92 @@ void ScrollFrameHelper::MaybeAddTopLayerItems(nsDisplayListBuilder* aBuilder,
|
|||
}
|
||||
}
|
||||
|
||||
nsRect ScrollFrameHelper::RestrictToRootCompositionBounds(
|
||||
const nsRect& aDisplayportBase) {
|
||||
nsPresContext* pc = mOuter->PresContext();
|
||||
const nsPresContext* rootPresContext =
|
||||
pc->GetToplevelContentDocumentPresContext();
|
||||
if (!rootPresContext) {
|
||||
rootPresContext = pc->GetRootPresContext();
|
||||
}
|
||||
if (!rootPresContext) {
|
||||
return aDisplayportBase;
|
||||
}
|
||||
const mozilla::PresShell* const rootPresShell = rootPresContext->PresShell();
|
||||
nsIFrame* rootFrame = rootPresShell->GetRootScrollFrame();
|
||||
if (!rootFrame) {
|
||||
rootFrame = rootPresShell->GetRootFrame();
|
||||
}
|
||||
if (!rootFrame) {
|
||||
return aDisplayportBase;
|
||||
}
|
||||
nsRect rootCompBounds = nsRect(
|
||||
nsPoint(0, 0),
|
||||
nsLayoutUtils::CalculateCompositionSizeForFrame(rootFrame));
|
||||
|
||||
// If rootFrame is the RCD-RSF then
|
||||
// CalculateCompositionSizeForFrame did not take the document's
|
||||
// resolution into account, so we must.
|
||||
if (rootPresContext->IsRootContentDocument() &&
|
||||
rootFrame == rootPresShell->GetRootScrollFrame()) {
|
||||
rootCompBounds = rootCompBounds.RemoveResolution(
|
||||
rootPresShell->GetResolution());
|
||||
}
|
||||
|
||||
// We want to convert the root composition bounds from the
|
||||
// coordinate space of |rootFrame| to the coordinate space of
|
||||
// |mOuter|. We do that with the TransformRect call below.
|
||||
// However, since we care about the root composition bounds
|
||||
// relative to what the user is actually seeing, we also need to
|
||||
// incorporate the APZ callback transforms into this. Most of the
|
||||
// time those transforms are negligible, but in some cases (e.g.
|
||||
// when a zoom is applied on an overflow:hidden document) it is
|
||||
// not (see bug 1280013).
|
||||
// XXX: Eventually we may want to create a modified version of
|
||||
// TransformRect that includes the APZ callback transforms
|
||||
// directly.
|
||||
nsLayoutUtils::TransformRect(rootFrame, mOuter, rootCompBounds);
|
||||
rootCompBounds += CSSPoint::ToAppUnits(
|
||||
nsLayoutUtils::GetCumulativeApzCallbackTransform(mOuter));
|
||||
|
||||
// We want to limit aDisplayportBase to be no larger than
|
||||
// rootCompBounds on either axis, but we don't want to just
|
||||
// blindly intersect the two, because rootCompBounds might be
|
||||
// offset from where aDisplayportBase is (see bug 1327095 comment
|
||||
// 8). Instead, we translate rootCompBounds so as to maximize the
|
||||
// overlap with aDisplayportBase, and *then* do the intersection.
|
||||
if (rootCompBounds.x > aDisplayportBase.x &&
|
||||
rootCompBounds.XMost() > aDisplayportBase.XMost()) {
|
||||
// rootCompBounds is at a greater x-position for both left and
|
||||
// right, so translate it such that the XMost() values are the
|
||||
// same. This will line up the right edge of the two rects, and
|
||||
// might mean that rootCompbounds.x is smaller than
|
||||
// aDisplayportBase.x. We can avoid that by taking the min of the
|
||||
// x delta and XMost() delta, but it doesn't really matter
|
||||
// because the intersection between the two rects below will end
|
||||
// up the same.
|
||||
rootCompBounds.x -=
|
||||
(rootCompBounds.XMost() - aDisplayportBase.XMost());
|
||||
} else if (rootCompBounds.x < aDisplayportBase.x &&
|
||||
rootCompBounds.XMost() < aDisplayportBase.XMost()) {
|
||||
// Analaogous code for when the rootCompBounds is at a smaller
|
||||
// x-position.
|
||||
rootCompBounds.x = aDisplayportBase.x;
|
||||
}
|
||||
// Do the same for y-axis
|
||||
if (rootCompBounds.y > aDisplayportBase.y &&
|
||||
rootCompBounds.YMost() > aDisplayportBase.YMost()) {
|
||||
rootCompBounds.y -=
|
||||
(rootCompBounds.YMost() - aDisplayportBase.YMost());
|
||||
} else if (rootCompBounds.y < aDisplayportBase.y &&
|
||||
rootCompBounds.YMost() < aDisplayportBase.YMost()) {
|
||||
rootCompBounds.y = aDisplayportBase.y;
|
||||
}
|
||||
|
||||
// Now we can do the intersection
|
||||
return aDisplayportBase.Intersect(rootCompBounds);
|
||||
}
|
||||
|
||||
bool ScrollFrameHelper::DecideScrollableLayer(
|
||||
nsDisplayListBuilder* aBuilder, nsRect* aVisibleRect, nsRect* aDirtyRect,
|
||||
bool aSetBase, bool* aDirtyRectHasBeenOverriden) {
|
||||
|
@ -3876,88 +3962,8 @@ bool ScrollFrameHelper::DecideScrollableLayer(
|
|||
// Only restrict to the root composition bounds if necessary,
|
||||
// as the required coordinate transformation is expensive.
|
||||
if (usingDisplayPort) {
|
||||
const nsPresContext* rootPresContext =
|
||||
pc->GetToplevelContentDocumentPresContext();
|
||||
if (!rootPresContext) {
|
||||
rootPresContext = pc->GetRootPresContext();
|
||||
}
|
||||
if (rootPresContext) {
|
||||
const mozilla::PresShell* const rootPresShell =
|
||||
rootPresContext->PresShell();
|
||||
nsIFrame* rootFrame = rootPresShell->GetRootScrollFrame();
|
||||
if (!rootFrame) {
|
||||
rootFrame = rootPresShell->GetRootFrame();
|
||||
}
|
||||
if (rootFrame) {
|
||||
nsRect rootCompBounds = nsRect(
|
||||
nsPoint(0, 0),
|
||||
nsLayoutUtils::CalculateCompositionSizeForFrame(rootFrame));
|
||||
|
||||
// If rootFrame is the RCD-RSF then
|
||||
// CalculateCompositionSizeForFrame did not take the document's
|
||||
// resolution into account, so we must.
|
||||
if (rootPresContext->IsRootContentDocument() &&
|
||||
rootFrame == rootPresShell->GetRootScrollFrame()) {
|
||||
rootCompBounds = rootCompBounds.RemoveResolution(
|
||||
rootPresShell->GetResolution());
|
||||
}
|
||||
|
||||
// We want to convert the root composition bounds from the
|
||||
// coordinate space of |rootFrame| to the coordinate space of
|
||||
// |mOuter|. We do that with the TransformRect call below.
|
||||
// However, since we care about the root composition bounds
|
||||
// relative to what the user is actually seeing, we also need to
|
||||
// incorporate the APZ callback transforms into this. Most of the
|
||||
// time those transforms are negligible, but in some cases (e.g.
|
||||
// when a zoom is applied on an overflow:hidden document) it is
|
||||
// not (see bug 1280013).
|
||||
// XXX: Eventually we may want to create a modified version of
|
||||
// TransformRect that includes the APZ callback transforms
|
||||
// directly.
|
||||
nsLayoutUtils::TransformRect(rootFrame, mOuter, rootCompBounds);
|
||||
rootCompBounds += CSSPoint::ToAppUnits(
|
||||
nsLayoutUtils::GetCumulativeApzCallbackTransform(mOuter));
|
||||
|
||||
// We want to limit displayportBase to be no larger than
|
||||
// rootCompBounds on either axis, but we don't want to just
|
||||
// blindly intersect the two, because rootCompBounds might be
|
||||
// offset from where displayportBase is (see bug 1327095 comment
|
||||
// 8). Instead, we translate rootCompBounds so as to maximize the
|
||||
// overlap with displayportBase, and *then* do the intersection.
|
||||
if (rootCompBounds.x > displayportBase.x &&
|
||||
rootCompBounds.XMost() > displayportBase.XMost()) {
|
||||
// rootCompBounds is at a greater x-position for both left and
|
||||
// right, so translate it such that the XMost() values are the
|
||||
// same. This will line up the right edge of the two rects, and
|
||||
// might mean that rootCompbounds.x is smaller than
|
||||
// displayportBase.x. We can avoid that by taking the min of the
|
||||
// x delta and XMost() delta, but it doesn't really matter
|
||||
// because the intersection between the two rects below will end
|
||||
// up the same.
|
||||
rootCompBounds.x -=
|
||||
(rootCompBounds.XMost() - displayportBase.XMost());
|
||||
} else if (rootCompBounds.x < displayportBase.x &&
|
||||
rootCompBounds.XMost() < displayportBase.XMost()) {
|
||||
// Analaogous code for when the rootCompBounds is at a smaller
|
||||
// x-position.
|
||||
rootCompBounds.x = displayportBase.x;
|
||||
}
|
||||
// Do the same for y-axis
|
||||
if (rootCompBounds.y > displayportBase.y &&
|
||||
rootCompBounds.YMost() > displayportBase.YMost()) {
|
||||
rootCompBounds.y -=
|
||||
(rootCompBounds.YMost() - displayportBase.YMost());
|
||||
} else if (rootCompBounds.y < displayportBase.y &&
|
||||
rootCompBounds.YMost() < displayportBase.YMost()) {
|
||||
rootCompBounds.y = displayportBase.y;
|
||||
}
|
||||
|
||||
// Now we can do the intersection
|
||||
displayportBase = displayportBase.Intersect(rootCompBounds);
|
||||
}
|
||||
}
|
||||
displayportBase = RestrictToRootCompositionBounds(displayportBase);
|
||||
}
|
||||
|
||||
displayportBase -= mScrollPort.TopLeft();
|
||||
}
|
||||
|
||||
|
|
|
@ -433,6 +433,7 @@ class ScrollFrameHelper : public nsIReflowCallback {
|
|||
ScrollSnapInfo GetScrollSnapInfo(
|
||||
const mozilla::Maybe<nsPoint>& aDestination) const;
|
||||
|
||||
nsRect RestrictToRootCompositionBounds(const nsRect& aDisplayportBase);
|
||||
bool DecideScrollableLayer(nsDisplayListBuilder* aBuilder,
|
||||
nsRect* aVisibleRect, nsRect* aDirtyRect,
|
||||
bool aSetBase,
|
||||
|
|
Загрузка…
Ссылка в новой задаче