Chromium Code Reviews| Index: Source/web/WebViewImpl.cpp |
| diff --git a/Source/web/WebViewImpl.cpp b/Source/web/WebViewImpl.cpp |
| index eaa7eab729498ecb75673326c935e7de35609570..b740f41eb7a656fac47ef05e46f6342135d4d3fa 100644 |
| --- a/Source/web/WebViewImpl.cpp |
| +++ b/Source/web/WebViewImpl.cpp |
| @@ -190,6 +190,8 @@ static const float doubleTapZoomContentMinimumMargin = 2; |
| static const double doubleTapZoomAnimationDurationInSeconds = 0.25; |
| static const float doubleTapZoomAlreadyLegibleRatio = 1.2f; |
| +static const double multipleTargetsZoomAnimationDurationInSeconds = 0.25; |
| + |
| // Constants for viewport anchoring on resize. |
| static const float viewportAnchorXCoord = 0.5f; |
| static const float viewportAnchorYCoord = 0; |
| @@ -773,7 +775,7 @@ bool WebViewImpl::handleGestureEvent(const WebGestureEvent& event) |
| case WebInputEvent::GestureDoubleTap: |
| if (m_webSettings->doubleTapToZoomEnabled() && minimumPageScaleFactor() != maximumPageScaleFactor()) { |
| m_client->cancelScheduledContentIntents(); |
| - animateZoomAroundPoint(platformEvent.position(), DoubleTap); |
| + animateZoomToRect(WebRect(platformEvent.position().x(), platformEvent.position().y(), 0, 0), DoubleTap); |
| } |
| // GestureDoubleTap is currently only used by Android for zooming. For WebCore, |
| // GestureTap with tap count = 2 is used instead. So we drop GestureDoubleTap here. |
| @@ -1134,7 +1136,9 @@ void WebViewImpl::computeScaleAndScrollForHitRect(const WebRect& hitRect, AutoZo |
| int padding = (zoomType == DoubleTap) ? touchPointPadding : nonUserInitiatedPointPadding; |
| if (targetRect.isEmpty()) |
| targetRect.width = targetRect.height = padding; |
| - WebRect rect = computeBlockBounds(targetRect, zoomType); |
| + WebRect rect = targetRect; |
| + if (zoomType != MultipleTargets) |
| + rect = computeBlockBounds(targetRect, zoomType); |
| if (zoomType == FindInPage && rect.isEmpty()) { |
| // Keep current scale (no need to scroll as x,y will normally already |
| // be visible). FIXME: Revisit this if it isn't always true. |
| @@ -1274,30 +1278,41 @@ void WebViewImpl::enableTapHighlight(const PlatformGestureEvent& tapEvent) |
| m_linkHighlight = LinkHighlight::create(touchNode, this); |
| } |
| -void WebViewImpl::animateZoomAroundPoint(const IntPoint& point, AutoZoomType zoomType) |
| +bool WebViewImpl::animateZoomToRect(const IntRect& rect, AutoZoomType zoomType) |
| { |
| if (!mainFrameImpl()) |
| - return; |
| + return false; |
| float scale; |
| WebPoint scroll; |
| bool isAnchor; |
| - WebPoint webPoint = point; |
| - computeScaleAndScrollForHitRect(WebRect(webPoint.x, webPoint.y, 0, 0), zoomType, scale, scroll, isAnchor); |
| + WebRect webRect = rect; |
| + computeScaleAndScrollForHitRect(webRect, zoomType, scale, scroll, isAnchor); |
| + |
| + if (zoomType == MultipleTargets && scale <= pageScaleFactor()) |
| + return false; |
| bool isDoubleTap = (zoomType == DoubleTap); |
| - double durationInSeconds = isDoubleTap ? doubleTapZoomAnimationDurationInSeconds : 0; |
| + double durationInSeconds = isDoubleTap ? doubleTapZoomAnimationDurationInSeconds : |
| + zoomType == MultipleTargets ? multipleTargetsZoomAnimationDurationInSeconds : 0; |
| + |
| bool isAnimating = startPageScaleAnimation(scroll, isAnchor, scale, durationInSeconds); |
| if (isDoubleTap && isAnimating) { |
| m_doubleTapZoomPageScaleFactor = scale; |
| m_doubleTapZoomPending = true; |
| } |
| + return true; |
| } |
| void WebViewImpl::zoomToFindInPageRect(const WebRect& rect) |
| { |
| - animateZoomAroundPoint(IntRect(rect).center(), FindInPage); |
| + animateZoomToRect(rect, FindInPage); |
|
jochen (gone - plz use gerrit)
2013/07/16 10:05:24
this is a slight change in behavior, no? Is this i
|
| +} |
| + |
| +bool WebViewImpl::zoomToMultipleTargetsRect(const WebRect& rect) |
| +{ |
| + return animateZoomToRect(rect, MultipleTargets); |
| } |
| void WebViewImpl::numberOfWheelEventHandlersChanged(unsigned numberOfWheelHandlers) |