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 2949 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2960 { | 2960 { |
2961 return m_pageScaleConstraintsSet.finalConstraints().clampToConstraints(scale
Factor); | 2961 return m_pageScaleConstraintsSet.finalConstraints().clampToConstraints(scale
Factor); |
2962 } | 2962 } |
2963 | 2963 |
2964 IntPoint WebViewImpl::clampOffsetAtScale(const IntPoint& offset, float scale) | 2964 IntPoint WebViewImpl::clampOffsetAtScale(const IntPoint& offset, float scale) |
2965 { | 2965 { |
2966 FrameView* view = mainFrameImpl()->frameView(); | 2966 FrameView* view = mainFrameImpl()->frameView(); |
2967 if (!view) | 2967 if (!view) |
2968 return offset; | 2968 return offset; |
2969 | 2969 |
2970 return view->clampOffsetAtScale(offset, scale); | 2970 if (!pinchVirtualViewportEnabled()) |
| 2971 return view->clampOffsetAtScale(offset, scale); |
| 2972 |
| 2973 return page()->frameHost().pinchViewport().clampDocumentOffsetAtScale(offset
, scale); |
2971 } | 2974 } |
2972 | 2975 |
2973 bool WebViewImpl::pinchVirtualViewportEnabled() const | 2976 bool WebViewImpl::pinchVirtualViewportEnabled() const |
2974 { | 2977 { |
2975 ASSERT(page()); | 2978 ASSERT(page()); |
2976 return page()->settings().pinchVirtualViewportEnabled(); | 2979 return page()->settings().pinchVirtualViewportEnabled(); |
2977 } | 2980 } |
2978 | 2981 |
2979 void WebViewImpl::setPinchViewportOffset(const WebFloatPoint& offset) | 2982 void WebViewImpl::setPinchViewportOffset(const WebFloatPoint& offset) |
2980 { | 2983 { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3019 // Order is important: pinch viewport location is clamped based on | 3022 // Order is important: pinch viewport location is clamped based on |
3020 // main frame scroll position and pinch viewport scale. | 3023 // main frame scroll position and pinch viewport scale. |
3021 | 3024 |
3022 view->setScrollOffset(mainFrameOrigin); | 3025 view->setScrollOffset(mainFrameOrigin); |
3023 | 3026 |
3024 setPageScaleFactor(scaleFactor); | 3027 setPageScaleFactor(scaleFactor); |
3025 | 3028 |
3026 page()->frameHost().pinchViewport().setLocation(pinchViewportOrigin); | 3029 page()->frameHost().pinchViewport().setLocation(pinchViewportOrigin); |
3027 } | 3030 } |
3028 | 3031 |
| 3032 void WebViewImpl::setPageScaleFactorAndLocation(float scaleFactor, const FloatPo
int& location) |
| 3033 { |
| 3034 ASSERT(pinchVirtualViewportEnabled()); |
| 3035 ASSERT(page()); |
| 3036 |
| 3037 page()->frameHost().pinchViewport().setScaleAndLocation( |
| 3038 clampPageScaleFactorToLimits(scaleFactor), |
| 3039 location); |
| 3040 deviceOrPageScaleFactorChanged(); |
| 3041 } |
| 3042 |
3029 void WebViewImpl::setPageScaleFactor(float scaleFactor) | 3043 void WebViewImpl::setPageScaleFactor(float scaleFactor) |
3030 { | 3044 { |
3031 ASSERT(page()); | 3045 ASSERT(page()); |
3032 | 3046 |
3033 scaleFactor = clampPageScaleFactorToLimits(scaleFactor); | 3047 scaleFactor = clampPageScaleFactorToLimits(scaleFactor); |
3034 if (scaleFactor == pageScaleFactor()) | 3048 if (scaleFactor == pageScaleFactor()) |
3035 return; | 3049 return; |
3036 | 3050 |
3037 // TODO(bokan): Old-style pinch path. Remove when we're migrated to | 3051 // FIXME(bokan): Old-style pinch path. Remove when we're migrated to |
3038 // virtual viewport pinch. | 3052 // virtual viewport pinch. |
3039 if (!pinchVirtualViewportEnabled()) { | 3053 if (!pinchVirtualViewportEnabled()) { |
3040 IntPoint scrollOffset(mainFrame()->scrollOffset().width, mainFrame()->sc
rollOffset().height); | 3054 IntPoint scrollOffset(mainFrame()->scrollOffset().width, mainFrame()->sc
rollOffset().height); |
3041 setPageScaleFactor(scaleFactor, scrollOffset); | 3055 setPageScaleFactor(scaleFactor, scrollOffset); |
3042 return; | 3056 return; |
3043 } | 3057 } |
3044 | 3058 |
3045 page()->frameHost().pinchViewport().setScale(scaleFactor); | 3059 page()->frameHost().pinchViewport().setScale(scaleFactor); |
3046 deviceOrPageScaleFactorChanged(); | 3060 deviceOrPageScaleFactorChanged(); |
3047 } | 3061 } |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3303 return m_pageScaleConstraintsSet.finalConstraints().minimumScale; | 3317 return m_pageScaleConstraintsSet.finalConstraints().minimumScale; |
3304 } | 3318 } |
3305 | 3319 |
3306 float WebViewImpl::maximumPageScaleFactor() const | 3320 float WebViewImpl::maximumPageScaleFactor() const |
3307 { | 3321 { |
3308 return m_pageScaleConstraintsSet.finalConstraints().maximumScale; | 3322 return m_pageScaleConstraintsSet.finalConstraints().maximumScale; |
3309 } | 3323 } |
3310 | 3324 |
3311 void WebViewImpl::resetScrollAndScaleState() | 3325 void WebViewImpl::resetScrollAndScaleState() |
3312 { | 3326 { |
3313 // TODO: This is done by the pinchViewport().reset() call below and can be r
emoved when | 3327 // FIXME(bokan): This is done by the pinchViewport().reset() call below and |
3314 // the new pinch path is the only one. | 3328 // can be removed when the new pinch path is the only one. |
3315 setPageScaleFactor(1); | 3329 setPageScaleFactor(1); |
3316 updateMainFrameScrollPosition(IntPoint(), true); | 3330 updateMainFrameScrollPosition(IntPoint(), true); |
3317 page()->frameHost().pinchViewport().reset(); | 3331 page()->frameHost().pinchViewport().reset(); |
3318 | 3332 |
3319 if (!page()->mainFrame()->isLocalFrame()) | 3333 if (!page()->mainFrame()->isLocalFrame()) |
3320 return; | 3334 return; |
3321 | 3335 |
3322 // Clear out the values for the current history item. This will prevent the
history item from clobbering the | 3336 // Clear out the values for the current history item. This will prevent the
history item from clobbering the |
3323 // value determined during page scale initialization, which may be less than
1. | 3337 // value determined during page scale initialization, which may be less than
1. |
3324 page()->deprecatedLocalMainFrame()->loader().clearScrollPositionAndViewState
(); | 3338 page()->deprecatedLocalMainFrame()->loader().clearScrollPositionAndViewState
(); |
(...skipping 898 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4223 frameView->notifyScrollPositionChanged(scrollPosition); | 4237 frameView->notifyScrollPositionChanged(scrollPosition); |
4224 frameView->setInProgrammaticScroll(oldProgrammaticScroll); | 4238 frameView->setInProgrammaticScroll(oldProgrammaticScroll); |
4225 } | 4239 } |
4226 | 4240 |
4227 void WebViewImpl::applyViewportDeltas( | 4241 void WebViewImpl::applyViewportDeltas( |
4228 const WebSize& pinchViewportDelta, | 4242 const WebSize& pinchViewportDelta, |
4229 const WebSize& mainFrameDelta, | 4243 const WebSize& mainFrameDelta, |
4230 float pageScaleDelta, | 4244 float pageScaleDelta, |
4231 float topControlsDelta) | 4245 float topControlsDelta) |
4232 { | 4246 { |
4233 // FIXME(bokan): Will be replaced in 3-sided patch once Chromium side is lan
ded. | 4247 ASSERT(pinchVirtualViewportEnabled()); |
4234 applyViewportDeltas(pinchViewportDelta + mainFrameDelta, pageScaleDelta, top
ControlsDelta); | 4248 |
| 4249 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) |
| 4250 return; |
| 4251 |
| 4252 setTopControlsContentOffset(m_topControlsContentOffset + topControlsDelta); |
| 4253 |
| 4254 FloatPoint pinchViewportOffset = page()->frameHost().pinchViewport().visible
Rect().location(); |
| 4255 pinchViewportOffset.move(pinchViewportDelta.width, pinchViewportDelta.height
); |
| 4256 setPageScaleFactorAndLocation(pageScaleFactor() * pageScaleDelta, pinchViewp
ortOffset); |
| 4257 |
| 4258 if (pageScaleDelta != 1) |
| 4259 m_doubleTapZoomPending = false; |
| 4260 |
| 4261 IntPoint mainFrameScrollOffset = IntPoint(mainFrame()->scrollOffset()); |
| 4262 mainFrameScrollOffset.move(mainFrameDelta.width, mainFrameDelta.height); |
| 4263 updateMainFrameScrollPosition(mainFrameScrollOffset, false); |
4235 } | 4264 } |
4236 | 4265 |
4237 void WebViewImpl::applyViewportDeltas(const WebSize& scrollDelta, float pageScal
eDelta, float topControlsDelta) | 4266 void WebViewImpl::applyViewportDeltas(const WebSize& scrollDelta, float pageScal
eDelta, float topControlsDelta) |
4238 { | 4267 { |
4239 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) | 4268 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) |
4240 return; | 4269 return; |
4241 | 4270 |
4242 setTopControlsContentOffset(m_topControlsContentOffset + topControlsDelta); | 4271 setTopControlsContentOffset(m_topControlsContentOffset + topControlsDelta); |
4243 | 4272 |
4244 if (pinchVirtualViewportEnabled()) { | |
4245 if (pageScaleDelta != 1) { | |
4246 // When the virtual viewport is enabled, offsets are already set for
us. | |
4247 setPageScaleFactor(pageScaleFactor() * pageScaleDelta); | |
4248 m_doubleTapZoomPending = false; | |
4249 } | |
4250 | |
4251 return; | |
4252 } | |
4253 | |
4254 // TODO(bokan): Old pinch path only - virtual viewport pinch scrolls are aut
omatically updated via GraphicsLayer::DidScroll. | |
4255 // this should be removed once old pinch is removed. | |
4256 if (pageScaleDelta == 1) { | 4273 if (pageScaleDelta == 1) { |
4257 TRACE_EVENT_INSTANT2("blink", "WebViewImpl::applyScrollAndScale::scrollB
y", "x", scrollDelta.width, "y", scrollDelta.height); | 4274 TRACE_EVENT_INSTANT2("blink", "WebViewImpl::applyScrollAndScale::scrollB
y", "x", scrollDelta.width, "y", scrollDelta.height); |
4258 WebSize webScrollOffset = mainFrame()->scrollOffset(); | 4275 WebSize webScrollOffset = mainFrame()->scrollOffset(); |
4259 IntPoint scrollOffset(webScrollOffset.width + scrollDelta.width, webScro
llOffset.height + scrollDelta.height); | 4276 IntPoint scrollOffset(webScrollOffset.width + scrollDelta.width, webScro
llOffset.height + scrollDelta.height); |
4260 updateMainFrameScrollPosition(scrollOffset, false); | 4277 updateMainFrameScrollPosition(scrollOffset, false); |
4261 } else { | 4278 } else { |
4262 // The page scale changed, so apply a scale and scroll in a single | 4279 // The page scale changed, so apply a scale and scroll in a single |
4263 // operation. | 4280 // operation. |
4264 WebSize scrollOffset = mainFrame()->scrollOffset(); | 4281 WebSize scrollOffset = mainFrame()->scrollOffset(); |
4265 scrollOffset.width += scrollDelta.width; | 4282 scrollOffset.width += scrollDelta.width; |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4414 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi
nedConstraints(); | 4431 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi
nedConstraints(); |
4415 | 4432 |
4416 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) | 4433 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) |
4417 return false; | 4434 return false; |
4418 | 4435 |
4419 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width | 4436 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width |
4420 || (constraints.minimumScale == constraints.maximumScale && constraints.
minimumScale != -1); | 4437 || (constraints.minimumScale == constraints.maximumScale && constraints.
minimumScale != -1); |
4421 } | 4438 } |
4422 | 4439 |
4423 } // namespace blink | 4440 } // namespace blink |
OLD | NEW |