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