Bug 802415 - Report virtual cursor position on selected tab when tab changes, or when focus moves to content area. r=davidb

This commit is contained in:
Eitan Isaacson 2012-10-19 10:06:08 -07:00
Родитель 39d0142c1b
Коммит 53bb206f98
3 изменённых файлов: 49 добавлений и 1 удалений

Просмотреть файл

@ -98,7 +98,9 @@ var AccessFu = {
Services.obs.addObserver(this, 'remote-browser-frame-shown', false);
Services.obs.addObserver(this, 'Accessibility:NextObject', false);
Services.obs.addObserver(this, 'Accessibility:PreviousObject', false);
Services.obs.addObserver(this, 'Accessibility:Focus', false);
this.chromeWin.addEventListener('TabOpen', this);
this.chromeWin.addEventListener('TabSelect', this);
},
/**
@ -119,10 +121,12 @@ var AccessFu = {
Input.detach();
this.chromeWin.removeEventListener('TabOpen', this);
this.chromeWin.removeEventListener('TabSelect', this);
Services.obs.removeObserver(this, 'remote-browser-frame-shown');
Services.obs.removeObserver(this, 'Accessibility:NextObject');
Services.obs.removeObserver(this, 'Accessibility:PreviousObject');
Services.obs.removeObserver(this, 'Accessibility:Focus');
},
_enableOrDisable: function _enableOrDisable() {
@ -184,6 +188,13 @@ var AccessFu = {
case 'Accessibility:PreviousObject':
Input.moveCursor('movePrevious', 'Simple', 'gesture');
break;
case 'Accessibility:Focus':
this._focused = JSON.parse(aData);
if (this._focused) {
let mm = Utils.getMessageManager(Utils.getCurrentBrowser(this.chromeWin));
mm.sendAsyncMessage('AccessFu:VirtualCursor',
{action: 'whereIsIt', move: true});
}
break;
case 'nsPref:changed':
if (aData == 'activate') {
@ -215,11 +226,28 @@ var AccessFu = {
this._loadFrameScript(Utils.getMessageManager(aEvent.target));
break;
}
case 'TabSelect':
{
if (this._focused) {
let mm = Utils.getMessageManager(Utils.getCurrentBrowser(this.chromeWin));
// We delay this for half a second so the awesomebar could close,
// and we could use the current coordinates for the content item.
// XXX TODO figure out how to avoid magic wait here.
this.chromeWin.setTimeout(
function () {
mm.sendAsyncMessage('AccessFu:VirtualCursor', {action: 'whereIsIt'});
}, 500);
}
break;
}
}
},
// So we don't enable/disable twice
_enabled: false
_enabled: false,
// Layerview is focused
_focused: false
};
var Output = {

Просмотреть файл

@ -244,6 +244,17 @@ var EventManager = {
}
},
presentVirtualCursorPosition: function presentVirtualCursorPosition(aVirtualCursor) {
let presenterContext =
new PresenterContext(aVirtualCursor.position, null);
this.present(
function(p) {
return p.pivotChanged(presenterContext, Ci.nsIAccessiblePivot.REASON_NONE);
}
);
},
onStateChange: function onStateChange(aWebProgress, aRequest, aStateFlags, aStatus) {
let tabstate = '';

Просмотреть файл

@ -53,6 +53,15 @@ function virtualCursorControl(aMessage) {
break;
case 'moveToPoint':
moved = vc.moveToPoint(rule, details.x, details.y, true);
break;
case 'whereIsIt':
if (!forwardMessage(vc, aMessage)) {
if (!vc.position && aMessage.json.move)
vc.moveFirst(TraversalRules.Simple);
else
EventManager.presentVirtualCursorPosition(vc);
}
break;
default:
break;