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 | |
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 | <!DOCTYPE bindings [ |
michael@0 | 8 | <!ENTITY % notificationDTD SYSTEM "chrome://global/locale/notification.dtd"> |
michael@0 | 9 | %notificationDTD; |
michael@0 | 10 | ]> |
michael@0 | 11 | |
michael@0 | 12 | <bindings id="notificationBindings" |
michael@0 | 13 | xmlns="http://www.mozilla.org/xbl" |
michael@0 | 14 | xmlns:xbl="http://www.mozilla.org/xbl" |
michael@0 | 15 | xmlns:html="http://www.w3.org/1999/xhtml" |
michael@0 | 16 | xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> |
michael@0 | 17 | |
michael@0 | 18 | <binding id="notificationbox" extends="chrome://global/content/bindings/notification.xml#notificationbox"> |
michael@0 | 19 | <content> |
michael@0 | 20 | <xul:stack xbl:inherits="hidden=notificationshidden" |
michael@0 | 21 | class="notificationbox-stack"> |
michael@0 | 22 | <xul:spacer/> |
michael@0 | 23 | <children includes="notification"/> |
michael@0 | 24 | </xul:stack> |
michael@0 | 25 | <html:div anonid="layer1" class="notification-layer"></html:div> |
michael@0 | 26 | <html:div anonid="layer2" class="notification-layer"></html:div> |
michael@0 | 27 | <children/> |
michael@0 | 28 | </content> |
michael@0 | 29 | |
michael@0 | 30 | <implementation> |
michael@0 | 31 | <constructor> |
michael@0 | 32 | <![CDATA[ |
michael@0 | 33 | this.addEventListener("AlertActive", this.handleEvent, true); |
michael@0 | 34 | this.addEventListener("AlertClose", this.handleEvent, true); |
michael@0 | 35 | this.setAttribute("count", 0); |
michael@0 | 36 | ]]> |
michael@0 | 37 | </constructor> |
michael@0 | 38 | <destructor> |
michael@0 | 39 | <![CDATA[ |
michael@0 | 40 | this.removeEventListener("AlertActive", this.handleEvent, true); |
michael@0 | 41 | this.removeEventListener("AlertClose", this.handleEvent, true); |
michael@0 | 42 | ]]> |
michael@0 | 43 | </destructor> |
michael@0 | 44 | <method name="adoptNotification"> |
michael@0 | 45 | <parameter name="aItem"/> |
michael@0 | 46 | <body> |
michael@0 | 47 | <![CDATA[ |
michael@0 | 48 | // insert an existing notification element |
michael@0 | 49 | // XXX: borrows code from appendNotification in toolkit/content/widgets/notification.xml |
michael@0 | 50 | // if this sticks around, we'll want to refactor both to eliminate duplication |
michael@0 | 51 | |
michael@0 | 52 | let priority = aItem.priority; |
michael@0 | 53 | // check for where the notification should be inserted according to |
michael@0 | 54 | // priority. If two are equal, the existing one appears on top. |
michael@0 | 55 | let notifications = this.allNotifications; |
michael@0 | 56 | let insertPos = null; |
michael@0 | 57 | for (let n = notifications.length - 1; n >= 0; n--) { |
michael@0 | 58 | if (notifications[n].priority < priority) |
michael@0 | 59 | break; |
michael@0 | 60 | insertPos = notifications[n]; |
michael@0 | 61 | } |
michael@0 | 62 | if (!insertPos) { |
michael@0 | 63 | aItem.style.position = "fixed"; |
michael@0 | 64 | aItem.style.top = "100%"; |
michael@0 | 65 | aItem.style.marginTop = "-15px"; |
michael@0 | 66 | aItem.style.opacity = "0"; |
michael@0 | 67 | } |
michael@0 | 68 | let label = aItem.label; |
michael@0 | 69 | this.insertBefore(aItem, insertPos); |
michael@0 | 70 | aItem.label = label; |
michael@0 | 71 | |
michael@0 | 72 | if (!insertPos) |
michael@0 | 73 | this._showNotification(aItem, true, true); |
michael@0 | 74 | |
michael@0 | 75 | // Fire event for accessibility APIs |
michael@0 | 76 | var event = document.createEvent("Events"); |
michael@0 | 77 | event.initEvent("AlertActive", true, true); |
michael@0 | 78 | aItem.dispatchEvent(event); |
michael@0 | 79 | |
michael@0 | 80 | return aItem; |
michael@0 | 81 | ]]> |
michael@0 | 82 | </body> |
michael@0 | 83 | </method> |
michael@0 | 84 | <method name="removeNotification"> |
michael@0 | 85 | <parameter name="aItem"/> |
michael@0 | 86 | <parameter name="aSkipAnimation"/> |
michael@0 | 87 | <body> |
michael@0 | 88 | <![CDATA[ |
michael@0 | 89 | if (aItem == this.currentNotification) |
michael@0 | 90 | this.removeCurrentNotification(aSkipAnimation); |
michael@0 | 91 | else if (aItem != this._closedNotification) |
michael@0 | 92 | this._removeNotificationElement(aItem); |
michael@0 | 93 | |
michael@0 | 94 | // Fire notification closed event. |
michael@0 | 95 | let event = new Event('AlertClose'); |
michael@0 | 96 | event.notification = aItem; |
michael@0 | 97 | this.dispatchEvent(event); |
michael@0 | 98 | |
michael@0 | 99 | return aItem; |
michael@0 | 100 | ]]> |
michael@0 | 101 | </body> |
michael@0 | 102 | </method> |
michael@0 | 103 | <method name="handleEvent"> |
michael@0 | 104 | <parameter name="aEvent"/> |
michael@0 | 105 | <body> |
michael@0 | 106 | <![CDATA[ |
michael@0 | 107 | switch (aEvent.type) { |
michael@0 | 108 | case "AlertActive": |
michael@0 | 109 | case "AlertClose": |
michael@0 | 110 | this.setAttribute("count", this.allNotifications.length); |
michael@0 | 111 | break; |
michael@0 | 112 | } |
michael@0 | 113 | ]]> |
michael@0 | 114 | </body> |
michael@0 | 115 | </method> |
michael@0 | 116 | </implementation> |
michael@0 | 117 | </binding> |
michael@0 | 118 | |
michael@0 | 119 | <binding id="notification" role="xul:alert" extends="chrome://global/content/bindings/notification.xml#notification"> |
michael@0 | 120 | <implementation> |
michael@0 | 121 | <property name="_messageContainer" onget="return document.getAnonymousElementByAttribute(this, 'anonid', 'messageText');"/> |
michael@0 | 122 | <property name="label"> |
michael@0 | 123 | <getter><![CDATA[ |
michael@0 | 124 | if (this._messageContainer.childElementCount) { |
michael@0 | 125 | // return a document fragment when our label is a complex value containing elements |
michael@0 | 126 | // by cloning childNodes into a document fragment, the returned value |
michael@0 | 127 | // is *not* live and will survive unbinding of this notification |
michael@0 | 128 | let frag = this.ownerDocument.createDocumentFragment(); |
michael@0 | 129 | let containerNode = this._messageContainer; |
michael@0 | 130 | for(let cnode of containerNode.childNodes) { |
michael@0 | 131 | frag.appendChild(cnode.cloneNode(true)); |
michael@0 | 132 | } |
michael@0 | 133 | return frag; |
michael@0 | 134 | } else { |
michael@0 | 135 | return String.trim(this._messageContainer.textContent) || |
michael@0 | 136 | this.getAttribute("label"); |
michael@0 | 137 | } |
michael@0 | 138 | ]]></getter> |
michael@0 | 139 | <setter><![CDATA[ |
michael@0 | 140 | // accept a string or node (e.g. document fragment, element or text node) as label value |
michael@0 | 141 | if (val && "object" == typeof val && ('nodeType' in val)) { |
michael@0 | 142 | let containerNode = this._messageContainer; |
michael@0 | 143 | let cnode; |
michael@0 | 144 | while((cnode = containerNode.firstChild)) { |
michael@0 | 145 | cnode.remove(); |
michael@0 | 146 | } |
michael@0 | 147 | if (val.ownerDocument !== this.ownerDocument) { |
michael@0 | 148 | val = this.ownerDocument.importNode(val, true); |
michael@0 | 149 | } |
michael@0 | 150 | return containerNode.appendChild(val); |
michael@0 | 151 | } else { |
michael@0 | 152 | return (this._messageContainer.textContent = val); |
michael@0 | 153 | } |
michael@0 | 154 | ]]></setter> |
michael@0 | 155 | </property> |
michael@0 | 156 | </implementation> |
michael@0 | 157 | </binding> |
michael@0 | 158 | </bindings> |