OLD | NEW |
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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 // (such as due to a double tap gesture or find in page etc.). These are | 184 // (such as due to a double tap gesture or find in page etc.). These are |
185 // experimentally determined. | 185 // experimentally determined. |
186 static const int touchPointPadding = 32; | 186 static const int touchPointPadding = 32; |
187 static const int nonUserInitiatedPointPadding = 11; | 187 static const int nonUserInitiatedPointPadding = 11; |
188 static const float minScaleDifference = 0.01f; | 188 static const float minScaleDifference = 0.01f; |
189 static const float doubleTapZoomContentDefaultMargin = 5; | 189 static const float doubleTapZoomContentDefaultMargin = 5; |
190 static const float doubleTapZoomContentMinimumMargin = 2; | 190 static const float doubleTapZoomContentMinimumMargin = 2; |
191 static const double doubleTapZoomAnimationDurationInSeconds = 0.25; | 191 static const double doubleTapZoomAnimationDurationInSeconds = 0.25; |
192 static const float doubleTapZoomAlreadyLegibleRatio = 1.2f; | 192 static const float doubleTapZoomAlreadyLegibleRatio = 1.2f; |
193 | 193 |
| 194 static const double multipleTargetsZoomAnimationDurationInSeconds = 0.25; |
| 195 static const double findInPageAnimationDurationInSeconds = 0; |
| 196 |
194 // Constants for viewport anchoring on resize. | 197 // Constants for viewport anchoring on resize. |
195 static const float viewportAnchorXCoord = 0.5f; | 198 static const float viewportAnchorXCoord = 0.5f; |
196 static const float viewportAnchorYCoord = 0; | 199 static const float viewportAnchorYCoord = 0; |
197 | 200 |
198 // Constants for zooming in on a focused text field. | 201 // Constants for zooming in on a focused text field. |
199 static const double scrollAndScaleAnimationDurationInSeconds = 0.2; | 202 static const double scrollAndScaleAnimationDurationInSeconds = 0.2; |
200 static const int minReadableCaretHeight = 18; | 203 static const int minReadableCaretHeight = 18; |
201 static const float minScaleChangeToTriggerZoom = 1.05f; | 204 static const float minScaleChangeToTriggerZoom = 1.05f; |
202 static const float leftBoxRatio = 0.3f; | 205 static const float leftBoxRatio = 0.3f; |
203 static const int caretPadding = 10; | 206 static const int caretPadding = 10; |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 #ifndef NDEBUG | 380 #ifndef NDEBUG |
378 , m_newNavigationLoader(0) | 381 , m_newNavigationLoader(0) |
379 #endif | 382 #endif |
380 , m_zoomLevel(0) | 383 , m_zoomLevel(0) |
381 , m_minimumZoomLevel(zoomFactorToZoomLevel(minTextSizeMultiplier)) | 384 , m_minimumZoomLevel(zoomFactorToZoomLevel(minTextSizeMultiplier)) |
382 , m_maximumZoomLevel(zoomFactorToZoomLevel(maxTextSizeMultiplier)) | 385 , m_maximumZoomLevel(zoomFactorToZoomLevel(maxTextSizeMultiplier)) |
383 , m_savedPageScaleFactor(0) | 386 , m_savedPageScaleFactor(0) |
384 , m_exitFullscreenPageScaleFactor(0) | 387 , m_exitFullscreenPageScaleFactor(0) |
385 , m_doubleTapZoomPageScaleFactor(0) | 388 , m_doubleTapZoomPageScaleFactor(0) |
386 , m_doubleTapZoomPending(false) | 389 , m_doubleTapZoomPending(false) |
387 , m_enableFakeDoubleTapAnimationForTesting(false) | 390 , m_enableFakePageScaleAnimationForTesting(false) |
388 , m_fakeDoubleTapPageScaleFactor(0) | 391 , m_fakePageScaleAnimationPageScaleFactor(0) |
389 , m_fakeDoubleTapUseAnchor(false) | 392 , m_fakePageScaleAnimationUseAnchor(false) |
390 , m_contextMenuAllowed(false) | 393 , m_contextMenuAllowed(false) |
391 , m_doingDragAndDrop(false) | 394 , m_doingDragAndDrop(false) |
392 , m_ignoreInputEvents(false) | 395 , m_ignoreInputEvents(false) |
393 , m_suppressNextKeypressEvent(false) | 396 , m_suppressNextKeypressEvent(false) |
394 , m_imeAcceptEvents(true) | 397 , m_imeAcceptEvents(true) |
395 , m_operationsAllowed(WebDragOperationNone) | 398 , m_operationsAllowed(WebDragOperationNone) |
396 , m_dragOperation(WebDragOperationNone) | 399 , m_dragOperation(WebDragOperationNone) |
397 , m_featureSwitchClient(adoptPtr(new ContextFeaturesClientImpl())) | 400 , m_featureSwitchClient(adoptPtr(new ContextFeaturesClientImpl())) |
398 , m_autofillPopupShowing(false) | 401 , m_autofillPopupShowing(false) |
399 , m_autofillPopup(0) | 402 , m_autofillPopup(0) |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
764 break; | 767 break; |
765 } | 768 } |
766 case WebInputEvent::GestureTapDown: { | 769 case WebInputEvent::GestureTapDown: { |
767 m_client->cancelScheduledContentIntents(); | 770 m_client->cancelScheduledContentIntents(); |
768 eventSwallowed = mainFrameImpl()->frame()->eventHandler()->handleGesture
Event(platformEvent); | 771 eventSwallowed = mainFrameImpl()->frame()->eventHandler()->handleGesture
Event(platformEvent); |
769 break; | 772 break; |
770 } | 773 } |
771 case WebInputEvent::GestureDoubleTap: | 774 case WebInputEvent::GestureDoubleTap: |
772 if (m_webSettings->doubleTapToZoomEnabled() && minimumPageScaleFactor()
!= maximumPageScaleFactor()) { | 775 if (m_webSettings->doubleTapToZoomEnabled() && minimumPageScaleFactor()
!= maximumPageScaleFactor()) { |
773 m_client->cancelScheduledContentIntents(); | 776 m_client->cancelScheduledContentIntents(); |
774 animateZoomAroundPoint(platformEvent.position(), DoubleTap); | 777 animateDoubleTapZoom(platformEvent.position()); |
775 } | 778 } |
776 // GestureDoubleTap is currently only used by Android for zooming. For W
ebCore, | 779 // GestureDoubleTap is currently only used by Android for zooming. For W
ebCore, |
777 // GestureTap with tap count = 2 is used instead. So we drop GestureDoub
leTap here. | 780 // GestureTap with tap count = 2 is used instead. So we drop GestureDoub
leTap here. |
778 eventSwallowed = true; | 781 eventSwallowed = true; |
779 break; | 782 break; |
780 case WebInputEvent::GestureScrollBegin: | 783 case WebInputEvent::GestureScrollBegin: |
781 case WebInputEvent::GesturePinchBegin: | 784 case WebInputEvent::GesturePinchBegin: |
782 m_client->cancelScheduledContentIntents(); | 785 m_client->cancelScheduledContentIntents(); |
783 case WebInputEvent::GestureScrollEnd: | 786 case WebInputEvent::GestureScrollEnd: |
784 case WebInputEvent::GestureScrollUpdate: | 787 case WebInputEvent::GestureScrollUpdate: |
(...skipping 30 matching lines...) Expand all Loading... |
815 if (!useAnchor) { | 818 if (!useAnchor) { |
816 clampedPoint = clampOffsetAtScale(targetPosition, newScale); | 819 clampedPoint = clampOffsetAtScale(targetPosition, newScale); |
817 if (!durationInSeconds) { | 820 if (!durationInSeconds) { |
818 setPageScaleFactor(newScale, clampedPoint); | 821 setPageScaleFactor(newScale, clampedPoint); |
819 return false; | 822 return false; |
820 } | 823 } |
821 } | 824 } |
822 if (useAnchor && newScale == pageScaleFactor()) | 825 if (useAnchor && newScale == pageScaleFactor()) |
823 return false; | 826 return false; |
824 | 827 |
825 if (m_enableFakeDoubleTapAnimationForTesting) { | 828 if (m_enableFakePageScaleAnimationForTesting) { |
826 m_fakeDoubleTapTargetPosition = targetPosition; | 829 m_fakePageScaleAnimationTargetPosition = targetPosition; |
827 m_fakeDoubleTapUseAnchor = useAnchor; | 830 m_fakePageScaleAnimationUseAnchor = useAnchor; |
828 m_fakeDoubleTapPageScaleFactor = newScale; | 831 m_fakePageScaleAnimationPageScaleFactor = newScale; |
829 } else { | 832 } else { |
830 if (!m_layerTreeView) | 833 if (!m_layerTreeView) |
831 return false; | 834 return false; |
832 m_layerTreeView->startPageScaleAnimation(targetPosition, useAnchor, newS
cale, durationInSeconds); | 835 m_layerTreeView->startPageScaleAnimation(targetPosition, useAnchor, newS
cale, durationInSeconds); |
833 } | 836 } |
834 return true; | 837 return true; |
835 } | 838 } |
836 | 839 |
837 void WebViewImpl::enableFakeDoubleTapAnimationForTesting(bool enable) | 840 void WebViewImpl::enableFakePageScaleAnimationForTesting(bool enable) |
838 { | 841 { |
839 m_enableFakeDoubleTapAnimationForTesting = enable; | 842 m_enableFakePageScaleAnimationForTesting = enable; |
840 } | 843 } |
841 | 844 |
842 WebViewBenchmarkSupport* WebViewImpl::benchmarkSupport() | 845 WebViewBenchmarkSupport* WebViewImpl::benchmarkSupport() |
843 { | 846 { |
844 return &m_benchmarkSupport; | 847 return &m_benchmarkSupport; |
845 } | 848 } |
846 | 849 |
847 void WebViewImpl::setShowFPSCounter(bool show) | 850 void WebViewImpl::setShowFPSCounter(bool show) |
848 { | 851 { |
849 if (m_layerTreeView) { | 852 if (m_layerTreeView) { |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1055 // events. | 1058 // events. |
1056 if (evt.isSystemKey()) | 1059 if (evt.isSystemKey()) |
1057 return false; | 1060 return false; |
1058 | 1061 |
1059 if (!suppress && !handler->keyEvent(evt)) | 1062 if (!suppress && !handler->keyEvent(evt)) |
1060 return keyEventDefault(event); | 1063 return keyEventDefault(event); |
1061 | 1064 |
1062 return true; | 1065 return true; |
1063 } | 1066 } |
1064 | 1067 |
1065 WebRect WebViewImpl::computeBlockBounds(const WebRect& rect, AutoZoomType zoomTy
pe) | 1068 WebRect WebViewImpl::computeBlockBounds(const WebRect& rect, bool ignoreClipping
) |
1066 { | 1069 { |
1067 if (!mainFrameImpl()) | 1070 if (!mainFrameImpl()) |
1068 return WebRect(); | 1071 return WebRect(); |
1069 | 1072 |
1070 // Use the rect-based hit test to find the node. | 1073 // Use the rect-based hit test to find the node. |
1071 IntPoint point = mainFrameImpl()->frameView()->windowToContents(IntPoint(rec
t.x, rect.y)); | 1074 IntPoint point = mainFrameImpl()->frameView()->windowToContents(IntPoint(rec
t.x, rect.y)); |
1072 HitTestRequest::HitTestRequestType hitType = HitTestRequest::ReadOnly | HitT
estRequest::Active | HitTestRequest::DisallowShadowContent | 1075 HitTestRequest::HitTestRequestType hitType = HitTestRequest::ReadOnly | HitT
estRequest::Active | HitTestRequest::DisallowShadowContent | (ignoreClipping ? H
itTestRequest::IgnoreClipping : 0); |
1073 | ((zoomType == FindInPage) ? HitTestRequest::IgnoreClipping : 0); | |
1074 HitTestResult result = mainFrameImpl()->frame()->eventHandler()->hitTestResu
ltAtPoint(point, hitType, IntSize(rect.width, rect.height)); | 1076 HitTestResult result = mainFrameImpl()->frame()->eventHandler()->hitTestResu
ltAtPoint(point, hitType, IntSize(rect.width, rect.height)); |
1075 | 1077 |
1076 Node* node = result.innerNonSharedNode(); | 1078 Node* node = result.innerNonSharedNode(); |
1077 if (!node) | 1079 if (!node) |
1078 return WebRect(); | 1080 return WebRect(); |
1079 | 1081 |
1080 // Find the block type node based on the hit node. | 1082 // Find the block type node based on the hit node. |
1081 while (node && (!node->renderer() || node->renderer()->isInline())) | 1083 while (node && (!node->renderer() || node->renderer()->isInline())) |
1082 node = node->parentNode(); | 1084 node = node->parentNode(); |
1083 | 1085 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1115 | 1117 |
1116 const int newWidth = source.width + leftMargin + rightMargin; | 1118 const int newWidth = source.width + leftMargin + rightMargin; |
1117 const int newX = source.x - leftMargin; | 1119 const int newX = source.x - leftMargin; |
1118 | 1120 |
1119 ASSERT(newWidth >= 0); | 1121 ASSERT(newWidth >= 0); |
1120 ASSERT(scrollOffset.width() + newX + newWidth <= maxSize.width); | 1122 ASSERT(scrollOffset.width() + newX + newWidth <= maxSize.width); |
1121 | 1123 |
1122 return WebRect(newX, source.y, newWidth, source.height); | 1124 return WebRect(newX, source.y, newWidth, source.height); |
1123 } | 1125 } |
1124 | 1126 |
1125 void WebViewImpl::computeScaleAndScrollForHitRect(const WebRect& hitRect, AutoZo
omType zoomType, float& scale, WebPoint& scroll, bool& isAnchor) | 1127 void WebViewImpl::computeScaleAndScrollForBlockRect(const WebRect& blockRect, fl
oat padding, float& scale, WebPoint& scroll, bool& doubleTapShouldZoomOut) |
1126 { | 1128 { |
1127 scale = pageScaleFactor(); | 1129 scale = pageScaleFactor(); |
1128 scroll.x = scroll.y = 0; | 1130 scroll.x = scroll.y = 0; |
1129 WebRect targetRect = hitRect; | 1131 |
1130 // Padding only depends on page scale when triggered by manually tapping | 1132 WebRect rect = blockRect; |
1131 int padding = (zoomType == DoubleTap) ? touchPointPadding : nonUserInitiated
PointPadding; | |
1132 if (targetRect.isEmpty()) | |
1133 targetRect.width = targetRect.height = padding; | |
1134 WebRect rect = computeBlockBounds(targetRect, zoomType); | |
1135 if (zoomType == FindInPage && rect.isEmpty()) { | |
1136 // Keep current scale (no need to scroll as x,y will normally already | |
1137 // be visible). FIXME: Revisit this if it isn't always true. | |
1138 return; | |
1139 } | |
1140 | 1133 |
1141 bool scaleUnchanged = true; | 1134 bool scaleUnchanged = true; |
1142 if (!rect.isEmpty()) { | 1135 if (!rect.isEmpty()) { |
1143 // Pages should be as legible as on desktop when at dpi scale, so no | 1136 // Pages should be as legible as on desktop when at dpi scale, so no |
1144 // need to zoom in further when automatically determining zoom level | 1137 // need to zoom in further when automatically determining zoom level |
1145 // (after double tap, find in page, etc), though the user should still | 1138 // (after double tap, find in page, etc), though the user should still |
1146 // be allowed to manually pinch zoom in further if they desire. | 1139 // be allowed to manually pinch zoom in further if they desire. |
1147 const float defaultScaleWhenAlreadyLegible = minimumPageScaleFactor() *
doubleTapZoomAlreadyLegibleRatio; | 1140 const float defaultScaleWhenAlreadyLegible = minimumPageScaleFactor() *
doubleTapZoomAlreadyLegibleRatio; |
1148 float legibleScale = 1; | 1141 float legibleScale = 1; |
1149 if (page() && page()->settings()) | 1142 if (page() && page()->settings()) |
(...skipping 16 matching lines...) Expand all Loading... |
1166 scale = static_cast<float>(m_size.width) / rect.width; | 1159 scale = static_cast<float>(m_size.width) / rect.width; |
1167 scale = min(scale, legibleScale); | 1160 scale = min(scale, legibleScale); |
1168 scale = clampPageScaleFactorToLimits(scale); | 1161 scale = clampPageScaleFactorToLimits(scale); |
1169 | 1162 |
1170 scaleUnchanged = fabs(pageScaleFactor() - scale) < minScaleDifference; | 1163 scaleUnchanged = fabs(pageScaleFactor() - scale) < minScaleDifference; |
1171 } | 1164 } |
1172 | 1165 |
1173 bool stillAtPreviousDoubleTapScale = (pageScaleFactor() == m_doubleTapZoomPa
geScaleFactor | 1166 bool stillAtPreviousDoubleTapScale = (pageScaleFactor() == m_doubleTapZoomPa
geScaleFactor |
1174 && m_doubleTapZoomPageScaleFactor != minimumPageScaleFactor()) | 1167 && m_doubleTapZoomPageScaleFactor != minimumPageScaleFactor()) |
1175 || m_doubleTapZoomPending; | 1168 || m_doubleTapZoomPending; |
1176 if (zoomType == DoubleTap && (rect.isEmpty() || scaleUnchanged || stillAtPre
viousDoubleTapScale)) { | 1169 |
1177 // Zoom out to minimum scale. | 1170 doubleTapShouldZoomOut = rect.isEmpty() || scaleUnchanged || stillAtPrevious
DoubleTapScale; |
1178 scale = minimumPageScaleFactor(); | 1171 |
1179 scroll = WebPoint(hitRect.x, hitRect.y); | 1172 // FIXME: If this is being called for auto zoom during find in page, |
1180 isAnchor = true; | 1173 // then if the user manually zooms in it'd be nice to preserve the |
| 1174 // relative increase in zoom they caused (if they zoom out then it's ok |
| 1175 // to zoom them back in again). This isn't compatible with our current |
| 1176 // double-tap zoom strategy (fitting the containing block to the screen) |
| 1177 // though. |
| 1178 |
| 1179 float screenWidth = m_size.width / scale; |
| 1180 float screenHeight = m_size.height / scale; |
| 1181 |
| 1182 // Scroll to vertically align the block. |
| 1183 if (rect.height < screenHeight) { |
| 1184 // Vertically center short blocks. |
| 1185 rect.y -= 0.5 * (screenHeight - rect.height); |
1181 } else { | 1186 } else { |
1182 // FIXME: If this is being called for auto zoom during find in page, | 1187 // Ensure position we're zooming to (+ padding) isn't off the bottom of |
1183 // then if the user manually zooms in it'd be nice to preserve the | 1188 // the screen. |
1184 // relative increase in zoom they caused (if they zoom out then it's ok | 1189 rect.y = max<float>(rect.y, blockRect.y + padding - screenHeight); |
1185 // to zoom them back in again). This isn't compatible with our current | 1190 } // Otherwise top align the block. |
1186 // double-tap zoom strategy (fitting the containing block to the screen) | |
1187 // though. | |
1188 | 1191 |
1189 float screenWidth = m_size.width / scale; | 1192 // Do the same thing for horizontal alignment. |
1190 float screenHeight = m_size.height / scale; | 1193 if (rect.width < screenWidth) |
1191 | 1194 rect.x -= 0.5 * (screenWidth - rect.width); |
1192 // Scroll to vertically align the block. | 1195 else |
1193 if (rect.height < screenHeight) { | 1196 rect.x = max<float>(rect.x, blockRect.x + padding - screenWidth); |
1194 // Vertically center short blocks. | 1197 scroll.x = rect.x; |
1195 rect.y -= 0.5 * (screenHeight - rect.height); | 1198 scroll.y = rect.y; |
1196 } else { | |
1197 // Ensure position we're zooming to (+ padding) isn't off the bottom
of | |
1198 // the screen. | |
1199 rect.y = max<float>(rect.y, hitRect.y + padding - screenHeight); | |
1200 } // Otherwise top align the block. | |
1201 | |
1202 // Do the same thing for horizontal alignment. | |
1203 if (rect.width < screenWidth) | |
1204 rect.x -= 0.5 * (screenWidth - rect.width); | |
1205 else | |
1206 rect.x = max<float>(rect.x, hitRect.x + padding - screenWidth); | |
1207 scroll.x = rect.x; | |
1208 scroll.y = rect.y; | |
1209 isAnchor = false; | |
1210 } | |
1211 | 1199 |
1212 scale = clampPageScaleFactorToLimits(scale); | 1200 scale = clampPageScaleFactorToLimits(scale); |
1213 scroll = mainFrameImpl()->frameView()->windowToContents(scroll); | 1201 scroll = mainFrameImpl()->frameView()->windowToContents(scroll); |
1214 if (!isAnchor) | 1202 scroll = clampOffsetAtScale(scroll, scale); |
1215 scroll = clampOffsetAtScale(scroll, scale); | |
1216 } | 1203 } |
1217 | 1204 |
1218 static bool invokesHandCursor(Node* node, bool shiftKey, Frame* frame) | 1205 static bool invokesHandCursor(Node* node, bool shiftKey, Frame* frame) |
1219 { | 1206 { |
1220 if (!node || !node->renderer()) | 1207 if (!node || !node->renderer()) |
1221 return false; | 1208 return false; |
1222 | 1209 |
1223 ECursor cursor = node->renderer()->style()->cursor(); | 1210 ECursor cursor = node->renderer()->style()->cursor(); |
1224 return cursor == CURSOR_POINTER | 1211 return cursor == CURSOR_POINTER |
1225 || (cursor == CURSOR_AUTO && frame->eventHandler()->useHandCursor(node,
node->isLink(), shiftKey)); | 1212 || (cursor == CURSOR_AUTO && frame->eventHandler()->useHandCursor(node,
node->isLink(), shiftKey)); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1264 Color highlightColor = touchNode->renderer()->resolveColor(CSSPropertyWebkit
TapHighlightColor); | 1251 Color highlightColor = touchNode->renderer()->resolveColor(CSSPropertyWebkit
TapHighlightColor); |
1265 // Safari documentation for -webkit-tap-highlight-color says if the specifie
d color has 0 alpha, | 1252 // Safari documentation for -webkit-tap-highlight-color says if the specifie
d color has 0 alpha, |
1266 // then tap highlighting is disabled. | 1253 // then tap highlighting is disabled. |
1267 // http://developer.apple.com/library/safari/#documentation/appleapplication
s/reference/safaricssref/articles/standardcssproperties.html | 1254 // http://developer.apple.com/library/safari/#documentation/appleapplication
s/reference/safaricssref/articles/standardcssproperties.html |
1268 if (!highlightColor.alpha()) | 1255 if (!highlightColor.alpha()) |
1269 return; | 1256 return; |
1270 | 1257 |
1271 m_linkHighlight = LinkHighlight::create(touchNode, this); | 1258 m_linkHighlight = LinkHighlight::create(touchNode, this); |
1272 } | 1259 } |
1273 | 1260 |
1274 void WebViewImpl::animateZoomAroundPoint(const IntPoint& point, AutoZoomType zoo
mType) | 1261 void WebViewImpl::animateDoubleTapZoom(const IntPoint& point) |
1275 { | 1262 { |
1276 if (!mainFrameImpl()) | 1263 if (!mainFrameImpl()) |
1277 return; | 1264 return; |
1278 | 1265 |
| 1266 WebRect rect(point.x(), point.y(), touchPointPadding, touchPointPadding); |
| 1267 WebRect blockBounds = computeBlockBounds(rect, false); |
| 1268 |
1279 float scale; | 1269 float scale; |
1280 WebPoint scroll; | 1270 WebPoint scroll; |
1281 bool isAnchor; | 1271 bool doubleTapShouldZoomOut; |
1282 WebPoint webPoint = point; | |
1283 computeScaleAndScrollForHitRect(WebRect(webPoint.x, webPoint.y, 0, 0), zoomT
ype, scale, scroll, isAnchor); | |
1284 | 1272 |
1285 bool isDoubleTap = (zoomType == DoubleTap); | 1273 computeScaleAndScrollForBlockRect(blockBounds, touchPointPadding, scale, scr
oll, doubleTapShouldZoomOut); |
1286 double durationInSeconds = isDoubleTap ? doubleTapZoomAnimationDurationInSec
onds : 0; | |
1287 bool isAnimating = startPageScaleAnimation(scroll, isAnchor, scale, duration
InSeconds); | |
1288 | 1274 |
1289 if (isDoubleTap && isAnimating) { | 1275 bool isAnimating; |
| 1276 |
| 1277 if (doubleTapShouldZoomOut) { |
| 1278 isAnimating = startPageScaleAnimation(mainFrameImpl()->frameView()->wind
owToContents(point), true, minimumPageScaleFactor(), doubleTapZoomAnimationDurat
ionInSeconds); |
| 1279 } else { |
| 1280 isAnimating = startPageScaleAnimation(scroll, false, scale, doubleTapZoo
mAnimationDurationInSeconds); |
| 1281 } |
| 1282 |
| 1283 if (isAnimating) { |
1290 m_doubleTapZoomPageScaleFactor = scale; | 1284 m_doubleTapZoomPageScaleFactor = scale; |
1291 m_doubleTapZoomPending = true; | 1285 m_doubleTapZoomPending = true; |
1292 } | 1286 } |
1293 } | 1287 } |
1294 | 1288 |
1295 void WebViewImpl::zoomToFindInPageRect(const WebRect& rect) | 1289 void WebViewImpl::zoomToFindInPageRect(const WebRect& rect) |
1296 { | 1290 { |
1297 animateZoomAroundPoint(IntRect(rect).center(), FindInPage); | 1291 if (!mainFrameImpl()) |
| 1292 return; |
| 1293 |
| 1294 WebRect blockBounds = computeBlockBounds(rect, true); |
| 1295 |
| 1296 if (blockBounds.isEmpty()) { |
| 1297 // Keep current scale (no need to scroll as x,y will normally already |
| 1298 // be visible). FIXME: Revisit this if it isn't always true. |
| 1299 return; |
| 1300 } |
| 1301 |
| 1302 float scale; |
| 1303 WebPoint scroll; |
| 1304 bool doubleTapShouldZoomOut; |
| 1305 |
| 1306 computeScaleAndScrollForBlockRect(blockBounds, nonUserInitiatedPointPadding,
scale, scroll, doubleTapShouldZoomOut); |
| 1307 |
| 1308 startPageScaleAnimation(scroll, false, scale, findInPageAnimationDurationInS
econds); |
| 1309 } |
| 1310 |
| 1311 bool WebViewImpl::zoomToMultipleTargetsRect(const WebRect& rect) |
| 1312 { |
| 1313 if (!mainFrameImpl()) |
| 1314 return false; |
| 1315 |
| 1316 float scale; |
| 1317 WebPoint scroll; |
| 1318 bool doubleTapShouldZoomOut; |
| 1319 |
| 1320 computeScaleAndScrollForBlockRect(rect, nonUserInitiatedPointPadding, scale,
scroll, doubleTapShouldZoomOut); |
| 1321 |
| 1322 if (scale <= pageScaleFactor()) |
| 1323 return false; |
| 1324 |
| 1325 startPageScaleAnimation(scroll, false, scale, multipleTargetsZoomAnimationDu
rationInSeconds); |
| 1326 return true; |
1298 } | 1327 } |
1299 | 1328 |
1300 void WebViewImpl::numberOfWheelEventHandlersChanged(unsigned numberOfWheelHandle
rs) | 1329 void WebViewImpl::numberOfWheelEventHandlersChanged(unsigned numberOfWheelHandle
rs) |
1301 { | 1330 { |
1302 if (m_client) | 1331 if (m_client) |
1303 m_client->numberOfWheelEventHandlersChanged(numberOfWheelHandlers); | 1332 m_client->numberOfWheelEventHandlersChanged(numberOfWheelHandlers); |
1304 } | 1333 } |
1305 | 1334 |
1306 void WebViewImpl::hasTouchEventHandlers(bool hasTouchHandlers) | 1335 void WebViewImpl::hasTouchEventHandlers(bool hasTouchHandlers) |
1307 { | 1336 { |
(...skipping 2857 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4165 } | 4194 } |
4166 | 4195 |
4167 bool WebViewImpl::shouldDisableDesktopWorkarounds() | 4196 bool WebViewImpl::shouldDisableDesktopWorkarounds() |
4168 { | 4197 { |
4169 ViewportArguments arguments = mainFrameImpl()->frame()->document()->viewport
Arguments(); | 4198 ViewportArguments arguments = mainFrameImpl()->frame()->document()->viewport
Arguments(); |
4170 return arguments.width == ViewportArguments::ValueDeviceWidth || !arguments.
userZoom | 4199 return arguments.width == ViewportArguments::ValueDeviceWidth || !arguments.
userZoom |
4171 || (arguments.minZoom == arguments.maxZoom && arguments.minZoom != Viewp
ortArguments::ValueAuto); | 4200 || (arguments.minZoom == arguments.maxZoom && arguments.minZoom != Viewp
ortArguments::ValueAuto); |
4172 } | 4201 } |
4173 | 4202 |
4174 } // namespace WebKit | 4203 } // namespace WebKit |
OLD | NEW |