OLD | NEW |
---|---|
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/glue/fling_animator_impl_android.h" | 5 #include "webkit/glue/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 | 10 |
11 using namespace base::android; | 11 using namespace base::android; |
joth
2012/10/04 17:59:59
oh! this is not allowed is it?
bulach
2012/10/04 18:58:17
aarrggghh!!! :)
done.
| |
12 | 12 |
13 namespace webkit_glue { | 13 namespace webkit_glue { |
14 | 14 |
15 FlingAnimatorImpl::FlingAnimatorImpl() | 15 FlingAnimatorImpl::FlingAnimatorImpl() |
16 : is_active_(false) { | 16 : is_active_(false) { |
17 // hold the global reference of the Java objects. | 17 // hold the global reference of the Java objects. |
18 JNIEnv* env = AttachCurrentThread(); | 18 JNIEnv* env = AttachCurrentThread(); |
19 DCHECK(env); | 19 DCHECK(env); |
20 ScopedJavaLocalRef<jclass> cls(GetClass(env, "android/widget/OverScroller")); | 20 ScopedJavaLocalRef<jclass> cls(GetClass(env, "android/widget/OverScroller")); |
21 jmethodID constructor = GetMethodID(env, cls, "<init>", | 21 jmethodID constructor = MethodID::Get< |
joth
2012/10/04 17:59:59
should at least add the explicit 'using ..MethodI
bulach
2012/10/04 18:58:17
added the correct "using" above..
| |
22 "(Landroid/content/Context;)V"); | 22 MethodID::METHODTYPE_NORMAL, MethodID::EXCEPTIONCHECK_YES>( |
23 env, cls.obj(), "<init>", "(Landroid/content/Context;)V"); | |
23 ScopedJavaLocalRef<jobject> tmp(env, env->NewObject(cls.obj(), constructor, | 24 ScopedJavaLocalRef<jobject> tmp(env, env->NewObject(cls.obj(), constructor, |
24 GetApplicationContext())); | 25 GetApplicationContext())); |
25 DCHECK(tmp.obj()); | 26 DCHECK(tmp.obj()); |
26 java_scroller_.Reset(tmp); | 27 java_scroller_.Reset(tmp); |
27 | 28 |
28 fling_method_id_ = GetMethodID(env, cls, "fling", "(IIIIIIII)V"); | 29 fling_method_id_ = MethodID::Get< |
29 abort_method_id_ = GetMethodID(env, cls, "abortAnimation", "()V"); | 30 MethodID::METHODTYPE_NORMAL, MethodID::EXCEPTIONCHECK_YES>( |
30 compute_method_id_ = GetMethodID(env, cls, "computeScrollOffset", "()Z"); | 31 env, cls.obj(), "fling", "(IIIIIIII)V"); |
31 getX_method_id_ = GetMethodID(env, cls, "getCurrX", "()I"); | 32 abort_method_id_ = MethodID::Get< |
32 getY_method_id_ = GetMethodID(env, cls, "getCurrY", "()I"); | 33 MethodID::METHODTYPE_NORMAL, MethodID::EXCEPTIONCHECK_YES>( |
34 env, cls.obj(), "abortAnimation", "()V"); | |
35 compute_method_id_ = MethodID::Get< | |
36 MethodID::METHODTYPE_NORMAL, MethodID::EXCEPTIONCHECK_YES>( | |
37 env, cls.obj(), "computeScrollOffset", "()Z"); | |
38 getX_method_id_ = MethodID::Get< | |
39 MethodID::METHODTYPE_NORMAL, MethodID::EXCEPTIONCHECK_YES>( | |
40 env, cls.obj(), "getCurrX", "()I"); | |
41 getY_method_id_ = MethodID::Get< | |
42 MethodID::METHODTYPE_NORMAL, MethodID::EXCEPTIONCHECK_YES>( | |
43 env, cls.obj(), "getCurrY", "()I"); | |
33 } | 44 } |
34 | 45 |
35 FlingAnimatorImpl::~FlingAnimatorImpl() | 46 FlingAnimatorImpl::~FlingAnimatorImpl() |
36 { | 47 { |
37 } | 48 } |
38 | 49 |
39 void FlingAnimatorImpl::startFling(const WebKit::WebFloatPoint& velocity, | 50 void FlingAnimatorImpl::startFling(const WebKit::WebFloatPoint& velocity, |
40 const WebKit::WebRect& /* range */) | 51 const WebKit::WebRect& /* range */) |
41 { | 52 { |
42 // Ignore "range" as it's always empty -- see http://webkit.org/b/96403 | 53 // Ignore "range" as it's always empty -- see http://webkit.org/b/96403 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
82 { | 93 { |
83 JNIEnv* env = AttachCurrentThread(); | 94 JNIEnv* env = AttachCurrentThread(); |
84 WebKit::WebPoint position( | 95 WebKit::WebPoint position( |
85 env->CallIntMethod(java_scroller_.obj(), getX_method_id_), | 96 env->CallIntMethod(java_scroller_.obj(), getX_method_id_), |
86 env->CallIntMethod(java_scroller_.obj(), getY_method_id_)); | 97 env->CallIntMethod(java_scroller_.obj(), getY_method_id_)); |
87 CheckException(env); | 98 CheckException(env); |
88 return position; | 99 return position; |
89 } | 100 } |
90 | 101 |
91 } // namespace webkit_glue | 102 } // namespace webkit_glue |
OLD | NEW |