Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)

This commit is contained in:
Neil Deakin
2009-06-10 14:00:39 -04:00
parent 66b8500cf2
commit f62906b6b1
139 changed files with 7382 additions and 6804 deletions

View File

@@ -285,23 +285,13 @@ var PrintUtils = {
var printPreviewTB = document.getElementById("print-preview-toolbar");
getNavToolbox().parentNode.removeChild(printPreviewTB);
var contentWindow = aWindow || window.content;
contentWindow.focus();
var cmdDispatcher = document.commandDispatcher;
cmdDispatcher.suppressFocusScroll = true;
if (gFocusedElement instanceof HTMLElement ||
gFocusedElement instanceof XULElement ||
gFocusedElement instanceof Window) {
gFocusedElement.focus();
}
else if (gFocusedElement instanceof Node) {
var content = window.content;
if (content instanceof Components.interfaces.nsIInterfaceRequestor)
content.getInterface(Components.interfaces.nsIDOMWindowUtils).focus(gFocusedElement);
}
var fm = Components.classes["@mozilla.org/focus-manager;1"]
.getService(Components.interfaces.nsIFocusManager);
if (gFocusedElement)
fm.setFocus(gFocusedElement, fm.FLAG_NOSCROLL);
else
(aWindow || window.content).focus();
gFocusedElement = null;
cmdDispatcher.suppressFocusScroll = false;
// on Exit PP Call back
if (this._onExitPP) {