summaryrefslogtreecommitdiffstats
path: root/WebKit/android/WebCoreSupport
diff options
context:
space:
mode:
authorPatrick Scott <phanna@android.com>2009-11-18 13:55:30 -0500
committerPatrick Scott <phanna@android.com>2009-11-19 09:19:18 -0500
commit27e40b2407e7e39b8fde83728baee90aae279760 (patch)
treef06d6bbc372c2f3541721893f0c6e1e2bef7a085 /WebKit/android/WebCoreSupport
parent19e61e8bbfd288bd9bf211069dd66e51ffadce15 (diff)
downloadexternal_webkit-27e40b2407e7e39b8fde83728baee90aae279760.zip
external_webkit-27e40b2407e7e39b8fde83728baee90aae279760.tar.gz
external_webkit-27e40b2407e7e39b8fde83728baee90aae279760.tar.bz2
Change window focus only if the user initiated the event.
This does not work in the javascript case because the user gesture is stored in the caller's script environment and that knowledge is not obtainable in the receiving frame. However, this change allows targeted links to change the focus to the correct window but prevents sites like slate.com from changing back to the opening window. This change will be followed by a simple revert of the previous change in the Browser app. Bug: 2161671
Diffstat (limited to 'WebKit/android/WebCoreSupport')
-rw-r--r--WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp11
-rw-r--r--WebKit/android/WebCoreSupport/ChromeClientAndroid.h4
2 files changed, 14 insertions, 1 deletions
diff --git a/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp b/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp
index cfac25e..f441aa1 100644
--- a/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp
+++ b/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp
@@ -105,10 +105,19 @@ float ChromeClientAndroid::scaleFactor()
return 1.0f;
}
+#ifdef ANDROID_USER_GESTURE
+void ChromeClientAndroid::focus(bool userGesture) {
+#else
void ChromeClientAndroid::focus() {
+ // The old behavior was to always allow javascript to focus a window. If we
+ // turn off ANDROID_USER_GESTURE, go back to the old behavior by forcing
+ // userGesture to be true.
+ bool userGesture = true;
+#endif
ASSERT(m_webFrame);
// Ask the application to focus this WebView.
- m_webFrame->requestFocus();
+ if (userGesture)
+ m_webFrame->requestFocus();
}
void ChromeClientAndroid::unfocus() { notImplemented(); }
diff --git a/WebKit/android/WebCoreSupport/ChromeClientAndroid.h b/WebKit/android/WebCoreSupport/ChromeClientAndroid.h
index 7bd7088..5ed785a 100644
--- a/WebKit/android/WebCoreSupport/ChromeClientAndroid.h
+++ b/WebKit/android/WebCoreSupport/ChromeClientAndroid.h
@@ -53,7 +53,11 @@ namespace android {
virtual float scaleFactor();
+#ifdef ANDROID_USER_GESTURE
+ virtual void focus(bool userGesture);
+#else
virtual void focus();
+#endif
virtual void unfocus();
virtual bool canTakeFocus(FocusDirection);