OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/layers/layer_impl.h" | 5 #include "cc/layers/layer_impl.h" |
6 | 6 |
7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
8 #include "base/debug/trace_event_argument.h" | 8 #include "base/debug/trace_event_argument.h" |
9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
(...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
764 | 764 |
765 layer_tree_impl_->DidAnimateScrollOffset(); | 765 layer_tree_impl_->DidAnimateScrollOffset(); |
766 } | 766 } |
767 | 767 |
768 void LayerImpl::OnAnimationWaitingForDeletion() {} | 768 void LayerImpl::OnAnimationWaitingForDeletion() {} |
769 | 769 |
770 bool LayerImpl::IsActive() const { | 770 bool LayerImpl::IsActive() const { |
771 return layer_tree_impl_->IsActiveTree(); | 771 return layer_tree_impl_->IsActiveTree(); |
772 } | 772 } |
773 | 773 |
774 // TODO(aelias): Convert so that bounds returns SizeF. | |
775 gfx::Size LayerImpl::bounds() const { | 774 gfx::Size LayerImpl::bounds() const { |
776 return gfx::ToCeiledSize(gfx::SizeF(bounds_.width() + bounds_delta_.x(), | 775 gfx::Vector2d delta = gfx::ToCeiledVector2d(bounds_delta_); |
777 bounds_.height() + bounds_delta_.y())); | 776 return gfx::Size(bounds_.width() + delta.x(), |
| 777 bounds_.height() + delta.y()); |
| 778 } |
| 779 |
| 780 gfx::SizeF LayerImpl::BoundsForScrolling() const { |
| 781 return gfx::SizeF(bounds_.width() + bounds_delta_.x(), |
| 782 bounds_.height() + bounds_delta_.y()); |
778 } | 783 } |
779 | 784 |
780 void LayerImpl::SetBounds(const gfx::Size& bounds) { | 785 void LayerImpl::SetBounds(const gfx::Size& bounds) { |
781 if (bounds_ == bounds) | 786 if (bounds_ == bounds) |
782 return; | 787 return; |
783 | 788 |
784 bounds_ = bounds; | 789 bounds_ = bounds; |
785 | 790 |
786 ScrollbarParametersDidChange(true); | 791 ScrollbarParametersDidChange(true); |
787 if (masks_to_bounds()) | 792 if (masks_to_bounds()) |
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1163 | 1168 |
1164 gfx::ScrollOffset LayerImpl::MaxScrollOffset() const { | 1169 gfx::ScrollOffset LayerImpl::MaxScrollOffset() const { |
1165 if (!scroll_clip_layer_ || bounds().IsEmpty()) | 1170 if (!scroll_clip_layer_ || bounds().IsEmpty()) |
1166 return gfx::ScrollOffset(); | 1171 return gfx::ScrollOffset(); |
1167 | 1172 |
1168 LayerImpl const* page_scale_layer = layer_tree_impl()->page_scale_layer(); | 1173 LayerImpl const* page_scale_layer = layer_tree_impl()->page_scale_layer(); |
1169 DCHECK(this != page_scale_layer); | 1174 DCHECK(this != page_scale_layer); |
1170 DCHECK(this != layer_tree_impl()->InnerViewportScrollLayer() || | 1175 DCHECK(this != layer_tree_impl()->InnerViewportScrollLayer() || |
1171 IsContainerForFixedPositionLayers()); | 1176 IsContainerForFixedPositionLayers()); |
1172 | 1177 |
1173 gfx::SizeF scaled_scroll_bounds(bounds()); | 1178 gfx::SizeF scaled_scroll_bounds(BoundsForScrolling()); |
1174 | 1179 |
1175 float scale_factor = 1.f; | 1180 float scale_factor = 1.f; |
1176 for (LayerImpl const* current_layer = this; | 1181 for (LayerImpl const* current_layer = this; |
1177 current_layer != scroll_clip_layer_; | 1182 current_layer != scroll_clip_layer_; |
1178 current_layer = current_layer->parent()) { | 1183 current_layer = current_layer->parent()) { |
1179 DCHECK(current_layer); | 1184 DCHECK(current_layer); |
1180 float current_layer_scale = 1.f; | 1185 float current_layer_scale = 1.f; |
1181 | 1186 |
1182 const gfx::Transform& layer_transform = current_layer->transform(); | 1187 const gfx::Transform& layer_transform = current_layer->transform(); |
1183 if (current_layer == page_scale_layer) { | 1188 if (current_layer == page_scale_layer) { |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1231 void LayerImpl::SetScrollbarPosition(ScrollbarLayerImplBase* scrollbar_layer, | 1236 void LayerImpl::SetScrollbarPosition(ScrollbarLayerImplBase* scrollbar_layer, |
1232 LayerImpl* scrollbar_clip_layer, | 1237 LayerImpl* scrollbar_clip_layer, |
1233 bool on_resize) const { | 1238 bool on_resize) const { |
1234 DCHECK(scrollbar_layer); | 1239 DCHECK(scrollbar_layer); |
1235 LayerImpl* page_scale_layer = layer_tree_impl()->page_scale_layer(); | 1240 LayerImpl* page_scale_layer = layer_tree_impl()->page_scale_layer(); |
1236 | 1241 |
1237 DCHECK(this != page_scale_layer); | 1242 DCHECK(this != page_scale_layer); |
1238 DCHECK(scrollbar_clip_layer); | 1243 DCHECK(scrollbar_clip_layer); |
1239 DCHECK(this != layer_tree_impl()->InnerViewportScrollLayer() || | 1244 DCHECK(this != layer_tree_impl()->InnerViewportScrollLayer() || |
1240 IsContainerForFixedPositionLayers()); | 1245 IsContainerForFixedPositionLayers()); |
1241 gfx::RectF clip_rect(gfx::PointF(), scrollbar_clip_layer->bounds()); | 1246 gfx::RectF clip_rect(gfx::PointF(), |
| 1247 scrollbar_clip_layer->BoundsForScrolling()); |
1242 | 1248 |
1243 // See comment in MaxScrollOffset() regarding the use of the content layer | 1249 // See comment in MaxScrollOffset() regarding the use of the content layer |
1244 // bounds here. | 1250 // bounds here. |
1245 gfx::RectF scroll_rect(gfx::PointF(), bounds()); | 1251 gfx::RectF scroll_rect(gfx::PointF(), BoundsForScrolling()); |
1246 | 1252 |
1247 if (scroll_rect.size().IsEmpty()) | 1253 if (scroll_rect.size().IsEmpty()) |
1248 return; | 1254 return; |
1249 | 1255 |
1250 // TODO(wjmaclean) This computation is nearly identical to the one in | 1256 // TODO(wjmaclean) This computation is nearly identical to the one in |
1251 // MaxScrollOffset. Find some way to combine these. | 1257 // MaxScrollOffset. Find some way to combine these. |
1252 gfx::ScrollOffset current_offset; | 1258 gfx::ScrollOffset current_offset; |
1253 for (LayerImpl const* current_layer = this; | 1259 for (LayerImpl const* current_layer = this; |
1254 current_layer != scrollbar_clip_layer; | 1260 current_layer != scrollbar_clip_layer; |
1255 current_layer = current_layer->parent()) { | 1261 current_layer = current_layer->parent()) { |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1556 } | 1562 } |
1557 | 1563 |
1558 void LayerImpl::NotifyAnimationFinished( | 1564 void LayerImpl::NotifyAnimationFinished( |
1559 base::TimeTicks monotonic_time, | 1565 base::TimeTicks monotonic_time, |
1560 Animation::TargetProperty target_property) { | 1566 Animation::TargetProperty target_property) { |
1561 if (target_property == Animation::ScrollOffset) | 1567 if (target_property == Animation::ScrollOffset) |
1562 layer_tree_impl_->InputScrollAnimationFinished(); | 1568 layer_tree_impl_->InputScrollAnimationFinished(); |
1563 } | 1569 } |
1564 | 1570 |
1565 } // namespace cc | 1571 } // namespace cc |
OLD | NEW |