mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1119609 part.2 Don't dispatch keyboard events from TextEventDispatcher if there is a composition r=smaug
This commit is contained in:
parent
fd631dd6f0
commit
7921d21dce
@ -161,6 +161,11 @@ pref("dom.gamepad.non_standard_events.enabled", true);
|
||||
// Whether the KeyboardEvent.code is enabled
|
||||
pref("dom.keyboardevent.code.enabled", true);
|
||||
|
||||
// If this is true, TextEventDispatcher dispatches keydown and keyup events
|
||||
// even during composition (keypress events are never fired during composition
|
||||
// even if this is true).
|
||||
pref("dom.keyboardevent.dispatch_during_composition", false);
|
||||
|
||||
// Whether the WebCrypto API is enabled
|
||||
pref("dom.webcrypto.enabled", true);
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/TextEvents.h"
|
||||
#include "mozilla/TextEventDispatcher.h"
|
||||
#include "nsIDocShell.h"
|
||||
@ -19,12 +20,23 @@ namespace widget {
|
||||
* TextEventDispatcher
|
||||
*****************************************************************************/
|
||||
|
||||
bool TextEventDispatcher::sDispatchKeyEventsDuringComposition = false;
|
||||
|
||||
TextEventDispatcher::TextEventDispatcher(nsIWidget* aWidget)
|
||||
: mWidget(aWidget)
|
||||
, mForTests(false)
|
||||
, mIsComposing(false)
|
||||
{
|
||||
MOZ_RELEASE_ASSERT(mWidget, "aWidget must not be nullptr");
|
||||
|
||||
static bool sInitialized = false;
|
||||
if (!sInitialized) {
|
||||
Preferences::AddBoolVarCache(
|
||||
&sDispatchKeyEventsDuringComposition,
|
||||
"dom.keyboardevent.dispatch_during_composition",
|
||||
false);
|
||||
sInitialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
nsresult
|
||||
@ -253,6 +265,19 @@ TextEventDispatcher::DispatchKeyboardEventInternal(
|
||||
return false;
|
||||
}
|
||||
|
||||
// Basically, key events shouldn't be dispatched during composition.
|
||||
if (IsComposing()) {
|
||||
// However, if we need to behave like other browsers, we need the keydown
|
||||
// and keyup events. Note that this behavior is also allowed by D3E spec.
|
||||
// FYI: keypress events must not be fired during composition.
|
||||
if (!sDispatchKeyEventsDuringComposition || aMessage == NS_KEY_PRESS) {
|
||||
return false;
|
||||
}
|
||||
// XXX If there was mOnlyContentDispatch for this case, it might be useful
|
||||
// because our chrome doesn't assume that key events are fired during
|
||||
// composition.
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIWidget> widget(mWidget);
|
||||
|
||||
WidgetKeyboardEvent keyEvent(true, aMessage, widget);
|
||||
|
@ -235,6 +235,10 @@ private:
|
||||
// See IsComposing().
|
||||
bool mIsComposing;
|
||||
|
||||
// If this is true, keydown and keyup events are dispatched even when there
|
||||
// is a composition.
|
||||
static bool sDispatchKeyEventsDuringComposition;
|
||||
|
||||
nsresult BeginInputTransactionInternal(
|
||||
TextEventDispatcherListener* aListener,
|
||||
bool aForTests);
|
||||
|
Loading…
Reference in New Issue
Block a user