Bug 960255 - Emit 'change' event after adjusting range widgets. r=yzen

This commit is contained in:
Eitan Isaacson 2014-01-27 10:38:06 -08:00
parent 9d62049fa4
commit 42d5b92630

View File

@ -344,13 +344,21 @@ function scroll(aMessage) {
function adjustRange(aMessage) {
function sendUpDownKey(aAccessible) {
let acc = Utils.getEmbeddedControl(aAccessible) || aAccessible;
if (acc.DOMNode) {
let evt = content.document.createEvent('KeyboardEvent');
let keycode = aMessage.json.direction == 'forward' ?
content.KeyEvent.DOM_VK_DOWN : content.KeyEvent.DOM_VK_UP;
evt.initKeyEvent(
"keypress", false, true, null, false, false, false, false, keycode, 0);
acc.DOMNode.dispatchEvent(evt);
let elem = acc.DOMNode;
if (elem) {
if (elem.tagName === 'INPUT' && elem.type === 'range') {
elem[aMessage.json.direction === 'forward' ? 'stepDown' : 'stepUp']();
let changeEvent = content.document.createEvent('UIEvent');
changeEvent.initEvent('change', true, true);
elem.dispatchEvent(changeEvent);
} else {
let evt = content.document.createEvent('KeyboardEvent');
let keycode = aMessage.json.direction == 'forward' ?
content.KeyEvent.DOM_VK_DOWN : content.KeyEvent.DOM_VK_UP;
evt.initKeyEvent(
"keypress", false, true, null, false, false, false, false, keycode, 0);
elem.dispatchEvent(evt);
}
}
}