Chromium Code Reviews| Index: Source/web/WebViewImpl.cpp |
| diff --git a/Source/web/WebViewImpl.cpp b/Source/web/WebViewImpl.cpp |
| index 9c7f9baa726108aa84e977ab7fd54c5e872ebff1..2e1835090bbc50925c050127050fd78de00ae2d1 100644 |
| --- a/Source/web/WebViewImpl.cpp |
| +++ b/Source/web/WebViewImpl.cpp |
| @@ -1124,26 +1124,29 @@ WebRect WebViewImpl::widenRectWithinPageBounds(const WebRect& source, int target |
| return WebRect(newX, source.y, newWidth, source.height); |
| } |
| -void WebViewImpl::computeScaleAndScrollForBlockRect(const WebRect& blockRect, float padding, float& scale, WebPoint& scroll, bool& doubleTapShouldZoomOut) |
| +float WebViewImpl::computeLegibleScale() |
| +{ |
| + // Pages should be as legible as on desktop when at dpi scale, so no |
| + // need to zoom in further when automatically determining zoom level |
| + // (after double tap, find in page, etc), though the user should still |
| + // be allowed to manually pinch zoom in further if they desire. |
| + const float defaultScaleWhenAlreadyLegible = minimumPageScaleFactor() * doubleTapZoomAlreadyLegibleRatio; |
| + float legibleScale = 1; |
| + if (page()) |
| + legibleScale *= page()->settings().textAutosizingFontScaleFactor(); |
| + if (legibleScale < defaultScaleWhenAlreadyLegible) |
|
aelias_OOO_until_Jul13
2013/08/29 00:19:32
Delete these two lines.
|
| + legibleScale = (pageScaleFactor() == minimumPageScaleFactor()) ? defaultScaleWhenAlreadyLegible : minimumPageScaleFactor(); |
| + return legibleScale; |
| +} |
| + |
| +void WebViewImpl::computeScaleAndScrollForBlockRect(const WebRect& blockRect, float padding, float& scale, WebPoint& scroll) |
|
aelias_OOO_until_Jul13
2013/08/29 00:19:32
Come to think of it, the defaultScaleWhenAlreadyLe
|
| { |
| scale = pageScaleFactor(); |
| scroll.x = scroll.y = 0; |
| WebRect rect = blockRect; |
| - bool scaleUnchanged = true; |
| if (!rect.isEmpty()) { |
| - // Pages should be as legible as on desktop when at dpi scale, so no |
| - // need to zoom in further when automatically determining zoom level |
| - // (after double tap, find in page, etc), though the user should still |
| - // be allowed to manually pinch zoom in further if they desire. |
| - const float defaultScaleWhenAlreadyLegible = minimumPageScaleFactor() * doubleTapZoomAlreadyLegibleRatio; |
| - float legibleScale = 1; |
| - if (page()) |
| - legibleScale *= page()->settings().textAutosizingFontScaleFactor(); |
| - if (legibleScale < defaultScaleWhenAlreadyLegible) |
| - legibleScale = (scale == minimumPageScaleFactor()) ? defaultScaleWhenAlreadyLegible : minimumPageScaleFactor(); |
| - |
| float defaultMargin = doubleTapZoomContentDefaultMargin; |
| float minimumMargin = doubleTapZoomContentMinimumMargin; |
| // We want the margins to have the same physical size, which means we |
| @@ -1157,18 +1160,10 @@ void WebViewImpl::computeScaleAndScrollForBlockRect(const WebRect& blockRect, fl |
| static_cast<int>(minimumMargin * rect.width / m_size.width)); |
| // Fit block to screen, respecting limits. |
| scale = static_cast<float>(m_size.width) / rect.width; |
| - scale = min(scale, legibleScale); |
| + scale = min(scale, computeLegibleScale()); |
|
aelias_OOO_until_Jul13
2013/08/29 00:19:32
Immediately after this line add the lines:
if (pa
|
| scale = clampPageScaleFactorToLimits(scale); |
| - |
| - scaleUnchanged = fabs(pageScaleFactor() - scale) < minScaleDifference; |
| } |
| - bool stillAtPreviousDoubleTapScale = (pageScaleFactor() == m_doubleTapZoomPageScaleFactor |
| - && m_doubleTapZoomPageScaleFactor != minimumPageScaleFactor()) |
| - || m_doubleTapZoomPending; |
| - |
| - doubleTapShouldZoomOut = rect.isEmpty() || scaleUnchanged || stillAtPreviousDoubleTapScale; |
|
aelias_OOO_until_Jul13
2013/08/29 00:19:32
Good idea, there was no reason to keep this in thi
|
| - |
| // FIXME: If this is being called for auto zoom during find in page, |
| // then if the user manually zooms in it'd be nice to preserve the |
| // relative increase in zoom they caused (if they zoom out then it's ok |
| @@ -1197,7 +1192,6 @@ void WebViewImpl::computeScaleAndScrollForBlockRect(const WebRect& blockRect, fl |
| scroll.x = rect.x; |
| scroll.y = rect.y; |
| - scale = clampPageScaleFactorToLimits(scale); |
| scroll = mainFrameImpl()->frameView()->windowToContents(scroll); |
| scroll = clampOffsetAtScale(scroll, scale); |
|
aelias_OOO_until_Jul13
2013/08/29 00:19:32
The amount of scaling must be finalized before thi
|
| } |
| @@ -1268,13 +1262,24 @@ void WebViewImpl::animateDoubleTapZoom(const IntPoint& point) |
| float scale; |
| WebPoint scroll; |
| - bool doubleTapShouldZoomOut; |
| - computeScaleAndScrollForBlockRect(blockBounds, touchPointPadding, scale, scroll, doubleTapShouldZoomOut); |
| + computeScaleAndScrollForBlockRect(blockBounds, touchPointPadding, scale, scroll); |
| + |
| + bool stillAtPreviousDoubleTapScale = (pageScaleFactor() == m_doubleTapZoomPageScaleFactor |
| + && m_doubleTapZoomPageScaleFactor != minimumPageScaleFactor()) |
| + || m_doubleTapZoomPending; |
| + |
| + bool scaleUnchanged = fabs(pageScaleFactor() - scale) < minScaleDifference; |
| + bool shouldZoomOut = blockBounds.isEmpty() || scaleUnchanged || stillAtPreviousDoubleTapScale; |
| + |
| + if ((blockBounds.isEmpty() || scaleUnchanged) && fabs(scale - minimumPageScaleFactor()) < minScaleDifference) { |
|
aelias_OOO_until_Jul13
2013/08/29 00:19:32
Delete this block.
|
| + scale = computeLegibleScale(); |
| + shouldZoomOut = false; |
| + } |
| bool isAnimating; |
| - if (doubleTapShouldZoomOut) { |
| + if (shouldZoomOut) { |
| scale = minimumPageScaleFactor(); |
| isAnimating = startPageScaleAnimation(mainFrameImpl()->frameView()->windowToContents(point), true, scale, doubleTapZoomAnimationDurationInSeconds); |
| } else { |
| @@ -1302,9 +1307,8 @@ void WebViewImpl::zoomToFindInPageRect(const WebRect& rect) |
| float scale; |
| WebPoint scroll; |
| - bool doubleTapShouldZoomOut; |
| - computeScaleAndScrollForBlockRect(blockBounds, nonUserInitiatedPointPadding, scale, scroll, doubleTapShouldZoomOut); |
| + computeScaleAndScrollForBlockRect(blockBounds, nonUserInitiatedPointPadding, scale, scroll); |
| startPageScaleAnimation(scroll, false, scale, findInPageAnimationDurationInSeconds); |
| } |
| @@ -1316,9 +1320,8 @@ bool WebViewImpl::zoomToMultipleTargetsRect(const WebRect& rect) |
| float scale; |
| WebPoint scroll; |
| - bool doubleTapShouldZoomOut; |
| - computeScaleAndScrollForBlockRect(rect, nonUserInitiatedPointPadding, scale, scroll, doubleTapShouldZoomOut); |
| + computeScaleAndScrollForBlockRect(rect, nonUserInitiatedPointPadding, scale, scroll); |
| if (scale <= pageScaleFactor()) |
| return false; |