From c7d9090583638605a2c8a779642ad09d1a228520 Mon Sep 17 00:00:00 2001 From: Derek Sollenberger Date: Tue, 27 Oct 2009 09:50:23 -0400 Subject: 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 --- WebCore/plugins/PluginView.cpp | 4 ++++ WebCore/plugins/PluginView.h | 1 + WebCore/plugins/android/PluginViewAndroid.cpp | 18 +++++++++++++++++- 3 files changed, 22 insertions(+), 1 deletion(-) (limited to 'WebCore/plugins') 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(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) -- cgit v1.1