Chromium Code Reviews| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 200 scroll_state->delta_consumed_for_scroll_sequence() && | 200 scroll_state->delta_consumed_for_scroll_sequence() && |
| 201 scroll_state->current_native_scrolling_node()->owner_id != id()) { | 201 scroll_state->current_native_scrolling_node()->owner_id != id()) { |
| 202 return; | 202 return; |
| 203 } | 203 } |
| 204 | 204 |
| 205 ApplyScroll(scroll_state); | 205 ApplyScroll(scroll_state); |
| 206 } | 206 } |
| 207 | 207 |
| 208 void LayerImpl::ApplyScroll(ScrollState* scroll_state) { | 208 void LayerImpl::ApplyScroll(ScrollState* scroll_state) { |
| 209 DCHECK(scroll_state); | 209 DCHECK(scroll_state); |
| 210 layer_tree_impl()->ApplyScroll(this, scroll_state); | 210 ScrollNode* node = layer_tree_impl()->property_trees()->scroll_tree.Node( |
| 211 scroll_tree_index()); | |
| 212 layer_tree_impl()->ApplyScroll(node, scroll_state); | |
| 211 } | 213 } |
| 212 | 214 |
| 213 void LayerImpl::SetNumDescendantsThatDrawContent(int num_descendants) { | 215 void LayerImpl::SetNumDescendantsThatDrawContent(int num_descendants) { |
| 214 if (num_descendants_that_draw_content_ == num_descendants) | 216 if (num_descendants_that_draw_content_ == num_descendants) |
| 215 return; | 217 return; |
| 216 num_descendants_that_draw_content_ = num_descendants; | 218 num_descendants_that_draw_content_ = num_descendants; |
| 217 SetNeedsPushProperties(); | 219 SetNeedsPushProperties(); |
| 218 } | 220 } |
| 219 | 221 |
| 220 void LayerImpl::SetClipParent(LayerImpl* ancestor) { | 222 void LayerImpl::SetClipParent(LayerImpl* ancestor) { |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 420 } | 422 } |
| 421 } | 423 } |
| 422 | 424 |
| 423 void LayerImpl::GetContentsResourceId(ResourceId* resource_id, | 425 void LayerImpl::GetContentsResourceId(ResourceId* resource_id, |
| 424 gfx::Size* resource_size) const { | 426 gfx::Size* resource_size) const { |
| 425 NOTREACHED(); | 427 NOTREACHED(); |
| 426 *resource_id = 0; | 428 *resource_id = 0; |
| 427 } | 429 } |
| 428 | 430 |
| 429 gfx::Vector2dF LayerImpl::ScrollBy(const gfx::Vector2dF& scroll) { | 431 gfx::Vector2dF LayerImpl::ScrollBy(const gfx::Vector2dF& scroll) { |
| 430 gfx::ScrollOffset adjusted_scroll(scroll); | 432 ScrollTree& scroll_tree = layer_tree_impl()->property_trees()->scroll_tree; |
| 431 if (!user_scrollable_horizontal_) | 433 ScrollNode* scroll_node = scroll_tree.Node(scroll_tree_index()); |
| 432 adjusted_scroll.set_x(0); | 434 return scroll_tree.ScrollBy(scroll_node, scroll, layer_tree_impl()); |
| 433 if (!user_scrollable_vertical_) | |
| 434 adjusted_scroll.set_y(0); | |
| 435 DCHECK(scrollable()); | |
| 436 gfx::ScrollOffset old_offset = CurrentScrollOffset(); | |
| 437 gfx::ScrollOffset new_offset = | |
| 438 ClampScrollOffsetToLimits(old_offset + adjusted_scroll); | |
| 439 SetCurrentScrollOffset(new_offset); | |
| 440 | |
| 441 gfx::ScrollOffset unscrolled = | |
| 442 old_offset + gfx::ScrollOffset(scroll) - new_offset; | |
| 443 return gfx::Vector2dF(unscrolled.x(), unscrolled.y()); | |
| 444 } | 435 } |
| 445 | 436 |
| 446 void LayerImpl::SetScrollClipLayer(int scroll_clip_layer_id) { | 437 void LayerImpl::SetScrollClipLayer(int scroll_clip_layer_id) { |
| 447 if (scroll_clip_layer_id_ == scroll_clip_layer_id) | 438 if (scroll_clip_layer_id_ == scroll_clip_layer_id) |
| 448 return; | 439 return; |
| 449 | 440 |
| 450 layer_tree_impl()->UnregisterScrollLayer(this); | 441 layer_tree_impl()->UnregisterScrollLayer(this); |
| 451 scroll_clip_layer_id_ = scroll_clip_layer_id; | 442 scroll_clip_layer_id_ = scroll_clip_layer_id; |
| 452 layer_tree_impl()->RegisterScrollLayer(this); | 443 layer_tree_impl()->RegisterScrollLayer(this); |
| 453 } | 444 } |
| 454 | 445 |
| 455 LayerImpl* LayerImpl::scroll_clip_layer() const { | 446 LayerImpl* LayerImpl::scroll_clip_layer() const { |
| 456 return layer_tree_impl()->LayerById(scroll_clip_layer_id_); | 447 return layer_tree_impl()->LayerById(scroll_clip_layer_id_); |
| 457 } | 448 } |
| 458 | 449 |
| 459 bool LayerImpl::scrollable() const { | 450 bool LayerImpl::scrollable() const { |
| 460 return scroll_clip_layer_id_ != Layer::INVALID_ID; | 451 return scroll_clip_layer_id_ != Layer::INVALID_ID; |
| 461 } | 452 } |
| 462 | 453 |
| 454 void LayerImpl::set_user_scrollable_horizontal(bool scrollable) { | |
| 455 user_scrollable_horizontal_ = scrollable; | |
| 456 if (!layer_tree_impl_->property_trees()->needs_rebuild && layer_tree_impl_ && | |
|
ajuma
2016/03/16 21:49:24
Horizontal/vertical scrollability should never cha
sunxd
2016/03/16 23:30:23
Done.
| |
| 457 scroll_tree_index_ != -1) | |
| 458 layer_tree_impl_->property_trees() | |
| 459 ->scroll_tree.Node(scroll_tree_index_) | |
| 460 ->data.user_scrollable_horizontal = scrollable; | |
| 461 } | |
| 462 | |
| 463 void LayerImpl::set_user_scrollable_vertical(bool scrollable) { | |
| 464 user_scrollable_vertical_ = scrollable; | |
| 465 if (!layer_tree_impl_->property_trees()->needs_rebuild && layer_tree_impl_ && | |
| 466 scroll_tree_index_ != -1) | |
| 467 layer_tree_impl_->property_trees() | |
| 468 ->scroll_tree.Node(scroll_tree_index_) | |
| 469 ->data.user_scrollable_vertical = scrollable; | |
| 470 } | |
| 471 | |
| 463 bool LayerImpl::user_scrollable(ScrollbarOrientation orientation) const { | 472 bool LayerImpl::user_scrollable(ScrollbarOrientation orientation) const { |
| 464 return (orientation == HORIZONTAL) ? user_scrollable_horizontal_ | 473 return (orientation == HORIZONTAL) ? user_scrollable_horizontal_ |
| 465 : user_scrollable_vertical_; | 474 : user_scrollable_vertical_; |
| 466 } | 475 } |
| 467 | 476 |
| 468 skia::RefPtr<SkPicture> LayerImpl::GetPicture() { | 477 skia::RefPtr<SkPicture> LayerImpl::GetPicture() { |
| 469 return skia::RefPtr<SkPicture>(); | 478 return skia::RefPtr<SkPicture>(); |
| 470 } | 479 } |
| 471 | 480 |
| 472 scoped_ptr<LayerImpl> LayerImpl::CreateLayerImpl(LayerTreeImpl* tree_impl) { | 481 scoped_ptr<LayerImpl> LayerImpl::CreateLayerImpl(LayerTreeImpl* tree_impl) { |
| (...skipping 1108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1581 .layer_transforms_should_scale_layer_contents) { | 1590 .layer_transforms_should_scale_layer_contents) { |
| 1582 return default_scale; | 1591 return default_scale; |
| 1583 } | 1592 } |
| 1584 | 1593 |
| 1585 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents( | 1594 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents( |
| 1586 DrawTransform(), default_scale); | 1595 DrawTransform(), default_scale); |
| 1587 return std::max(transform_scales.x(), transform_scales.y()); | 1596 return std::max(transform_scales.x(), transform_scales.y()); |
| 1588 } | 1597 } |
| 1589 | 1598 |
| 1590 } // namespace cc | 1599 } // namespace cc |
| OLD | NEW |