Bug 921299 - Don't consider all keypresses to be synthetic events on b2g (r=smaug)

This commit is contained in:
Bill McCloskey 2014-07-10 16:46:28 -07:00
parent 039e7ab2b9
commit 055511bb01
3 changed files with 11 additions and 4 deletions

View File

@ -1242,7 +1242,9 @@ nsDOMWindowUtils::SendKeyEvent(const nsAString& aType,
event.refPoint.x = event.refPoint.y = 0;
event.time = PR_IntervalNow();
event.mFlags.mIsSynthesizedForTests = true;
if (!(aAdditionalFlags & KEY_FLAG_NOT_SYNTHESIZED_FOR_TESTS)) {
event.mFlags.mIsSynthesizedForTests = true;
}
if (aAdditionalFlags & KEY_FLAG_PREVENT_DEFAULT) {
event.mFlags.mDefaultPrevented = true;

View File

@ -508,17 +508,18 @@ let FormAssistant = {
case "Forms:Input:SendKey":
CompositionManager.endComposition('');
let flags = domWindowUtils.KEY_FLAG_NOT_SYNTHESIZED_FOR_TESTS;
this._editing = true;
let doKeypress = domWindowUtils.sendKeyEvent('keydown', json.keyCode,
json.charCode, json.modifiers);
json.charCode, json.modifiers, flags);
if (doKeypress) {
domWindowUtils.sendKeyEvent('keypress', json.keyCode,
json.charCode, json.modifiers);
json.charCode, json.modifiers, flags);
}
if(!json.repeat) {
domWindowUtils.sendKeyEvent('keyup', json.keyCode,
json.charCode, json.modifiers);
json.charCode, json.modifiers, flags);
}
this._editing = false;

View File

@ -539,6 +539,10 @@ interface nsIDOMWindowUtils : nsISupports {
// If this is set, preventDefault() the event before dispatch.
const unsigned long KEY_FLAG_PREVENT_DEFAULT = 0x0001;
// If this is set, the mIsSynthesizedForTests flag is set to false
// on the key event. Otherwise it is true.
const unsigned long KEY_FLAG_NOT_SYNTHESIZED_FOR_TESTS = 0x0002;
// if one of these flags is set, the KeyboardEvent.location will be the value.
// Otherwise, it will be computed from aKeyCode.
const unsigned long KEY_FLAG_LOCATION_STANDARD = 0x0010;