toolkit/components/printing/content/printPreviewBindings.xml

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     1 <?xml version="1.0"?>
     3 <!-- This Source Code Form is subject to the terms of the Mozilla Public
     4    - License, v. 2.0. If a copy of the MPL was not distributed with this
     5    - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
     7 <!-- this file depends on printUtils.js -->
     9 <!DOCTYPE bindings [
    10 <!ENTITY % printPreviewDTD SYSTEM "chrome://global/locale/printPreview.dtd" >
    11 %printPreviewDTD;
    12 ]>
    14 <bindings id="printPreviewBindings"
    15    xmlns="http://www.mozilla.org/xbl"
    16    xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
    18   <binding id="printpreviewtoolbar" 
    19            extends="chrome://global/content/bindings/toolbar.xml#toolbar">
    20     <resources>
    21       <stylesheet src="chrome://global/skin/printPreview.css"/>
    22     </resources>
    24     <content>
    25       <xul:button label="&print.label;" accesskey="&print.accesskey;"
    26         oncommand="PrintUtils.print();" icon="print"/>
    28       <xul:button label="&pageSetup.label;" accesskey="&pageSetup.accesskey;"
    29         oncommand="this.parentNode.doPageSetup();"/>
    31       <xul:vbox align="center" pack="center">
    32         <xul:label value="&page.label;" accesskey="&page.accesskey;" control="pageNumber"/>
    33       </xul:vbox>
    34       <xul:toolbarbutton class="home-arrow tabbable"
    35         oncommand="parentNode.navigate(0, 0, 'home');" tooltiptext="&homearrow.tooltip;"/>
    36       <xul:toolbarbutton class="previous-arrow tabbable"
    37         oncommand="parentNode.navigate(-1, 0, 0);" tooltiptext="&previousarrow.tooltip;"/>
    38       <xul:hbox align="center" pack="center">
    39         <xul:textbox id="pageNumber" size="3" value="1" min="1" type="number"
    40           hidespinbuttons="true" onchange="navigate(0, this.valueNumber, 0);"/>
    41         <xul:label value="&of.label;"/>
    42         <xul:label value="1"/>
    43       </xul:hbox>
    44       <xul:toolbarbutton class="next-arrow tabbable"
    45         oncommand="parentNode.navigate(1, 0, 0);" tooltiptext="&nextarrow.tooltip;"/>
    46       <xul:toolbarbutton class="end-arrow tabbable"
    47         oncommand="parentNode.navigate(0, 0, 'end');" tooltiptext="&endarrow.tooltip;"/>
    49       <xul:toolbarseparator class="toolbarseparator-primary"/>
    50       <xul:vbox align="center" pack="center">
    51         <xul:label value="&scale.label;" accesskey="&scale.accesskey;" control="scale"/>
    52       </xul:vbox>
    54       <xul:hbox align="center" pack="center">
    55         <xul:menulist id="scale" crop="none" 
    56           oncommand="parentNode.parentNode.scale(this.selectedItem.value);">
    57           <xul:menupopup>
    58             <xul:menuitem value="0.3" label="&p30.label;"/>
    59             <xul:menuitem value="0.4" label="&p40.label;"/>
    60             <xul:menuitem value="0.5" label="&p50.label;"/>
    61             <xul:menuitem value="0.6" label="&p60.label;"/>
    62             <xul:menuitem value="0.7" label="&p70.label;"/>
    63             <xul:menuitem value="0.8" label="&p80.label;"/>
    64             <xul:menuitem value="0.9" label="&p90.label;"/>
    65             <xul:menuitem value="1" label="&p100.label;"/>
    66             <xul:menuitem value="1.25" label="&p125.label;"/>
    67             <xul:menuitem value="1.5" label="&p150.label;"/>
    68             <xul:menuitem value="1.75" label="&p175.label;"/>
    69             <xul:menuitem value="2" label="&p200.label;"/>
    70             <xul:menuseparator/>
    71             <xul:menuitem flex="1" value="ShrinkToFit" 
    72               label="&ShrinkToFit.label;"/>
    73             <xul:menuitem value="Custom" label="&Custom.label;"/>
    74           </xul:menupopup>
    75         </xul:menulist>
    76       </xul:hbox>
    78       <xul:toolbarseparator class="toolbarseparator-primary"/>
    79       <xul:hbox align="center" pack="center">
    80         <xul:toolbarbutton label="&portrait.label;" checked="true"
    81           accesskey="&portrait.accesskey;"
    82           type="radio" group="orient" class="toolbar-portrait-page tabbable"
    83           oncommand="parentNode.parentNode.orient('portrait');"/>
    84         <xul:toolbarbutton label="&landscape.label;" 
    85           accesskey="&landscape.accesskey;"
    86           type="radio" group="orient" class="toolbar-landscape-page tabbable"
    87           oncommand="parentNode.parentNode.orient('landscape');"/>
    88       </xul:hbox>
    90       <xul:toolbarseparator class="toolbarseparator-primary"/>
    91       <xul:button label="&close.label;" accesskey="&close.accesskey;"
    92         oncommand="PrintUtils.exitPrintPreview();" icon="close"/>
    93       <xul:data value="&customPrompt.title;"/>
    94     </content>
    96     <implementation>
    97       <field name="mPrintButton">
    98         document.getAnonymousNodes(this)[0]
    99       </field>
   100       <field name="mPageTextBox">
   101         document.getAnonymousNodes(this)[5].childNodes[0]
   102       </field>
   103       <field name="mTotalPages">
   104         document.getAnonymousNodes(this)[5].childNodes[2]
   105       </field>
   106       <field name="mScaleLabel">
   107         document.getAnonymousNodes(this)[9].firstChild
   108       </field>
   109       <field name="mScaleCombobox">
   110         document.getAnonymousNodes(this)[10].firstChild
   111       </field>
   112       <field name="mOrientButtonsBox">
   113         document.getAnonymousNodes(this)[12]
   114       </field>
   115       <field name="mPortaitButton">
   116         this.mOrientButtonsBox.childNodes[0]
   117       </field>
   118       <field name="mLandscapeButton">
   119         this.mOrientButtonsBox.childNodes[1]
   120       </field>
   121       <field name="mCustomTitle">
   122         document.getAnonymousNodes(this)[15].firstChild
   123       </field>
   124       <field name="mPrintPreviewObs">
   125       </field>
   126       <field name="mWebProgress">
   127       </field>
   129       <constructor>
   130       <![CDATA[
   131         var print = PrintUtils.getPrintPreview();
   132         this.mTotalPages.value = print.printPreviewNumPages;
   133         this.mPageTextBox.max = print.printPreviewNumPages;
   135         this.updateToolbar();
   136       ]]>
   137       </constructor>
   139       <method name="doPageSetup">
   140         <body>
   141         <![CDATA[
   142           var didOK = PrintUtils.showPageSetup();
   143           if (didOK) {
   144             // the changes that effect the UI
   145             this.updateToolbar();
   147             // Now do PrintPreview
   148             PrintUtils.printPreview();
   149           }
   150         ]]>
   151         </body>
   152       </method>
   154       <method name="navigate">
   155         <parameter name="aDirection"/>
   156         <parameter name="aPageNum"/>
   157         <parameter name="aHomeOrEnd"/>
   158         <body>
   159         <![CDATA[          
   160           var print = PrintUtils.getPrintPreview();
   162           // we use only one of aHomeOrEnd, aDirection, or aPageNum
   163           if (aHomeOrEnd)
   164           {
   165             var homeOrEnd;
   166             if (aHomeOrEnd == "home")
   167             {
   168               homeOrEnd = print.PRINTPREVIEW_HOME;
   169               this.mPageTextBox.value = 1;  
   170             }
   171             else
   172             {
   173               homeOrEnd = print.PRINTPREVIEW_END;
   174               this.mPageTextBox.value = print.printPreviewNumPages;
   175             }
   177             print.printPreviewNavigate(homeOrEnd, 0);
   178           }
   179           else if (aDirection)
   180           {
   181             this.mPageTextBox.valueNumber += aDirection;
   182             print.printPreviewNavigate(
   183               print.PRINTPREVIEW_GOTO_PAGENUM,
   184               this.mPageTextBox.valueNumber);
   185           }
   186           else 
   187           {
   188             print.printPreviewNavigate(
   189               print.PRINTPREVIEW_GOTO_PAGENUM, aPageNum);
   190           }
   191         ]]>
   192         </body>
   193       </method>
   195       <method name="promptForScaleValue">
   196         <parameter name="aValue"/>
   197         <body>
   198         <![CDATA[
   199           var value = Math.round(aValue);
   200           var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService);
   201           var promptStr = this.mScaleLabel.value;
   202           var renameTitle = this.mCustomTitle;
   203           var result = {value:value};
   204           var confirmed = promptService.prompt(window, renameTitle, promptStr, result, null, {value:value});
   205           if (!confirmed || (!result.value) || (result.value == "") || result.value == value) {
   206             return(-1);
   207           }
   208           return result.value;
   209         ]]>
   210         </body>
   211       </method>
   213       <method name="setScaleCombobox">
   214         <parameter name="aValue"/>
   215         <body>
   216         <![CDATA[
   217           var scaleValues = [0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1, 1.25, 1.5, 1.75, 2];
   219           aValue = new Number(aValue);
   221           for (var i = 0; i < scaleValues.length; i++) {
   222             if (aValue == scaleValues[i]) {
   223               this.mScaleCombobox.selectedIndex = i;
   224               return;
   225             }
   226           }
   227           this.mScaleCombobox.value = "Custom";
   228         ]]>
   229         </body>
   230       </method>
   232       <method name="scale">
   233         <parameter name="aValue"/>
   234         <body>
   235         <![CDATA[
   236           var settings = PrintUtils.getPrintSettings();
   237           if (aValue == "ShrinkToFit") {
   238             if (!settings.shrinkToFit) {
   239               settings.shrinkToFit = true;
   240               this.savePrintSettings(settings, settings.kInitSaveShrinkToFit | settings.kInitSaveScaling);
   241               PrintUtils.printPreview();
   242             }
   243             return;
   244           }
   246           if (aValue == "Custom") {
   247             aValue = this.promptForScaleValue(settings.scaling * 100.0);
   248             if (aValue >= 10) {
   249               aValue /= 100.0;
   250             } else {
   251               if (this.mScaleCombobox.hasAttribute('lastValidInx')) {
   252                 this.mScaleCombobox.selectedIndex = this.mScaleCombobox.getAttribute('lastValidInx');
   253               }
   254               return;
   255             }
   256           }
   258           this.setScaleCombobox(aValue);
   259           this.mScaleCombobox.setAttribute('lastValidInx', this.mScaleCombobox.selectedIndex);
   261           if (settings.scaling != aValue || settings.shrinkToFit)
   262           {
   263             settings.shrinkToFit = false;
   264             settings.scaling = aValue;
   265             this.savePrintSettings(settings, settings.kInitSaveShrinkToFit | settings.kInitSaveScaling);
   266             PrintUtils.printPreview();
   267           }
   268         ]]>
   269         </body>
   270       </method>
   272       <method name="orient">
   273         <parameter name="aOrientation"/>
   274         <body>
   275         <![CDATA[
   276           const kIPrintSettings = Components.interfaces.nsIPrintSettings;
   277           var orientValue = (aOrientation == "portrait") ? kIPrintSettings.kPortraitOrientation :
   278                                                            kIPrintSettings.kLandscapeOrientation;
   279           var settings = PrintUtils.getPrintSettings();
   280           if (settings.orientation != orientValue)
   281           {
   282             settings.orientation = orientValue;
   283             this.savePrintSettings(settings, settings.kInitSaveOrientation);
   284             PrintUtils.printPreview();
   285           }
   286         ]]>
   287         </body>
   288       </method>
   290       <method name="updateToolbar">
   291         <body>
   292         <![CDATA[
   293           var print = PrintUtils.getPrintPreview();
   294           var settings = PrintUtils.getPrintSettings();
   296           var isPortrait = settings.orientation == Components.interfaces.nsIPrintSettings.kPortraitOrientation;
   298           this.mPortaitButton.checked = isPortrait;
   299           this.mLandscapeButton.checked = !isPortrait;
   301           if (settings.shrinkToFit) {
   302             this.mScaleCombobox.value = "ShrinkToFit";
   303           } else {
   304             this.setScaleCombobox(settings.scaling);
   305           }
   307           this.mTotalPages.value = print.printPreviewNumPages;
   308           this.mPageTextBox.max = print.printPreviewNumPages;
   309           this.mPageTextBox.value = 1;
   310         ]]>
   311         </body>
   312       </method>
   314       <method name="savePrintSettings">
   315         <parameter name="settings"/>
   316         <parameter name="flags"/>
   317         <body><![CDATA[
   318           var PSSVC = Components.classes["@mozilla.org/gfx/printsettings-service;1"]
   319                                 .getService(Components.interfaces.nsIPrintSettingsService);
   320           PSSVC.savePrintSettingsToPrefs(settings, true, flags);
   321         ]]></body>
   322       </method>
   323     </implementation>
   324   </binding>
   326 </bindings>

mercurial