Bug 1471466: Don't fire a focus event for a remote accessible if focus has moved into the chrome since the event was sent. r=surkov

For example, this can happen when choosing File menu -> new Tab.
Focus briefly returns to the document in the original tab, so we ask that document to restore focus.
The remote document then sends a focus event to the parent.
However, before the parent can process that event, focus has already moved to the address bar for the new tab.
With this check, we discover that focus is now in the chrome and thus avoid firing the event for the remote accessible.

MozReview-Commit-ID: 7k58dzREqZD

--HG--
extra : rebase_source : 51303f54293957f562e8540c8bf98f821694be54
This commit is contained in:
James Teh 2018-06-27 15:33:08 +10:00
Родитель 8732380db5
Коммит 2202cef9bf
1 изменённых файлов: 12 добавлений и 0 удалений

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

@ -131,6 +131,18 @@ void
a11y::ProxyFocusEvent(ProxyAccessible* aTarget,
const LayoutDeviceIntRect& aCaretRect)
{
FocusManager* focusMgr = FocusMgr();
if (focusMgr && focusMgr->FocusedAccessible()) {
// This is a focus event from a remote document, but focus has moved out
// of that document into the chrome since that event was sent. For example,
// this can happen when choosing File menu -> New Tab. See bug 1471466.
// Note that this does not handle the case where a focus event is sent from
// one remote document, but focus moved into a second remote document
// since that event was sent. However, this isn't something anyone has been
// able to trigger.
return;
}
AccessibleWrap::UpdateSystemCaretFor(aTarget, aCaretRect);
AccessibleWrap::FireWinEvent(WrapperFor(aTarget),
nsIAccessibleEvent::EVENT_FOCUS);