Chromium Code Reviews| 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 | |
| 193 // Constants for viewport anchoring on resize. | 195 // Constants for viewport anchoring on resize. |
| 194 static const float viewportAnchorXCoord = 0.5f; | 196 static const float viewportAnchorXCoord = 0.5f; |
| 195 static const float viewportAnchorYCoord = 0; | 197 static const float viewportAnchorYCoord = 0; |
| 196 | 198 |
| 197 // Constants for zooming in on a focused text field. | 199 // Constants for zooming in on a focused text field. |
| 198 static const double scrollAndScaleAnimationDurationInSeconds = 0.2; | 200 static const double scrollAndScaleAnimationDurationInSeconds = 0.2; |
| 199 static const int minReadableCaretHeight = 18; | 201 static const int minReadableCaretHeight = 18; |
| 200 static const float minScaleChangeToTriggerZoom = 1.05f; | 202 static const float minScaleChangeToTriggerZoom = 1.05f; |
| 201 static const float leftBoxRatio = 0.3f; | 203 static const float leftBoxRatio = 0.3f; |
| 202 static const int caretPadding = 10; | 204 static const int caretPadding = 10; |
| (...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 766 break; | 768 break; |
| 767 } | 769 } |
| 768 case WebInputEvent::GestureTapDown: { | 770 case WebInputEvent::GestureTapDown: { |
| 769 m_client->cancelScheduledContentIntents(); | 771 m_client->cancelScheduledContentIntents(); |
| 770 eventSwallowed = mainFrameImpl()->frame()->eventHandler()->handleGesture Event(platformEvent); | 772 eventSwallowed = mainFrameImpl()->frame()->eventHandler()->handleGesture Event(platformEvent); |
| 771 break; | 773 break; |
| 772 } | 774 } |
| 773 case WebInputEvent::GestureDoubleTap: | 775 case WebInputEvent::GestureDoubleTap: |
| 774 if (m_webSettings->doubleTapToZoomEnabled() && minimumPageScaleFactor() != maximumPageScaleFactor()) { | 776 if (m_webSettings->doubleTapToZoomEnabled() && minimumPageScaleFactor() != maximumPageScaleFactor()) { |
| 775 m_client->cancelScheduledContentIntents(); | 777 m_client->cancelScheduledContentIntents(); |
| 776 animateZoomAroundPoint(platformEvent.position(), DoubleTap); | 778 animateZoomToRect(WebRect(platformEvent.position().x(), platformEven t.position().y(), 0, 0), DoubleTap); |
| 777 } | 779 } |
| 778 // GestureDoubleTap is currently only used by Android for zooming. For W ebCore, | 780 // 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. | 781 // GestureTap with tap count = 2 is used instead. So we drop GestureDoub leTap here. |
| 780 eventSwallowed = true; | 782 eventSwallowed = true; |
| 781 break; | 783 break; |
| 782 case WebInputEvent::GestureScrollBegin: | 784 case WebInputEvent::GestureScrollBegin: |
| 783 case WebInputEvent::GesturePinchBegin: | 785 case WebInputEvent::GesturePinchBegin: |
| 784 m_client->cancelScheduledContentIntents(); | 786 m_client->cancelScheduledContentIntents(); |
| 785 case WebInputEvent::GestureScrollEnd: | 787 case WebInputEvent::GestureScrollEnd: |
| 786 case WebInputEvent::GestureScrollUpdate: | 788 case WebInputEvent::GestureScrollUpdate: |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1127 | 1129 |
| 1128 void WebViewImpl::computeScaleAndScrollForHitRect(const WebRect& hitRect, AutoZo omType zoomType, float& scale, WebPoint& scroll, bool& isAnchor) | 1130 void WebViewImpl::computeScaleAndScrollForHitRect(const WebRect& hitRect, AutoZo omType zoomType, float& scale, WebPoint& scroll, bool& isAnchor) |
| 1129 { | 1131 { |
| 1130 scale = pageScaleFactor(); | 1132 scale = pageScaleFactor(); |
| 1131 scroll.x = scroll.y = 0; | 1133 scroll.x = scroll.y = 0; |
| 1132 WebRect targetRect = hitRect; | 1134 WebRect targetRect = hitRect; |
| 1133 // Padding only depends on page scale when triggered by manually tapping | 1135 // Padding only depends on page scale when triggered by manually tapping |
| 1134 int padding = (zoomType == DoubleTap) ? touchPointPadding : nonUserInitiated PointPadding; | 1136 int padding = (zoomType == DoubleTap) ? touchPointPadding : nonUserInitiated PointPadding; |
| 1135 if (targetRect.isEmpty()) | 1137 if (targetRect.isEmpty()) |
| 1136 targetRect.width = targetRect.height = padding; | 1138 targetRect.width = targetRect.height = padding; |
| 1137 WebRect rect = computeBlockBounds(targetRect, zoomType); | 1139 WebRect rect = targetRect; |
| 1140 if (zoomType != MultipleTargets) | |
| 1141 rect = computeBlockBounds(targetRect, zoomType); | |
| 1138 if (zoomType == FindInPage && rect.isEmpty()) { | 1142 if (zoomType == FindInPage && rect.isEmpty()) { |
| 1139 // Keep current scale (no need to scroll as x,y will normally already | 1143 // 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. | 1144 // be visible). FIXME: Revisit this if it isn't always true. |
| 1141 return; | 1145 return; |
| 1142 } | 1146 } |
| 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 |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1267 Color highlightColor = touchNode->renderer()->style()->tapHighlightColor(); | 1271 Color highlightColor = touchNode->renderer()->style()->tapHighlightColor(); |
| 1268 // Safari documentation for -webkit-tap-highlight-color says if the specifie d color has 0 alpha, | 1272 // Safari documentation for -webkit-tap-highlight-color says if the specifie d color has 0 alpha, |
| 1269 // then tap highlighting is disabled. | 1273 // then tap highlighting is disabled. |
| 1270 // http://developer.apple.com/library/safari/#documentation/appleapplication s/reference/safaricssref/articles/standardcssproperties.html | 1274 // http://developer.apple.com/library/safari/#documentation/appleapplication s/reference/safaricssref/articles/standardcssproperties.html |
| 1271 if (!highlightColor.alpha()) | 1275 if (!highlightColor.alpha()) |
| 1272 return; | 1276 return; |
| 1273 | 1277 |
| 1274 m_linkHighlight = LinkHighlight::create(touchNode, this); | 1278 m_linkHighlight = LinkHighlight::create(touchNode, this); |
| 1275 } | 1279 } |
| 1276 | 1280 |
| 1277 void WebViewImpl::animateZoomAroundPoint(const IntPoint& point, AutoZoomType zoo mType) | 1281 bool WebViewImpl::animateZoomToRect(const IntRect& rect, AutoZoomType zoomType) |
| 1278 { | 1282 { |
| 1279 if (!mainFrameImpl()) | 1283 if (!mainFrameImpl()) |
| 1280 return; | 1284 return false; |
| 1281 | 1285 |
| 1282 float scale; | 1286 float scale; |
| 1283 WebPoint scroll; | 1287 WebPoint scroll; |
| 1284 bool isAnchor; | 1288 bool isAnchor; |
| 1285 WebPoint webPoint = point; | 1289 WebRect webRect = rect; |
| 1286 computeScaleAndScrollForHitRect(WebRect(webPoint.x, webPoint.y, 0, 0), zoomT ype, scale, scroll, isAnchor); | 1290 computeScaleAndScrollForHitRect(webRect, zoomType, scale, scroll, isAnchor); |
| 1291 | |
| 1292 if (zoomType == MultipleTargets && scale <= pageScaleFactor()) | |
| 1293 return false; | |
| 1287 | 1294 |
| 1288 bool isDoubleTap = (zoomType == DoubleTap); | 1295 bool isDoubleTap = (zoomType == DoubleTap); |
| 1289 double durationInSeconds = isDoubleTap ? doubleTapZoomAnimationDurationInSec onds : 0; | 1296 double durationInSeconds = isDoubleTap ? doubleTapZoomAnimationDurationInSec onds : |
| 1297 zoomType == MultipleTargets ? multipleTargetsZoomAnimationDurationInSeco nds : 0; | |
| 1298 | |
| 1290 bool isAnimating = startPageScaleAnimation(scroll, isAnchor, scale, duration InSeconds); | 1299 bool isAnimating = startPageScaleAnimation(scroll, isAnchor, scale, duration InSeconds); |
| 1291 | 1300 |
| 1292 if (isDoubleTap && isAnimating) { | 1301 if (isDoubleTap && isAnimating) { |
| 1293 m_doubleTapZoomPageScaleFactor = scale; | 1302 m_doubleTapZoomPageScaleFactor = scale; |
| 1294 m_doubleTapZoomPending = true; | 1303 m_doubleTapZoomPending = true; |
| 1295 } | 1304 } |
| 1305 return true; | |
| 1296 } | 1306 } |
| 1297 | 1307 |
| 1298 void WebViewImpl::zoomToFindInPageRect(const WebRect& rect) | 1308 void WebViewImpl::zoomToFindInPageRect(const WebRect& rect) |
| 1299 { | 1309 { |
| 1300 animateZoomAroundPoint(IntRect(rect).center(), FindInPage); | 1310 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
| |
| 1311 } | |
| 1312 | |
| 1313 bool WebViewImpl::zoomToMultipleTargetsRect(const WebRect& rect) | |
| 1314 { | |
| 1315 return animateZoomToRect(rect, MultipleTargets); | |
| 1301 } | 1316 } |
| 1302 | 1317 |
| 1303 void WebViewImpl::numberOfWheelEventHandlersChanged(unsigned numberOfWheelHandle rs) | 1318 void WebViewImpl::numberOfWheelEventHandlersChanged(unsigned numberOfWheelHandle rs) |
| 1304 { | 1319 { |
| 1305 if (m_client) | 1320 if (m_client) |
| 1306 m_client->numberOfWheelEventHandlersChanged(numberOfWheelHandlers); | 1321 m_client->numberOfWheelEventHandlersChanged(numberOfWheelHandlers); |
| 1307 } | 1322 } |
| 1308 | 1323 |
| 1309 void WebViewImpl::hasTouchEventHandlers(bool hasTouchHandlers) | 1324 void WebViewImpl::hasTouchEventHandlers(bool hasTouchHandlers) |
| 1310 { | 1325 { |
| (...skipping 2848 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4159 } | 4174 } |
| 4160 | 4175 |
| 4161 bool WebViewImpl::shouldDisableDesktopWorkarounds() | 4176 bool WebViewImpl::shouldDisableDesktopWorkarounds() |
| 4162 { | 4177 { |
| 4163 ViewportArguments arguments = mainFrameImpl()->frame()->document()->viewport Arguments(); | 4178 ViewportArguments arguments = mainFrameImpl()->frame()->document()->viewport Arguments(); |
| 4164 return arguments.width == ViewportArguments::ValueDeviceWidth || !arguments. userZoom | 4179 return arguments.width == ViewportArguments::ValueDeviceWidth || !arguments. userZoom |
| 4165 || (arguments.minZoom == arguments.maxZoom && arguments.minZoom != Viewp ortArguments::ValueAuto); | 4180 || (arguments.minZoom == arguments.maxZoom && arguments.minZoom != Viewp ortArguments::ValueAuto); |
| 4166 } | 4181 } |
| 4167 | 4182 |
| 4168 } // namespace WebKit | 4183 } // namespace WebKit |
| OLD | NEW |