| 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 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 // Pending tree never has sent scroll deltas | 358 // Pending tree never has sent scroll deltas |
| 359 DCHECK(layer_tree_impl()->IsActiveTree()); | 359 DCHECK(layer_tree_impl()->IsActiveTree()); |
| 360 | 360 |
| 361 if (sent_scroll_delta_ == sent_scroll_delta) | 361 if (sent_scroll_delta_ == sent_scroll_delta) |
| 362 return; | 362 return; |
| 363 | 363 |
| 364 sent_scroll_delta_ = sent_scroll_delta; | 364 sent_scroll_delta_ = sent_scroll_delta; |
| 365 } | 365 } |
| 366 | 366 |
| 367 gfx::Vector2dF LayerImpl::ScrollBy(const gfx::Vector2dF& scroll) { | 367 gfx::Vector2dF LayerImpl::ScrollBy(const gfx::Vector2dF& scroll) { |
| 368 gfx::Vector2dF adjusted_scroll = scroll; |
| 369 if (layer_tree_impl()->settings().use_pinch_virtual_viewport) { |
| 370 if (!user_scrollable_horizontal_) |
| 371 adjusted_scroll.set_x(0); |
| 372 if (!user_scrollable_vertical_) |
| 373 adjusted_scroll.set_y(0); |
| 374 } |
| 368 DCHECK(scrollable()); | 375 DCHECK(scrollable()); |
| 369 gfx::Vector2dF min_delta = -ScrollOffsetToVector2dF(scroll_offset_); | 376 gfx::Vector2dF min_delta = -ScrollOffsetToVector2dF(scroll_offset_); |
| 370 gfx::Vector2dF max_delta = MaxScrollOffset().DeltaFrom(scroll_offset_); | 377 gfx::Vector2dF max_delta = MaxScrollOffset().DeltaFrom(scroll_offset_); |
| 371 // Clamp new_delta so that position + delta stays within scroll bounds. | 378 // Clamp new_delta so that position + delta stays within scroll bounds. |
| 372 gfx::Vector2dF new_delta = (ScrollDelta() + scroll); | 379 gfx::Vector2dF new_delta = (ScrollDelta() + adjusted_scroll); |
| 373 new_delta.SetToMax(min_delta); | 380 new_delta.SetToMax(min_delta); |
| 374 new_delta.SetToMin(max_delta); | 381 new_delta.SetToMin(max_delta); |
| 375 gfx::Vector2dF unscrolled = | 382 gfx::Vector2dF unscrolled = |
| 376 ScrollDelta() + scroll - new_delta; | 383 ScrollDelta() + scroll - new_delta; |
| 377 SetScrollDelta(new_delta); | 384 SetScrollDelta(new_delta); |
| 378 | 385 |
| 379 return unscrolled; | 386 return unscrolled; |
| 380 } | 387 } |
| 381 | 388 |
| 382 void LayerImpl::SetScrollClipLayer(int scroll_clip_layer_id) { | 389 void LayerImpl::SetScrollClipLayer(int scroll_clip_layer_id) { |
| (...skipping 1172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1555 } | 1562 } |
| 1556 | 1563 |
| 1557 void LayerImpl::NotifyAnimationFinished( | 1564 void LayerImpl::NotifyAnimationFinished( |
| 1558 base::TimeTicks monotonic_time, | 1565 base::TimeTicks monotonic_time, |
| 1559 Animation::TargetProperty target_property) { | 1566 Animation::TargetProperty target_property) { |
| 1560 if (target_property == Animation::ScrollOffset) | 1567 if (target_property == Animation::ScrollOffset) |
| 1561 layer_tree_impl_->InputScrollAnimationFinished(); | 1568 layer_tree_impl_->InputScrollAnimationFinished(); |
| 1562 } | 1569 } |
| 1563 | 1570 |
| 1564 } // namespace cc | 1571 } // namespace cc |
| OLD | NEW |