OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "config.h" | 5 #include "config.h" |
6 | 6 |
7 #include "cc/layer_tree_host_impl.h" | 7 #include "cc/layer_tree_host_impl.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
(...skipping 994 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1005 contentBounds.set_height(contentBounds.height() / pageScaleFactor); | 1005 contentBounds.set_height(contentBounds.height() / pageScaleFactor); |
1006 } else { | 1006 } else { |
1007 viewBounds = viewBounds.Scale(1 / m_pinchZoomViewport.pageScaleDelta()); | 1007 viewBounds = viewBounds.Scale(1 / m_pinchZoomViewport.pageScaleDelta()); |
1008 } | 1008 } |
1009 | 1009 |
1010 gfx::Vector2dF maxScroll = BottomRight(gfx::Rect(contentBounds)) - BottomRig
ht(gfx::RectF(viewBounds)); | 1010 gfx::Vector2dF maxScroll = BottomRight(gfx::Rect(contentBounds)) - BottomRig
ht(gfx::RectF(viewBounds)); |
1011 maxScroll.Scale(1 / m_deviceScaleFactor); | 1011 maxScroll.Scale(1 / m_deviceScaleFactor); |
1012 | 1012 |
1013 // The viewport may be larger than the contents in some cases, such as | 1013 // The viewport may be larger than the contents in some cases, such as |
1014 // having a vertical scrollbar but no horizontal overflow. | 1014 // having a vertical scrollbar but no horizontal overflow. |
1015 maxScroll = ClampFromBelow(maxScroll, gfx::Vector2dF()); | 1015 maxScroll.ClampToMin(gfx::Vector2dF()); |
1016 | 1016 |
1017 m_rootScrollLayerImpl->setMaxScrollOffset(gfx::ToFlooredVector2d(maxScroll))
; | 1017 m_rootScrollLayerImpl->setMaxScrollOffset(gfx::ToFlooredVector2d(maxScroll))
; |
1018 } | 1018 } |
1019 | 1019 |
1020 void LayerTreeHostImpl::setNeedsRedraw() | 1020 void LayerTreeHostImpl::setNeedsRedraw() |
1021 { | 1021 { |
1022 m_client->setNeedsRedrawOnImplThread(); | 1022 m_client->setNeedsRedrawOnImplThread(); |
1023 } | 1023 } |
1024 | 1024 |
1025 bool LayerTreeHostImpl::ensureRenderSurfaceLayerList() | 1025 bool LayerTreeHostImpl::ensureRenderSurfaceLayerList() |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1293 gfx::Vector2dF scrollBegin = m_rootScrollLayerImpl->scrollOffset() + m_rootS
crollLayerImpl->scrollDelta(); | 1293 gfx::Vector2dF scrollBegin = m_rootScrollLayerImpl->scrollOffset() + m_rootS
crollLayerImpl->scrollDelta(); |
1294 scrollBegin.Scale(m_pinchZoomViewport.pageScaleDelta()); | 1294 scrollBegin.Scale(m_pinchZoomViewport.pageScaleDelta()); |
1295 float scaleBegin = m_pinchZoomViewport.totalPageScaleFactor(); | 1295 float scaleBegin = m_pinchZoomViewport.totalPageScaleFactor(); |
1296 float pageScaleDeltaToSend = m_pinchZoomViewport.minPageScaleFactor() / m_pi
nchZoomViewport.pageScaleFactor(); | 1296 float pageScaleDeltaToSend = m_pinchZoomViewport.minPageScaleFactor() / m_pi
nchZoomViewport.pageScaleFactor(); |
1297 gfx::SizeF scaledContentsSize = contentSize().Scale(pageScaleDeltaToSend); | 1297 gfx::SizeF scaledContentsSize = contentSize().Scale(pageScaleDeltaToSend); |
1298 | 1298 |
1299 gfx::Vector2d anchorOffset = m_previousPinchAnchor.OffsetFromOrigin(); | 1299 gfx::Vector2d anchorOffset = m_previousPinchAnchor.OffsetFromOrigin(); |
1300 gfx::Vector2dF scrollEnd = scrollBegin + anchorOffset; | 1300 gfx::Vector2dF scrollEnd = scrollBegin + anchorOffset; |
1301 scrollEnd.Scale(m_pinchZoomViewport.minPageScaleFactor() / scaleBegin); | 1301 scrollEnd.Scale(m_pinchZoomViewport.minPageScaleFactor() / scaleBegin); |
1302 scrollEnd -= anchorOffset; | 1302 scrollEnd -= anchorOffset; |
1303 scrollEnd = ClampFromAbove(scrollEnd, BottomRight(gfx::RectF(scaledContentsS
ize)) - BottomRight(gfx::Rect(m_deviceViewportSize))); | 1303 scrollEnd.ClampToMax(BottomRight(gfx::RectF(scaledContentsSize)) - BottomRig
ht(gfx::Rect(m_deviceViewportSize))); |
1304 scrollEnd = ClampFromBelow(scrollEnd, gfx::Vector2d()); | 1304 scrollEnd.ClampToMin(gfx::Vector2d()); |
1305 scrollEnd.Scale(1 / pageScaleDeltaToSend); | 1305 scrollEnd.Scale(1 / pageScaleDeltaToSend); |
1306 scrollEnd.Scale(m_deviceScaleFactor); | 1306 scrollEnd.Scale(m_deviceScaleFactor); |
1307 | 1307 |
1308 makeScrollAndScaleSet(scrollInfo, gfx::ToRoundedVector2d(scrollEnd), m_pinch
ZoomViewport.minPageScaleFactor()); | 1308 makeScrollAndScaleSet(scrollInfo, gfx::ToRoundedVector2d(scrollEnd), m_pinch
ZoomViewport.minPageScaleFactor()); |
1309 } | 1309 } |
1310 | 1310 |
1311 void LayerTreeHostImpl::makeScrollAndScaleSet(ScrollAndScaleSet* scrollInfo, gfx
::Vector2d scrollOffset, float pageScale) | 1311 void LayerTreeHostImpl::makeScrollAndScaleSet(ScrollAndScaleSet* scrollInfo, gfx
::Vector2d scrollOffset, float pageScale) |
1312 { | 1312 { |
1313 if (!m_rootScrollLayerImpl) | 1313 if (!m_rootScrollLayerImpl) |
1314 return; | 1314 return; |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1497 ScrollbarAnimationController* scrollbarController = layer->scrollbarAnimatio
nController(); | 1497 ScrollbarAnimationController* scrollbarController = layer->scrollbarAnimatio
nController(); |
1498 double monotonicTime = (time - base::TimeTicks()).InSecondsF(); | 1498 double monotonicTime = (time - base::TimeTicks()).InSecondsF(); |
1499 if (scrollbarController && scrollbarController->animate(monotonicTime)) | 1499 if (scrollbarController && scrollbarController->animate(monotonicTime)) |
1500 m_client->setNeedsRedrawOnImplThread(); | 1500 m_client->setNeedsRedrawOnImplThread(); |
1501 | 1501 |
1502 for (size_t i = 0; i < layer->children().size(); ++i) | 1502 for (size_t i = 0; i < layer->children().size(); ++i) |
1503 animateScrollbarsRecursive(layer->children()[i], time); | 1503 animateScrollbarsRecursive(layer->children()[i], time); |
1504 } | 1504 } |
1505 | 1505 |
1506 } // namespace cc | 1506 } // namespace cc |
OLD | NEW |