Bug 1211122 - ensuring that we check position against an actual doc/dialog on doc load event. r=marcoz

This commit is contained in:
Yura Zenevich 2015-10-15 10:06:36 -04:00
parent eef4977b53
commit 7d922096c5
2 changed files with 20 additions and 1 deletions

View File

@ -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;

View File

@ -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;