Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(569)

Side by Side Diff: content/child/fling_animator_impl_android.cc

Issue 136173004: Early terminate flings when scrolling impossible (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "content/child/fling_animator_impl_android.h" 5 #include "content/child/fling_animator_impl_android.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "third_party/WebKit/public/platform/WebFloatSize.h" 8 #include "third_party/WebKit/public/platform/WebFloatSize.h"
9 #include "third_party/WebKit/public/platform/WebGestureCurveTarget.h" 9 #include "third_party/WebKit/public/platform/WebGestureCurveTarget.h"
10 #include "ui/gfx/android/view_configuration.h" 10 #include "ui/gfx/android/view_configuration.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 blink::WebGestureCurveTarget* target) { 65 blink::WebGestureCurveTarget* target) {
66 // Historically, Android's Scroller used |currentAnimationTimeMillis()|, 66 // Historically, Android's Scroller used |currentAnimationTimeMillis()|,
67 // which is equivalent to gfx::FrameTime::Now(). In practice, this produces 67 // which is equivalent to gfx::FrameTime::Now(). In practice, this produces
68 // smoother results than using |time|, so continue using FrameTime::Now(). 68 // smoother results than using |time|, so continue using FrameTime::Now().
69 // TODO(jdduke): Use |time| upon resolution of crbug.com/345459. 69 // TODO(jdduke): Use |time| upon resolution of crbug.com/345459.
70 if (!scroller_.ComputeScrollOffset(gfx::FrameTime::Now())) { 70 if (!scroller_.ComputeScrollOffset(gfx::FrameTime::Now())) {
71 is_active_ = false; 71 is_active_ = false;
72 return false; 72 return false;
73 } 73 }
74 74
75 target->notifyCurrentFlingVelocity(blink::WebFloatSize(
76 scroller_.GetCurrVelocityX(), scroller_.GetCurrVelocityY()));
77
78 gfx::PointF current_position(scroller_.GetCurrX(), scroller_.GetCurrY()); 75 gfx::PointF current_position(scroller_.GetCurrX(), scroller_.GetCurrY());
79 gfx::Vector2dF scroll_amount(current_position - last_position_); 76 gfx::Vector2dF scroll_amount(current_position - last_position_);
80 last_position_ = current_position; 77 last_position_ = current_position;
81 78
82 // scrollBy() could delete this curve if the animation is over, so don't touch 79 // scrollBy() could delete this curve if the animation is over, so don't touch
83 // any member variables after making that call. 80 // any member variables after making that call.
84 target->scrollBy(blink::WebFloatSize(scroll_amount)); 81 return target->scrollBy(blink::WebFloatSize(scroll_amount),
85 return true; 82 blink::WebFloatSize(scroller_.GetCurrVelocityX(),
83 scroller_.GetCurrVelocityY()));
86 } 84 }
87 85
88 FlingAnimatorImpl* FlingAnimatorImpl::CreateAndroidGestureCurve( 86 FlingAnimatorImpl* FlingAnimatorImpl::CreateAndroidGestureCurve(
89 const blink::WebFloatPoint& velocity, 87 const blink::WebFloatPoint& velocity,
90 const blink::WebSize&) { 88 const blink::WebSize&) {
91 FlingAnimatorImpl* gesture_curve = new FlingAnimatorImpl(); 89 FlingAnimatorImpl* gesture_curve = new FlingAnimatorImpl();
92 gesture_curve->StartFling(velocity); 90 gesture_curve->StartFling(velocity);
93 return gesture_curve; 91 return gesture_curve;
94 } 92 }
95 93
96 } // namespace content 94 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/android/in_process/synchronous_input_event_filter.cc ('k') | content/child/touch_fling_gesture_curve.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698