| 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 "cc/layer_tree_impl.h" | 5 #include "cc/layer_tree_impl.h" |
| 6 | 6 |
| 7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
| 8 #include "cc/layer_tree_host_common.h" | 8 #include "cc/layer_tree_host_common.h" |
| 9 #include "cc/layer_tree_host_impl.h" | 9 #include "cc/layer_tree_host_impl.h" |
| 10 #include "ui/gfx/vector2d_conversions.h" | 10 #include "ui/gfx/vector2d_conversions.h" |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 gfx::Vector2dF max_scroll = gfx::Rect(ScrollableSize()).bottom_right() - | 113 gfx::Vector2dF max_scroll = gfx::Rect(ScrollableSize()).bottom_right() - |
| 114 gfx::RectF(view_bounds).bottom_right(); | 114 gfx::RectF(view_bounds).bottom_right(); |
| 115 | 115 |
| 116 // The viewport may be larger than the contents in some cases, such as | 116 // The viewport may be larger than the contents in some cases, such as |
| 117 // having a vertical scrollbar but no horizontal overflow. | 117 // having a vertical scrollbar but no horizontal overflow. |
| 118 max_scroll.ClampToMin(gfx::Vector2dF()); | 118 max_scroll.ClampToMin(gfx::Vector2dF()); |
| 119 | 119 |
| 120 root_scroll_layer_->setMaxScrollOffset(gfx::ToFlooredVector2d(max_scroll)); | 120 root_scroll_layer_->setMaxScrollOffset(gfx::ToFlooredVector2d(max_scroll)); |
| 121 } | 121 } |
| 122 | 122 |
| 123 static gfx::Vector2dF toVector2dF(const gfx::Size& size) { return gfx::Vector2dF
(size.width(), size.height()); } |
| 124 static gfx::Vector2dF toVector2dF(const gfx::SizeF& size) { return gfx::Vector2d
F(size.width(), size.height()); } |
| 125 |
| 126 void LayerTreeImpl::UpdateFixedPositionViewport() { |
| 127 if (!root_scroll_layer_) |
| 128 return; |
| 129 |
| 130 const gfx::Vector2dF total_scroll_offset = root_scroll_layer_->scrollOffset()
+ root_scroll_layer_->scrollDelta(); |
| 131 const gfx::Vector2dF layout_viewport_size = toVector2dF(pinch_zoom_viewport().
layout_viewport_size()); |
| 132 const gfx::Vector2d desktop_compatibility_viewport_offset = root_scroll_layer_
->desktopCompatibilityViewportOffsetFromScrollPosition(); |
| 133 |
| 134 gfx::Vector2dF desktop_compatibility_viewport_offset_delta = root_scroll_layer
_->desktopCompatibilityViewportOffsetFromScrollPositionDelta(); |
| 135 |
| 136 // Make sure fixed position viewport contains the visible viewport |
| 137 { |
| 138 const gfx::Vector2dF offset_min = toVector2dF(pinch_zoom_viewport().LayoutSp
aceViewportSize()) - layout_viewport_size; |
| 139 desktop_compatibility_viewport_offset_delta.ClampToMin(offset_min - desktop_
compatibility_viewport_offset); |
| 140 const gfx::Vector2dF offset_max; |
| 141 desktop_compatibility_viewport_offset_delta.ClampToMax(offset_max - desktop_
compatibility_viewport_offset); |
| 142 } |
| 143 |
| 144 // Clamp the fixed position viewport within the document bounds. |
| 145 { |
| 146 const gfx::Vector2dF offset_max = toVector2dF(ScrollableSize()) - layout_vie
wport_size - total_scroll_offset; |
| 147 desktop_compatibility_viewport_offset_delta.ClampToMax(offset_max - desktop_
compatibility_viewport_offset); |
| 148 const gfx::Vector2dF offset_min = -total_scroll_offset; |
| 149 desktop_compatibility_viewport_offset_delta.ClampToMin(offset_min - desktop_
compatibility_viewport_offset); |
| 150 } |
| 151 |
| 152 root_scroll_layer_->setDesktopCompatibilityViewportOffsetFromScrollPositionDel
ta(desktop_compatibility_viewport_offset_delta); |
| 153 } |
| 154 |
| 123 void LayerTreeImpl::UpdateDrawProperties() { | 155 void LayerTreeImpl::UpdateDrawProperties() { |
| 124 render_surface_layer_list_.clear(); | 156 render_surface_layer_list_.clear(); |
| 125 if (!RootLayer()) | 157 if (!RootLayer()) |
| 126 return; | 158 return; |
| 127 | 159 |
| 128 if (root_scroll_layer_) { | 160 if (root_scroll_layer_) { |
| 129 root_scroll_layer_->setImplTransform( | 161 root_scroll_layer_->setImplTransform( |
| 130 layer_tree_host_impl_->implTransform()); | 162 layer_tree_host_impl_->implTransform()); |
| 131 } | 163 } |
| 132 | 164 |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 | 362 |
| 331 AnimationRegistrar* LayerTreeImpl::animationRegistrar() const { | 363 AnimationRegistrar* LayerTreeImpl::animationRegistrar() const { |
| 332 return layer_tree_host_impl_->animationRegistrar(); | 364 return layer_tree_host_impl_->animationRegistrar(); |
| 333 } | 365 } |
| 334 | 366 |
| 335 const PinchZoomViewport& LayerTreeImpl::pinch_zoom_viewport() const { | 367 const PinchZoomViewport& LayerTreeImpl::pinch_zoom_viewport() const { |
| 336 return layer_tree_host_impl_->pinchZoomViewport(); | 368 return layer_tree_host_impl_->pinchZoomViewport(); |
| 337 } | 369 } |
| 338 | 370 |
| 339 } // namespace cc | 371 } // namespace cc |
| OLD | NEW |