Bug 1077044 - Store previous cursor position when dialog pops up, and restore it when it is hidden. r=yzen

This commit is contained in:
Eitan Isaacson 2014-10-12 11:23:45 -07:00
parent 41fd369c9e
commit a1dd393a36
3 changed files with 17 additions and 11 deletions

View File

@ -61,6 +61,7 @@ this.EventManager.prototype = {
this.addEventListener('wheel', this, true);
this.addEventListener('scroll', this, true);
this.addEventListener('resize', this, true);
this._preDialogPosition = new WeakMap();
}
this.present(Presentation.tabStateChanged(null, 'newtab'));
@ -78,6 +79,7 @@ this.EventManager.prototype = {
Logger.debug('EventManager.stop');
AccessibilityEventObserver.removeListener(this);
try {
this._preDialogPosition.clear();
this.webProgress.removeProgressListener(this);
this.removeEventListener('wheel', this, true);
this.removeEventListener('scroll', this, true);
@ -272,8 +274,8 @@ this.EventManager.prototype = {
// positioned inside it.
break;
}
this.contentControl.autoMove(
aEvent.accessible, { delay: 500 });
this._preDialogPosition.set(aEvent.accessible.DOMNode, position);
this.contentControl.autoMove(aEvent.accessible, { delay: 500 });
break;
}
case Events.VALUE_CHANGE:
@ -366,7 +368,8 @@ this.EventManager.prototype = {
if (vc.position &&
(Utils.getState(vc.position).contains(States.DEFUNCT) ||
Utils.isInSubtree(vc.position, acc))) {
let position = aEvent.targetPrevSibling || aEvent.targetParent;
let position = this._preDialogPosition.get(aEvent.accessible.DOMNode) ||
aEvent.targetPrevSibling || aEvent.targetParent;
if (!position) {
try {
position = acc.previousSibling;

View File

@ -75,13 +75,13 @@
<div>Phone status bar</div>
<div id="windows">
<button id="back">Back</button>
<div id="appframe"></div>
<div role="dialog" id="alert" hidden>
<h1>This is an alert!</h1>
<p>Do you agree?</p>
<button onclick="hideAlert()">Yes</button>
<button onclick="setTimeout(hideAlert, 500)">Yes</button>
<button onclick="hideAlert()">No</button>
</div>
<div id="appframe"></div>
</div>
<button id="home">Home</button>
</body>

View File

@ -179,16 +179,15 @@
[ContentMessages.clearCursor, 'AccessFu:CursorCleared'],
// Open dialog in outer doc, while cursor is also in outer doc
[ContentMessages.simpleMoveNext,
new ExpectedCursorChange(['Phone status bar', 'Traversal Rule test document'])],
[ContentMessages.simpleMoveLast,
new ExpectedCursorChange(['Home', {'string': 'pushbutton'}])],
[doc.defaultView.showAlert,
new ExpectedCursorChange(['This is an alert!',
{'string': 'headingLevel', 'args': [1]},
{'string': 'dialog'}])],
[doc.defaultView.hideAlert,
new ExpectedCursorChange(["wow",
{"string": "headingLevel", "args": [1]}, "such app"])],
new ExpectedCursorChange(['Home', {'string': 'pushbutton'}])],
[ContentMessages.clearCursor, 'AccessFu:CursorCleared'],
@ -204,8 +203,12 @@
{'string': 'headingLevel', 'args': [1]},
{'string': 'dialog'}])],
// XXX: Place cursor back where it was.
[doc.defaultView.hideAlert,
[ContentMessages.simpleMoveNext,
new ExpectedCursorChange(['Do you agree?'])],
[ContentMessages.simpleMoveNext,
new ExpectedCursorChange(['Yes', {'string': 'pushbutton'}])],
[ContentMessages.activateCurrent(),
new ExpectedClickAction(),
new ExpectedCursorChange(
['wow', {'string': 'headingLevel', 'args': [1]}, 'such app'])],