diff options
author | Derek Sollenberger <djsollen@google.com> | 2009-10-27 09:50:23 -0400 |
---|---|---|
committer | Derek Sollenberger <djsollen@google.com> | 2009-10-27 11:11:18 -0400 |
commit | c7d9090583638605a2c8a779642ad09d1a228520 (patch) | |
tree | 7693477019ffab57fe521cad49464ab29f1c432a /WebCore/plugins | |
parent | 21088f4092362b3eac4b6ad7d7050aabb833dfcf (diff) | |
download | external_webkit-c7d9090583638605a2c8a779642ad09d1a228520.zip external_webkit-c7d9090583638605a2c8a779642ad09d1a228520.tar.gz external_webkit-c7d9090583638605a2c8a779642ad09d1a228520.tar.bz2 |
changing how plugins gain/lose focus.
Previously we were keeping our own state in the UI thread to
determine when to send events to the plugin. This change removes
that logic and uses the document focus to determine when events
are to be sent. This also fixes problems with the plugins
occasionally not receiving lose focus events.
see bug http://b/2033843
Diffstat (limited to 'WebCore/plugins')
-rw-r--r-- | WebCore/plugins/PluginView.cpp | 4 | ||||
-rw-r--r-- | WebCore/plugins/PluginView.h | 1 | ||||
-rw-r--r-- | WebCore/plugins/android/PluginViewAndroid.cpp | 18 |
3 files changed, 22 insertions, 1 deletions
diff --git a/WebCore/plugins/PluginView.cpp b/WebCore/plugins/PluginView.cpp index 811f6be..13d8511 100644 --- a/WebCore/plugins/PluginView.cpp +++ b/WebCore/plugins/PluginView.cpp @@ -165,6 +165,10 @@ void PluginView::handleEvent(Event* event) #if defined(ANDROID_PLUGINS) else if (event->isTouchEvent()) handleTouchEvent(static_cast<TouchEvent*>(event)); + else if (event->type() == eventNames().DOMFocusOutEvent) + handleFocusEvent(false); + else if (event->type() == eventNames().DOMFocusInEvent) + handleFocusEvent(true); #endif #if defined(Q_WS_X11) else if (event->type() == eventNames().DOMFocusOutEvent) diff --git a/WebCore/plugins/PluginView.h b/WebCore/plugins/PluginView.h index 0fd0d4f..b385d41 100644 --- a/WebCore/plugins/PluginView.h +++ b/WebCore/plugins/PluginView.h @@ -289,6 +289,7 @@ namespace WebCore { #endif #ifdef ANDROID_PLUGINS + void handleFocusEvent(bool hasFocus); void handleTouchEvent(TouchEvent*); // called at the end of the base constructor void platformInit(); diff --git a/WebCore/plugins/android/PluginViewAndroid.cpp b/WebCore/plugins/android/PluginViewAndroid.cpp index 0c69cfd..529458b 100644 --- a/WebCore/plugins/android/PluginViewAndroid.cpp +++ b/WebCore/plugins/android/PluginViewAndroid.cpp @@ -258,6 +258,20 @@ static ANPKeyModifier make_modifiers(bool shift, bool alt) { return mod; } +void PluginView::handleFocusEvent(bool hasFocus) +{ + ANPEvent evt; + SkANP::InitEvent(&evt, kLifecycle_ANPEventType); + evt.data.lifecycle.action = hasFocus ? kGainFocus_ANPLifecycleAction : + kLoseFocus_ANPLifecycleAction; + m_window->sendEvent(evt); + + // redraw the plugin which subsequently invalidates the nav cache + IntRect rect = IntRect(m_npWindow.x, m_npWindow.y, + m_npWindow.width, m_npWindow.height); + m_window->webViewCore()->contentInvalidate(rect); +} + void PluginView::handleKeyboardEvent(KeyboardEvent* event) { if (!m_window->isAcceptingEvent(kKey_ANPEventFlag)) @@ -319,6 +333,9 @@ void PluginView::handleKeyboardEvent(KeyboardEvent* event) if (m_plugin->pluginFuncs()->event(m_instance, &evt)) { event->setDefaultHandled(); + } else { + // remove the plugin from the document's focus + m_parentFrame->document()->focusedNodeRemoved(); } } @@ -498,7 +515,6 @@ void PluginView::invalidateRect(NPRect* rect) } m_window->inval(r, true); -// android::WebViewCore::getWebViewCore(parent())->contentInvalidate(r); } void PluginView::invalidateRegion(NPRegion region) |