OSDN Git Service

hack to set focus for plugins
authorMike Reed <reed@google.com>
Thu, 28 May 2009 19:09:41 +0000 (15:09 -0400)
committerMike Reed <reed@google.com>
Thu, 28 May 2009 19:38:10 +0000 (15:38 -0400)
expose pluginview from pluginwidget

WebKit/android/jni/WebViewCore.cpp
WebKit/android/plugins/PluginWidgetAndroid.h

index 89013ff..c1df546 100644 (file)
@@ -1273,6 +1273,15 @@ void WebViewCore::setKitFocus(int moveGeneration, int buildGeneration,
     finalKitFocus(frame, node, x, y);
 }
 
+static bool nodeIsPlugin(Node* node) {
+    RenderObject* renderer = node->renderer();
+    if (renderer->isWidget()) {
+        Widget* widget = static_cast<RenderWidget*>(renderer)->widget();
+        return widget && widget->isPluginView();
+    }
+    return NULL;
+}
+
 // Update mouse position and may change focused node.
 bool WebViewCore::finalKitFocus(WebCore::Frame* frame, WebCore::Node* node,
     int x, int y)
@@ -1300,6 +1309,11 @@ bool WebViewCore::finalKitFocus(WebCore::Frame* frame, WebCore::Node* node,
     builder.setLastFocus(node);
     m_lastFocused = node;
     m_lastFocusedBounds = node->getRect();
+
+    // hack to give the plugin focus (for keys). better fix on the way
+    if (nodeIsPlugin(node)) {
+        node->document()->setFocusedNode(node);
+    }
     return true;
 }
 
index e8f5e6a..157651c 100644 (file)
@@ -49,7 +49,9 @@ struct PluginWidgetAndroid {
     // destroyed.
     PluginWidgetAndroid(WebCore::PluginView* view);
     ~PluginWidgetAndroid();
-    
+
+    WebCore::PluginView* pluginView() const { return m_pluginView; }
+
     /*  Can't determine our core at construction time, so PluginView calls this
         as soon as it has a parent.
      */