OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/animation/scroll_offset_animations_impl.h" | 5 #include "cc/animation/scroll_offset_animations_impl.h" |
6 | 6 |
7 #include "cc/animation/animation_events.h" | 7 #include "cc/animation/animation_events.h" |
8 #include "cc/animation/animation_host.h" | 8 #include "cc/animation/animation_host.h" |
9 #include "cc/animation/animation_id_provider.h" | 9 #include "cc/animation/animation_id_provider.h" |
10 #include "cc/animation/animation_player.h" | 10 #include "cc/animation/animation_player.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 const gfx::Vector2dF& scroll_delta, | 63 const gfx::Vector2dF& scroll_delta, |
64 const gfx::ScrollOffset& max_scroll_offset, | 64 const gfx::ScrollOffset& max_scroll_offset, |
65 base::TimeTicks frame_monotonic_time, | 65 base::TimeTicks frame_monotonic_time, |
66 base::TimeDelta delayed_by) { | 66 base::TimeDelta delayed_by) { |
67 DCHECK(scroll_offset_animation_player_); | 67 DCHECK(scroll_offset_animation_player_); |
68 if (!scroll_offset_animation_player_->element_animations()) | 68 if (!scroll_offset_animation_player_->element_animations()) |
69 return false; | 69 return false; |
70 | 70 |
71 DCHECK_EQ(element_id, scroll_offset_animation_player_->element_id()); | 71 DCHECK_EQ(element_id, scroll_offset_animation_player_->element_id()); |
72 | 72 |
73 Animation* animation = | 73 Animation* animation = scroll_offset_animation_player_->GetAnimation( |
74 scroll_offset_animation_player_->element_animations()->GetAnimation( | 74 TargetProperty::SCROLL_OFFSET); |
75 TargetProperty::SCROLL_OFFSET); | |
76 if (!animation) { | 75 if (!animation) { |
77 scroll_offset_animation_player_->DetachElement(); | 76 scroll_offset_animation_player_->DetachElement(); |
78 return false; | 77 return false; |
79 } | 78 } |
80 if (scroll_delta.IsZero()) | 79 if (scroll_delta.IsZero()) |
81 return true; | 80 return true; |
82 | 81 |
83 ScrollOffsetAnimationCurve* curve = | 82 ScrollOffsetAnimationCurve* curve = |
84 animation->curve()->ToScrollOffsetAnimationCurve(); | 83 animation->curve()->ToScrollOffsetAnimationCurve(); |
85 | 84 |
(...skipping 22 matching lines...) Expand all Loading... |
108 void ScrollOffsetAnimationsImpl::ScrollAnimationApplyAdjustment( | 107 void ScrollOffsetAnimationsImpl::ScrollAnimationApplyAdjustment( |
109 ElementId element_id, | 108 ElementId element_id, |
110 const gfx::Vector2dF& adjustment) { | 109 const gfx::Vector2dF& adjustment) { |
111 DCHECK(scroll_offset_animation_player_); | 110 DCHECK(scroll_offset_animation_player_); |
112 if (element_id != scroll_offset_animation_player_->element_id()) | 111 if (element_id != scroll_offset_animation_player_->element_id()) |
113 return; | 112 return; |
114 | 113 |
115 if (!scroll_offset_animation_player_->element_animations()) | 114 if (!scroll_offset_animation_player_->element_animations()) |
116 return; | 115 return; |
117 | 116 |
118 Animation* animation = | 117 Animation* animation = scroll_offset_animation_player_->GetAnimation( |
119 scroll_offset_animation_player_->element_animations()->GetAnimation( | 118 TargetProperty::SCROLL_OFFSET); |
120 TargetProperty::SCROLL_OFFSET); | |
121 if (!animation) | 119 if (!animation) |
122 return; | 120 return; |
123 | 121 |
124 std::unique_ptr<ScrollOffsetAnimationCurve> new_curve = | 122 std::unique_ptr<ScrollOffsetAnimationCurve> new_curve = |
125 animation->curve() | 123 animation->curve() |
126 ->ToScrollOffsetAnimationCurve() | 124 ->ToScrollOffsetAnimationCurve() |
127 ->CloneToScrollOffsetAnimationCurve(); | 125 ->CloneToScrollOffsetAnimationCurve(); |
128 new_curve->ApplyAdjustment(adjustment); | 126 new_curve->ApplyAdjustment(adjustment); |
129 | 127 |
130 std::unique_ptr<Animation> new_animation = Animation::Create( | 128 std::unique_ptr<Animation> new_animation = Animation::Create( |
(...skipping 29 matching lines...) Expand all Loading... |
160 ElementId element_id) { | 158 ElementId element_id) { |
161 if (scroll_offset_animation_player_->element_id() != element_id) { | 159 if (scroll_offset_animation_player_->element_id() != element_id) { |
162 if (scroll_offset_animation_player_->element_id()) | 160 if (scroll_offset_animation_player_->element_id()) |
163 scroll_offset_animation_player_->DetachElement(); | 161 scroll_offset_animation_player_->DetachElement(); |
164 if (element_id) | 162 if (element_id) |
165 scroll_offset_animation_player_->AttachElement(element_id); | 163 scroll_offset_animation_player_->AttachElement(element_id); |
166 } | 164 } |
167 } | 165 } |
168 | 166 |
169 } // namespace cc | 167 } // namespace cc |
OLD | NEW |