Bug 1211122 - ensuring that we check position against an actual doc/dialog on doc load event. r=marcoz
authorYura Zenevich <yzenevich@mozilla.com>
Thu, 15 Oct 2015 10:06:36 -0400
changeset 301419 e8133cb912d3b41c4418c7195c758c3203f644e5
parent 301418 4fda345579d439eabcc83745accc2eeac9fbb56f
child 301420 0d5765f295a8d5d77dca9e9c2f2fb3f128cc164d
child 301463 b0fc271e4897a3572592fe04ac06df1c7c8ca3eb
push id5392
push userraliiev@mozilla.com
push dateMon, 14 Dec 2015 20:08:23 +0000
treeherdermozilla-beta@16ce8562a975 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmarcoz
bugs1211122
milestone44.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1211122 - ensuring that we check position against an actual doc/dialog on doc load event. r=marcoz
accessible/jsat/EventManager.jsm
accessible/jsat/Utils.jsm
--- a/accessible/jsat/EventManager.jsm
+++ b/accessible/jsat/EventManager.jsm
@@ -282,18 +282,22 @@ this.EventManager.prototype = {
        if (this.inTest) {
         this.sendMsgFunc("AccessFu:Focused");
        }
        break;
       }
       case Events.DOCUMENT_LOAD_COMPLETE:
       {
         let position = this.contentControl.vc.position;
+        // Check if position is in the subtree of the DOCUMENT_LOAD_COMPLETE
+        // event's dialog accesible or accessible document
+        let subtreeRoot = aEvent.accessible.role === Roles.DIALOG ?
+          aEvent.accessible : aEvent.accessibleDocument;
         if (aEvent.accessible === aEvent.accessibleDocument ||
-            (position && Utils.isInSubtree(position, aEvent.accessible))) {
+            (position && Utils.isInSubtree(position, subtreeRoot))) {
           // Do not automove into the document if the virtual cursor is already
           // positioned inside it.
           break;
         }
         this._preDialogPosition.set(aEvent.accessible.DOMNode, position);
         this.contentControl.autoMove(aEvent.accessible, { delay: 500 });
         break;
       }
--- a/accessible/jsat/Utils.jsm
+++ b/accessible/jsat/Utils.jsm
@@ -340,16 +340,31 @@ this.Utils = { // jshint ignore:line
   get dpi() {
     delete this.dpi;
     this.dpi = this.winUtils.displayDPI;
     return this.dpi;
   },
 
   isInSubtree: function isInSubtree(aAccessible, aSubTreeRoot) {
     let acc = aAccessible;
+
+    // If aSubTreeRoot is an accessible document, we will only walk up the
+    // ancestry of documents and skip everything else.
+    if (aSubTreeRoot instanceof Ci.nsIAccessibleDocument) {
+      while (acc) {
+        let parentDoc = acc instanceof Ci.nsIAccessibleDocument ?
+          acc.parentDocument : acc.document;
+        if (parentDoc === aSubTreeRoot) {
+          return true;
+        }
+        acc = parentDoc;
+      }
+      return false;
+    }
+
     while (acc) {
       if (acc == aSubTreeRoot) {
         return true;
       }
 
       try {
         acc = acc.parent;
       } catch (x) {