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 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 Loading... | |
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 Loading... | |
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 Loading... | |
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 Loading... | |
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 Loading... | |
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::computeScaleAndScrollForHitRect( |
1137 const WebRect& hitRect, | |
aelias_OOO_until_Jul13
2013/07/27 05:59:24
Since this doesn't really take a hitrect anymore,
| |
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 = hitRect; |
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 Loading... | |
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, hitRect.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, hitRect.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) | |
1218 scroll = clampOffsetAtScale(scroll, scale); | |
aelias_OOO_until_Jul13
2013/07/27 05:59:24
This line should still be there since we want to m
| |
1219 } | 1217 } |
1220 | 1218 |
1221 static bool invokesHandCursor(Node* node, bool shiftKey, Frame* frame) | 1219 static bool invokesHandCursor(Node* node, bool shiftKey, Frame* frame) |
1222 { | 1220 { |
1223 if (!node || !node->renderer()) | 1221 if (!node || !node->renderer()) |
1224 return false; | 1222 return false; |
1225 | 1223 |
1226 ECursor cursor = node->renderer()->style()->cursor(); | 1224 ECursor cursor = node->renderer()->style()->cursor(); |
1227 return cursor == CURSOR_POINTER | 1225 return cursor == CURSOR_POINTER |
1228 || (cursor == CURSOR_AUTO && frame->eventHandler()->useHandCursor(node, node->isLink(), shiftKey)); | 1226 || (cursor == CURSOR_AUTO && frame->eventHandler()->useHandCursor(node, node->isLink(), shiftKey)); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1267 Color highlightColor = touchNode->renderer()->style()->tapHighlightColor(); | 1265 Color highlightColor = touchNode->renderer()->style()->tapHighlightColor(); |
1268 // Safari documentation for -webkit-tap-highlight-color says if the specifie d color has 0 alpha, | 1266 // Safari documentation for -webkit-tap-highlight-color says if the specifie d color has 0 alpha, |
1269 // then tap highlighting is disabled. | 1267 // then tap highlighting is disabled. |
1270 // http://developer.apple.com/library/safari/#documentation/appleapplication s/reference/safaricssref/articles/standardcssproperties.html | 1268 // http://developer.apple.com/library/safari/#documentation/appleapplication s/reference/safaricssref/articles/standardcssproperties.html |
1271 if (!highlightColor.alpha()) | 1269 if (!highlightColor.alpha()) |
1272 return; | 1270 return; |
1273 | 1271 |
1274 m_linkHighlight = LinkHighlight::create(touchNode, this); | 1272 m_linkHighlight = LinkHighlight::create(touchNode, this); |
1275 } | 1273 } |
1276 | 1274 |
1277 void WebViewImpl::animateZoomAroundPoint(const IntPoint& point, AutoZoomType zoo mType) | 1275 void WebViewImpl::animateDoubleTapZoom(const IntPoint& point) |
1278 { | 1276 { |
1279 if (!mainFrameImpl()) | 1277 if (!mainFrameImpl()) |
1280 return; | 1278 return; |
1281 | 1279 |
1280 WebRect rect(point.x(), point.y(), touchPointPadding, touchPointPadding); | |
1281 WebRect blockBounds = computeBlockBounds(rect, false); | |
1282 | |
1282 float scale; | 1283 float scale; |
1283 WebPoint scroll; | 1284 WebPoint scroll; |
1284 bool isAnchor; | 1285 bool doubleTapShouldZoomOut; |
1285 WebPoint webPoint = point; | |
1286 computeScaleAndScrollForHitRect(WebRect(webPoint.x, webPoint.y, 0, 0), zoomT ype, scale, scroll, isAnchor); | |
1287 | 1286 |
1288 bool isDoubleTap = (zoomType == DoubleTap); | 1287 computeScaleAndScrollForHitRect( |
1289 double durationInSeconds = isDoubleTap ? doubleTapZoomAnimationDurationInSec onds : 0; | 1288 blockBounds, touchPointPadding, scale, scroll, doubleTapShouldZoomOut); |
1290 bool isAnimating = startPageScaleAnimation(scroll, isAnchor, scale, duration InSeconds); | |
1291 | 1289 |
1292 if (isDoubleTap && isAnimating) { | 1290 bool isAnimating; |
1291 | |
1292 if (doubleTapShouldZoomOut) { | |
1293 isAnimating = startPageScaleAnimation( | |
1294 mainFrameImpl()->frameView()->windowToContents(point), | |
1295 true, | |
1296 minimumPageScaleFactor(), | |
1297 doubleTapZoomAnimationDurationInSeconds); | |
1298 } else { | |
1299 isAnimating = startPageScaleAnimation( | |
1300 scroll, false, scale, doubleTapZoomAnimationDurationInSeconds); | |
1301 } | |
1302 | |
1303 if (isAnimating) { | |
1293 m_doubleTapZoomPageScaleFactor = scale; | 1304 m_doubleTapZoomPageScaleFactor = scale; |
1294 m_doubleTapZoomPending = true; | 1305 m_doubleTapZoomPending = true; |
1295 } | 1306 } |
1296 } | 1307 } |
1297 | 1308 |
1298 void WebViewImpl::zoomToFindInPageRect(const WebRect& rect) | 1309 void WebViewImpl::zoomToFindInPageRect(const WebRect& rect) |
1299 { | 1310 { |
1300 animateZoomAroundPoint(IntRect(rect).center(), FindInPage); | 1311 if (!mainFrameImpl()) |
1312 return; | |
1313 | |
1314 WebRect blockBounds = computeBlockBounds(rect, true); | |
1315 | |
1316 if (blockBounds.isEmpty()) { | |
1317 // Keep current scale (no need to scroll as x,y will normally already | |
1318 // be visible). FIXME: Revisit this if it isn't always true. | |
1319 return; | |
1320 } | |
1321 | |
1322 float scale; | |
1323 WebPoint scroll; | |
1324 bool doubleTapShouldZoomOut; | |
1325 | |
1326 computeScaleAndScrollForHitRect(blockBounds, nonUserInitiatedPointPadding, | |
1327 scale, scroll, doubleTapShouldZoomOut); | |
1328 | |
1329 startPageScaleAnimation( | |
1330 scroll, false, scale, findInPageAnimationDurationInSeconds); | |
1331 } | |
1332 | |
1333 bool WebViewImpl::zoomToMultipleTargetsRect(const WebRect& rect) | |
1334 { | |
1335 if (!mainFrameImpl()) | |
1336 return false; | |
1337 | |
1338 float scale; | |
1339 WebPoint scroll; | |
1340 bool doubleTapShouldZoomOut; | |
1341 | |
1342 computeScaleAndScrollForHitRect(rect, nonUserInitiatedPointPadding, | |
1343 scale, scroll, doubleTapShouldZoomOut); | |
1344 | |
1345 if (scale <= pageScaleFactor()) | |
1346 return false; | |
1347 | |
1348 startPageScaleAnimation( | |
1349 scroll, false, scale, multipleTargetsZoomAnimationDurationInSeconds); | |
1350 return true; | |
1301 } | 1351 } |
1302 | 1352 |
1303 void WebViewImpl::numberOfWheelEventHandlersChanged(unsigned numberOfWheelHandle rs) | 1353 void WebViewImpl::numberOfWheelEventHandlersChanged(unsigned numberOfWheelHandle rs) |
1304 { | 1354 { |
1305 if (m_client) | 1355 if (m_client) |
1306 m_client->numberOfWheelEventHandlersChanged(numberOfWheelHandlers); | 1356 m_client->numberOfWheelEventHandlersChanged(numberOfWheelHandlers); |
1307 } | 1357 } |
1308 | 1358 |
1309 void WebViewImpl::hasTouchEventHandlers(bool hasTouchHandlers) | 1359 void WebViewImpl::hasTouchEventHandlers(bool hasTouchHandlers) |
1310 { | 1360 { |
(...skipping 2848 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4159 } | 4209 } |
4160 | 4210 |
4161 bool WebViewImpl::shouldDisableDesktopWorkarounds() | 4211 bool WebViewImpl::shouldDisableDesktopWorkarounds() |
4162 { | 4212 { |
4163 ViewportArguments arguments = mainFrameImpl()->frame()->document()->viewport Arguments(); | 4213 ViewportArguments arguments = mainFrameImpl()->frame()->document()->viewport Arguments(); |
4164 return arguments.width == ViewportArguments::ValueDeviceWidth || !arguments. userZoom | 4214 return arguments.width == ViewportArguments::ValueDeviceWidth || !arguments. userZoom |
4165 || (arguments.minZoom == arguments.maxZoom && arguments.minZoom != Viewp ortArguments::ValueAuto); | 4215 || (arguments.minZoom == arguments.maxZoom && arguments.minZoom != Viewp ortArguments::ValueAuto); |
4166 } | 4216 } |
4167 | 4217 |
4168 } // namespace WebKit | 4218 } // namespace WebKit |
OLD | NEW |