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, a=lizzard
authorJames Teh <jteh@mozilla.com>
Wed, 27 Jun 2018 15:33:08 +1000
changeset 478373 3a49b45d3428
parent 478372 adfbbc7a8f60
child 478374 40006339de0c
push id9639
push userryanvm@gmail.com
push date2018-08-10 20:54 +0000
treeherdermozilla-beta@4471d22def67 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssurkov, lizzard
bugs1471466
milestone62.0
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, a=lizzard 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
accessible/windows/msaa/Platform.cpp
--- a/accessible/windows/msaa/Platform.cpp
+++ b/accessible/windows/msaa/Platform.cpp
@@ -126,16 +126,28 @@ a11y::ProxyStateChangeEvent(ProxyAccessi
   AccessibleWrap::FireWinEvent(WrapperFor(aTarget),
                                nsIAccessibleEvent::EVENT_STATE_CHANGE);
 }
 
 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);
 }
 
 void
 a11y::ProxyCaretMoveEvent(ProxyAccessible* aTarget,
                           const LayoutDeviceIntRect& aCaretRect)