Bug 1204932 - When C++APZ is enabled, elements that are zoomed with double tap should be centered. r=botond

This commit is contained in:
Randall Barker 2015-09-16 10:53:00 +02:00
Родитель 90420c357e
Коммит a7e6f1f6ef
1 изменённых файлов: 12 добавлений и 1 удалений

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

@ -3130,13 +3130,16 @@ void AsyncPanZoomController::ZoomToRect(CSSRect aRect) {
targetZoom = CSSToParentLayerScale(std::min(compositionBounds.width / aRect.width,
compositionBounds.height / aRect.height));
}
// 1. If the rect is empty, request received from browserElementScrolling.js
// 1. If the rect is empty, the content-side logic for handling a double-tap
// requested that we zoom out.
// 2. currentZoom is equal to mZoomConstraints.mMaxZoom and user still double-tapping it
// 3. currentZoom is equal to localMinZoom and user still double-tapping it
// Treat these three cases as a request to zoom out as much as possible.
bool zoomOut = false;
if (aRect.IsEmpty() ||
(currentZoom == localMaxZoom && targetZoom >= localMaxZoom) ||
(currentZoom == localMinZoom && targetZoom <= localMinZoom)) {
zoomOut = true;
CSSSize compositedSize = mFrameMetrics.CalculateCompositedSizeInCssPixels();
float y = scrollOffset.y;
float newHeight =
@ -3170,6 +3173,14 @@ void AsyncPanZoomController::ZoomToRect(CSSRect aRect) {
aRect.x = aRect.x > 0 ? aRect.x : 0;
}
// Vertically center the zoomed element in the screen.
if (!zoomOut && (sizeAfterZoom.height > aRect.height)) {
aRect.y -= (sizeAfterZoom.height - aRect.height) * 0.5f;
if (aRect.y < 0.0f) {
aRect.y = 0.0f;
}
}
endZoomToMetrics.SetScrollOffset(aRect.TopLeft());
endZoomToMetrics.SetDisplayPortMargins(
CalculatePendingDisplayPort(endZoomToMetrics,