summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authoramanda@chromium.org <amanda@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-19 15:34:01 +0000
committeramanda@chromium.org <amanda@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-19 15:34:01 +0000
commit3dd2b11fffe7475cc2b00db8a538cc26dddeda2b (patch)
treeca4c6994f006268f45e852b4554bd350dfae2fd4 /webkit
parentbd5624b004af9e7db9b72f5a8c51bc897962fd43 (diff)
downloadchromium_src-3dd2b11fffe7475cc2b00db8a538cc26dddeda2b.zip
chromium_src-3dd2b11fffe7475cc2b00db8a538cc26dddeda2b.tar.gz
chromium_src-3dd2b11fffe7475cc2b00db8a538cc26dddeda2b.tar.bz2
Allow keyboard input to work in Mac plugins. Filed bug 25183 to revive "figure out why windows needs to invert the setDefaultHandled() logic", which has been a very long-standing question.
BUG=19194 TEST=typing into text fields in plugin areas should work once they are focused by clicking on the plugin. jam: primary reviewer pkasting: FYI, since one of the changes is a TODO(pkasting) hbono: FYI, since this may improve IME compatibility as well Review URL: http://codereview.chromium.org/269084 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@29400 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/api/src/WebInputEventConversion.cpp8
-rw-r--r--webkit/api/src/WebPluginContainerImpl.cpp28
2 files changed, 30 insertions, 6 deletions
diff --git a/webkit/api/src/WebInputEventConversion.cpp b/webkit/api/src/WebInputEventConversion.cpp
index 1a66c6e..125789a 100644
--- a/webkit/api/src/WebInputEventConversion.cpp
+++ b/webkit/api/src/WebInputEventConversion.cpp
@@ -237,12 +237,20 @@ WebKeyboardEventBuilder::WebKeyboardEventBuilder(const KeyboardEvent& event) {
type = KeyDown;
else if (event.type() == eventNames().keyupEvent)
type = WebInputEvent::KeyUp;
+ else if (event.type() == eventNames().keypressEvent)
+ type = WebInputEvent::Char;
else
return; // Skip all other keyboard events.
modifiers = getWebInputModifiers(event);
timeStampSeconds = event.timeStamp() * 1.0e-3;
windowsKeyCode = event.keyCode();
nativeKeyCode = event.keyEvent()->nativeVirtualKeyCode();
+ unsigned int numChars = std::min(event.keyEvent()->text().length(),
+ static_cast<unsigned int>(WebKeyboardEvent::textLengthCap));
+ for (unsigned int i = 0; i < numChars; i++) {
+ text[i] = event.keyEvent()->text()[i];
+ unmodifiedText[i] = event.keyEvent()->unmodifiedText()[i];
+ }
}
} // namespace WebKit
diff --git a/webkit/api/src/WebPluginContainerImpl.cpp b/webkit/api/src/WebPluginContainerImpl.cpp
index 5f5fd36..828075d 100644
--- a/webkit/api/src/WebPluginContainerImpl.cpp
+++ b/webkit/api/src/WebPluginContainerImpl.cpp
@@ -350,11 +350,23 @@ void WebPluginContainerImpl::handleMouseEvent(MouseEvent* event)
containingFrame->document()->setFocusedNode(m_element);
}
- // TODO(pkasting): http://b/1119691 This conditional seems exactly
- // backwards, but it matches Safari's code, and if I reverse it, giving
- // focus to a transparent (windowless) plugin fails.
WebCursorInfo cursorInfo;
- if (!m_webPlugin->handleInputEvent(webEvent, cursorInfo))
+ bool handled = m_webPlugin->handleInputEvent(webEvent, cursorInfo);
+#if !PLATFORM(DARWIN)
+ // TODO(pkasting): http://b/1119691 This conditional seems exactly
+ // backwards, but if I reverse it, giving focus to a transparent
+ // (windowless) plugin fails.
+ handled = !handled;
+ // TODO(awalker): oddly, the above is not true in Mac builds. Looking
+ // at Apple's corresponding code for Mac and Windows (PluginViewMac and
+ // PluginViewWin), setDefaultHandled() gets called when handleInputEvent()
+ // returns true, which then indicates to WebCore that the plugin wants to
+ // swallow the event--which is what we want. Calling setDefaultHandled()
+ // fixes several Mac Chromium bugs, but does indeed prevent windowless plugins
+ // from getting focus in Windows builds, as pkasting notes above. So for
+ // now, we only do so in Mac builds.
+#endif
+ if (handled)
event->setDefaultHandled();
// A windowless plugin can change the cursor in response to a mouse move
@@ -369,9 +381,13 @@ void WebPluginContainerImpl::handleKeyboardEvent(KeyboardEvent* event)
if (webEvent.type == WebInputEvent::Undefined)
return;
- // TODO(pkasting): http://b/1119691 See above.
WebCursorInfo cursor_info;
- if (!m_webPlugin->handleInputEvent(webEvent, cursor_info))
+ bool handled = m_webPlugin->handleInputEvent(webEvent, cursor_info);
+#if !PLATFORM(DARWIN)
+ // TODO(pkasting): http://b/1119691 See above.
+ handled = !handled;
+#endif
+ if (handled)
event->setDefaultHandled();
}