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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
78 | 78 |
79 void LayerTreeImpl::ClearCurrentlyScrollingLayer() { | 79 void LayerTreeImpl::ClearCurrentlyScrollingLayer() { |
80 currently_scrolling_layer_ = NULL; | 80 currently_scrolling_layer_ = NULL; |
81 scrolling_layer_id_from_previous_tree_ = 0; | 81 scrolling_layer_id_from_previous_tree_ = 0; |
82 } | 82 } |
83 | 83 |
84 void LayerTreeImpl::UpdateMaxScrollOffset() { | 84 void LayerTreeImpl::UpdateMaxScrollOffset() { |
85 if (!root_scroll_layer() || !root_scroll_layer()->children().size()) | 85 if (!root_scroll_layer() || !root_scroll_layer()->children().size()) |
86 return; | 86 return; |
87 | 87 |
88 gfx::SizeF view_bounds = device_viewport_size(); | 88 gfx::SizeF view_bounds; |
89 if (LayerImpl* clip_layer = root_scroll_layer()->parent()) { | 89 if (!settings().pageScalePinchZoomEnabled) { |
90 // Compensate for non-overlay scrollbars. | 90 view_bounds = device_viewport_size(); |
91 if (clip_layer->masksToBounds()) | 91 if (LayerImpl* clip_layer = root_scroll_layer()->parent()) { |
92 view_bounds = gfx::ScaleSize(clip_layer->bounds(), device_scale_factor()); | 92 // Compensate for non-overlay scrollbars. |
93 if (clip_layer->masksToBounds()) | |
94 view_bounds = gfx::ScaleSize(clip_layer->bounds(), device_scale_factor() ); | |
danakj
2013/01/17 18:02:49
This bound here (and above) is in physical pixels,
aelias_OOO_until_Jul13
2013/01/17 19:59:46
This clause is for the old coordinate space so it
| |
95 } | |
96 view_bounds.Scale(1 / pinch_zoom_viewport().page_scale_delta()); | |
97 } else { | |
98 view_bounds = layout_viewport_size(); | |
93 } | 99 } |
94 | 100 |
95 gfx::Size content_bounds = ContentSize(); | 101 gfx::Vector2dF max_scroll = gfx::Rect(ScrollableSize()).bottom_right() - |
danakj
2013/01/17 18:02:49
I do like this :)
| |
96 if (settings().pageScalePinchZoomEnabled) { | |
97 // Pinch with pageScale scrolls entirely in layout space. ContentSize | |
98 // returns the bounds including the page scale factor, so calculate the | |
99 // pre page-scale layout size here. | |
100 float page_scale_factor = pinch_zoom_viewport().page_scale_factor(); | |
101 content_bounds.set_width(content_bounds.width() / page_scale_factor); | |
102 content_bounds.set_height(content_bounds.height() / page_scale_factor); | |
103 } else { | |
104 view_bounds.Scale(1 / pinch_zoom_viewport().page_scale_delta()); | |
105 } | |
106 | |
107 gfx::Vector2dF max_scroll = gfx::Rect(content_bounds).bottom_right() - | |
108 gfx::RectF(view_bounds).bottom_right(); | 102 gfx::RectF(view_bounds).bottom_right(); |
109 max_scroll.Scale(1 / device_scale_factor()); | |
110 | 103 |
111 // The viewport may be larger than the contents in some cases, such as | 104 // The viewport may be larger than the contents in some cases, such as |
112 // having a vertical scrollbar but no horizontal overflow. | 105 // having a vertical scrollbar but no horizontal overflow. |
113 max_scroll.ClampToMin(gfx::Vector2dF()); | 106 max_scroll.ClampToMin(gfx::Vector2dF()); |
114 | 107 |
115 root_scroll_layer()->setMaxScrollOffset(gfx::ToFlooredVector2d(max_scroll)); | 108 root_scroll_layer()->setMaxScrollOffset(gfx::ToFlooredVector2d(max_scroll)); |
116 } | 109 } |
117 | 110 |
118 void LayerTreeImpl::UpdateDrawProperties() { | 111 void LayerTreeImpl::UpdateDrawProperties() { |
119 render_surface_layer_list_.clear(); | 112 render_surface_layer_list_.clear(); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
168 | 161 |
169 return true; | 162 return true; |
170 } | 163 } |
171 | 164 |
172 const LayerTreeImpl::LayerList& LayerTreeImpl::RenderSurfaceLayerList() const { | 165 const LayerTreeImpl::LayerList& LayerTreeImpl::RenderSurfaceLayerList() const { |
173 // If this assert triggers, then the list is dirty. | 166 // If this assert triggers, then the list is dirty. |
174 DCHECK(!layer_tree_host_impl_->needsUpdateDrawProperties()); | 167 DCHECK(!layer_tree_host_impl_->needsUpdateDrawProperties()); |
175 return render_surface_layer_list_; | 168 return render_surface_layer_list_; |
176 } | 169 } |
177 | 170 |
178 gfx::Size LayerTreeImpl::ContentSize() const { | 171 gfx::Size LayerTreeImpl::ScrollableSize() const { |
179 // TODO(aelias): Hardcoding the first child here is weird. Think of | |
180 // a cleaner way to get the contentBounds on the Impl side. | |
181 if (!root_scroll_layer() || root_scroll_layer()->children().empty()) | 172 if (!root_scroll_layer() || root_scroll_layer()->children().empty()) |
182 return gfx::Size(); | 173 return gfx::Size(); |
183 return root_scroll_layer()->children()[0]->contentBounds(); | 174 return root_scroll_layer()->children()[0]->bounds(); |
184 } | 175 } |
185 | 176 |
186 LayerImpl* LayerTreeImpl::LayerById(int id) { | 177 LayerImpl* LayerTreeImpl::LayerById(int id) { |
187 LayerIdMap::iterator iter = layer_id_map_.find(id); | 178 LayerIdMap::iterator iter = layer_id_map_.find(id); |
188 return iter != layer_id_map_.end() ? iter->second : NULL; | 179 return iter != layer_id_map_.end() ? iter->second : NULL; |
189 } | 180 } |
190 | 181 |
191 void LayerTreeImpl::RegisterLayer(LayerImpl* layer) { | 182 void LayerTreeImpl::RegisterLayer(LayerImpl* layer) { |
192 DCHECK(!LayerById(layer->id())); | 183 DCHECK(!LayerById(layer->id())); |
193 layer_id_map_[layer->id()] = layer; | 184 layer_id_map_[layer->id()] = layer; |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
299 | 290 |
300 AnimationRegistrar* LayerTreeImpl::animationRegistrar() const { | 291 AnimationRegistrar* LayerTreeImpl::animationRegistrar() const { |
301 return layer_tree_host_impl_->animationRegistrar(); | 292 return layer_tree_host_impl_->animationRegistrar(); |
302 } | 293 } |
303 | 294 |
304 const PinchZoomViewport& LayerTreeImpl::pinch_zoom_viewport() const { | 295 const PinchZoomViewport& LayerTreeImpl::pinch_zoom_viewport() const { |
305 return layer_tree_host_impl_->pinchZoomViewport(); | 296 return layer_tree_host_impl_->pinchZoomViewport(); |
306 } | 297 } |
307 | 298 |
308 } // namespace cc | 299 } // namespace cc |
OLD | NEW |