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 2871 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2882 { | 2882 { |
2883 return m_pageScaleConstraintsSet.finalConstraints().clampToConstraints(scale Factor); | 2883 return m_pageScaleConstraintsSet.finalConstraints().clampToConstraints(scale Factor); |
2884 } | 2884 } |
2885 | 2885 |
2886 IntPoint WebViewImpl::clampOffsetAtScale(const IntPoint& offset, float scale) | 2886 IntPoint WebViewImpl::clampOffsetAtScale(const IntPoint& offset, float scale) |
2887 { | 2887 { |
2888 FrameView* view = mainFrameImpl()->frameView(); | 2888 FrameView* view = mainFrameImpl()->frameView(); |
2889 if (!view) | 2889 if (!view) |
2890 return offset; | 2890 return offset; |
2891 | 2891 |
2892 return view->clampOffsetAtScale(offset, scale); | 2892 if (!pinchVirtualViewportEnabled()) |
2893 return view->clampOffsetAtScale(offset, scale); | |
2894 | |
2895 return page()->frameHost().pinchViewport().clampDocumentOffsetAtScale(offset , scale); | |
2893 } | 2896 } |
2894 | 2897 |
2895 bool WebViewImpl::pinchVirtualViewportEnabled() const | 2898 bool WebViewImpl::pinchVirtualViewportEnabled() const |
2896 { | 2899 { |
2897 ASSERT(page()); | 2900 ASSERT(page()); |
2898 return page()->settings().pinchVirtualViewportEnabled(); | 2901 return page()->settings().pinchVirtualViewportEnabled(); |
2899 } | 2902 } |
2900 | 2903 |
2901 void WebViewImpl::setPinchViewportOffset(const WebFloatPoint& offset) | 2904 void WebViewImpl::setPinchViewportOffset(const WebFloatPoint& offset) |
2902 { | 2905 { |
(...skipping 28 matching lines...) Expand all Loading... | |
2931 if (!pinchVirtualViewportEnabled()) { | 2934 if (!pinchVirtualViewportEnabled()) { |
2932 IntPoint scrollOffset(mainFrame()->scrollOffset().width, mainFrame()->sc rollOffset().height); | 2935 IntPoint scrollOffset(mainFrame()->scrollOffset().width, mainFrame()->sc rollOffset().height); |
2933 setPageScaleFactor(scaleFactor, scrollOffset); | 2936 setPageScaleFactor(scaleFactor, scrollOffset); |
2934 return; | 2937 return; |
2935 } | 2938 } |
2936 | 2939 |
2937 page()->frameHost().pinchViewport().setScale(scaleFactor); | 2940 page()->frameHost().pinchViewport().setScale(scaleFactor); |
2938 deviceOrPageScaleFactorChanged(); | 2941 deviceOrPageScaleFactorChanged(); |
2939 } | 2942 } |
2940 | 2943 |
2944 void WebViewImpl::setPageScaleFactorFromImpl(float scaleFactor) | |
2945 { | |
2946 ASSERT(page()); | |
2947 ASSERT(pinchVirtualViewportEnabled()); | |
2948 | |
2949 scaleFactor = clampPageScaleFactorToLimits(scaleFactor); | |
2950 if (scaleFactor == pageScaleFactor()) | |
2951 return; | |
2952 | |
2953 page()->frameHost().pinchViewport().setScaleWithoutClampingViewportOffset(sc aleFactor); | |
2954 deviceOrPageScaleFactorChanged(); | |
2955 } | |
2956 | |
2941 void WebViewImpl::setMainFrameScrollOffset(const WebPoint& origin) | 2957 void WebViewImpl::setMainFrameScrollOffset(const WebPoint& origin) |
2942 { | 2958 { |
2943 updateMainFrameScrollPosition(origin, false); | 2959 updateMainFrameScrollPosition(origin, false); |
2944 } | 2960 } |
2945 | 2961 |
2946 void WebViewImpl::setPageScaleFactor(float scaleFactor, const WebPoint& origin) | 2962 void WebViewImpl::setPageScaleFactor(float scaleFactor, const WebPoint& origin) |
2947 { | 2963 { |
2948 if (!page()) | 2964 if (!page()) |
2949 return; | 2965 return; |
2950 | 2966 |
(...skipping 1188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4139 | 4155 |
4140 void WebViewImpl::applyViewportDeltas(const WebSize& scrollDelta, float pageScal eDelta, float topControlsDelta) | 4156 void WebViewImpl::applyViewportDeltas(const WebSize& scrollDelta, float pageScal eDelta, float topControlsDelta) |
4141 { | 4157 { |
4142 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) | 4158 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) |
4143 return; | 4159 return; |
4144 | 4160 |
4145 setTopControlsContentOffset(m_topControlsContentOffset + topControlsDelta); | 4161 setTopControlsContentOffset(m_topControlsContentOffset + topControlsDelta); |
4146 | 4162 |
4147 if (pinchVirtualViewportEnabled()) { | 4163 if (pinchVirtualViewportEnabled()) { |
4148 if (pageScaleDelta != 1) { | 4164 if (pageScaleDelta != 1) { |
4149 // When the virtual viewport is enabled, offsets are already set for us. | 4165 // When the virtual viewport is enabled, offsets are already set for us. Don't clamp |
aelias_OOO_until_Jul13
2014/09/19 22:39:21
We've so far always been able to avoid "don't clam
| |
4150 setPageScaleFactor(pageScaleFactor() * pageScaleDelta); | 4166 // the viewport offset when setting page scale here, it will be clam ped when the |
4167 // compositor sets the viewport offset immediately following this. | |
4168 setPageScaleFactorFromImpl(pageScaleFactor() * pageScaleDelta); | |
4151 m_doubleTapZoomPending = false; | 4169 m_doubleTapZoomPending = false; |
4152 } | 4170 } |
4153 | 4171 |
4154 return; | 4172 return; |
4155 } | 4173 } |
4156 | 4174 |
4157 // TODO(bokan): Old pinch path only - virtual viewport pinch scrolls are aut omatically updated via GraphicsLayer::DidScroll. | 4175 // TODO(bokan): Old pinch path only - virtual viewport pinch scrolls are aut omatically updated via GraphicsLayer::DidScroll. |
4158 // this should be removed once old pinch is removed. | 4176 // this should be removed once old pinch is removed. |
4159 if (pageScaleDelta == 1) { | 4177 if (pageScaleDelta == 1) { |
4160 TRACE_EVENT_INSTANT2("blink", "WebViewImpl::applyScrollAndScale::scrollB y", "x", scrollDelta.width, "y", scrollDelta.height); | 4178 TRACE_EVENT_INSTANT2("blink", "WebViewImpl::applyScrollAndScale::scrollB y", "x", scrollDelta.width, "y", scrollDelta.height); |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4317 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi nedConstraints(); | 4335 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi nedConstraints(); |
4318 | 4336 |
4319 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) | 4337 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) |
4320 return false; | 4338 return false; |
4321 | 4339 |
4322 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width | 4340 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width |
4323 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1); | 4341 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1); |
4324 } | 4342 } |
4325 | 4343 |
4326 } // namespace blink | 4344 } // namespace blink |
OLD | NEW |