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

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

Issue 61553006: Rename WebKit namespace to blink (part 5) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « webkit/child/fling_animator_impl_android.h ('k') | webkit/child/fling_curve_configuration.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "webkit/child/fling_animator_impl_android.h" 5 #include "webkit/child/fling_animator_impl_android.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "base/android/scoped_java_ref.h" 8 #include "base/android/scoped_java_ref.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "jni/OverScroller_jni.h" 10 #include "jni/OverScroller_jni.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 float FlingAnimatorImpl::GetCurrentVelocity() 91 float FlingAnimatorImpl::GetCurrentVelocity()
92 { 92 {
93 JNIEnv* env = base::android::AttachCurrentThread(); 93 JNIEnv* env = base::android::AttachCurrentThread();
94 // TODO(jdduke): Add Java-side hooks for getCurrVelocityX/Y, and return 94 // TODO(jdduke): Add Java-side hooks for getCurrVelocityX/Y, and return
95 // vector velocity. 95 // vector velocity.
96 return JNI_OverScroller::Java_OverScroller_getCurrVelocity( 96 return JNI_OverScroller::Java_OverScroller_getCurrVelocity(
97 env, java_scroller_.obj()); 97 env, java_scroller_.obj());
98 } 98 }
99 99
100 bool FlingAnimatorImpl::apply(double time, 100 bool FlingAnimatorImpl::apply(double time,
101 WebKit::WebGestureCurveTarget* target) { 101 blink::WebGestureCurveTarget* target) {
102 if (!UpdatePosition()) 102 if (!UpdatePosition())
103 return false; 103 return false;
104 104
105 gfx::Point current_position = GetCurrentPosition(); 105 gfx::Point current_position = GetCurrentPosition();
106 gfx::Vector2d diff(current_position - last_position_); 106 gfx::Vector2d diff(current_position - last_position_);
107 last_position_ = current_position; 107 last_position_ = current_position;
108 float dpi_scale = gfx::Screen::GetNativeScreen()->GetPrimaryDisplay() 108 float dpi_scale = gfx::Screen::GetNativeScreen()->GetPrimaryDisplay()
109 .device_scale_factor(); 109 .device_scale_factor();
110 WebKit::WebFloatSize scroll_amount(diff.x() / dpi_scale, 110 blink::WebFloatSize scroll_amount(diff.x() / dpi_scale,
111 diff.y() / dpi_scale); 111 diff.y() / dpi_scale);
112 112
113 float delta_time = time - last_time_; 113 float delta_time = time - last_time_;
114 last_time_ = time; 114 last_time_ = time;
115 115
116 // Currently, the OverScroller only provides the velocity magnitude; use the 116 // Currently, the OverScroller only provides the velocity magnitude; use the
117 // angle of the scroll delta to yield approximate x and y velocity components. 117 // angle of the scroll delta to yield approximate x and y velocity components.
118 // TODO(jdduke): Remove this when we can properly poll OverScroller velocity. 118 // TODO(jdduke): Remove this when we can properly poll OverScroller velocity.
119 gfx::PointF current_velocity = last_velocity_; 119 gfx::PointF current_velocity = last_velocity_;
120 if (delta_time > kEpsilon) { 120 if (delta_time > kEpsilon) {
121 float diff_length = diff.Length(); 121 float diff_length = diff.Length();
122 if (diff_length > kEpsilon) { 122 if (diff_length > kEpsilon) {
123 float velocity = GetCurrentVelocity(); 123 float velocity = GetCurrentVelocity();
124 float scroll_to_velocity = velocity / diff_length; 124 float scroll_to_velocity = velocity / diff_length;
125 current_velocity = gfx::PointF(diff.x() * scroll_to_velocity, 125 current_velocity = gfx::PointF(diff.x() * scroll_to_velocity,
126 diff.y() * scroll_to_velocity); 126 diff.y() * scroll_to_velocity);
127 } 127 }
128 } 128 }
129 last_velocity_ = current_velocity; 129 last_velocity_ = current_velocity;
130 WebKit::WebFloatSize fling_velocity(current_velocity.x() / dpi_scale, 130 blink::WebFloatSize fling_velocity(current_velocity.x() / dpi_scale,
131 current_velocity.y() / dpi_scale); 131 current_velocity.y() / dpi_scale);
132 target->notifyCurrentFlingVelocity(fling_velocity); 132 target->notifyCurrentFlingVelocity(fling_velocity);
133 133
134 // scrollBy() could delete this curve if the animation is over, so don't touch 134 // scrollBy() could delete this curve if the animation is over, so don't touch
135 // any member variables after making that call. 135 // any member variables after making that call.
136 target->scrollBy(scroll_amount); 136 target->scrollBy(scroll_amount);
137 return true; 137 return true;
138 } 138 }
139 139
140 FlingAnimatorImpl* FlingAnimatorImpl::CreateAndroidGestureCurve( 140 FlingAnimatorImpl* FlingAnimatorImpl::CreateAndroidGestureCurve(
141 const WebKit::WebFloatPoint& velocity, 141 const blink::WebFloatPoint& velocity,
142 const WebKit::WebSize&) { 142 const blink::WebSize&) {
143 FlingAnimatorImpl* gesture_curve = new FlingAnimatorImpl(); 143 FlingAnimatorImpl* gesture_curve = new FlingAnimatorImpl();
144 gesture_curve->StartFling(velocity); 144 gesture_curve->StartFling(velocity);
145 return gesture_curve; 145 return gesture_curve;
146 } 146 }
147 147
148 } // namespace webkit_glue 148 } // namespace webkit_glue
OLDNEW
« no previous file with comments | « webkit/child/fling_animator_impl_android.h ('k') | webkit/child/fling_curve_configuration.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698