mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 15:52:07 +00:00
backout Bug 544018
This commit is contained in:
parent
93a48e52ac
commit
f09ebf9810
@ -2536,34 +2536,11 @@ function BrowserReloadWithFlags(reloadFlags) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var PrintPreviewListener = {
|
var PrintPreviewListener = {
|
||||||
_printPreviewTab: null,
|
|
||||||
_tabBeforePrintPreview: null,
|
|
||||||
|
|
||||||
getPrintPreviewBrowser: function () {
|
|
||||||
if (!this._printPreviewTab) {
|
|
||||||
this._tabBeforePrintPreview = gBrowser.selectedTab;
|
|
||||||
this._printPreviewTab = gBrowser.loadOneTab("about:blank",
|
|
||||||
{ inBackground: false });
|
|
||||||
gBrowser.selectedTab = this._printPreviewTab;
|
|
||||||
}
|
|
||||||
return gBrowser.getBrowserForTab(this._printPreviewTab);
|
|
||||||
},
|
|
||||||
getSourceBrowser: function () {
|
|
||||||
return this._tabBeforePrintPreview ?
|
|
||||||
this._tabBeforePrintPreview.linkedBrowser : gBrowser.selectedBrowser;
|
|
||||||
},
|
|
||||||
getNavToolbox: function () {
|
|
||||||
return gNavToolbox;
|
|
||||||
},
|
|
||||||
onEnter: function () {
|
onEnter: function () {
|
||||||
gInPrintPreviewMode = true;
|
gInPrintPreviewMode = true;
|
||||||
this._toggleAffectedChrome();
|
this._toggleAffectedChrome();
|
||||||
},
|
},
|
||||||
onExit: function () {
|
onExit: function () {
|
||||||
gBrowser.selectedTab = this._tabBeforePrintPreview;
|
|
||||||
this._tabBeforePrintPreview = null;
|
|
||||||
gBrowser.removeTab(this._printPreviewTab);
|
|
||||||
this._printPreviewTab = null;
|
|
||||||
gInPrintPreviewMode = false;
|
gInPrintPreviewMode = false;
|
||||||
this._toggleAffectedChrome();
|
this._toggleAffectedChrome();
|
||||||
},
|
},
|
||||||
@ -2595,7 +2572,8 @@ var PrintPreviewListener = {
|
|||||||
this._chromeState.sidebarOpen = !sidebar.hidden;
|
this._chromeState.sidebarOpen = !sidebar.hidden;
|
||||||
this._sidebarCommand = sidebar.getAttribute("sidebarcommand");
|
this._sidebarCommand = sidebar.getAttribute("sidebarcommand");
|
||||||
|
|
||||||
gBrowser.mStrip.setAttribute("moz-collapsed", "true");
|
this._chromeState.hadTabStrip = gBrowser.getStripVisibility();
|
||||||
|
gBrowser.setStripVisibilityTo(false);
|
||||||
|
|
||||||
var notificationBox = gBrowser.getNotificationBox();
|
var notificationBox = gBrowser.getNotificationBox();
|
||||||
this._chromeState.notificationsOpen = !notificationBox.notificationsHidden;
|
this._chromeState.notificationsOpen = !notificationBox.notificationsHidden;
|
||||||
@ -2610,7 +2588,8 @@ var PrintPreviewListener = {
|
|||||||
gFindBar.close();
|
gFindBar.close();
|
||||||
},
|
},
|
||||||
_showChrome: function () {
|
_showChrome: function () {
|
||||||
gBrowser.mStrip.removeAttribute("moz-collapsed");
|
if (this._chromeState.hadTabStrip)
|
||||||
|
gBrowser.setStripVisibilityTo(true);
|
||||||
|
|
||||||
if (this._chromeState.notificationsOpen)
|
if (this._chromeState.notificationsOpen)
|
||||||
gBrowser.getNotificationBox().notificationsHidden = false;
|
gBrowser.getNotificationBox().notificationsHidden = false;
|
||||||
@ -2623,6 +2602,11 @@ var PrintPreviewListener = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getPPBrowser()
|
||||||
|
{
|
||||||
|
return gBrowser;
|
||||||
|
}
|
||||||
|
|
||||||
function getMarkupDocumentViewer()
|
function getMarkupDocumentViewer()
|
||||||
{
|
{
|
||||||
return gBrowser.markupDocumentViewer;
|
return gBrowser.markupDocumentViewer;
|
||||||
|
@ -1798,7 +1798,6 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsDocument)
|
|||||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mOnloadBlocker)
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mOnloadBlocker)
|
||||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mFirstBaseNodeWithHref)
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mFirstBaseNodeWithHref)
|
||||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mDOMImplementation)
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mDOMImplementation)
|
||||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mOriginalDocument)
|
|
||||||
|
|
||||||
// An element will only be in the linkmap as long as it's in the
|
// An element will only be in the linkmap as long as it's in the
|
||||||
// document, so we'll traverse the table here instead of from the element.
|
// document, so we'll traverse the table here instead of from the element.
|
||||||
@ -1852,7 +1851,6 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsDocument)
|
|||||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mDisplayDocument)
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mDisplayDocument)
|
||||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mFirstBaseNodeWithHref)
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mFirstBaseNodeWithHref)
|
||||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mDOMImplementation)
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mDOMImplementation)
|
||||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mOriginalDocument)
|
|
||||||
|
|
||||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_USERDATA
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_USERDATA
|
||||||
|
|
||||||
|
@ -87,27 +87,32 @@ var PrintUtils = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// If aCallback is not null, it must be an object which has the following methods:
|
// calling PrintUtils.printPreview() requires that you have three functions
|
||||||
// getPrintPreviewBrowser(), getSourceBrowser(),
|
// in the global scope: getPPBrowser(), which returns the browser element in
|
||||||
// getNavToolbox(), onEnter() and onExit().
|
// the window print preview uses, getNavToolbox(), which returns the element
|
||||||
// If aCallback is null, then printPreview must previously have been called with
|
// (usually the main toolbox element) before which the print preview toolbar
|
||||||
// non-null aCallback and that object will be reused.
|
// should be inserted, and getWebNavigation(), which returns the document's
|
||||||
printPreview: function (aCallback)
|
// nsIWebNavigation object
|
||||||
|
printPreview: function (aListenerOrEnterCallback, aExitCallback)
|
||||||
{
|
{
|
||||||
// if we're already in PP mode, don't set the callback; chances
|
// if we're already in PP mode, don't set the callbacks; chances
|
||||||
// are it is null because someone is calling printPreview() to
|
// are they're null because someone is calling printPreview() to
|
||||||
// get us to refresh the display.
|
// get us to refresh the display.
|
||||||
if (!document.getElementById("print-preview-toolbar")) {
|
if (!document.getElementById("print-preview-toolbar")) {
|
||||||
this._callback = aCallback;
|
if (typeof aListenerOrEnterCallback == "object") {
|
||||||
this._sourceBrowser = aCallback.getSourceBrowser();
|
this._onEnterPP = function () { aListenerOrEnterCallback.onEnter(); };
|
||||||
this._originalTitle = this._sourceBrowser.contentDocument.title;
|
this._onExitPP = function () { aListenerOrEnterCallback.onExit(); };
|
||||||
this._originalURL = this._sourceBrowser.currentURI.spec;
|
} else {
|
||||||
|
this._onEnterPP = aListenerOrEnterCallback;
|
||||||
|
this._onExitPP = aExitCallback;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// collapse the browser here -- it will be shown in
|
// collapse the browser here -- it will be shown in
|
||||||
// enterPrintPreview; this forces a reflow which fixes display
|
// onEnterPrintPreview; this forces a reflow which fixes display
|
||||||
// issues in bug 267422.
|
// issues in bug 267422.
|
||||||
this._sourceBrowser = this._callback.getPrintPreviewBrowser();
|
var browser = getPPBrowser();
|
||||||
this._sourceBrowser.collapsed = true;
|
if (browser)
|
||||||
|
browser.collapsed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
this._webProgressPP = {};
|
this._webProgressPP = {};
|
||||||
@ -128,8 +133,9 @@ var PrintUtils = {
|
|||||||
PPROMPTSVC.showProgress(window, webBrowserPrint, printSettings, this._obsPP, false,
|
PPROMPTSVC.showProgress(window, webBrowserPrint, printSettings, this._obsPP, false,
|
||||||
this._webProgressPP, ppParams, notifyOnOpen);
|
this._webProgressPP, ppParams, notifyOnOpen);
|
||||||
if (ppParams.value) {
|
if (ppParams.value) {
|
||||||
ppParams.value.docTitle = this._originalTitle;
|
var webNav = getWebNavigation();
|
||||||
ppParams.value.docURL = this._originalURL;
|
ppParams.value.docTitle = webNav.document.title;
|
||||||
|
ppParams.value.docURL = webNav.currentURI.spec;
|
||||||
}
|
}
|
||||||
|
|
||||||
// this tells us whether we should continue on with PP or
|
// this tells us whether we should continue on with PP or
|
||||||
@ -149,7 +155,11 @@ var PrintUtils = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
getPrintPreview: function() {
|
getPrintPreview: function() {
|
||||||
return this._callback.getPrintPreviewBrowser().docShell.printPreview;
|
if (this._printPreviewTab) {
|
||||||
|
var docShell = getPPBrowser().getBrowserForTab(this._printPreviewTab).docShell;
|
||||||
|
return docShell.printPreview;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
},
|
},
|
||||||
|
|
||||||
////////////////////////////////////////
|
////////////////////////////////////////
|
||||||
@ -195,10 +205,8 @@ var PrintUtils = {
|
|||||||
_originalZoomValue: null,
|
_originalZoomValue: null,
|
||||||
_closeHandlerPP: null,
|
_closeHandlerPP: null,
|
||||||
_webProgressPP: null,
|
_webProgressPP: null,
|
||||||
_callback: null,
|
_onEnterPP: null,
|
||||||
_sourceBrowser: null,
|
_onExitPP: null,
|
||||||
_originalTitle: "",
|
|
||||||
_originalURL: "",
|
|
||||||
|
|
||||||
// This observer is called once the progress dialog has been "opened"
|
// This observer is called once the progress dialog has been "opened"
|
||||||
_obsPP:
|
_obsPP:
|
||||||
@ -219,6 +227,9 @@ var PrintUtils = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_originalTab: null,
|
||||||
|
_printPreviewTab: null,
|
||||||
|
|
||||||
enterPrintPreview: function ()
|
enterPrintPreview: function ()
|
||||||
{
|
{
|
||||||
gFocusedElement = document.commandDispatcher.focusedElement;
|
gFocusedElement = document.commandDispatcher.focusedElement;
|
||||||
@ -231,13 +242,27 @@ var PrintUtils = {
|
|||||||
|
|
||||||
var webBrowserPrint;
|
var webBrowserPrint;
|
||||||
var printSettings = this.getPrintSettings();
|
var printSettings = this.getPrintSettings();
|
||||||
var originalWindow = this._sourceBrowser.contentWindow;
|
var tabbrowser = getPPBrowser();
|
||||||
|
var contentWindow = null;
|
||||||
|
if (tabbrowser) {
|
||||||
|
if (this._printPreviewTab) {
|
||||||
|
contentWindow =
|
||||||
|
tabbrowser.getBrowserForTab(this._printPreviewTab).contentWindow;
|
||||||
|
} else {
|
||||||
|
this._originalTab = tabbrowser.mCurrentTab;
|
||||||
|
contentWindow = window.content
|
||||||
|
this._printPreviewTab = tabbrowser.loadOneTab("about:blank", null, null,
|
||||||
|
null, true, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
webBrowserPrint = this.getPrintPreview();
|
webBrowserPrint = this.getPrintPreview();
|
||||||
webBrowserPrint.printPreview(printSettings, originalWindow,
|
webBrowserPrint.printPreview(printSettings, contentWindow,
|
||||||
this._webProgressPP.value);
|
this._webProgressPP.value);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
this._printPreviewTab = null;
|
||||||
|
this._originalTab = null;
|
||||||
if (typeof ZoomManager == "object")
|
if (typeof ZoomManager == "object")
|
||||||
ZoomManager.zoom = this._originalZoomValue;
|
ZoomManager.zoom = this._originalZoomValue;
|
||||||
// Pressing cancel is expressed as an NS_ERROR_ABORT return value,
|
// Pressing cancel is expressed as an NS_ERROR_ABORT return value,
|
||||||
@ -250,9 +275,12 @@ var PrintUtils = {
|
|||||||
var printPreviewTB = document.getElementById("print-preview-toolbar");
|
var printPreviewTB = document.getElementById("print-preview-toolbar");
|
||||||
if (printPreviewTB) {
|
if (printPreviewTB) {
|
||||||
printPreviewTB.updateToolbar();
|
printPreviewTB.updateToolbar();
|
||||||
var browser = this._callback.getPrintPreviewBrowser();
|
var browser = getPPBrowser();
|
||||||
browser.collapsed = false;
|
if (browser)
|
||||||
browser.contentWindow.focus();
|
browser.collapsed = false;
|
||||||
|
|
||||||
|
tabbrowser.getBrowserForTab(this._printPreviewTab).contentWindow.focus();
|
||||||
|
tabbrowser.selectedTab = this._printPreviewTab;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -265,7 +293,7 @@ var PrintUtils = {
|
|||||||
printPreviewTB.id = "print-preview-toolbar";
|
printPreviewTB.id = "print-preview-toolbar";
|
||||||
printPreviewTB.className = "toolbar-primary";
|
printPreviewTB.className = "toolbar-primary";
|
||||||
|
|
||||||
var navToolbox = this._callback.getNavToolbox();
|
var navToolbox = getNavToolbox();
|
||||||
navToolbox.parentNode.insertBefore(printPreviewTB, navToolbox);
|
navToolbox.parentNode.insertBefore(printPreviewTB, navToolbox);
|
||||||
|
|
||||||
// copy the window close handler
|
// copy the window close handler
|
||||||
@ -278,12 +306,14 @@ var PrintUtils = {
|
|||||||
// disable chrome shortcuts...
|
// disable chrome shortcuts...
|
||||||
window.addEventListener("keypress", this.onKeyPressPP, true);
|
window.addEventListener("keypress", this.onKeyPressPP, true);
|
||||||
|
|
||||||
var browser = this._callback.getPrintPreviewBrowser();
|
tabbrowser.getBrowserForTab(this._printPreviewTab).contentWindow.focus();
|
||||||
browser.collapsed = false;
|
tabbrowser.selectedTab = this._printPreviewTab;
|
||||||
browser.contentWindow.focus();
|
|
||||||
|
|
||||||
// on Enter PP Call back
|
// on Enter PP Call back
|
||||||
this._callback.onEnter();
|
if (this._onEnterPP) {
|
||||||
|
this._onEnterPP();
|
||||||
|
this._onEnterPP = null;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
exitPrintPreview: function ()
|
exitPrintPreview: function ()
|
||||||
@ -294,15 +324,23 @@ var PrintUtils = {
|
|||||||
document.documentElement.setAttribute("onclose", this._closeHandlerPP);
|
document.documentElement.setAttribute("onclose", this._closeHandlerPP);
|
||||||
this._closeHandlerPP = null;
|
this._closeHandlerPP = null;
|
||||||
|
|
||||||
var webBrowserPrint = this.getPrintPreview();
|
var webBrowserPrint = this.getWebBrowserPrint();
|
||||||
webBrowserPrint.exitPrintPreview();
|
webBrowserPrint.exitPrintPreview();
|
||||||
|
|
||||||
|
var tabbrowser = getPPBrowser();
|
||||||
|
if (tabbrowser) {
|
||||||
|
tabbrowser.removeTab(this._printPreviewTab);
|
||||||
|
tabbrowser.selectedTab = this._originalTab;
|
||||||
|
this._originalTab = null;
|
||||||
|
this._printPreviewTab = null;
|
||||||
|
}
|
||||||
|
|
||||||
if (typeof ZoomManager == "object")
|
if (typeof ZoomManager == "object")
|
||||||
ZoomManager.zoom = this._originalZoomValue;
|
ZoomManager.zoom = this._originalZoomValue;
|
||||||
|
|
||||||
// remove the print preview toolbar
|
// remove the print preview toolbar
|
||||||
var printPreviewTB = document.getElementById("print-preview-toolbar");
|
var printPreviewTB = document.getElementById("print-preview-toolbar");
|
||||||
this._callback.getNavToolbox().parentNode.removeChild(printPreviewTB);
|
getNavToolbox().parentNode.removeChild(printPreviewTB);
|
||||||
|
|
||||||
var fm = Components.classes["@mozilla.org/focus-manager;1"]
|
var fm = Components.classes["@mozilla.org/focus-manager;1"]
|
||||||
.getService(Components.interfaces.nsIFocusManager);
|
.getService(Components.interfaces.nsIFocusManager);
|
||||||
@ -312,7 +350,11 @@ var PrintUtils = {
|
|||||||
window.content.focus();
|
window.content.focus();
|
||||||
gFocusedElement = null;
|
gFocusedElement = null;
|
||||||
|
|
||||||
this._callback.onExit();
|
// on Exit PP Call back
|
||||||
|
if (this._onExitPP) {
|
||||||
|
this._onExitPP();
|
||||||
|
this._onExitPP = null;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onKeyPressPP: function (aEvent)
|
onKeyPressPP: function (aEvent)
|
||||||
|
@ -78,7 +78,7 @@
|
|||||||
|
|
||||||
<command id="cmd_savePage" oncommand="ViewSourceSavePage();"/>
|
<command id="cmd_savePage" oncommand="ViewSourceSavePage();"/>
|
||||||
<command id="cmd_print" oncommand="PrintUtils.print();"/>
|
<command id="cmd_print" oncommand="PrintUtils.print();"/>
|
||||||
<command id="cmd_printpreview" oncommand="PrintUtils.printPreview(PrintPreviewListener);"/>
|
<command id="cmd_printpreview" oncommand="PrintUtils.printPreview(onEnterPP, onExitPP);"/>
|
||||||
<command id="cmd_pagesetup" oncommand="PrintUtils.showPageSetup();"/>
|
<command id="cmd_pagesetup" oncommand="PrintUtils.showPageSetup();"/>
|
||||||
<command id="cmd_close" oncommand="window.close();"/>
|
<command id="cmd_close" oncommand="window.close();"/>
|
||||||
<commandset id="editMenuCommands"/>
|
<commandset id="editMenuCommands"/>
|
||||||
|
@ -383,34 +383,26 @@ function ViewSourceSavePage()
|
|||||||
saveURL(window.content.location.href.substring(12), null, "SaveLinkTitle");
|
saveURL(window.content.location.href.substring(12), null, "SaveLinkTitle");
|
||||||
}
|
}
|
||||||
|
|
||||||
var PrintPreviewListener = {
|
function onEnterPP()
|
||||||
getPrintPreviewBrowser: function () {
|
{
|
||||||
var browser = document.getElementById("ppBrowser");
|
var toolbox = document.getElementById("viewSource-toolbox");
|
||||||
if (!browser) {
|
toolbox.hidden = true;
|
||||||
browser = document.createElement("browser");
|
}
|
||||||
browser.setAttribute("id", "ppBrowser");
|
|
||||||
browser.setAttribute("flex", "1");
|
function onExitPP()
|
||||||
document.getElementById("appcontent").
|
{
|
||||||
insertBefore(browser, document.getElementById("FindToolbar"));
|
var toolbox = document.getElementById("viewSource-toolbox");
|
||||||
}
|
toolbox.hidden = false;
|
||||||
return browser;
|
}
|
||||||
},
|
|
||||||
getSourceBrowser: function () {
|
function getPPBrowser() {
|
||||||
return gBrowser;
|
return gBrowser;
|
||||||
},
|
}
|
||||||
getNavToolbox: function () {
|
|
||||||
return document.getElementById("appcontent");
|
// printUtils.js uses this
|
||||||
},
|
function getNavToolbox()
|
||||||
onEnter: function () {
|
{
|
||||||
var toolbox = document.getElementById("viewSource-toolbox");
|
return document.getElementById("appcontent");
|
||||||
toolbox.hidden = true;
|
|
||||||
gBrowser.collapsed = true;
|
|
||||||
},
|
|
||||||
onExit: function () {
|
|
||||||
document.getElementById("ppBrowser").collapsed = true;
|
|
||||||
gBrowser.collapsed = false;
|
|
||||||
document.getElementById("viewSource-toolbox").hidden = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getWebNavigation()
|
function getWebNavigation()
|
||||||
|
@ -78,7 +78,7 @@
|
|||||||
|
|
||||||
<command id="cmd_savePage" oncommand="ViewSourceSavePage();"/>
|
<command id="cmd_savePage" oncommand="ViewSourceSavePage();"/>
|
||||||
<command id="cmd_print" oncommand="PrintUtils.print();"/>
|
<command id="cmd_print" oncommand="PrintUtils.print();"/>
|
||||||
<command id="cmd_printpreview" oncommand="PrintUtils.printPreview(PrintPreviewListener);"/>
|
<command id="cmd_printpreview" oncommand="PrintUtils.printPreview(onEnterPP, onExitPP);"/>
|
||||||
<command id="cmd_pagesetup" oncommand="PrintUtils.showPageSetup();"/>
|
<command id="cmd_pagesetup" oncommand="PrintUtils.showPageSetup();"/>
|
||||||
<command id="cmd_close" oncommand="window.close();"/>
|
<command id="cmd_close" oncommand="window.close();"/>
|
||||||
<commandset id="editMenuCommands"/>
|
<commandset id="editMenuCommands"/>
|
||||||
|
Loading…
Reference in New Issue
Block a user