| 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 | 90 |
| 91 void LayerTreeImpl::ClearCurrentlyScrollingLayer() { | 91 void LayerTreeImpl::ClearCurrentlyScrollingLayer() { |
| 92 currently_scrolling_layer_ = NULL; | 92 currently_scrolling_layer_ = NULL; |
| 93 scrolling_layer_id_from_previous_tree_ = 0; | 93 scrolling_layer_id_from_previous_tree_ = 0; |
| 94 } | 94 } |
| 95 | 95 |
| 96 void LayerTreeImpl::UpdateMaxScrollOffset() { | 96 void LayerTreeImpl::UpdateMaxScrollOffset() { |
| 97 if (!root_scroll_layer_ || !root_scroll_layer_->children().size()) | 97 if (!root_scroll_layer_ || !root_scroll_layer_->children().size()) |
| 98 return; | 98 return; |
| 99 | 99 |
| 100 gfx::SizeF view_bounds = device_viewport_size(); | 100 gfx::SizeF view_bounds; |
| 101 if (LayerImpl* clip_layer = root_scroll_layer_->parent()) { | 101 if (!settings().pageScalePinchZoomEnabled) { |
| 102 // Compensate for non-overlay scrollbars. | 102 view_bounds = device_viewport_size(); |
| 103 if (clip_layer->masksToBounds()) | 103 if (LayerImpl* clip_layer = root_scroll_layer_->parent()) { |
| 104 view_bounds = gfx::ScaleSize(clip_layer->bounds(), device_scale_factor()); | 104 // Compensate for non-overlay scrollbars. |
| 105 if (clip_layer->masksToBounds()) |
| 106 view_bounds = gfx::ScaleSize(clip_layer->bounds(), device_scale_factor()
); |
| 107 } |
| 108 view_bounds.Scale(1 / pinch_zoom_viewport().page_scale_delta()); |
| 109 } else { |
| 110 view_bounds = layout_viewport_size(); |
| 105 } | 111 } |
| 106 | 112 |
| 107 gfx::Size content_bounds = ContentSize(); | 113 gfx::Vector2dF max_scroll = gfx::Rect(ScrollableSize()).bottom_right() - |
| 108 if (settings().pageScalePinchZoomEnabled) { | |
| 109 // Pinch with pageScale scrolls entirely in layout space. ContentSize | |
| 110 // returns the bounds including the page scale factor, so calculate the | |
| 111 // pre page-scale layout size here. | |
| 112 float page_scale_factor = pinch_zoom_viewport().page_scale_factor(); | |
| 113 content_bounds.set_width(content_bounds.width() / page_scale_factor); | |
| 114 content_bounds.set_height(content_bounds.height() / page_scale_factor); | |
| 115 } else { | |
| 116 view_bounds.Scale(1 / pinch_zoom_viewport().page_scale_delta()); | |
| 117 } | |
| 118 | |
| 119 gfx::Vector2dF max_scroll = gfx::Rect(content_bounds).bottom_right() - | |
| 120 gfx::RectF(view_bounds).bottom_right(); | 114 gfx::RectF(view_bounds).bottom_right(); |
| 121 max_scroll.Scale(1 / device_scale_factor()); | |
| 122 | 115 |
| 123 // 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 |
| 124 // having a vertical scrollbar but no horizontal overflow. | 117 // having a vertical scrollbar but no horizontal overflow. |
| 125 max_scroll.ClampToMin(gfx::Vector2dF()); | 118 max_scroll.ClampToMin(gfx::Vector2dF()); |
| 126 | 119 |
| 127 root_scroll_layer_->setMaxScrollOffset(gfx::ToFlooredVector2d(max_scroll)); | 120 root_scroll_layer_->setMaxScrollOffset(gfx::ToFlooredVector2d(max_scroll)); |
| 128 } | 121 } |
| 129 | 122 |
| 130 void LayerTreeImpl::UpdateDrawProperties() { | 123 void LayerTreeImpl::UpdateDrawProperties() { |
| 131 render_surface_layer_list_.clear(); | 124 render_surface_layer_list_.clear(); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 | 173 |
| 181 return true; | 174 return true; |
| 182 } | 175 } |
| 183 | 176 |
| 184 const LayerTreeImpl::LayerList& LayerTreeImpl::RenderSurfaceLayerList() const { | 177 const LayerTreeImpl::LayerList& LayerTreeImpl::RenderSurfaceLayerList() const { |
| 185 // If this assert triggers, then the list is dirty. | 178 // If this assert triggers, then the list is dirty. |
| 186 DCHECK(!layer_tree_host_impl_->needsUpdateDrawProperties()); | 179 DCHECK(!layer_tree_host_impl_->needsUpdateDrawProperties()); |
| 187 return render_surface_layer_list_; | 180 return render_surface_layer_list_; |
| 188 } | 181 } |
| 189 | 182 |
| 190 gfx::Size LayerTreeImpl::ContentSize() const { | 183 gfx::Size LayerTreeImpl::ScrollableSize() const { |
| 191 if (!root_scroll_layer_ || root_scroll_layer_->children().empty()) | 184 if (!root_scroll_layer_ || root_scroll_layer_->children().empty()) |
| 192 return gfx::Size(); | 185 return gfx::Size(); |
| 193 return root_scroll_layer_->children()[0]->bounds(); | 186 return root_scroll_layer_->children()[0]->bounds(); |
| 194 } | 187 } |
| 195 | 188 |
| 196 LayerImpl* LayerTreeImpl::LayerById(int id) { | 189 LayerImpl* LayerTreeImpl::LayerById(int id) { |
| 197 LayerIdMap::iterator iter = layer_id_map_.find(id); | 190 LayerIdMap::iterator iter = layer_id_map_.find(id); |
| 198 return iter != layer_id_map_.end() ? iter->second : NULL; | 191 return iter != layer_id_map_.end() ? iter->second : NULL; |
| 199 } | 192 } |
| 200 | 193 |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 | 322 |
| 330 AnimationRegistrar* LayerTreeImpl::animationRegistrar() const { | 323 AnimationRegistrar* LayerTreeImpl::animationRegistrar() const { |
| 331 return layer_tree_host_impl_->animationRegistrar(); | 324 return layer_tree_host_impl_->animationRegistrar(); |
| 332 } | 325 } |
| 333 | 326 |
| 334 const PinchZoomViewport& LayerTreeImpl::pinch_zoom_viewport() const { | 327 const PinchZoomViewport& LayerTreeImpl::pinch_zoom_viewport() const { |
| 335 return layer_tree_host_impl_->pinchZoomViewport(); | 328 return layer_tree_host_impl_->pinchZoomViewport(); |
| 336 } | 329 } |
| 337 | 330 |
| 338 } // namespace cc | 331 } // namespace cc |
| OLD | NEW |