Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1237)

Side by Side Diff: Source/web/WebViewImpl.cpp

Issue 19281007: Allow zoom-in to a target rect when tapping multiple targets. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 // (such as due to a double tap gesture or find in page etc.). These are 183 // (such as due to a double tap gesture or find in page etc.). These are
184 // experimentally determined. 184 // experimentally determined.
185 static const int touchPointPadding = 32; 185 static const int touchPointPadding = 32;
186 static const int nonUserInitiatedPointPadding = 11; 186 static const int nonUserInitiatedPointPadding = 11;
187 static const float minScaleDifference = 0.01f; 187 static const float minScaleDifference = 0.01f;
188 static const float doubleTapZoomContentDefaultMargin = 5; 188 static const float doubleTapZoomContentDefaultMargin = 5;
189 static const float doubleTapZoomContentMinimumMargin = 2; 189 static const float doubleTapZoomContentMinimumMargin = 2;
190 static const double doubleTapZoomAnimationDurationInSeconds = 0.25; 190 static const double doubleTapZoomAnimationDurationInSeconds = 0.25;
191 static const float doubleTapZoomAlreadyLegibleRatio = 1.2f; 191 static const float doubleTapZoomAlreadyLegibleRatio = 1.2f;
192 192
193 static const double multipleTargetsZoomAnimationDurationInSeconds = 0.25;
194 static const double findInPageAnimationDurationInSeconds = 0;
195
193 // Constants for viewport anchoring on resize. 196 // Constants for viewport anchoring on resize.
194 static const float viewportAnchorXCoord = 0.5f; 197 static const float viewportAnchorXCoord = 0.5f;
195 static const float viewportAnchorYCoord = 0; 198 static const float viewportAnchorYCoord = 0;
196 199
197 // Constants for zooming in on a focused text field. 200 // Constants for zooming in on a focused text field.
198 static const double scrollAndScaleAnimationDurationInSeconds = 0.2; 201 static const double scrollAndScaleAnimationDurationInSeconds = 0.2;
199 static const int minReadableCaretHeight = 18; 202 static const int minReadableCaretHeight = 18;
200 static const float minScaleChangeToTriggerZoom = 1.05f; 203 static const float minScaleChangeToTriggerZoom = 1.05f;
201 static const float leftBoxRatio = 0.3f; 204 static const float leftBoxRatio = 0.3f;
202 static const int caretPadding = 10; 205 static const int caretPadding = 10;
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 #ifndef NDEBUG 379 #ifndef NDEBUG
377 , m_newNavigationLoader(0) 380 , m_newNavigationLoader(0)
378 #endif 381 #endif
379 , m_zoomLevel(0) 382 , m_zoomLevel(0)
380 , m_minimumZoomLevel(zoomFactorToZoomLevel(minTextSizeMultiplier)) 383 , m_minimumZoomLevel(zoomFactorToZoomLevel(minTextSizeMultiplier))
381 , m_maximumZoomLevel(zoomFactorToZoomLevel(maxTextSizeMultiplier)) 384 , m_maximumZoomLevel(zoomFactorToZoomLevel(maxTextSizeMultiplier))
382 , m_savedPageScaleFactor(0) 385 , m_savedPageScaleFactor(0)
383 , m_exitFullscreenPageScaleFactor(0) 386 , m_exitFullscreenPageScaleFactor(0)
384 , m_doubleTapZoomPageScaleFactor(0) 387 , m_doubleTapZoomPageScaleFactor(0)
385 , m_doubleTapZoomPending(false) 388 , m_doubleTapZoomPending(false)
386 , m_enableFakeDoubleTapAnimationForTesting(false) 389 , m_enableFakePageScaleAnimationForTesting(false)
387 , m_fakeDoubleTapPageScaleFactor(0) 390 , m_fakePageScaleAnimationPageScaleFactor(0)
388 , m_fakeDoubleTapUseAnchor(false) 391 , m_fakePageScaleAnimationUseAnchor(false)
389 , m_contextMenuAllowed(false) 392 , m_contextMenuAllowed(false)
390 , m_doingDragAndDrop(false) 393 , m_doingDragAndDrop(false)
391 , m_ignoreInputEvents(false) 394 , m_ignoreInputEvents(false)
392 , m_suppressNextKeypressEvent(false) 395 , m_suppressNextKeypressEvent(false)
393 , m_imeAcceptEvents(true) 396 , m_imeAcceptEvents(true)
394 , m_operationsAllowed(WebDragOperationNone) 397 , m_operationsAllowed(WebDragOperationNone)
395 , m_dragOperation(WebDragOperationNone) 398 , m_dragOperation(WebDragOperationNone)
396 , m_featureSwitchClient(adoptPtr(new ContextFeaturesClientImpl())) 399 , m_featureSwitchClient(adoptPtr(new ContextFeaturesClientImpl()))
397 , m_autofillPopupShowing(false) 400 , m_autofillPopupShowing(false)
398 , m_autofillPopup(0) 401 , m_autofillPopup(0)
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
766 break; 769 break;
767 } 770 }
768 case WebInputEvent::GestureTapDown: { 771 case WebInputEvent::GestureTapDown: {
769 m_client->cancelScheduledContentIntents(); 772 m_client->cancelScheduledContentIntents();
770 eventSwallowed = mainFrameImpl()->frame()->eventHandler()->handleGesture Event(platformEvent); 773 eventSwallowed = mainFrameImpl()->frame()->eventHandler()->handleGesture Event(platformEvent);
771 break; 774 break;
772 } 775 }
773 case WebInputEvent::GestureDoubleTap: 776 case WebInputEvent::GestureDoubleTap:
774 if (m_webSettings->doubleTapToZoomEnabled() && minimumPageScaleFactor() != maximumPageScaleFactor()) { 777 if (m_webSettings->doubleTapToZoomEnabled() && minimumPageScaleFactor() != maximumPageScaleFactor()) {
775 m_client->cancelScheduledContentIntents(); 778 m_client->cancelScheduledContentIntents();
776 animateZoomAroundPoint(platformEvent.position(), DoubleTap); 779 animateDoubleTapZoom(platformEvent.position());
777 } 780 }
778 // GestureDoubleTap is currently only used by Android for zooming. For W ebCore, 781 // GestureDoubleTap is currently only used by Android for zooming. For W ebCore,
779 // GestureTap with tap count = 2 is used instead. So we drop GestureDoub leTap here. 782 // GestureTap with tap count = 2 is used instead. So we drop GestureDoub leTap here.
780 eventSwallowed = true; 783 eventSwallowed = true;
781 break; 784 break;
782 case WebInputEvent::GestureScrollBegin: 785 case WebInputEvent::GestureScrollBegin:
783 case WebInputEvent::GesturePinchBegin: 786 case WebInputEvent::GesturePinchBegin:
784 m_client->cancelScheduledContentIntents(); 787 m_client->cancelScheduledContentIntents();
785 case WebInputEvent::GestureScrollEnd: 788 case WebInputEvent::GestureScrollEnd:
786 case WebInputEvent::GestureScrollUpdate: 789 case WebInputEvent::GestureScrollUpdate:
(...skipping 30 matching lines...) Expand all
817 if (!useAnchor) { 820 if (!useAnchor) {
818 clampedPoint = clampOffsetAtScale(targetPosition, newScale); 821 clampedPoint = clampOffsetAtScale(targetPosition, newScale);
819 if (!durationInSeconds) { 822 if (!durationInSeconds) {
820 setPageScaleFactor(newScale, clampedPoint); 823 setPageScaleFactor(newScale, clampedPoint);
821 return false; 824 return false;
822 } 825 }
823 } 826 }
824 if (useAnchor && newScale == pageScaleFactor()) 827 if (useAnchor && newScale == pageScaleFactor())
825 return false; 828 return false;
826 829
827 if (m_enableFakeDoubleTapAnimationForTesting) { 830 if (m_enableFakePageScaleAnimationForTesting) {
828 m_fakeDoubleTapTargetPosition = targetPosition; 831 m_fakePageScaleAnimationTargetPosition = targetPosition;
829 m_fakeDoubleTapUseAnchor = useAnchor; 832 m_fakePageScaleAnimationUseAnchor = useAnchor;
830 m_fakeDoubleTapPageScaleFactor = newScale; 833 m_fakePageScaleAnimationPageScaleFactor = newScale;
831 } else { 834 } else {
832 if (!m_layerTreeView) 835 if (!m_layerTreeView)
833 return false; 836 return false;
834 m_layerTreeView->startPageScaleAnimation(targetPosition, useAnchor, newS cale, durationInSeconds); 837 m_layerTreeView->startPageScaleAnimation(targetPosition, useAnchor, newS cale, durationInSeconds);
835 } 838 }
836 return true; 839 return true;
837 } 840 }
838 841
839 void WebViewImpl::enableFakeDoubleTapAnimationForTesting(bool enable) 842 void WebViewImpl::enableFakePageScaleAnimationForTesting(bool enable)
840 { 843 {
841 m_enableFakeDoubleTapAnimationForTesting = enable; 844 m_enableFakePageScaleAnimationForTesting = enable;
842 } 845 }
843 846
844 WebViewBenchmarkSupport* WebViewImpl::benchmarkSupport() 847 WebViewBenchmarkSupport* WebViewImpl::benchmarkSupport()
845 { 848 {
846 return &m_benchmarkSupport; 849 return &m_benchmarkSupport;
847 } 850 }
848 851
849 void WebViewImpl::setShowFPSCounter(bool show) 852 void WebViewImpl::setShowFPSCounter(bool show)
850 { 853 {
851 if (m_layerTreeView) { 854 if (m_layerTreeView) {
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
1058 // events. 1061 // events.
1059 if (evt.isSystemKey()) 1062 if (evt.isSystemKey())
1060 return false; 1063 return false;
1061 1064
1062 if (!suppress && !handler->keyEvent(evt)) 1065 if (!suppress && !handler->keyEvent(evt))
1063 return keyEventDefault(event); 1066 return keyEventDefault(event);
1064 1067
1065 return true; 1068 return true;
1066 } 1069 }
1067 1070
1068 WebRect WebViewImpl::computeBlockBounds(const WebRect& rect, AutoZoomType zoomTy pe) 1071 WebRect WebViewImpl::computeBlockBounds(
1072 const WebRect& rect,
1073 bool ignoreClipping)
1069 { 1074 {
1070 if (!mainFrameImpl()) 1075 if (!mainFrameImpl())
1071 return WebRect(); 1076 return WebRect();
1072 1077
1073 // Use the rect-based hit test to find the node. 1078 // Use the rect-based hit test to find the node.
1074 IntPoint point = mainFrameImpl()->frameView()->windowToContents(IntPoint(rec t.x, rect.y)); 1079 IntPoint point = mainFrameImpl()->frameView()->windowToContents(IntPoint(rec t.x, rect.y));
1075 HitTestRequest::HitTestRequestType hitType = HitTestRequest::ReadOnly | HitT estRequest::Active | HitTestRequest::DisallowShadowContent 1080 HitTestRequest::HitTestRequestType hitType =
1076 | ((zoomType == FindInPage) ? HitTestRequest::IgnoreClipping : 0); 1081 HitTestRequest::ReadOnly |
1082 HitTestRequest::Active |
1083 HitTestRequest::DisallowShadowContent |
1084 (ignoreClipping ? HitTestRequest::IgnoreClipping : 0);
1077 HitTestResult result = mainFrameImpl()->frame()->eventHandler()->hitTestResu ltAtPoint(point, hitType, IntSize(rect.width, rect.height)); 1085 HitTestResult result = mainFrameImpl()->frame()->eventHandler()->hitTestResu ltAtPoint(point, hitType, IntSize(rect.width, rect.height));
1078 1086
1079 Node* node = result.innerNonSharedNode(); 1087 Node* node = result.innerNonSharedNode();
1080 if (!node) 1088 if (!node)
1081 return WebRect(); 1089 return WebRect();
1082 1090
1083 // Find the block type node based on the hit node. 1091 // Find the block type node based on the hit node.
1084 while (node && (!node->renderer() || node->renderer()->isInline())) 1092 while (node && (!node->renderer() || node->renderer()->isInline()))
1085 node = node->parentNode(); 1093 node = node->parentNode();
1086 1094
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1118 1126
1119 const int newWidth = source.width + leftMargin + rightMargin; 1127 const int newWidth = source.width + leftMargin + rightMargin;
1120 const int newX = source.x - leftMargin; 1128 const int newX = source.x - leftMargin;
1121 1129
1122 ASSERT(newWidth >= 0); 1130 ASSERT(newWidth >= 0);
1123 ASSERT(scrollOffset.width() + newX + newWidth <= maxSize.width); 1131 ASSERT(scrollOffset.width() + newX + newWidth <= maxSize.width);
1124 1132
1125 return WebRect(newX, source.y, newWidth, source.height); 1133 return WebRect(newX, source.y, newWidth, source.height);
1126 } 1134 }
1127 1135
1128 void WebViewImpl::computeScaleAndScrollForHitRect(const WebRect& hitRect, AutoZo omType zoomType, float& scale, WebPoint& scroll, bool& isAnchor) 1136 void WebViewImpl::computeScaleAndScrollForBlockRect(
1137 const WebRect& blockRect,
1138 float padding,
1139 float& scale,
1140 WebPoint& scroll,
1141 bool& doubleTapShouldZoomOut)
1129 { 1142 {
1130 scale = pageScaleFactor(); 1143 scale = pageScaleFactor();
1131 scroll.x = scroll.y = 0; 1144 scroll.x = scroll.y = 0;
1132 WebRect targetRect = hitRect; 1145
1133 // Padding only depends on page scale when triggered by manually tapping 1146 WebRect rect = blockRect;
1134 int padding = (zoomType == DoubleTap) ? touchPointPadding : nonUserInitiated PointPadding;
1135 if (targetRect.isEmpty())
1136 targetRect.width = targetRect.height = padding;
1137 WebRect rect = computeBlockBounds(targetRect, zoomType);
1138 if (zoomType == FindInPage && rect.isEmpty()) {
1139 // Keep current scale (no need to scroll as x,y will normally already
1140 // be visible). FIXME: Revisit this if it isn't always true.
1141 return;
1142 }
1143 1147
1144 bool scaleUnchanged = true; 1148 bool scaleUnchanged = true;
1145 if (!rect.isEmpty()) { 1149 if (!rect.isEmpty()) {
1146 // Pages should be as legible as on desktop when at dpi scale, so no 1150 // Pages should be as legible as on desktop when at dpi scale, so no
1147 // need to zoom in further when automatically determining zoom level 1151 // need to zoom in further when automatically determining zoom level
1148 // (after double tap, find in page, etc), though the user should still 1152 // (after double tap, find in page, etc), though the user should still
1149 // be allowed to manually pinch zoom in further if they desire. 1153 // be allowed to manually pinch zoom in further if they desire.
1150 const float defaultScaleWhenAlreadyLegible = minimumPageScaleFactor() * doubleTapZoomAlreadyLegibleRatio; 1154 const float defaultScaleWhenAlreadyLegible = minimumPageScaleFactor() * doubleTapZoomAlreadyLegibleRatio;
1151 float legibleScale = 1; 1155 float legibleScale = 1;
1152 if (page() && page()->settings()) 1156 if (page() && page()->settings())
(...skipping 16 matching lines...) Expand all
1169 scale = static_cast<float>(m_size.width) / rect.width; 1173 scale = static_cast<float>(m_size.width) / rect.width;
1170 scale = min(scale, legibleScale); 1174 scale = min(scale, legibleScale);
1171 scale = clampPageScaleFactorToLimits(scale); 1175 scale = clampPageScaleFactorToLimits(scale);
1172 1176
1173 scaleUnchanged = fabs(pageScaleFactor() - scale) < minScaleDifference; 1177 scaleUnchanged = fabs(pageScaleFactor() - scale) < minScaleDifference;
1174 } 1178 }
1175 1179
1176 bool stillAtPreviousDoubleTapScale = (pageScaleFactor() == m_doubleTapZoomPa geScaleFactor 1180 bool stillAtPreviousDoubleTapScale = (pageScaleFactor() == m_doubleTapZoomPa geScaleFactor
1177 && m_doubleTapZoomPageScaleFactor != minimumPageScaleFactor()) 1181 && m_doubleTapZoomPageScaleFactor != minimumPageScaleFactor())
1178 || m_doubleTapZoomPending; 1182 || m_doubleTapZoomPending;
1179 if (zoomType == DoubleTap && (rect.isEmpty() || scaleUnchanged || stillAtPre viousDoubleTapScale)) { 1183
1180 // Zoom out to minimum scale. 1184 doubleTapShouldZoomOut =
1181 scale = minimumPageScaleFactor(); 1185 rect.isEmpty() || scaleUnchanged || stillAtPreviousDoubleTapScale;
1182 scroll = WebPoint(hitRect.x, hitRect.y); 1186
1183 isAnchor = true; 1187 // FIXME: If this is being called for auto zoom during find in page,
1188 // then if the user manually zooms in it'd be nice to preserve the
1189 // relative increase in zoom they caused (if they zoom out then it's ok
1190 // to zoom them back in again). This isn't compatible with our current
1191 // double-tap zoom strategy (fitting the containing block to the screen)
1192 // though.
1193
1194 float screenWidth = m_size.width / scale;
1195 float screenHeight = m_size.height / scale;
1196
1197 // Scroll to vertically align the block.
1198 if (rect.height < screenHeight) {
1199 // Vertically center short blocks.
1200 rect.y -= 0.5 * (screenHeight - rect.height);
1184 } else { 1201 } else {
1185 // FIXME: If this is being called for auto zoom during find in page, 1202 // Ensure position we're zooming to (+ padding) isn't off the bottom of
1186 // then if the user manually zooms in it'd be nice to preserve the 1203 // the screen.
1187 // relative increase in zoom they caused (if they zoom out then it's ok 1204 rect.y = max<float>(rect.y, blockRect.y + padding - screenHeight);
1188 // to zoom them back in again). This isn't compatible with our current 1205 } // Otherwise top align the block.
1189 // double-tap zoom strategy (fitting the containing block to the screen)
1190 // though.
1191 1206
1192 float screenWidth = m_size.width / scale; 1207 // Do the same thing for horizontal alignment.
1193 float screenHeight = m_size.height / scale; 1208 if (rect.width < screenWidth)
1194 1209 rect.x -= 0.5 * (screenWidth - rect.width);
1195 // Scroll to vertically align the block. 1210 else
1196 if (rect.height < screenHeight) { 1211 rect.x = max<float>(rect.x, blockRect.x + padding - screenWidth);
1197 // Vertically center short blocks. 1212 scroll.x = rect.x;
1198 rect.y -= 0.5 * (screenHeight - rect.height); 1213 scroll.y = rect.y;
1199 } else {
1200 // Ensure position we're zooming to (+ padding) isn't off the bottom of
1201 // the screen.
1202 rect.y = max<float>(rect.y, hitRect.y + padding - screenHeight);
1203 } // Otherwise top align the block.
1204
1205 // Do the same thing for horizontal alignment.
1206 if (rect.width < screenWidth)
1207 rect.x -= 0.5 * (screenWidth - rect.width);
1208 else
1209 rect.x = max<float>(rect.x, hitRect.x + padding - screenWidth);
1210 scroll.x = rect.x;
1211 scroll.y = rect.y;
1212 isAnchor = false;
1213 }
1214 1214
1215 scale = clampPageScaleFactorToLimits(scale); 1215 scale = clampPageScaleFactorToLimits(scale);
1216 scroll = mainFrameImpl()->frameView()->windowToContents(scroll); 1216 scroll = mainFrameImpl()->frameView()->windowToContents(scroll);
1217 if (!isAnchor) 1217 scroll = clampOffsetAtScale(scroll, scale);
1218 scroll = clampOffsetAtScale(scroll, scale);
1219 } 1218 }
1220 1219
1221 static bool invokesHandCursor(Node* node, bool shiftKey, Frame* frame) 1220 static bool invokesHandCursor(Node* node, bool shiftKey, Frame* frame)
1222 { 1221 {
1223 if (!node || !node->renderer()) 1222 if (!node || !node->renderer())
1224 return false; 1223 return false;
1225 1224
1226 ECursor cursor = node->renderer()->style()->cursor(); 1225 ECursor cursor = node->renderer()->style()->cursor();
1227 return cursor == CURSOR_POINTER 1226 return cursor == CURSOR_POINTER
1228 || (cursor == CURSOR_AUTO && frame->eventHandler()->useHandCursor(node, node->isLink(), shiftKey)); 1227 || (cursor == CURSOR_AUTO && frame->eventHandler()->useHandCursor(node, node->isLink(), shiftKey));
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1267 Color highlightColor = touchNode->renderer()->style()->tapHighlightColor(); 1266 Color highlightColor = touchNode->renderer()->style()->tapHighlightColor();
1268 // Safari documentation for -webkit-tap-highlight-color says if the specifie d color has 0 alpha, 1267 // Safari documentation for -webkit-tap-highlight-color says if the specifie d color has 0 alpha,
1269 // then tap highlighting is disabled. 1268 // then tap highlighting is disabled.
1270 // http://developer.apple.com/library/safari/#documentation/appleapplication s/reference/safaricssref/articles/standardcssproperties.html 1269 // http://developer.apple.com/library/safari/#documentation/appleapplication s/reference/safaricssref/articles/standardcssproperties.html
1271 if (!highlightColor.alpha()) 1270 if (!highlightColor.alpha())
1272 return; 1271 return;
1273 1272
1274 m_linkHighlight = LinkHighlight::create(touchNode, this); 1273 m_linkHighlight = LinkHighlight::create(touchNode, this);
1275 } 1274 }
1276 1275
1277 void WebViewImpl::animateZoomAroundPoint(const IntPoint& point, AutoZoomType zoo mType) 1276 void WebViewImpl::animateDoubleTapZoom(const IntPoint& point)
1278 { 1277 {
1279 if (!mainFrameImpl()) 1278 if (!mainFrameImpl())
1280 return; 1279 return;
1281 1280
1281 WebRect rect(point.x(), point.y(), touchPointPadding, touchPointPadding);
1282 WebRect blockBounds = computeBlockBounds(rect, false);
1283
1282 float scale; 1284 float scale;
1283 WebPoint scroll; 1285 WebPoint scroll;
1284 bool isAnchor; 1286 bool doubleTapShouldZoomOut;
1285 WebPoint webPoint = point;
1286 computeScaleAndScrollForHitRect(WebRect(webPoint.x, webPoint.y, 0, 0), zoomT ype, scale, scroll, isAnchor);
1287 1287
1288 bool isDoubleTap = (zoomType == DoubleTap); 1288 computeScaleAndScrollForBlockRect(
1289 double durationInSeconds = isDoubleTap ? doubleTapZoomAnimationDurationInSec onds : 0; 1289 blockBounds, touchPointPadding, scale, scroll, doubleTapShouldZoomOut);
1290 bool isAnimating = startPageScaleAnimation(scroll, isAnchor, scale, duration InSeconds);
1291 1290
1292 if (isDoubleTap && isAnimating) { 1291 bool isAnimating;
1292
1293 if (doubleTapShouldZoomOut) {
1294 isAnimating = startPageScaleAnimation(
1295 mainFrameImpl()->frameView()->windowToContents(point),
1296 true,
1297 minimumPageScaleFactor(),
1298 doubleTapZoomAnimationDurationInSeconds);
1299 } else {
1300 isAnimating = startPageScaleAnimation(
1301 scroll, false, scale, doubleTapZoomAnimationDurationInSeconds);
1302 }
1303
1304 if (isAnimating) {
1293 m_doubleTapZoomPageScaleFactor = scale; 1305 m_doubleTapZoomPageScaleFactor = scale;
1294 m_doubleTapZoomPending = true; 1306 m_doubleTapZoomPending = true;
1295 } 1307 }
1296 } 1308 }
1297 1309
1298 void WebViewImpl::zoomToFindInPageRect(const WebRect& rect) 1310 void WebViewImpl::zoomToFindInPageRect(const WebRect& rect)
1299 { 1311 {
1300 animateZoomAroundPoint(IntRect(rect).center(), FindInPage); 1312 if (!mainFrameImpl())
1313 return;
1314
1315 WebRect blockBounds = computeBlockBounds(rect, true);
1316
1317 if (blockBounds.isEmpty()) {
1318 // Keep current scale (no need to scroll as x,y will normally already
1319 // be visible). FIXME: Revisit this if it isn't always true.
1320 return;
1321 }
1322
1323 float scale;
1324 WebPoint scroll;
1325 bool doubleTapShouldZoomOut;
1326
1327 computeScaleAndScrollForBlockRect(blockBounds, nonUserInitiatedPointPadding,
1328 scale, scroll, doubleTapShouldZoomOut);
1329
1330 startPageScaleAnimation(
1331 scroll, false, scale, findInPageAnimationDurationInSeconds);
1332 }
1333
1334 bool WebViewImpl::zoomToMultipleTargetsRect(const WebRect& rect)
1335 {
1336 if (!mainFrameImpl())
1337 return false;
1338
1339 float scale;
1340 WebPoint scroll;
1341 bool doubleTapShouldZoomOut;
1342
1343 computeScaleAndScrollForBlockRect(rect, nonUserInitiatedPointPadding,
1344 scale, scroll, doubleTapShouldZoomOut);
1345
1346 if (scale <= pageScaleFactor())
1347 return false;
1348
1349 startPageScaleAnimation(
1350 scroll, false, scale, multipleTargetsZoomAnimationDurationInSeconds);
1351 return true;
1301 } 1352 }
1302 1353
1303 void WebViewImpl::numberOfWheelEventHandlersChanged(unsigned numberOfWheelHandle rs) 1354 void WebViewImpl::numberOfWheelEventHandlersChanged(unsigned numberOfWheelHandle rs)
1304 { 1355 {
1305 if (m_client) 1356 if (m_client)
1306 m_client->numberOfWheelEventHandlersChanged(numberOfWheelHandlers); 1357 m_client->numberOfWheelEventHandlersChanged(numberOfWheelHandlers);
1307 } 1358 }
1308 1359
1309 void WebViewImpl::hasTouchEventHandlers(bool hasTouchHandlers) 1360 void WebViewImpl::hasTouchEventHandlers(bool hasTouchHandlers)
1310 { 1361 {
(...skipping 2848 matching lines...) Expand 10 before | Expand all | Expand 10 after
4159 } 4210 }
4160 4211
4161 bool WebViewImpl::shouldDisableDesktopWorkarounds() 4212 bool WebViewImpl::shouldDisableDesktopWorkarounds()
4162 { 4213 {
4163 ViewportArguments arguments = mainFrameImpl()->frame()->document()->viewport Arguments(); 4214 ViewportArguments arguments = mainFrameImpl()->frame()->document()->viewport Arguments();
4164 return arguments.width == ViewportArguments::ValueDeviceWidth || !arguments. userZoom 4215 return arguments.width == ViewportArguments::ValueDeviceWidth || !arguments. userZoom
4165 || (arguments.minZoom == arguments.maxZoom && arguments.minZoom != Viewp ortArguments::ValueAuto); 4216 || (arguments.minZoom == arguments.maxZoom && arguments.minZoom != Viewp ortArguments::ValueAuto);
4166 } 4217 }
4167 4218
4168 } // namespace WebKit 4219 } // namespace WebKit
OLDNEW
« Source/web/WebViewImpl.h ('K') | « Source/web/WebViewImpl.h ('k') | public/web/WebView.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698