From 7d922096c52ef87b40d293abf77ca3b52be7e621 Mon Sep 17 00:00:00 2001 From: Yura Zenevich Date: Thu, 15 Oct 2015 10:06:36 -0400 Subject: [PATCH] Bug 1211122 - ensuring that we check position against an actual doc/dialog on doc load event. r=marcoz --- accessible/jsat/EventManager.jsm | 6 +++++- accessible/jsat/Utils.jsm | 15 +++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/accessible/jsat/EventManager.jsm b/accessible/jsat/EventManager.jsm index 365eb10833f..ee9db5d5f95 100644 --- a/accessible/jsat/EventManager.jsm +++ b/accessible/jsat/EventManager.jsm @@ -287,8 +287,12 @@ this.EventManager.prototype = { 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; diff --git a/accessible/jsat/Utils.jsm b/accessible/jsat/Utils.jsm index be4909d94eb..f13fc337a12 100644 --- a/accessible/jsat/Utils.jsm +++ b/accessible/jsat/Utils.jsm @@ -345,6 +345,21 @@ this.Utils = { // jshint ignore:line 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;