diff options
author | boliu@chromium.org <boliu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-14 01:24:08 +0000 |
---|---|---|
committer | boliu@chromium.org <boliu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-14 01:24:08 +0000 |
commit | 549cc51caac81fa803d3a58845110fbdceb76246 (patch) | |
tree | 21b175370093c0825bcf3ec525cfd2349c9125b8 /android_webview/native/aw_contents.cc | |
parent | 44c466cd38e7d6b843ef4bc21572e1f3cc51c52a (diff) | |
download | chromium_src-549cc51caac81fa803d3a58845110fbdceb76246.zip chromium_src-549cc51caac81fa803d3a58845110fbdceb76246.tar.gz chromium_src-549cc51caac81fa803d3a58845110fbdceb76246.tar.bz2 |
Avoid unnecessary Java object creation in hit test
Do not create new AwContents.HitTestData by only having a
single final instance per AwContents and then updating that
instance. Will need to do appropriate information hiding in
glue layer later.
Avoid creating new HitTestData instance variable java
objects by only calling update when the native side received
new hit test result.
Downstream instrumentation tests still pass.
BUG=
Android only change, but android trybots are in a sad sad
state. Some of them are happy, others failing on known
issues.
NOTRY=true
Review URL: https://chromiumcodereview.appspot.com/11358183
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@167559 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'android_webview/native/aw_contents.cc')
-rw-r--r-- | android_webview/native/aw_contents.cc | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/android_webview/native/aw_contents.cc b/android_webview/native/aw_contents.cc index 7e28fdd..a75e986 100644 --- a/android_webview/native/aw_contents.cc +++ b/android_webview/native/aw_contents.cc @@ -335,9 +335,11 @@ void AwContents::RequestNewHitTestDataAt(JNIEnv* env, jobject obj, render_view_host_ext_->RequestNewHitTestDataAt(x, y); } -base::android::ScopedJavaLocalRef<jobject> AwContents::GetLastHitTestData( - JNIEnv* env, jobject obj) { +void AwContents::UpdateLastHitTestData(JNIEnv* env, jobject obj) { + if (!render_view_host_ext_->HasNewHitTestData()) return; + const AwHitTestData& data = render_view_host_ext_->GetLastHitTestData(); + render_view_host_ext_->MarkHitTestDataRead(); // Make sure to null the Java object if data is empty/invalid. ScopedJavaLocalRef<jstring> extra_data_for_type; @@ -357,12 +359,13 @@ base::android::ScopedJavaLocalRef<jobject> AwContents::GetLastHitTestData( if (data.img_src.is_valid()) img_src = ConvertUTF8ToJavaString(env, data.img_src.spec()); - return Java_AwContents_createHitTestData(env, - data.type, - extra_data_for_type.obj(), - href.obj(), - anchor_text.obj(), - img_src.obj()); + Java_AwContents_updateHitTestData(env, + obj, + data.type, + extra_data_for_type.obj(), + href.obj(), + anchor_text.obj(), + img_src.obj()); } } // namespace android_webview |