зеркало из https://github.com/mozilla/gecko-dev.git
Bug 975962 - Allow panning/zooming around the initial viewport for overflow:hidden elements. r=botond,tn
This commit is contained in:
Родитель
943ca63f3b
Коммит
9a8fe02e0e
|
@ -679,16 +679,18 @@ static void RecordFrameMetrics(nsIFrame* aForFrame,
|
|||
|
||||
if (scrollableFrame) {
|
||||
nsRect contentBounds = scrollableFrame->GetScrollRange();
|
||||
nsPoint scrollPosition = scrollableFrame->GetScrollPosition();
|
||||
if (scrollableFrame->GetScrollbarStyles().mVertical == NS_STYLE_OVERFLOW_HIDDEN) {
|
||||
metrics.SetDisableScrollingY(true);
|
||||
contentBounds.y = scrollPosition.y;
|
||||
contentBounds.height = 0;
|
||||
}
|
||||
if (scrollableFrame->GetScrollbarStyles().mHorizontal == NS_STYLE_OVERFLOW_HIDDEN) {
|
||||
metrics.SetDisableScrollingX(true);
|
||||
contentBounds.x = scrollPosition.x;
|
||||
contentBounds.width = 0;
|
||||
}
|
||||
contentBounds.width += scrollableFrame->GetScrollPortRect().width;
|
||||
contentBounds.height += scrollableFrame->GetScrollPortRect().height;
|
||||
metrics.mScrollableRect = CSSRect::FromAppUnits(contentBounds);
|
||||
nsPoint scrollPosition = scrollableFrame->GetScrollPosition();
|
||||
metrics.mScrollOffset = CSSPoint::FromAppUnits(scrollPosition);
|
||||
|
||||
// If the frame was scrolled since the last layers update, and by
|
||||
|
|
|
@ -105,6 +105,23 @@ ScrollFrameTo(nsIScrollableFrame* aFrame, const CSSPoint& aPoint, bool& aSuccess
|
|||
return aPoint;
|
||||
}
|
||||
|
||||
CSSPoint targetScrollPosition = aPoint;
|
||||
|
||||
// If the frame is overflow:hidden on a particular axis, we don't want to allow
|
||||
// user-driven scroll on that axis. Simply set the scroll position on that axis
|
||||
// to whatever it already is. Note that this will leave the APZ's async scroll
|
||||
// position out of sync with the gecko scroll position, but APZ can deal with that
|
||||
// (by design). Note also that when we run into this case, even if both axes
|
||||
// have overflow:hidden, we want to set aSuccessOut to true, so that the displayport
|
||||
// follows the async scroll position rather than the gecko scroll position.
|
||||
CSSPoint geckoScrollPosition = CSSPoint::FromAppUnits(aFrame->GetScrollPosition());
|
||||
if (aFrame->GetScrollbarStyles().mVertical == NS_STYLE_OVERFLOW_HIDDEN) {
|
||||
targetScrollPosition.y = geckoScrollPosition.y;
|
||||
}
|
||||
if (aFrame->GetScrollbarStyles().mHorizontal == NS_STYLE_OVERFLOW_HIDDEN) {
|
||||
targetScrollPosition.x = geckoScrollPosition.x;
|
||||
}
|
||||
|
||||
// If the scrollable frame is currently in the middle of an async or smooth
|
||||
// scroll then we don't want to interrupt it (see bug 961280).
|
||||
// Also if the scrollable frame got a scroll request from something other than us
|
||||
|
@ -112,13 +129,14 @@ ScrollFrameTo(nsIScrollableFrame* aFrame, const CSSPoint& aPoint, bool& aSuccess
|
|||
// because we'll clobber that one, which is bad.
|
||||
if (!aFrame->IsProcessingAsyncScroll() &&
|
||||
(!aFrame->OriginOfLastScroll() || aFrame->OriginOfLastScroll() == nsGkAtoms::apz)) {
|
||||
aFrame->ScrollToCSSPixelsApproximate(aPoint, nsGkAtoms::apz);
|
||||
aFrame->ScrollToCSSPixelsApproximate(targetScrollPosition, nsGkAtoms::apz);
|
||||
geckoScrollPosition = CSSPoint::FromAppUnits(aFrame->GetScrollPosition());
|
||||
aSuccessOut = true;
|
||||
}
|
||||
// Return the final scroll position after setting it so that anything that relies
|
||||
// on it can have an accurate value. Note that even if we set it above re-querying it
|
||||
// is a good idea because it may have gotten clamped or rounded.
|
||||
return CSSPoint::FromAppUnits(aFrame->GetScrollPosition());
|
||||
return geckoScrollPosition;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Загрузка…
Ссылка в новой задаче