gecko-dev/toolkit/components/viewsource/content/viewSource.xul
Mike Conley 03b699b5f3 Bug 1146454 - Stop using CPOWs for printing. r=billm
We were passing around content window CPOWs before to indicate
which content to send to the printer. This was, naturally, causing
unsafe CPOW usage warnings - especially when attempting to get at
the content window of an iframe with the context menu printing
command.

This patch changes the printing mechanism to use outer window IDs
instead of CPOWs.

--HG--
extra : commitid : 7bG2asTYoDR
extra : rebase_source : 3d8d10dbd0d7ce4b2891d81b5f15d71341b79f84
2015-07-03 16:06:04 -04:00

235 lines
12 KiB
XML

<?xml version="1.0"?>
# -*- Mode: HTML -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://global/content/viewSource.css" type="text/css"?>
<?xml-stylesheet href="chrome://mozapps/skin/viewsource/viewsource.css" type="text/css"?>
<?xul-overlay href="chrome://global/content/editMenuOverlay.xul"?>
<!DOCTYPE window [
<!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd" >
%brandDTD;
<!ENTITY % sourceDTD SYSTEM "chrome://global/locale/viewSource.dtd" >
%sourceDTD;
<!ENTITY % charsetDTD SYSTEM "chrome://global/locale/charsetMenu.dtd" >
%charsetDTD;
]>
<window id="viewSource"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
contenttitlesetting="true"
title="&mainWindow.title;"
titlemodifier="&mainWindow.titlemodifier;"
titlepreface="&mainWindow.preface;"
titlemenuseparator ="&mainWindow.titlemodifierseparator;"
windowtype="navigator:view-source"
width="640" height="480"
screenX="10" screenY="10"
persist="screenX screenY width height sizemode">
<script type="application/javascript" src="chrome://global/content/globalOverlay.js"/>
<script type="application/javascript" src="chrome://global/content/printUtils.js"/>
<script type="application/javascript" src="chrome://global/content/viewSource.js"/>
<script type="application/javascript" src="chrome://global/content/viewZoomOverlay.js"/>
<script type="application/javascript" src="chrome://global/content/contentAreaUtils.js"/>
<stringbundle id="viewSourceBundle" src="chrome://global/locale/viewSource.properties"/>
<command id="cmd_savePage" oncommand="ViewSourceSavePage();"/>
<command id="cmd_print" oncommand="PrintUtils.printWindow(gBrowser.outerWindowID, gBrowser);"/>
<command id="cmd_printpreview" oncommand="PrintUtils.printPreview(PrintPreviewListener);"/>
<command id="cmd_pagesetup" oncommand="PrintUtils.showPageSetup();"/>
<command id="cmd_close" oncommand="window.close();"/>
<commandset id="editMenuCommands"/>
<command id="cmd_find"
oncommand="document.getElementById('FindToolbar').onFindCommand();"/>
<command id="cmd_findAgain"
oncommand="document.getElementById('FindToolbar').onFindAgainCommand(false);"/>
<command id="cmd_findPrevious"
oncommand="document.getElementById('FindToolbar').onFindAgainCommand(true);"/>
#ifdef XP_MACOSX
<command id="cmd_findSelection"
oncommand="document.getElementById('FindToolbar').onFindSelectionCommand();"/>
#endif
<command id="cmd_reload" oncommand="viewSourceChrome.reload();"/>
<command id="cmd_goToLine" oncommand="viewSourceChrome.promptAndGoToLine();" disabled="true"/>
<command id="cmd_highlightSyntax" oncommand="viewSourceChrome.toggleSyntaxHighlighting();"/>
<command id="cmd_wrapLongLines" oncommand="viewSourceChrome.toggleWrapping();"/>
<command id="cmd_textZoomReduce" oncommand="ZoomManager.reduce();"/>
<command id="cmd_textZoomEnlarge" oncommand="ZoomManager.enlarge();"/>
<command id="cmd_textZoomReset" oncommand="ZoomManager.reset();"/>
<command id="Browser:Back" oncommand="viewSourceChrome.goBack()" observes="viewSourceNavigation"/>
<command id="Browser:Forward" oncommand="viewSourceChrome.goForward()" observes="viewSourceNavigation"/>
<broadcaster id="viewSourceNavigation"/>
<keyset id="editMenuKeys"/>
<keyset id="viewSourceKeys">
<key id="key_savePage" key="&savePageCmd.commandkey;" modifiers="accel" command="cmd_savePage"/>
<key id="key_print" key="&printCmd.commandkey;" modifiers="accel" command="cmd_print"/>
<key id="key_close" key="&closeCmd.commandkey;" modifiers="accel" command="cmd_close"/>
<key id="key_goToLine" key="&goToLineCmd.commandkey;" command="cmd_goToLine" modifiers="accel"/>
<key id="key_textZoomEnlarge" key="&textEnlarge.commandkey;" command="cmd_textZoomEnlarge" modifiers="accel"/>
<key id="key_textZoomEnlarge2" key="&textEnlarge.commandkey2;" command="cmd_textZoomEnlarge" modifiers="accel"/>
<key id="key_textZoomEnlarge3" key="&textEnlarge.commandkey3;" command="cmd_textZoomEnlarge" modifiers="accel"/>
<key id="key_textZoomReduce" key="&textReduce.commandkey;" command="cmd_textZoomReduce" modifiers="accel"/>
<key id="key_textZoomReduce2" key="&textReduce.commandkey2;" command="cmd_textZoomReduce" modifiers="accel"/>
<key id="key_textZoomReset" key="&textReset.commandkey;" command="cmd_textZoomReset" modifiers="accel"/>
<key id="key_textZoomReset2" key="&textReset.commandkey2;" command="cmd_textZoomReset" modifiers="accel"/>
<key id="key_reload" key="&reloadCmd.commandkey;" command="cmd_reload" modifiers="accel"/>
<key key="&reloadCmd.commandkey;" command="cmd_reload" modifiers="accel,shift"/>
<key keycode="VK_F5" command="cmd_reload"/>
<key keycode="VK_F5" command="cmd_reload" modifiers="accel"/>
<key id="key_find" key="&findOnCmd.commandkey;" command="cmd_find" modifiers="accel"/>
<key id="key_findAgain" key="&findAgainCmd.commandkey;" command="cmd_findAgain" modifiers="accel"/>
<key id="key_findPrevious" key="&findAgainCmd.commandkey;" command="cmd_findPrevious" modifiers="accel,shift"/>
#ifdef XP_MACOSX
<key id="key_findSelection" key="&findSelectionCmd.commandkey;" command="cmd_findSelection" modifiers="accel"/>
#endif
<key keycode="&findAgainCmd.commandkey2;" command="cmd_findAgain"/>
<key keycode="&findAgainCmd.commandkey2;" command="cmd_findPrevious" modifiers="shift"/>
<key keycode="VK_BACK" command="Browser:Back"/>
<key keycode="VK_BACK" command="Browser:Forward" modifiers="shift"/>
#ifndef XP_MACOSX
<key id="goBackKb" keycode="VK_LEFT" command="Browser:Back" modifiers="alt"/>
<key id="goForwardKb" keycode="VK_RIGHT" command="Browser:Forward" modifiers="alt"/>
#else
<key id="goBackKb" keycode="VK_LEFT" command="Browser:Back" modifiers="accel" />
<key id="goForwardKb" keycode="VK_RIGHT" command="Browser:Forward" modifiers="accel" />
#endif
#ifdef XP_UNIX
<key id="goBackKb2" key="&goBackCmd.commandKey;" command="Browser:Back" modifiers="accel"/>
<key id="goForwardKb2" key="&goForwardCmd.commandKey;" command="Browser:Forward" modifiers="accel"/>
#endif
</keyset>
<tooltip id="aHTMLTooltip" page="true"/>
<menupopup id="viewSourceContextMenu">
<menuitem id="context-back"
label="&backCmd.label;"
accesskey="&backCmd.accesskey;"
command="Browser:Back"
observes="viewSourceNavigation"/>
<menuitem id="context-forward"
label="&forwardCmd.label;"
accesskey="&forwardCmd.accesskey;"
command="Browser:Forward"
observes="viewSourceNavigation"/>
<menuseparator observes="viewSourceNavigation"/>
<menuitem id="cMenu_findAgain"/>
<menuseparator/>
<menuitem id="cMenu_copy"/>
<menuitem id="context-copyLink"
label="&copyLinkCmd.label;"
accesskey="&copyLinkCmd.accesskey;"
oncommand="viewSourceChrome.onContextMenuCopyLinkOrEmail();"/>
<menuitem id="context-copyEmail"
label="&copyEmailCmd.label;"
accesskey="&copyEmailCmd.accesskey;"
oncommand="viewSourceChrome.onContextMenuCopyLinkOrEmail();"/>
<menuseparator/>
<menuitem id="cMenu_selectAll"/>
</menupopup>
<!-- Menu -->
<toolbox id="viewSource-toolbox">
<menubar id="viewSource-main-menubar">
<menu id="menu_file" label="&fileMenu.label;" accesskey="&fileMenu.accesskey;">
<menupopup id="menu_FilePopup">
<menuitem key="key_savePage" command="cmd_savePage" id="menu_savePage"
label="&savePageCmd.label;" accesskey="&savePageCmd.accesskey;"/>
<menuitem command="cmd_pagesetup" id="menu_pageSetup"
label="&pageSetupCmd.label;" accesskey="&pageSetupCmd.accesskey;"/>
#ifndef XP_MACOSX
<menuitem command="cmd_printpreview" id="menu_printPreview"
label="&printPreviewCmd.label;" accesskey="&printPreviewCmd.accesskey;"/>
#endif
<menuitem key="key_print" command="cmd_print" id="menu_print"
label="&printCmd.label;" accesskey="&printCmd.accesskey;"/>
<menuseparator/>
<menuitem key="key_close" command="cmd_close" id="menu_close"
label="&closeCmd.label;" accesskey="&closeCmd.accesskey;"/>
</menupopup>
</menu>
<menu id="menu_edit">
<menupopup id="editmenu-popup">
<menuitem id="menu_undo"/>
<menuitem id="menu_redo"/>
<menuseparator/>
<menuitem id="menu_cut"/>
<menuitem id="menu_copy"/>
<menuitem id="menu_paste"/>
<menuitem id="menu_delete"/>
<menuseparator/>
<menuitem id="menu_selectAll"/>
<menuseparator/>
<menuitem id="menu_find"/>
<menuitem id="menu_findAgain"/>
<menuseparator/>
<menuitem id="menu_goToLine" key="key_goToLine" command="cmd_goToLine"
label="&goToLineCmd.label;" accesskey="&goToLineCmd.accesskey;"/>
</menupopup>
</menu>
<menu id="menu_view" label="&viewMenu.label;" accesskey="&viewMenu.accesskey;">
<menupopup id="viewmenu-popup">
<menuitem id="menu_reload" command="cmd_reload" accesskey="&reloadCmd.accesskey;"
label="&reloadCmd.label;" key="key_reload"/>
<menuseparator />
<menu id="viewTextZoomMenu" label="&menu_textSize.label;" accesskey="&menu_textSize.accesskey;">
<menupopup>
<menuitem id="menu_textEnlarge" command="cmd_textZoomEnlarge"
label="&menu_textEnlarge.label;" accesskey="&menu_textEnlarge.accesskey;"
key="key_textZoomEnlarge"/>
<menuitem id="menu_textReduce" command="cmd_textZoomReduce"
label="&menu_textReduce.label;" accesskey="&menu_textReduce.accesskey;"
key="key_textZoomReduce"/>
<menuseparator/>
<menuitem id="menu_textReset" command="cmd_textZoomReset"
label="&menu_textReset.label;" accesskey="&menu_textReset.accesskey;"
key="key_textZoomReset"/>
</menupopup>
</menu>
<!-- Charset Menu -->
<menu id="charsetMenu"
label="&charsetMenu2.label;"
accesskey="&charsetMenu2.accesskey;"
oncommand="viewSourceChrome.onSetCharacterSet(event);"
onpopupshowing="CharsetMenu.build(event.target);"
onpopupshown="CharsetMenu.update(event.target, content.document.characterSet);">
<menupopup/>
</menu>
<menuseparator/>
<menuitem id="menu_wrapLongLines" type="checkbox" command="cmd_wrapLongLines"
label="&menu_wrapLongLines.title;" accesskey="&menu_wrapLongLines.accesskey;"/>
<menuitem type="checkbox" id="menu_highlightSyntax" command="cmd_highlightSyntax"
label="&menu_highlightSyntax.label;" accesskey="&menu_highlightSyntax.accesskey;"/>
</menupopup>
</menu>
</menubar>
</toolbox>
<vbox id="appcontent" flex="1">
<browser id="content" type="content-primary" name="content" src="about:blank" flex="1"
context="viewSourceContextMenu" showcaret="true" tooltip="aHTMLTooltip" />
<findbar id="FindToolbar" browserid="content"/>
</vbox>
<statusbar id="status-bar" class="chromeclass-status">
<statusbarpanel id="statusbar-line-col" label="" flex="1"/>
</statusbar>
</window>