Bug 757418 - Do Presenter.tabSelected when tab's window receives focus.

This commit is contained in:
Eitan Isaacson 2012-05-22 13:44:17 -07:00
Родитель dd01817d8a
Коммит 498347b70f
1 изменённых файлов: 15 добавлений и 14 удалений

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

@ -74,6 +74,7 @@ var AccessFu = {
this.chromeWin.addEventListener('resize', this, true); this.chromeWin.addEventListener('resize', this, true);
this.chromeWin.addEventListener('scroll', this, true); this.chromeWin.addEventListener('scroll', this, true);
this.chromeWin.addEventListener('TabOpen', this, true); this.chromeWin.addEventListener('TabOpen', this, true);
this.chromeWin.addEventListener('focus', this, true);
}, },
/** /**
@ -96,6 +97,7 @@ var AccessFu = {
this.chromeWin.removeEventListener('resize', this, true); this.chromeWin.removeEventListener('resize', this, true);
this.chromeWin.removeEventListener('scroll', this, true); this.chromeWin.removeEventListener('scroll', this, true);
this.chromeWin.removeEventListener('TabOpen', this, true); this.chromeWin.removeEventListener('TabOpen', this, true);
this.chromeWin.removeEventListener('focus', this, true);
}, },
_processPreferences: function _processPreferences(aPref) { _processPreferences: function _processPreferences(aPref) {
@ -130,6 +132,19 @@ var AccessFu = {
handleEvent: function handleEvent(aEvent) { handleEvent: function handleEvent(aEvent) {
switch (aEvent.type) { switch (aEvent.type) {
case 'focus':
{
if (aEvent.target instanceof Ci.nsIDOMWindow) {
let docAcc = getAccessible(aEvent.target.document);
let docContext = new PresenterContext(docAcc, null);
let cursorable = docAcc.QueryInterface(Ci.nsIAccessibleCursorable);
let vcContext = new PresenterContext(
(cursorable) ? cursorable.virtualCursor.position : null, null);
this.presenters.forEach(
function(p) { p.tabSelected(docContext, vcContext); });
}
break;
}
case 'TabOpen': case 'TabOpen':
{ {
let browser = aEvent.target.linkedBrowser || aEvent.target; let browser = aEvent.target.linkedBrowser || aEvent.target;
@ -308,20 +323,6 @@ var AccessFu = {
); );
break; break;
} }
case Ci.nsIAccessibleEvent.EVENT_FOCUS:
{
if (this._isBrowserDoc(aEvent.accessible)) {
// The document recieved focus, call tabSelected to present current tab.
let docContext = new PresenterContext(aEvent.accessible, null);
let cursorable = aEvent.accessible.
QueryInterface(Ci.nsIAccessibleCursorable);
let vcContext = new PresenterContext(
(cursorable) ? cursorable.virtualCursor.position : null, null);
this.presenters.forEach(
function(p) { p.tabSelected(docContext, vcContext); });
}
break;
}
case Ci.nsIAccessibleEvent.EVENT_TEXT_INSERTED: case Ci.nsIAccessibleEvent.EVENT_TEXT_INSERTED:
case Ci.nsIAccessibleEvent.EVENT_TEXT_REMOVED: case Ci.nsIAccessibleEvent.EVENT_TEXT_REMOVED:
{ {