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/trees/layer_tree_impl.h" | 5 #include "cc/trees/layer_tree_impl.h" |
6 | 6 |
7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
8 #include "cc/animation/keyframed_animation_curve.h" | 8 #include "cc/animation/keyframed_animation_curve.h" |
9 #include "cc/animation/scrollbar_animation_controller.h" | 9 #include "cc/animation/scrollbar_animation_controller.h" |
10 #include "cc/debug/traced_value.h" | 10 #include "cc/debug/traced_value.h" |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
129 | 129 |
130 if (hud_layer()) | 130 if (hud_layer()) |
131 target_tree->set_hud_layer(static_cast<HeadsUpDisplayLayerImpl*>( | 131 target_tree->set_hud_layer(static_cast<HeadsUpDisplayLayerImpl*>( |
132 LayerTreeHostCommon::FindLayerInSubtree( | 132 LayerTreeHostCommon::FindLayerInSubtree( |
133 target_tree->root_layer(), hud_layer()->id()))); | 133 target_tree->root_layer(), hud_layer()->id()))); |
134 else | 134 else |
135 target_tree->set_hud_layer(NULL); | 135 target_tree->set_hud_layer(NULL); |
136 } | 136 } |
137 | 137 |
138 LayerImpl* LayerTreeImpl::RootScrollLayer() const { | 138 LayerImpl* LayerTreeImpl::RootScrollLayer() const { |
139 DCHECK(IsActiveTree()); | |
140 return root_scroll_layer_; | 139 return root_scroll_layer_; |
141 } | 140 } |
142 | 141 |
143 LayerImpl* LayerTreeImpl::RootClipLayer() const { | 142 LayerImpl* LayerTreeImpl::RootClipLayer() const { |
144 return root_scroll_layer_ ? root_scroll_layer_->parent() : NULL; | 143 return root_scroll_layer_ ? root_scroll_layer_->parent() : NULL; |
145 } | 144 } |
146 | 145 |
147 LayerImpl* LayerTreeImpl::CurrentlyScrollingLayer() const { | 146 LayerImpl* LayerTreeImpl::CurrentlyScrollingLayer() const { |
148 DCHECK(IsActiveTree()); | 147 DCHECK(IsActiveTree()); |
149 return currently_scrolling_layer_; | 148 return currently_scrolling_layer_; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
202 UpdateMaxScrollOffset(); | 201 UpdateMaxScrollOffset(); |
203 set_needs_update_draw_properties(); | 202 set_needs_update_draw_properties(); |
204 } | 203 } |
205 | 204 |
206 gfx::SizeF LayerTreeImpl::ScrollableViewportSize() const { | 205 gfx::SizeF LayerTreeImpl::ScrollableViewportSize() const { |
207 return gfx::ScaleSize(layer_tree_host_impl_->VisibleViewportSize(), | 206 return gfx::ScaleSize(layer_tree_host_impl_->VisibleViewportSize(), |
208 1.0f / total_page_scale_factor()); | 207 1.0f / total_page_scale_factor()); |
209 } | 208 } |
210 | 209 |
211 void LayerTreeImpl::UpdateMaxScrollOffset() { | 210 void LayerTreeImpl::UpdateMaxScrollOffset() { |
212 if (!root_scroll_layer_ || !root_scroll_layer_->children().size()) | 211 LayerImpl* root_scroll = RootScrollLayer(); |
212 if (!root_scroll || !root_scroll->children().size()) | |
213 return; | 213 return; |
214 | 214 |
215 gfx::Vector2dF max_scroll = gfx::Rect(ScrollableSize()).bottom_right() - | 215 gfx::Vector2dF max_scroll = gfx::Rect(ScrollableSize()).bottom_right() - |
216 gfx::RectF(ScrollableViewportSize()).bottom_right(); | 216 gfx::RectF(ScrollableViewportSize()).bottom_right(); |
217 | 217 |
218 // The scrollable viewport size is based on device viewport instead of Blink's | |
219 // container layer, so we need to adjust for non-overlay scrollbars. | |
220 ScrollbarLayerImpl* horiz = root_scroll->horizontal_scrollbar_layer(); | |
221 ScrollbarLayerImpl* vertical = root_scroll->vertical_scrollbar_layer(); | |
222 if (horiz && !horiz->is_overlay_scrollbar()) | |
223 max_scroll.set_y(max_scroll.y() + horiz->thumb_thickness()); | |
enne (OOO)
2013/07/12 23:48:05
I still don't really understand this. You can scr
enne (OOO)
2013/07/12 23:50:30
Eh, sorry, misreading code late on a Friday.
I gu
| |
224 if (vertical && !vertical->is_overlay_scrollbar()) | |
225 max_scroll.set_x(max_scroll.x() + vertical->thumb_thickness()); | |
226 | |
218 // The viewport may be larger than the contents in some cases, such as | 227 // The viewport may be larger than the contents in some cases, such as |
219 // having a vertical scrollbar but no horizontal overflow. | 228 // having a vertical scrollbar but no horizontal overflow. |
220 max_scroll.SetToMax(gfx::Vector2dF()); | 229 max_scroll.SetToMax(gfx::Vector2dF()); |
221 | 230 |
222 root_scroll_layer_->SetMaxScrollOffset(gfx::ToFlooredVector2d(max_scroll)); | 231 root_scroll_layer_->SetMaxScrollOffset(gfx::ToFlooredVector2d(max_scroll)); |
223 } | 232 } |
224 | 233 |
225 void LayerTreeImpl::UpdateSolidColorScrollbars() { | 234 void LayerTreeImpl::UpdateSolidColorScrollbars() { |
226 DCHECK(settings().solid_color_scrollbars); | 235 DCHECK(settings().solid_color_scrollbars); |
227 | 236 |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
586 const std::vector<LayerImpl*> LayerTreeImpl::LayersWithCopyOutputRequest() | 595 const std::vector<LayerImpl*> LayerTreeImpl::LayersWithCopyOutputRequest() |
587 const { | 596 const { |
588 // Only the active tree needs to know about layers with copy requests, as | 597 // Only the active tree needs to know about layers with copy requests, as |
589 // they are aborted if not serviced during draw. | 598 // they are aborted if not serviced during draw. |
590 DCHECK(IsActiveTree()); | 599 DCHECK(IsActiveTree()); |
591 | 600 |
592 return layers_with_copy_output_request_; | 601 return layers_with_copy_output_request_; |
593 } | 602 } |
594 | 603 |
595 } // namespace cc | 604 } // namespace cc |
OLD | NEW |