summaryrefslogtreecommitdiffstats
path: root/WebKit/android/plugins
diff options
context:
space:
mode:
authorDerek Sollenberger <djsollen@google.com>2010-01-25 15:12:16 -0500
committerDerek Sollenberger <djsollen@google.com>2010-01-25 16:04:31 -0500
commit53c84f3caf7c84282400134fa9554cd465ec7da8 (patch)
treec198c44089b3cbb9363dafb1dcabdd49cedfa9b9 /WebKit/android/plugins
parentc45f962cdbdd4a870b7af94ce48f48e36c5b53cb (diff)
downloadexternal_webkit-53c84f3caf7c84282400134fa9554cd465ec7da8.zip
external_webkit-53c84f3caf7c84282400134fa9554cd465ec7da8.tar.gz
external_webkit-53c84f3caf7c84282400134fa9554cd465ec7da8.tar.bz2
Do not allow the plugin to show or hide the keyboard unless it has focus.
Diffstat (limited to 'WebKit/android/plugins')
-rw-r--r--WebKit/android/plugins/ANPWindowInterface.cpp3
-rw-r--r--WebKit/android/plugins/PluginWidgetAndroid.cpp20
-rw-r--r--WebKit/android/plugins/PluginWidgetAndroid.h6
3 files changed, 22 insertions, 7 deletions
diff --git a/WebKit/android/plugins/ANPWindowInterface.cpp b/WebKit/android/plugins/ANPWindowInterface.cpp
index 06afab1..bb7b9a3 100644
--- a/WebKit/android/plugins/ANPWindowInterface.cpp
+++ b/WebKit/android/plugins/ANPWindowInterface.cpp
@@ -49,7 +49,8 @@ static void anp_clearVisibleRects(NPP instance) {
static void anp_showKeyboard(NPP instance, bool value) {
PluginView* pluginView = pluginViewForInstance(instance);
PluginWidgetAndroid* pluginWidget = pluginView->platformPluginWidget();
- pluginWidget->webViewCore()->requestKeyboard(value, false);
+ if(pluginWidget->hasFocus())
+ pluginWidget->webViewCore()->requestKeyboard(value, false);
}
static void anp_requestFullScreen(NPP instance) {
diff --git a/WebKit/android/plugins/PluginWidgetAndroid.cpp b/WebKit/android/plugins/PluginWidgetAndroid.cpp
index 8bbe531..00f7165 100644
--- a/WebKit/android/plugins/PluginWidgetAndroid.cpp
+++ b/WebKit/android/plugins/PluginWidgetAndroid.cpp
@@ -229,12 +229,11 @@ int16 PluginWidgetAndroid::sendEvent(const ANPEvent& evt) {
// "missing" plugins won't have these
if (pkg && instance) {
- // keep track of whether or not the plugin currently has focus
- if (evt.eventType == kLifecycle_ANPEventType) {
- if (evt.data.lifecycle.action == kLoseFocus_ANPLifecycleAction)
- m_hasFocus = false;
- else if (evt.data.lifecycle.action == kGainFocus_ANPLifecycleAction)
- m_hasFocus = true;
+ // if the plugin is gaining focus then update our state now to allow
+ // the plugin's event handler to perform actions that require focus
+ if (evt.eventType == kLifecycle_ANPEventType &&
+ evt.data.lifecycle.action == kGainFocus_ANPLifecycleAction) {
+ m_hasFocus = true;
}
// make a localCopy since the actual plugin may not respect its constness,
@@ -242,6 +241,15 @@ int16 PluginWidgetAndroid::sendEvent(const ANPEvent& evt) {
ANPEvent localCopy = evt;
int16 result = pkg->pluginFuncs()->event(instance, &localCopy);
PLUGIN_LOG_EVENT(instance, &evt, result);
+
+ // if the plugin is losing focus then delay the update of our state
+ // until after we notify the plugin and allow them to perform actions
+ // that may require focus
+ if (evt.eventType == kLifecycle_ANPEventType &&
+ evt.data.lifecycle.action == kLoseFocus_ANPLifecycleAction) {
+ m_hasFocus = false;
+ }
+
return result;
}
return 0;
diff --git a/WebKit/android/plugins/PluginWidgetAndroid.h b/WebKit/android/plugins/PluginWidgetAndroid.h
index b723995..1245d0c 100644
--- a/WebKit/android/plugins/PluginWidgetAndroid.h
+++ b/WebKit/android/plugins/PluginWidgetAndroid.h
@@ -134,6 +134,12 @@ struct PluginWidgetAndroid {
bool inFullScreen() { return m_isFullScreen; }
+ /** Called to check if a plugin currently has document focus, which is
+ required for certain operations (e.g. show/hide keyboard). It returns
+ true if the plugin currently has focus and false otherwise.
+ */
+ bool hasFocus() const { return m_hasFocus; }
+
private:
void computeVisiblePluginRect();
void scrollToVisiblePluginRect();