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 | <!-- This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | - License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | - file, You can obtain one at http://mozilla.org/MPL/2.0/. --> |
michael@0 | 5 | |
michael@0 | 6 | |
michael@0 | 7 | <bindings id="toolbarBindings" |
michael@0 | 8 | xmlns="http://www.mozilla.org/xbl" |
michael@0 | 9 | xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" |
michael@0 | 10 | xmlns:xbl="http://www.mozilla.org/xbl"> |
michael@0 | 11 | |
michael@0 | 12 | <binding id="toolbar-base"> |
michael@0 | 13 | <resources> |
michael@0 | 14 | <stylesheet src="chrome://global/skin/toolbar.css"/> |
michael@0 | 15 | </resources> |
michael@0 | 16 | </binding> |
michael@0 | 17 | |
michael@0 | 18 | <binding id="toolbox" extends="chrome://global/content/bindings/toolbar.xml#toolbar-base"> |
michael@0 | 19 | <implementation> |
michael@0 | 20 | <field name="palette"> |
michael@0 | 21 | null |
michael@0 | 22 | </field> |
michael@0 | 23 | |
michael@0 | 24 | <field name="toolbarset"> |
michael@0 | 25 | null |
michael@0 | 26 | </field> |
michael@0 | 27 | |
michael@0 | 28 | <field name="customToolbarCount"> |
michael@0 | 29 | 0 |
michael@0 | 30 | </field> |
michael@0 | 31 | |
michael@0 | 32 | <field name="externalToolbars"> |
michael@0 | 33 | [] |
michael@0 | 34 | </field> |
michael@0 | 35 | |
michael@0 | 36 | <!-- Set by customizeToolbar.js --> |
michael@0 | 37 | <property name="customizing"> |
michael@0 | 38 | <getter><![CDATA[ |
michael@0 | 39 | return this.getAttribute("customizing") == "true"; |
michael@0 | 40 | ]]></getter> |
michael@0 | 41 | <setter><![CDATA[ |
michael@0 | 42 | if (val) |
michael@0 | 43 | this.setAttribute("customizing", "true"); |
michael@0 | 44 | else |
michael@0 | 45 | this.removeAttribute("customizing"); |
michael@0 | 46 | return val; |
michael@0 | 47 | ]]></setter> |
michael@0 | 48 | </property> |
michael@0 | 49 | |
michael@0 | 50 | <constructor> |
michael@0 | 51 | <![CDATA[ |
michael@0 | 52 | // Look to see if there is a toolbarset. |
michael@0 | 53 | this.toolbarset = this.firstChild; |
michael@0 | 54 | while (this.toolbarset && this.toolbarset.localName != "toolbarset") |
michael@0 | 55 | this.toolbarset = toolbarset.nextSibling; |
michael@0 | 56 | |
michael@0 | 57 | if (this.toolbarset) { |
michael@0 | 58 | // Create each toolbar described by the toolbarset. |
michael@0 | 59 | var index = 0; |
michael@0 | 60 | while (toolbarset.hasAttribute("toolbar"+(++index))) { |
michael@0 | 61 | var toolbarInfo = toolbarset.getAttribute("toolbar"+index); |
michael@0 | 62 | var infoSplit = toolbarInfo.split(":"); |
michael@0 | 63 | this.appendCustomToolbar(infoSplit[0], infoSplit[1]); |
michael@0 | 64 | } |
michael@0 | 65 | } |
michael@0 | 66 | ]]> |
michael@0 | 67 | </constructor> |
michael@0 | 68 | |
michael@0 | 69 | <method name="appendCustomToolbar"> |
michael@0 | 70 | <parameter name="aName"/> |
michael@0 | 71 | <parameter name="aCurrentSet"/> |
michael@0 | 72 | <body> |
michael@0 | 73 | <![CDATA[ |
michael@0 | 74 | if (!this.toolbarset) |
michael@0 | 75 | return null; |
michael@0 | 76 | var toolbar = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", |
michael@0 | 77 | "toolbar"); |
michael@0 | 78 | toolbar.id = "__customToolbar_" + aName.replace(" ", "_"); |
michael@0 | 79 | toolbar.setAttribute("customizable", "true"); |
michael@0 | 80 | toolbar.setAttribute("customindex", ++this.customToolbarCount); |
michael@0 | 81 | toolbar.setAttribute("toolbarname", aName); |
michael@0 | 82 | toolbar.setAttribute("currentset", aCurrentSet); |
michael@0 | 83 | toolbar.setAttribute("mode", this.getAttribute("mode")); |
michael@0 | 84 | toolbar.setAttribute("iconsize", this.getAttribute("iconsize")); |
michael@0 | 85 | toolbar.setAttribute("context", this.toolbarset.getAttribute("context")); |
michael@0 | 86 | toolbar.setAttribute("class", "chromeclass-toolbar"); |
michael@0 | 87 | |
michael@0 | 88 | this.insertBefore(toolbar, this.toolbarset); |
michael@0 | 89 | return toolbar; |
michael@0 | 90 | ]]> |
michael@0 | 91 | </body> |
michael@0 | 92 | </method> |
michael@0 | 93 | </implementation> |
michael@0 | 94 | </binding> |
michael@0 | 95 | |
michael@0 | 96 | <binding id="toolbar" role="xul:toolbar" |
michael@0 | 97 | extends="chrome://global/content/bindings/toolbar.xml#toolbar-base"> |
michael@0 | 98 | <implementation> |
michael@0 | 99 | <property name="toolbarName" |
michael@0 | 100 | onget="return this.getAttribute('toolbarname');" |
michael@0 | 101 | onset="this.setAttribute('toolbarname', val); return val;"/> |
michael@0 | 102 | |
michael@0 | 103 | <field name="_toolbox">null</field> |
michael@0 | 104 | <property name="toolbox" readonly="true"> |
michael@0 | 105 | <getter><![CDATA[ |
michael@0 | 106 | if (this._toolbox) |
michael@0 | 107 | return this._toolbox; |
michael@0 | 108 | |
michael@0 | 109 | let toolboxId = this.getAttribute("toolboxid"); |
michael@0 | 110 | if (toolboxId) { |
michael@0 | 111 | let toolbox = document.getElementById(toolboxId); |
michael@0 | 112 | if (!toolbox) { |
michael@0 | 113 | let tbName = this.toolbarName; |
michael@0 | 114 | if (tbName) |
michael@0 | 115 | tbName = " (" + tbName + ")"; |
michael@0 | 116 | else |
michael@0 | 117 | tbName = ""; |
michael@0 | 118 | throw("toolbar ID " + this.id + tbName + ": toolboxid attribute '" + toolboxId + "' points to a toolbox that doesn't exist"); |
michael@0 | 119 | } |
michael@0 | 120 | |
michael@0 | 121 | if (toolbox.externalToolbars.indexOf(this) == -1) |
michael@0 | 122 | toolbox.externalToolbars.push(this); |
michael@0 | 123 | |
michael@0 | 124 | return this._toolbox = toolbox; |
michael@0 | 125 | } |
michael@0 | 126 | |
michael@0 | 127 | return this._toolbox = (this.parentNode && |
michael@0 | 128 | this.parentNode.localName == "toolbox") ? |
michael@0 | 129 | this.parentNode : null; |
michael@0 | 130 | ]]></getter> |
michael@0 | 131 | </property> |
michael@0 | 132 | |
michael@0 | 133 | <constructor> |
michael@0 | 134 | <![CDATA[ |
michael@0 | 135 | if (document.readyState == "complete") { |
michael@0 | 136 | this._init(); |
michael@0 | 137 | } else { |
michael@0 | 138 | // Need to wait until XUL overlays are loaded. See bug 554279. |
michael@0 | 139 | let self = this; |
michael@0 | 140 | document.addEventListener("readystatechange", function (event) { |
michael@0 | 141 | if (document.readyState != "complete") |
michael@0 | 142 | return; |
michael@0 | 143 | document.removeEventListener("readystatechange", arguments.callee, false); |
michael@0 | 144 | self._init(); |
michael@0 | 145 | }, false); |
michael@0 | 146 | } |
michael@0 | 147 | ]]> |
michael@0 | 148 | </constructor> |
michael@0 | 149 | |
michael@0 | 150 | <method name="_init"> |
michael@0 | 151 | <body> |
michael@0 | 152 | <![CDATA[ |
michael@0 | 153 | // Searching for the toolbox palette in the toolbar binding because |
michael@0 | 154 | // toolbars are constructed first. |
michael@0 | 155 | var toolbox = this.toolbox; |
michael@0 | 156 | if (!toolbox) |
michael@0 | 157 | return; |
michael@0 | 158 | |
michael@0 | 159 | if (!toolbox.palette) { |
michael@0 | 160 | // Look to see if there is a toolbarpalette. |
michael@0 | 161 | var node = toolbox.firstChild; |
michael@0 | 162 | while (node) { |
michael@0 | 163 | if (node.localName == "toolbarpalette") |
michael@0 | 164 | break; |
michael@0 | 165 | node = node.nextSibling; |
michael@0 | 166 | } |
michael@0 | 167 | |
michael@0 | 168 | if (!node) |
michael@0 | 169 | return; |
michael@0 | 170 | |
michael@0 | 171 | // Hold on to the palette but remove it from the document. |
michael@0 | 172 | toolbox.palette = node; |
michael@0 | 173 | toolbox.removeChild(node); |
michael@0 | 174 | } |
michael@0 | 175 | |
michael@0 | 176 | // Build up our contents from the palette. |
michael@0 | 177 | var currentSet = this.getAttribute("currentset"); |
michael@0 | 178 | if (!currentSet) |
michael@0 | 179 | currentSet = this.getAttribute("defaultset"); |
michael@0 | 180 | if (currentSet) |
michael@0 | 181 | this.currentSet = currentSet; |
michael@0 | 182 | ]]> |
michael@0 | 183 | </body> |
michael@0 | 184 | </method> |
michael@0 | 185 | |
michael@0 | 186 | <method name="_idFromNode"> |
michael@0 | 187 | <parameter name="aNode"/> |
michael@0 | 188 | <body> |
michael@0 | 189 | <![CDATA[ |
michael@0 | 190 | if (aNode.getAttribute("skipintoolbarset") == "true") |
michael@0 | 191 | return ""; |
michael@0 | 192 | |
michael@0 | 193 | switch (aNode.localName) { |
michael@0 | 194 | case "toolbarseparator": |
michael@0 | 195 | return "separator"; |
michael@0 | 196 | case "toolbarspring": |
michael@0 | 197 | return "spring"; |
michael@0 | 198 | case "toolbarspacer": |
michael@0 | 199 | return "spacer"; |
michael@0 | 200 | default: |
michael@0 | 201 | return aNode.id; |
michael@0 | 202 | } |
michael@0 | 203 | ]]> |
michael@0 | 204 | </body> |
michael@0 | 205 | </method> |
michael@0 | 206 | |
michael@0 | 207 | <property name="currentSet"> |
michael@0 | 208 | <getter> |
michael@0 | 209 | <![CDATA[ |
michael@0 | 210 | var node = this.firstChild; |
michael@0 | 211 | var currentSet = []; |
michael@0 | 212 | while (node) { |
michael@0 | 213 | var id = this._idFromNode(node); |
michael@0 | 214 | if (id) { |
michael@0 | 215 | currentSet.push(id); |
michael@0 | 216 | } |
michael@0 | 217 | node = node.nextSibling; |
michael@0 | 218 | } |
michael@0 | 219 | |
michael@0 | 220 | return currentSet.join(",") || "__empty"; |
michael@0 | 221 | ]]> |
michael@0 | 222 | </getter> |
michael@0 | 223 | |
michael@0 | 224 | <setter> |
michael@0 | 225 | <![CDATA[ |
michael@0 | 226 | if (val == this.currentSet) |
michael@0 | 227 | return val; |
michael@0 | 228 | |
michael@0 | 229 | var ids = (val == "__empty") ? [] : val.split(","); |
michael@0 | 230 | |
michael@0 | 231 | var nodeidx = 0; |
michael@0 | 232 | var paletteItems = { }, added = { }; |
michael@0 | 233 | |
michael@0 | 234 | var palette = this.toolbox ? this.toolbox.palette : null; |
michael@0 | 235 | |
michael@0 | 236 | // build a cache of items in the toolbarpalette |
michael@0 | 237 | var paletteChildren = palette ? palette.childNodes : []; |
michael@0 | 238 | for (let c = 0; c < paletteChildren.length; c++) { |
michael@0 | 239 | let curNode = paletteChildren[c]; |
michael@0 | 240 | paletteItems[curNode.id] = curNode; |
michael@0 | 241 | } |
michael@0 | 242 | |
michael@0 | 243 | var children = this.childNodes; |
michael@0 | 244 | |
michael@0 | 245 | iter: |
michael@0 | 246 | // iterate over the ids to use on the toolbar |
michael@0 | 247 | for (let i = 0; i < ids.length; i++) { |
michael@0 | 248 | let id = ids[i]; |
michael@0 | 249 | // iterate over the existing nodes on the toolbar. nodeidx is the |
michael@0 | 250 | // spot where we want to insert items. |
michael@0 | 251 | for (let c = nodeidx; c < children.length; c++) { |
michael@0 | 252 | let curNode = children[c]; |
michael@0 | 253 | if (this._idFromNode(curNode) == id) { |
michael@0 | 254 | // the node already exists. If c equals nodeidx, we haven't |
michael@0 | 255 | // iterated yet, so the item is already in the right position. |
michael@0 | 256 | // Otherwise, insert it here. |
michael@0 | 257 | if (c != nodeidx) { |
michael@0 | 258 | this.insertBefore(curNode, children[nodeidx]); |
michael@0 | 259 | } |
michael@0 | 260 | |
michael@0 | 261 | added[curNode.id] = true; |
michael@0 | 262 | nodeidx++; |
michael@0 | 263 | continue iter; // move on to the next id |
michael@0 | 264 | } |
michael@0 | 265 | } |
michael@0 | 266 | |
michael@0 | 267 | // the node isn't already on the toolbar, so add a new one. |
michael@0 | 268 | var nodeToAdd = paletteItems[id] || this._getToolbarItem(id); |
michael@0 | 269 | if (nodeToAdd && !(nodeToAdd.id in added)) { |
michael@0 | 270 | added[nodeToAdd.id] = true; |
michael@0 | 271 | this.insertBefore(nodeToAdd, children[nodeidx] || null); |
michael@0 | 272 | nodeToAdd.setAttribute("removable", "true"); |
michael@0 | 273 | nodeidx++; |
michael@0 | 274 | } |
michael@0 | 275 | } |
michael@0 | 276 | |
michael@0 | 277 | // remove any leftover removable nodes |
michael@0 | 278 | for (let i = children.length - 1; i >= nodeidx; i--) { |
michael@0 | 279 | let curNode = children[i]; |
michael@0 | 280 | |
michael@0 | 281 | let curNodeId = this._idFromNode(curNode); |
michael@0 | 282 | // skip over fixed items |
michael@0 | 283 | if (curNodeId && curNode.getAttribute("removable") == "true") { |
michael@0 | 284 | if (palette) |
michael@0 | 285 | palette.appendChild(curNode); |
michael@0 | 286 | else |
michael@0 | 287 | this.removeChild(curNode); |
michael@0 | 288 | } |
michael@0 | 289 | } |
michael@0 | 290 | |
michael@0 | 291 | return val; |
michael@0 | 292 | ]]> |
michael@0 | 293 | </setter> |
michael@0 | 294 | </property> |
michael@0 | 295 | |
michael@0 | 296 | <field name="_newElementCount">0</field> |
michael@0 | 297 | <method name="_getToolbarItem"> |
michael@0 | 298 | <parameter name="aId"/> |
michael@0 | 299 | <body> |
michael@0 | 300 | <![CDATA[ |
michael@0 | 301 | const XUL_NS = "http://www.mozilla.org/keymaster/" + |
michael@0 | 302 | "gatekeeper/there.is.only.xul"; |
michael@0 | 303 | |
michael@0 | 304 | var newItem = null; |
michael@0 | 305 | switch (aId) { |
michael@0 | 306 | // Handle special cases |
michael@0 | 307 | case "separator": |
michael@0 | 308 | case "spring": |
michael@0 | 309 | case "spacer": |
michael@0 | 310 | newItem = document.createElementNS(XUL_NS, "toolbar" + aId); |
michael@0 | 311 | // Due to timers resolution Date.now() can be the same for |
michael@0 | 312 | // elements created in small timeframes. So ids are |
michael@0 | 313 | // differentiated through a unique count suffix. |
michael@0 | 314 | newItem.id = aId + Date.now() + (++this._newElementCount); |
michael@0 | 315 | if (aId == "spring") |
michael@0 | 316 | newItem.flex = 1; |
michael@0 | 317 | break; |
michael@0 | 318 | default: |
michael@0 | 319 | var toolbox = this.toolbox; |
michael@0 | 320 | if (!toolbox) |
michael@0 | 321 | break; |
michael@0 | 322 | |
michael@0 | 323 | // look for an item with the same id, as the item may be |
michael@0 | 324 | // in a different toolbar. |
michael@0 | 325 | var item = document.getElementById(aId); |
michael@0 | 326 | if (item && item.parentNode && |
michael@0 | 327 | item.parentNode.localName == "toolbar" && |
michael@0 | 328 | item.parentNode.toolbox == toolbox) { |
michael@0 | 329 | newItem = item; |
michael@0 | 330 | break; |
michael@0 | 331 | } |
michael@0 | 332 | |
michael@0 | 333 | if (toolbox.palette) { |
michael@0 | 334 | // Attempt to locate an item with a matching ID within |
michael@0 | 335 | // the palette. |
michael@0 | 336 | let paletteItem = this.toolbox.palette.firstChild; |
michael@0 | 337 | while (paletteItem) { |
michael@0 | 338 | if (paletteItem.id == aId) { |
michael@0 | 339 | newItem = paletteItem; |
michael@0 | 340 | break; |
michael@0 | 341 | } |
michael@0 | 342 | paletteItem = paletteItem.nextSibling; |
michael@0 | 343 | } |
michael@0 | 344 | } |
michael@0 | 345 | break; |
michael@0 | 346 | } |
michael@0 | 347 | |
michael@0 | 348 | return newItem; |
michael@0 | 349 | ]]> |
michael@0 | 350 | </body> |
michael@0 | 351 | </method> |
michael@0 | 352 | |
michael@0 | 353 | <method name="insertItem"> |
michael@0 | 354 | <parameter name="aId"/> |
michael@0 | 355 | <parameter name="aBeforeElt"/> |
michael@0 | 356 | <parameter name="aWrapper"/> |
michael@0 | 357 | <body> |
michael@0 | 358 | <![CDATA[ |
michael@0 | 359 | var newItem = this._getToolbarItem(aId); |
michael@0 | 360 | if (!newItem) |
michael@0 | 361 | return null; |
michael@0 | 362 | |
michael@0 | 363 | var insertItem = newItem; |
michael@0 | 364 | // make sure added items are removable |
michael@0 | 365 | newItem.setAttribute("removable", "true"); |
michael@0 | 366 | |
michael@0 | 367 | // Wrap the item in another node if so inclined. |
michael@0 | 368 | if (aWrapper) { |
michael@0 | 369 | aWrapper.appendChild(newItem); |
michael@0 | 370 | insertItem = aWrapper; |
michael@0 | 371 | } |
michael@0 | 372 | |
michael@0 | 373 | // Insert the palette item into the toolbar. |
michael@0 | 374 | if (aBeforeElt) |
michael@0 | 375 | this.insertBefore(insertItem, aBeforeElt); |
michael@0 | 376 | else |
michael@0 | 377 | this.appendChild(insertItem); |
michael@0 | 378 | |
michael@0 | 379 | return newItem; |
michael@0 | 380 | ]]> |
michael@0 | 381 | </body> |
michael@0 | 382 | </method> |
michael@0 | 383 | |
michael@0 | 384 | <method name="hasCustomInteractiveItems"> |
michael@0 | 385 | <parameter name="aCurrentSet"/> |
michael@0 | 386 | <body><![CDATA[ |
michael@0 | 387 | if (aCurrentSet == "__empty") |
michael@0 | 388 | return false; |
michael@0 | 389 | |
michael@0 | 390 | var defaultOrNoninteractive = (this.getAttribute("defaultset") || "") |
michael@0 | 391 | .split(",") |
michael@0 | 392 | .concat(["separator", "spacer", "spring"]); |
michael@0 | 393 | return aCurrentSet.split(",").some(function (item) { |
michael@0 | 394 | return defaultOrNoninteractive.indexOf(item) == -1; |
michael@0 | 395 | }); |
michael@0 | 396 | ]]></body> |
michael@0 | 397 | </method> |
michael@0 | 398 | </implementation> |
michael@0 | 399 | </binding> |
michael@0 | 400 | |
michael@0 | 401 | <binding id="toolbar-menubar-autohide" |
michael@0 | 402 | extends="chrome://global/content/bindings/toolbar.xml#toolbar"> |
michael@0 | 403 | <implementation> |
michael@0 | 404 | <constructor> |
michael@0 | 405 | this._setInactive(); |
michael@0 | 406 | </constructor> |
michael@0 | 407 | <destructor> |
michael@0 | 408 | this._setActive(); |
michael@0 | 409 | </destructor> |
michael@0 | 410 | |
michael@0 | 411 | <field name="_inactiveTimeout">null</field> |
michael@0 | 412 | |
michael@0 | 413 | <field name="_contextMenuListener"><![CDATA[({ |
michael@0 | 414 | toolbar: this, |
michael@0 | 415 | contextMenu: null, |
michael@0 | 416 | |
michael@0 | 417 | get active () !!this.contextMenu, |
michael@0 | 418 | |
michael@0 | 419 | init: function (event) { |
michael@0 | 420 | var node = event.target; |
michael@0 | 421 | while (node != this.toolbar) { |
michael@0 | 422 | if (node.localName == "menupopup") |
michael@0 | 423 | return; |
michael@0 | 424 | node = node.parentNode; |
michael@0 | 425 | } |
michael@0 | 426 | |
michael@0 | 427 | var contextMenuId = this.toolbar.getAttribute("context"); |
michael@0 | 428 | if (!contextMenuId) |
michael@0 | 429 | return; |
michael@0 | 430 | |
michael@0 | 431 | this.contextMenu = document.getElementById(contextMenuId); |
michael@0 | 432 | if (!this.contextMenu) |
michael@0 | 433 | return; |
michael@0 | 434 | |
michael@0 | 435 | this.contextMenu.addEventListener("popupshown", this, false); |
michael@0 | 436 | this.contextMenu.addEventListener("popuphiding", this, false); |
michael@0 | 437 | this.toolbar.addEventListener("mousemove", this, false); |
michael@0 | 438 | }, |
michael@0 | 439 | handleEvent: function (event) { |
michael@0 | 440 | switch (event.type) { |
michael@0 | 441 | case "popupshown": |
michael@0 | 442 | this.toolbar.removeEventListener("mousemove", this, false); |
michael@0 | 443 | break; |
michael@0 | 444 | case "popuphiding": |
michael@0 | 445 | case "mousemove": |
michael@0 | 446 | this.toolbar._setInactiveAsync(); |
michael@0 | 447 | this.toolbar.removeEventListener("mousemove", this, false); |
michael@0 | 448 | this.contextMenu.removeEventListener("popuphiding", this, false); |
michael@0 | 449 | this.contextMenu.removeEventListener("popupshown", this, false); |
michael@0 | 450 | this.contextMenu = null; |
michael@0 | 451 | break; |
michael@0 | 452 | } |
michael@0 | 453 | } |
michael@0 | 454 | })]]></field> |
michael@0 | 455 | |
michael@0 | 456 | <method name="_setInactive"> |
michael@0 | 457 | <body><![CDATA[ |
michael@0 | 458 | this.setAttribute("inactive", "true"); |
michael@0 | 459 | ]]></body> |
michael@0 | 460 | </method> |
michael@0 | 461 | |
michael@0 | 462 | <method name="_setInactiveAsync"> |
michael@0 | 463 | <body><![CDATA[ |
michael@0 | 464 | this._inactiveTimeout = setTimeout(function (self) { |
michael@0 | 465 | if (self.getAttribute("autohide") == "true") { |
michael@0 | 466 | self._inactiveTimeout = null; |
michael@0 | 467 | self._setInactive(); |
michael@0 | 468 | } |
michael@0 | 469 | }, 0, this); |
michael@0 | 470 | ]]></body> |
michael@0 | 471 | </method> |
michael@0 | 472 | |
michael@0 | 473 | <method name="_setActive"> |
michael@0 | 474 | <body><![CDATA[ |
michael@0 | 475 | if (this._inactiveTimeout) { |
michael@0 | 476 | clearTimeout(this._inactiveTimeout); |
michael@0 | 477 | this._inactiveTimeout = null; |
michael@0 | 478 | } |
michael@0 | 479 | this.removeAttribute("inactive"); |
michael@0 | 480 | ]]></body> |
michael@0 | 481 | </method> |
michael@0 | 482 | </implementation> |
michael@0 | 483 | |
michael@0 | 484 | <handlers> |
michael@0 | 485 | <handler event="DOMMenuBarActive" action="this._setActive();"/> |
michael@0 | 486 | <handler event="popupshowing" action="this._setActive();"/> |
michael@0 | 487 | <handler event="mousedown" button="2" action="this._contextMenuListener.init(event);"/> |
michael@0 | 488 | <handler event="DOMMenuBarInactive"><![CDATA[ |
michael@0 | 489 | if (!this._contextMenuListener.active) |
michael@0 | 490 | this._setInactiveAsync(); |
michael@0 | 491 | ]]></handler> |
michael@0 | 492 | </handlers> |
michael@0 | 493 | </binding> |
michael@0 | 494 | |
michael@0 | 495 | <binding id="toolbar-drag" |
michael@0 | 496 | extends="chrome://global/content/bindings/toolbar.xml#toolbar"> |
michael@0 | 497 | <implementation> |
michael@0 | 498 | <field name="_dragBindingAlive">true</field> |
michael@0 | 499 | <constructor><![CDATA[ |
michael@0 | 500 | if (!this._draggableStarted) { |
michael@0 | 501 | this._draggableStarted = true; |
michael@0 | 502 | try { |
michael@0 | 503 | let tmp = {}; |
michael@0 | 504 | Components.utils.import("resource://gre/modules/WindowDraggingUtils.jsm", tmp); |
michael@0 | 505 | let draggableThis = new tmp.WindowDraggingElement(this); |
michael@0 | 506 | draggableThis.mouseDownCheck = function(e) { |
michael@0 | 507 | // Don't move while customizing. |
michael@0 | 508 | return this._dragBindingAlive && |
michael@0 | 509 | this.getAttribute("customizing") != "true"; |
michael@0 | 510 | }; |
michael@0 | 511 | } catch (e) {} |
michael@0 | 512 | } |
michael@0 | 513 | ]]></constructor> |
michael@0 | 514 | </implementation> |
michael@0 | 515 | </binding> |
michael@0 | 516 | |
michael@0 | 517 | <binding id="menubar" role="xul:menubar" |
michael@0 | 518 | extends="chrome://global/content/bindings/toolbar.xml#toolbar-base" display="xul:menubar"> |
michael@0 | 519 | <implementation> |
michael@0 | 520 | <field name="_active">false</field> |
michael@0 | 521 | <field name="_statusbar">null</field> |
michael@0 | 522 | <field name="_originalStatusText">null</field> |
michael@0 | 523 | <property name="statusbar" onget="return this.getAttribute('statusbar');" |
michael@0 | 524 | onset="this.setAttribute('statusbar', val); return val;"/> |
michael@0 | 525 | <method name="_updateStatusText"> |
michael@0 | 526 | <parameter name="itemText"/> |
michael@0 | 527 | <body> |
michael@0 | 528 | <![CDATA[ |
michael@0 | 529 | if (!this._active) |
michael@0 | 530 | return; |
michael@0 | 531 | var newText = itemText ? itemText : this._originalStatusText; |
michael@0 | 532 | if (newText != this._statusbar.label) |
michael@0 | 533 | this._statusbar.label = newText; |
michael@0 | 534 | ]]> |
michael@0 | 535 | </body> |
michael@0 | 536 | </method> |
michael@0 | 537 | </implementation> |
michael@0 | 538 | <handlers> |
michael@0 | 539 | <handler event="DOMMenuBarActive"> |
michael@0 | 540 | <![CDATA[ |
michael@0 | 541 | if (!this.statusbar) return; |
michael@0 | 542 | this._statusbar = document.getElementById(this.statusbar); |
michael@0 | 543 | if (!this._statusbar) |
michael@0 | 544 | return; |
michael@0 | 545 | this._active = true; |
michael@0 | 546 | this._originalStatusText = this._statusbar.label; |
michael@0 | 547 | ]]> |
michael@0 | 548 | </handler> |
michael@0 | 549 | <handler event="DOMMenuBarInactive"> |
michael@0 | 550 | <![CDATA[ |
michael@0 | 551 | if (!this._active) |
michael@0 | 552 | return; |
michael@0 | 553 | this._active = false; |
michael@0 | 554 | this._statusbar.label = this._originalStatusText; |
michael@0 | 555 | ]]> |
michael@0 | 556 | </handler> |
michael@0 | 557 | <handler event="DOMMenuItemActive">this._updateStatusText(event.target.statusText);</handler> |
michael@0 | 558 | <handler event="DOMMenuItemInactive">this._updateStatusText("");</handler> |
michael@0 | 559 | </handlers> |
michael@0 | 560 | </binding> |
michael@0 | 561 | |
michael@0 | 562 | <binding id="toolbardecoration" role="xul:toolbarseparator" extends="chrome://global/content/bindings/toolbar.xml#toolbar-base"> |
michael@0 | 563 | </binding> |
michael@0 | 564 | |
michael@0 | 565 | <binding id="toolbarpaletteitem" extends="chrome://global/content/bindings/toolbar.xml#toolbar-base" display="xul:button"> |
michael@0 | 566 | <content> |
michael@0 | 567 | <xul:hbox class="toolbarpaletteitem-box" flex="1" xbl:inherits="type,place"> |
michael@0 | 568 | <children/> |
michael@0 | 569 | </xul:hbox> |
michael@0 | 570 | </content> |
michael@0 | 571 | </binding> |
michael@0 | 572 | |
michael@0 | 573 | <binding id="toolbarpaletteitem-palette" extends="chrome://global/content/bindings/toolbar.xml#toolbarpaletteitem"> |
michael@0 | 574 | <content> |
michael@0 | 575 | <xul:hbox class="toolbarpaletteitem-box" xbl:inherits="type,place"> |
michael@0 | 576 | <children/> |
michael@0 | 577 | </xul:hbox> |
michael@0 | 578 | <xul:label xbl:inherits="value=title"/> |
michael@0 | 579 | </content> |
michael@0 | 580 | </binding> |
michael@0 | 581 | |
michael@0 | 582 | </bindings> |
michael@0 | 583 |