Commit 44e38978 authored by andersca@apple.com's avatar andersca@apple.com

Fix handling of keyup events in the new Cocoa text input model

https://bugs.webkit.org/show_bug.cgi?id=67045

Reviewed by Sam Weinig.

Use a counter instead of a boolean for deciding when to ignore keyup events, because
if multiple keys are pressed simultaneously then we need to ignore more than one keyup event in a row.

Also if a keyboard event is an autorepeating event we won't get a keyup event so don't increment the counter
in that case.

* WebProcess/Plugins/Netscape/NetscapePlugin.cpp:
(WebKit::NetscapePlugin::NetscapePlugin):
* WebProcess/Plugins/Netscape/NetscapePlugin.h:
* WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm:
(WebKit::NetscapePlugin::platformHandleKeyboardEvent):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@93887 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 40d9a46b
2011-08-26 Anders Carlsson <andersca@apple.com>
Fix handling of keyup events in the new Cocoa text input model
https://bugs.webkit.org/show_bug.cgi?id=67045
Reviewed by Sam Weinig.
Use a counter instead of a boolean for deciding when to ignore keyup events, because
if multiple keys are pressed simultaneously then we need to ignore more than one keyup event in a row.
Also if a keyboard event is an autorepeating event we won't get a keyup event so don't increment the counter
in that case.
* WebProcess/Plugins/Netscape/NetscapePlugin.cpp:
(WebKit::NetscapePlugin::NetscapePlugin):
* WebProcess/Plugins/Netscape/NetscapePlugin.h:
* WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm:
(WebKit::NetscapePlugin::platformHandleKeyboardEvent):
2011-08-26 Jessie Berlin <jberlin@apple.com>
Gut WKPageCreateSnapshotOfVisibleContent so that it can be removed later.
......
......@@ -78,7 +78,7 @@ NetscapePlugin::NetscapePlugin(PassRefPtr<NetscapePluginModule> pluginModule)
, m_pluginWantsLegacyCocoaTextInput(true)
, m_isComplexTextInputEnabled(false)
, m_hasHandledAKeyDownEvent(false)
, m_ignoreNextKeyUpEvent(false)
, m_ignoreNextKeyUpEventCounter(0)
#ifndef NP_NO_CARBON
, m_nullEventTimer(RunLoop::main(), this, &NetscapePlugin::nullEventTimerFired)
, m_npCGContext()
......
......@@ -257,8 +257,8 @@ private:
// if we can tell the plug-in that we support the updated Cocoa text input specification.
bool m_hasHandledAKeyDownEvent;
// Whether the next NPCocoaEventKeyUp event should be ignored.
bool m_ignoreNextKeyUpEvent;
// The number of NPCocoaEventKeyUp events that should be ignored.
unsigned m_ignoreNextKeyUpEventCounter;
WebCore::IntRect m_windowFrameInScreenCoordinates;
WebCore::IntRect m_viewFrameInWindowCoordinates;
......
......@@ -740,14 +740,14 @@ bool NetscapePlugin::platformHandleKeyboardEvent(const WebKeyboardEvent& keyboar
if (keyboardEvent.type() == WebEvent::KeyDown) {
m_hasHandledAKeyDownEvent = true;
if (!m_pluginWantsLegacyCocoaTextInput && m_isComplexTextInputEnabled) {
if (!m_pluginWantsLegacyCocoaTextInput && m_isComplexTextInputEnabled && !keyboardEvent.isAutoRepeat()) {
// When complex text is enabled in the new model, the plug-in should never
// receive any key down or key up events until the composition is complete.
m_ignoreNextKeyUpEvent = true;
m_ignoreNextKeyUpEventCounter++;
return true;
}
} else if (keyboardEvent.type() == WebEvent::KeyUp && m_ignoreNextKeyUpEvent) {
m_ignoreNextKeyUpEvent = false;
} else if (keyboardEvent.type() == WebEvent::KeyUp && m_ignoreNextKeyUpEventCounter) {
m_ignoreNextKeyUpEventCounter--;
return true;
}
......@@ -757,7 +757,8 @@ bool NetscapePlugin::platformHandleKeyboardEvent(const WebKeyboardEvent& keyboar
if (!m_pluginWantsLegacyCocoaTextInput) {
if (event.type == NPCocoaEventKeyDown && returnValue == kNPEventStartIME) {
m_ignoreNextKeyUpEvent = true;
if (!keyboardEvent.isAutoRepeat())
m_ignoreNextKeyUpEventCounter++;
setComplexTextInputEnabled(true);
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment