| 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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 LayerImpl* LayerTreeImpl::CurrentlyScrollingLayer() { | 87 LayerImpl* LayerTreeImpl::CurrentlyScrollingLayer() { |
| 88 DCHECK(IsActiveTree()); | 88 DCHECK(IsActiveTree()); |
| 89 return currently_scrolling_layer_; | 89 return currently_scrolling_layer_; |
| 90 } | 90 } |
| 91 | 91 |
| 92 void LayerTreeImpl::ClearCurrentlyScrollingLayer() { | 92 void LayerTreeImpl::ClearCurrentlyScrollingLayer() { |
| 93 currently_scrolling_layer_ = NULL; | 93 currently_scrolling_layer_ = NULL; |
| 94 scrolling_layer_id_from_previous_tree_ = 0; | 94 scrolling_layer_id_from_previous_tree_ = 0; |
| 95 } | 95 } |
| 96 | 96 |
| 97 gfx::SizeF LayerTreeImpl::ScrollableViewportSize() const { |
| 98 gfx::SizeF view_bounds; |
| 99 // The clip layer should be used for scrolling bounds if available since it |
| 100 // adjusts for non-overlay scrollbars. Otherwise, fall back to our knowledge |
| 101 // of the physical viewport size. |
| 102 LayerImpl* clip_layer = NULL; |
| 103 if (root_scroll_layer_) |
| 104 clip_layer = root_scroll_layer_->parent(); |
| 105 if (clip_layer && clip_layer->masksToBounds()) { |
| 106 view_bounds = clip_layer->bounds(); |
| 107 } else { |
| 108 view_bounds = gfx::ScaleSize(device_viewport_size(), |
| 109 1 / device_scale_factor()); |
| 110 } |
| 111 view_bounds.Scale(1 / pinch_zoom_viewport().total_page_scale_factor()); |
| 112 |
| 113 return view_bounds; |
| 114 } |
| 115 |
| 97 void LayerTreeImpl::UpdateMaxScrollOffset() { | 116 void LayerTreeImpl::UpdateMaxScrollOffset() { |
| 98 if (!root_scroll_layer_ || !root_scroll_layer_->children().size()) | 117 if (!root_scroll_layer_ || !root_scroll_layer_->children().size()) |
| 99 return; | 118 return; |
| 100 | 119 |
| 101 gfx::SizeF view_bounds; | |
| 102 if (!settings().pageScalePinchZoomEnabled) { | |
| 103 view_bounds = device_viewport_size(); | |
| 104 if (LayerImpl* clip_layer = root_scroll_layer_->parent()) { | |
| 105 // Compensate for non-overlay scrollbars. | |
| 106 if (clip_layer->masksToBounds()) | |
| 107 view_bounds = gfx::ScaleSize(clip_layer->bounds(), device_scale_factor()
); | |
| 108 } | |
| 109 view_bounds.Scale(1 / pinch_zoom_viewport().page_scale_delta()); | |
| 110 } else { | |
| 111 view_bounds = layout_viewport_size(); | |
| 112 } | |
| 113 | |
| 114 gfx::Vector2dF max_scroll = gfx::Rect(ScrollableSize()).bottom_right() - | 120 gfx::Vector2dF max_scroll = gfx::Rect(ScrollableSize()).bottom_right() - |
| 115 gfx::RectF(view_bounds).bottom_right(); | 121 gfx::RectF(ScrollableViewportSize()).bottom_right(); |
| 116 | 122 |
| 117 // The viewport may be larger than the contents in some cases, such as | 123 // The viewport may be larger than the contents in some cases, such as |
| 118 // having a vertical scrollbar but no horizontal overflow. | 124 // having a vertical scrollbar but no horizontal overflow. |
| 119 max_scroll.ClampToMin(gfx::Vector2dF()); | 125 max_scroll.ClampToMin(gfx::Vector2dF()); |
| 120 | 126 |
| 121 root_scroll_layer_->setMaxScrollOffset(gfx::ToFlooredVector2d(max_scroll)); | 127 root_scroll_layer_->setMaxScrollOffset(gfx::ToFlooredVector2d(max_scroll)); |
| 122 } | 128 } |
| 123 | 129 |
| 124 struct UpdateTilePrioritiesForLayer { | 130 struct UpdateTilePrioritiesForLayer { |
| 125 void operator()(LayerImpl *layer) { | 131 void operator()(LayerImpl *layer) { |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 | 365 |
| 360 AnimationRegistrar* LayerTreeImpl::animationRegistrar() const { | 366 AnimationRegistrar* LayerTreeImpl::animationRegistrar() const { |
| 361 return layer_tree_host_impl_->animationRegistrar(); | 367 return layer_tree_host_impl_->animationRegistrar(); |
| 362 } | 368 } |
| 363 | 369 |
| 364 const PinchZoomViewport& LayerTreeImpl::pinch_zoom_viewport() const { | 370 const PinchZoomViewport& LayerTreeImpl::pinch_zoom_viewport() const { |
| 365 return layer_tree_host_impl_->pinchZoomViewport(); | 371 return layer_tree_host_impl_->pinchZoomViewport(); |
| 366 } | 372 } |
| 367 | 373 |
| 368 } // namespace cc | 374 } // namespace cc |
| OLD | NEW |