Bug 185239 - Print Frame in context menu. r=gavin, ui-r=mconnor.

This commit is contained in:
mozilla.mano%sent.com 2006-12-01 12:33:30 +00:00
Родитель 80fcb1bc9c
Коммит b33e19c89c
4 изменённых файлов: 27 добавлений и 14 удалений

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

@ -207,12 +207,16 @@
accesskey="&saveFrameCmd.accesskey;" accesskey="&saveFrameCmd.accesskey;"
oncommand="saveDocument(gContextMenu.target.ownerDocument);"/> oncommand="saveDocument(gContextMenu.target.ownerDocument);"/>
<menuseparator/> <menuseparator/>
<menuitem label="&printFrameCmd.label;"
accesskey="&printFrameCmd.accesskey;"
oncommand="gContextMenu.printFrame();"/>
<menuseparator/>
<menuitem label="&viewFrameSourceCmd.label;" <menuitem label="&viewFrameSourceCmd.label;"
accesskey="&viewFrameSourceCmd.accesskey;" accesskey="&viewFrameSourceCmd.accesskey;"
oncommand="gContextMenu.viewFrameSource();"/> oncommand="gContextMenu.viewFrameSource();"/>
<menuitem label="&viewFrameInfoCmd.label;" <menuitem label="&viewFrameInfoCmd.label;"
accesskey="&viewFrameInfoCmd.accesskey;" accesskey="&viewFrameInfoCmd.accesskey;"
oncommand="gContextMenu.viewFrameInfo();"/> oncommand="gContextMenu.viewFrameInfo();"/>
</menupopup> </menupopup>
</menu> </menu>
<menuseparator id="context-sep-properties"/> <menuseparator id="context-sep-properties"/>

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

@ -1118,5 +1118,9 @@ nsContextMenu.prototype = {
savePageAs: function() { savePageAs: function() {
saveDocument(this.browser.contentDocument); saveDocument(this.browser.contentDocument);
},
printFrame: function() {
PrintUtils.print(this.target.ownerDocument.defaultView);
} }
}; };

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

@ -281,6 +281,8 @@
<!ENTITY savePageCmd.commandkey "s"> <!ENTITY savePageCmd.commandkey "s">
<!ENTITY saveFrameCmd.label "Save Frame As..."> <!ENTITY saveFrameCmd.label "Save Frame As...">
<!ENTITY saveFrameCmd.accesskey "F"> <!ENTITY saveFrameCmd.accesskey "F">
<!ENTITY printFrameCmd.label "Print Frame...">
<!ENTITY printFrameCmd.accesskey "P">
<!ENTITY saveLinkCmd.label "Save Link As..."> <!ENTITY saveLinkCmd.label "Save Link As...">
<!ENTITY saveLinkCmd.accesskey "k"> <!ENTITY saveLinkCmd.accesskey "k">
<!ENTITY sendLinkCmd.label "Send Link..."> <!ENTITY sendLinkCmd.label "Send Link...">

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

@ -66,9 +66,9 @@ var PrintUtils = {
return true; return true;
}, },
print: function () print: function (aWindow)
{ {
var webBrowserPrint = this.getWebBrowserPrint(); var webBrowserPrint = this.getWebBrowserPrint(aWindow);
var printSettings = this.getPrintSettings(); var printSettings = this.getPrintSettings();
try { try {
webBrowserPrint.print(printSettings, null); webBrowserPrint.print(printSettings, null);
@ -88,7 +88,7 @@ var PrintUtils = {
} }
}, },
printPreview: function (aEnterPPCallback, aExitPPCallback) printPreview: function (aEnterPPCallback, aExitPPCallback, aWindow)
{ {
// if we're already in PP mode, don't set the callbacks; chances // if we're already in PP mode, don't set the callbacks; chances
// are they're null because someone is calling printPreview() to // are they're null because someone is calling printPreview() to
@ -107,7 +107,7 @@ var PrintUtils = {
this._webProgressPP = {}; this._webProgressPP = {};
var ppParams = {}; var ppParams = {};
var notifyOnOpen = {}; var notifyOnOpen = {};
var webBrowserPrint = this.getWebBrowserPrint(); var webBrowserPrint = this.getWebBrowserPrint(aWindow);
var printSettings = this.getPrintSettings(); var printSettings = this.getPrintSettings();
// Here we get the PrintingPromptService so we can display the PP Progress from script // Here we get the PrintingPromptService so we can display the PP Progress from script
// For the browser implemented via XUL with the PP toolbar we cannot let it be // For the browser implemented via XUL with the PP toolbar we cannot let it be
@ -136,10 +136,11 @@ var PrintUtils = {
} }
}, },
getWebBrowserPrint: function () getWebBrowserPrint: function (aWindow)
{ {
return _content.QueryInterface(Components.interfaces.nsIInterfaceRequestor) var contentWindow = aWindow ? aWindow : window.content;
.getInterface(Components.interfaces.nsIWebBrowserPrint); return contentWindow.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIWebBrowserPrint);
}, },
//////////////////////////////////////// ////////////////////////////////////////
@ -205,9 +206,9 @@ var PrintUtils = {
} }
}, },
enterPrintPreview: function () enterPrintPreview: function (aWindow)
{ {
var webBrowserPrint = this.getWebBrowserPrint(); var webBrowserPrint = this.getWebBrowserPrint(aWindow);
var printSettings = this.getPrintSettings(); var printSettings = this.getPrintSettings();
try { try {
webBrowserPrint.printPreview(printSettings, null, this._webProgressPP.value); webBrowserPrint.printPreview(printSettings, null, this._webProgressPP.value);
@ -252,7 +253,8 @@ var PrintUtils = {
// disable chrome shortcuts... // disable chrome shortcuts...
window.addEventListener("keypress", this.onKeyPressPP, true); window.addEventListener("keypress", this.onKeyPressPP, true);
_content.focus(); var contentWindow = aWindow ? aWindow : window.content;
contentWindow.focus();
// on Enter PP Call back // on Enter PP Call back
if (this._onEnterPP) { if (this._onEnterPP) {
@ -261,7 +263,7 @@ var PrintUtils = {
} }
}, },
exitPrintPreview: function () exitPrintPreview: function (aWindow)
{ {
window.removeEventListener("keypress", this.onKeyPressPP, true); window.removeEventListener("keypress", this.onKeyPressPP, true);
@ -277,14 +279,15 @@ var PrintUtils = {
if ("getStripVisibility" in getBrowser()) if ("getStripVisibility" in getBrowser())
getBrowser().setStripVisibilityTo(this._chromeState.hadTabStrip); getBrowser().setStripVisibilityTo(this._chromeState.hadTabStrip);
var webBrowserPrint = this.getWebBrowserPrint(); var webBrowserPrint = this.getWebBrowserPrint(aWindow);
webBrowserPrint.exitPrintPreview(); webBrowserPrint.exitPrintPreview();
// remove the print preview toolbar // remove the print preview toolbar
var printPreviewTB = document.getElementById("print-preview-toolbar"); var printPreviewTB = document.getElementById("print-preview-toolbar");
getBrowser().parentNode.removeChild(printPreviewTB); getBrowser().parentNode.removeChild(printPreviewTB);
_content.focus(); var contentWindow = aWindow ? aWindow : window.content;
contentWindow.focus();
// on Exit PP Call back // on Exit PP Call back
if (this._onExitPP) { if (this._onExitPP) {