Bug 421410 - "selected text in input box is cleared/unselected after print preview" [p=martijn.martijn@gmail.com (Martijn Wargers) r=Enn a1.9=beltzner]

This commit is contained in:
reed@reedloden.com 2008-03-08 01:49:02 -08:00
Родитель ed9ea84d85
Коммит 65db039b13
1 изменённых файлов: 18 добавлений и 0 удалений

Просмотреть файл

@ -41,6 +41,7 @@
var gPrintSettingsAreGlobal = false;
var gSavePrintSettings = false;
var gFocusedElement = null;
var PrintUtils = {
@ -215,6 +216,8 @@ var PrintUtils = {
enterPrintPreview: function (aWindow)
{
gFocusedElement = document.commandDispatcher.focusedElement;
var webBrowserPrint = this.getWebBrowserPrint(aWindow);
var printSettings = this.getPrintSettings();
try {
@ -285,6 +288,21 @@ var PrintUtils = {
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);
}
gFocusedElement = null;
cmdDispatcher.suppressFocusScroll = false;
// on Exit PP Call back
if (this._onExitPP) {
this._onExitPP();