Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
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 | <bindings |
michael@0 | 7 | xmlns="http://www.mozilla.org/xbl" |
michael@0 | 8 | xmlns:xbl="http://www.mozilla.org/xbl" |
michael@0 | 9 | xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> |
michael@0 | 10 | |
michael@0 | 11 | <binding id="dialog"> |
michael@0 | 12 | <content xbl:inherits="orient, closebutton" flex="1"> |
michael@0 | 13 | <children/> |
michael@0 | 14 | </content> |
michael@0 | 15 | |
michael@0 | 16 | <implementation implements="nsIDOMEventListener"> |
michael@0 | 17 | <field name="arguments"/> |
michael@0 | 18 | <field name="parent"/> |
michael@0 | 19 | <property name="_scrollbox" readonly="true" onget="return this.getElementsByTagName('scrollbox')[0];"/> |
michael@0 | 20 | |
michael@0 | 21 | <constructor><![CDATA[ |
michael@0 | 22 | this._closed = false; |
michael@0 | 23 | if (this.hasAttribute("script")) { |
michael@0 | 24 | try { |
michael@0 | 25 | Services.scriptloader.loadSubScript(this.getAttribute("script"), this); |
michael@0 | 26 | } catch(e) { |
michael@0 | 27 | throw("Dialog : Unable to load script : " + this.getAttribute("script") + "\n"); |
michael@0 | 28 | } |
michael@0 | 29 | } |
michael@0 | 30 | window.addEventListener("unload", this, true); |
michael@0 | 31 | |
michael@0 | 32 | let scrollbox = this._scrollbox; |
michael@0 | 33 | if (scrollbox) { |
michael@0 | 34 | window.addEventListener("resize", this, true); |
michael@0 | 35 | scrollbox.addEventListener("overflow", this, true); |
michael@0 | 36 | } |
michael@0 | 37 | setTimeout(this.load.bind(this), 0); |
michael@0 | 38 | ]]></constructor> |
michael@0 | 39 | |
michael@0 | 40 | <method name="handleEvent"> |
michael@0 | 41 | <parameter name="aEvent"/> |
michael@0 | 42 | <body><![CDATA[ |
michael@0 | 43 | switch(aEvent.type) { |
michael@0 | 44 | case "unload": |
michael@0 | 45 | if (aEvent.originalTarget == document) |
michael@0 | 46 | this._removeDialog(); |
michael@0 | 47 | break; |
michael@0 | 48 | |
michael@0 | 49 | case "resize": |
michael@0 | 50 | case "overflow": |
michael@0 | 51 | let scrollbox = this._scrollbox; |
michael@0 | 52 | let style = document.defaultView.getComputedStyle(scrollbox, null); |
michael@0 | 53 | let newHeight = Math.ceil(scrollbox.firstChild.getBoundingClientRect().height) + |
michael@0 | 54 | parseInt(style.marginTop) + |
michael@0 | 55 | parseInt(style.marginBottom); |
michael@0 | 56 | scrollbox.style.minHeight = Math.min(window.innerHeight / 2, newHeight) + "px"; |
michael@0 | 57 | break; |
michael@0 | 58 | } |
michael@0 | 59 | ]]></body> |
michael@0 | 60 | </method> |
michael@0 | 61 | |
michael@0 | 62 | <method name="load"> |
michael@0 | 63 | <body><![CDATA[ |
michael@0 | 64 | if (this.hasAttribute("onload")) { |
michael@0 | 65 | let func = new Function(this.getAttribute("onload")); |
michael@0 | 66 | func.call(this); |
michael@0 | 67 | } |
michael@0 | 68 | ]]></body> |
michael@0 | 69 | </method> |
michael@0 | 70 | |
michael@0 | 71 | <method name="close"> |
michael@0 | 72 | <body><![CDATA[ |
michael@0 | 73 | if (this.hasAttribute("onclose")) { |
michael@0 | 74 | let func = new Function(this.getAttribute("onclose")); |
michael@0 | 75 | func.call(this); |
michael@0 | 76 | } |
michael@0 | 77 | this._removeDialog(); |
michael@0 | 78 | ]]></body> |
michael@0 | 79 | </method> |
michael@0 | 80 | |
michael@0 | 81 | <method name="_removeDialog"> |
michael@0 | 82 | <body><![CDATA[ |
michael@0 | 83 | window.removeEventListener("unload", this, true); |
michael@0 | 84 | let scrollbox = this._scrollbox; |
michael@0 | 85 | if (scrollbox) { |
michael@0 | 86 | window.removeEventListener("resize", this, true); |
michael@0 | 87 | scrollbox.removeEventListener("overflow", this, true); |
michael@0 | 88 | } |
michael@0 | 89 | |
michael@0 | 90 | this.parentNode.parentNode.removeChild(this.parentNode); |
michael@0 | 91 | this._closed = true; |
michael@0 | 92 | |
michael@0 | 93 | // emit DOMModalDialogClosed event |
michael@0 | 94 | let event = document.createEvent("Events"); |
michael@0 | 95 | event.initEvent("DOMModalDialogClosed", true, false); |
michael@0 | 96 | let dispatcher = this.parent || getBrowser(); |
michael@0 | 97 | dispatcher.dispatchEvent(event); |
michael@0 | 98 | ]]></body> |
michael@0 | 99 | </method> |
michael@0 | 100 | |
michael@0 | 101 | <method name="waitForClose"> |
michael@0 | 102 | <body><![CDATA[ |
michael@0 | 103 | while (!this._closed) |
michael@0 | 104 | Services.tm.currentThread.processNextEvent(true); |
michael@0 | 105 | ]]></body> |
michael@0 | 106 | </method> |
michael@0 | 107 | </implementation> |
michael@0 | 108 | </binding> |
michael@0 | 109 | </bindings> |