~ubuntu-branches/ubuntu/intrepid/xulrunner-1.9/intrepid

« back to all changes in this revision

Viewing changes to mozilla/toolkit/content/widgets/notification.xml

  • Committer: Bazaar Package Importer
  • Author(s): Alexander Sack, Alexander Sack, Fabien Tassin
  • Date: 2008-02-13 11:47:21 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20080213114721-7om0mgzngvuk9czv
Tags: 1.9~b3+nobinonly-0ubuntu1
* release FIREFOX_3_0b3_RELEASE

[ Alexander Sack ]
* submit patch that ships xpcshell to bugzilla
  - rename debian/patches/ship_xpcshell.patch =>
           debian/patches/bz410617_att295212_ship_xpcshell.patch
  - update debian/patches/series
* fix tooltip in epiphany: previously displayed out of screen bounds
  (LP: #37507)
  - add debian/patches/bz233371_att297343_fix_outofscreen_embed_tooltip.patch
  - update debian/patches/series
* use default upstream gcc tweaks for improved performance - especially of the
  javascript engine
  - update debian/rules
* update global extension/plugin patch to apply cleanly against latest code
  - update debian/patches/bzXXX_gre_extension_plugin_support.patch
* fix pyxpcom build failure introduced by recent commit
  - add debian/patches/bzXXX_fix_pyxpcom_build_failure.patch
  - update debian/patches/series
* add distro independent global install locations for extensions,
  /usr/lib/mozilla/extensions and /usr/share/mozilla/extensions
  - update debian/xulrunner-1.9.dirs
* support embedded tarball layout when either there is a *.tar.bz2 in orig tarball
  or if DEBIAN_MOZCLIENT_EMBEDDED is not unset (you will need this to produce embedded
  tarballs during |get-orig-source|
  - update debian/rules
* bump minimum libnss3-dev build requirements to >= 3.12.0~1.9b3
  - update debian/control
* bump minimum libnspr4-dev build requirements to >= 4.7.0~1.9b3
  - update debian/control

[ Fabien Tassin ]
* Drop patches applied upstream
  - drop debian/patches/bz410617_att295212_ship_xpcshell.patch
  - drop debian/patches/bz404634_att294921.patch
  - drop debian/patches/bz386610_python2.5_ftbfs_amd64.patch
  - drop debian/patches/bz373918_att295042.patch
  - drop debian/patches/bz408062_unstable_pc.patch
  - drop debian/patches/bz384304_fix_recursive_symlinks.patch
  - update debian/patches/series
* Refresh diverged patches:
  - update debian/patches/bzXXX_pc_honour_system_nspr_nss.patch
  - update debian/patches/rename_venkman_addon.patch
  - update debian/patches/bz344818_cairo_xrender.patch
* Install links for all .so libs in the -dev package
  - update debian/patches/dont_install_so_in_dev.patch
* Bump gtk requirement to 2.12 as per Mozilla bug 412432
  - update debian/control
* Add #DEBHELPER# token to postinst/prerm scripts
  - update debian/xulrunner-1.9.{postinst,prerm}
* Install previously missed libdbusservice.so
  - update debian/xulrunner-1.9.install
* Update venkman patch to also rename locales
  - update debian/patches/rename_venkman_addon.patch
* Bump requirement for system cairo to >= 1.5.8 as we now need
  the newly added cairo_path_extents()
  - update debian/rules
* Include mozilla-devscripts file using -include so ifneq could be omitted
  - update debian/rules
* Fix missing .so symlinks regression
  - update debian/patches/dont_install_so_in_dev.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<?xml version="1.0"?>
2
 
 
3
 
<!DOCTYPE bindings [
4
 
<!ENTITY % notificationDTD SYSTEM "chrome://global/locale/notification.dtd">
5
 
%notificationDTD;
6
 
]>
7
 
 
8
 
<bindings id="notificationBindings"
9
 
          xmlns="http://www.mozilla.org/xbl"
10
 
          xmlns:xbl="http://www.mozilla.org/xbl"
11
 
          xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
12
 
 
13
 
  <binding id="notificationbox">
14
 
    <content>
15
 
      <xul:stack xbl:inherits="hidden=notificationshidden">
16
 
        <xul:spacer/>
17
 
        <children includes="notification"/>
18
 
      </xul:stack>
19
 
      <children/>
20
 
    </content>
21
 
 
22
 
    <implementation>
23
 
      <field name="PRIORITY_INFO_LOW" readonly="true">1</field>
24
 
      <field name="PRIORITY_INFO_MEDIUM" readonly="true">2</field>
25
 
      <field name="PRIORITY_INFO_HIGH" readonly="true">3</field>
26
 
      <field name="PRIORITY_WARNING_LOW" readonly="true">4</field>
27
 
      <field name="PRIORITY_WARNING_MEDIUM" readonly="true">5</field>
28
 
      <field name="PRIORITY_WARNING_HIGH" readonly="true">6</field>
29
 
      <field name="PRIORITY_CRITICAL_LOW" readonly="true">7</field>
30
 
      <field name="PRIORITY_CRITICAL_MEDIUM" readonly="true">8</field>
31
 
      <field name="PRIORITY_CRITICAL_HIGH" readonly="true">9</field>
32
 
      <field name="PRIORITY_CRITICAL_BLOCK" readonly="true">10</field>
33
 
 
34
 
      <field name="currentNotification">null</field>
35
 
      <field name="slideSteps">4</field>
36
 
 
37
 
      <field name="_timer">null</field>
38
 
      <field name="_closedNotification">null</field>
39
 
      <field name="_blockingCanvas">null</field>
40
 
 
41
 
      <property name="notificationsHidden"
42
 
                onget="return this.getAttribute('notificationshidden') == 'true';">
43
 
        <setter>
44
 
          if (val)
45
 
            this.setAttribute('notificationshidden', true);
46
 
          else this.removeAttribute('notificationshidden');
47
 
          return val;
48
 
        </setter>
49
 
      </property>
50
 
 
51
 
      <property name="allNotifications" readonly="true"
52
 
                onget="return this.getElementsByTagName('notification');"/>
53
 
 
54
 
      <method name="getNotificationWithValue">
55
 
        <parameter name="aValue"/>
56
 
        <body>
57
 
          <![CDATA[
58
 
            var notifications = this.allNotifications;
59
 
            for (var n = notifications.length - 1; n >= 0; n--) {
60
 
              if (aValue == notifications[n].value)
61
 
                return notifications[n];
62
 
            }
63
 
            return null;
64
 
          ]]>
65
 
        </body>
66
 
      </method>
67
 
 
68
 
      <method name="appendNotification">
69
 
        <parameter name="aLabel"/>
70
 
        <parameter name="aValue"/>
71
 
        <parameter name="aImage"/>
72
 
        <parameter name="aPriority"/>
73
 
        <parameter name="aButtons"/>
74
 
        <body>
75
 
          <![CDATA[
76
 
            if (aPriority < this.PRIORITY_INFO_LOW ||
77
 
                aPriority > this.PRIORITY_CRITICAL_BLOCK)
78
 
              throw "Invalid notification priority " + aPriority;
79
 
 
80
 
            // check for where the notification should be inserted according to
81
 
            // priority. If two are equal, the existing one appears on top.
82
 
            var notifications = this.allNotifications;
83
 
            var insertPos = null;
84
 
            for (var n = notifications.length - 1; n >= 0; n--) {
85
 
              if (notifications[n].priority < aPriority)
86
 
                break;
87
 
              insertPos = notifications[n];
88
 
            }
89
 
 
90
 
            const XULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
91
 
            var newitem = document.createElementNS(XULNS, "notification");
92
 
            newitem.setAttribute("label", aLabel);
93
 
            newitem.setAttribute("value", aValue);
94
 
            newitem.setAttribute("image", aImage);
95
 
            if (!insertPos) {
96
 
              newitem.style.position = "fixed";
97
 
              newitem.style.top = "100%";
98
 
            }
99
 
            this.insertBefore(newitem, insertPos);
100
 
 
101
 
            if (aButtons) {
102
 
              for (var b = 0; b < aButtons.length; b++) {
103
 
                var button = aButtons[b];
104
 
                var buttonElem = document.createElementNS(XULNS, "button");
105
 
                buttonElem.setAttribute("label", button.label);
106
 
                buttonElem.setAttribute("accesskey", button.accessKey);
107
 
 
108
 
                newitem.appendChild(buttonElem);
109
 
                buttonElem.buttonInfo = button;
110
 
              }
111
 
            }
112
 
 
113
 
            newitem.priority = aPriority;
114
 
            if (aPriority >= this.PRIORITY_CRITICAL_LOW)
115
 
              newitem.type = "critical";
116
 
            else if (aPriority <= this.PRIORITY_INFO_HIGH)
117
 
              newitem.type = "info";
118
 
            else
119
 
              newitem.type = "warning";
120
 
 
121
 
            if (!insertPos)
122
 
              this._showNotification(newitem, true);
123
 
 
124
 
            // Fire event for accessibility APIs
125
 
            var event = document.createEvent("Events");
126
 
            event.initEvent("AlertActive", true, true);
127
 
            newitem.dispatchEvent(event);
128
 
 
129
 
            return newitem;
130
 
          ]]>
131
 
        </body>
132
 
      </method>
133
 
 
134
 
      <method name="removeNotification">
135
 
        <parameter name="aItem"/>
136
 
        <body>
137
 
          <![CDATA[
138
 
            if (aItem == this.currentNotification)
139
 
              this.removeCurrentNotification();
140
 
            else
141
 
              this.removeChild(aItem);
142
 
            return aItem;
143
 
          ]]>
144
 
        </body>
145
 
      </method>
146
 
 
147
 
      <method name="removeCurrentNotification">
148
 
        <body>
149
 
          <![CDATA[
150
 
            this._showNotification(this.currentNotification, false);
151
 
            return null;
152
 
          ]]>
153
 
        </body>
154
 
      </method>
155
 
 
156
 
      <method name="removeAllNotifications">
157
 
        <parameter name="aImmediate"/>
158
 
        <body>
159
 
          <![CDATA[
160
 
            var notifications = this.allNotifications;
161
 
            for (var n = notifications.length - 1; n >= 0; n--) {
162
 
              if (aImmediate)
163
 
                this.removeChild(notifications[n]);
164
 
              else
165
 
                this.removeNotification(notifications[n]);
166
 
            }
167
 
            this.currentNotification = null;
168
 
          ]]>
169
 
        </body>
170
 
      </method>
171
 
 
172
 
      <method name="_showNotification">
173
 
        <parameter name="aNotification"/>
174
 
        <parameter name="aSlideIn"/>
175
 
        <body>
176
 
          <![CDATA[
177
 
            if (this._timer) {
178
 
              clearInterval(this._timer);
179
 
              if (this.currentNotification) {
180
 
                this.currentNotification.style.marginTop = "0px";
181
 
                this.currentNotification.style.opacity = 1;
182
 
              }
183
 
              if (this._closedNotification)
184
 
                this._closedNotification.parentNode.
185
 
                  removeChild(this._closedNotification);
186
 
              this._setBlockingState(this.currentNotification);
187
 
            }
188
 
 
189
 
            var height = aNotification.boxObject.height;
190
 
            var change = height / this.slideSteps;
191
 
            if (aSlideIn) {
192
 
              if (this.currentNotification &&
193
 
                  this.currentNotification.boxObject.height > height)
194
 
                height = this.currentNotification.boxObject.height;
195
 
 
196
 
              this.currentNotification = aNotification;
197
 
              this._closedNotification = null;
198
 
              aNotification.style.removeProperty("position");
199
 
              aNotification.style.removeProperty("top");
200
 
              aNotification.style.marginTop = -height + "px";
201
 
              aNotification.style.opacity = 0;
202
 
            }
203
 
            else {
204
 
              change = -change;
205
 
              this._closedNotification = aNotification;
206
 
              var notifications = this.allNotifications;
207
 
              var idx = notifications.length - 2;
208
 
              if (idx >= 0)
209
 
                this.currentNotification = notifications[idx];
210
 
              else
211
 
                this.currentNotification = null;
212
 
            }
213
 
            var opacitychange = change / height;
214
 
 
215
 
            var self = this;
216
 
            var slide = function slideInFn()
217
 
            {
218
 
              var done = false;
219
 
 
220
 
              var style = window.getComputedStyle(aNotification, null);
221
 
              var margin = style.getPropertyCSSValue("margin-top").
222
 
                             getFloatValue(CSSPrimitiveValue.CSS_PX);
223
 
 
224
 
              if (change > 0 && margin + change >= 0) {
225
 
                aNotification.style.marginTop = "0px";
226
 
                aNotification.style.opacity = 1;
227
 
                done = true;
228
 
              }
229
 
              else if (change < 0 && margin + change <= -height) {
230
 
                aNotification.style.marginTop = -height + "px";
231
 
                done = true;
232
 
              }
233
 
              else {
234
 
                aNotification.style.marginTop = (margin + change).toFixed(4) + "px";
235
 
                if (opacitychange)
236
 
                  aNotification.style.opacity =
237
 
                    Number(aNotification.style.opacity) + opacitychange;
238
 
              }
239
 
 
240
 
              if (done) {
241
 
                clearInterval(self._timer);
242
 
                self._timer = null;
243
 
                if (self._closedNotification)
244
 
                  self._closedNotification.parentNode.
245
 
                    removeChild(self._closedNotification);
246
 
                self._setBlockingState(self.currentNotification);
247
 
              }
248
 
            }
249
 
 
250
 
            this._timer = setInterval(slide, 50);
251
 
          ]]>
252
 
        </body>
253
 
      </method>
254
 
 
255
 
      <method name="_setBlockingState">
256
 
        <parameter name="aNotification"/>
257
 
        <body>
258
 
          <![CDATA[
259
 
            var isblock = aNotification &&
260
 
                          aNotification.priority == this.PRIORITY_CRITICAL_BLOCK;
261
 
            var canvas = this._blockingCanvas;
262
 
            if (isblock) {
263
 
              if (!canvas)
264
 
                canvas = document.createElementNS("http://www.w3.org/1999/xhtml", "canvas");
265
 
              const XULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
266
 
              var content = this.firstChild;
267
 
              if (!content ||
268
 
                   content.namespaceURI != XULNS ||
269
 
                   content.localName != "browser")
270
 
                return;
271
 
 
272
 
              var width = content.boxObject.width;
273
 
              var height = content.boxObject.height;
274
 
              content.collapsed = true;
275
 
 
276
 
              canvas.setAttribute("width", width);
277
 
              canvas.setAttribute("height", height);
278
 
              canvas.setAttribute("flex", "1");
279
 
 
280
 
              this.appendChild(canvas);
281
 
              this._blockingCanvas = canvas;
282
 
 
283
 
              var bgcolor = "white";
284
 
              try {
285
 
                var prefService = Components.classes["@mozilla.org/preferences-service;1"].
286
 
                                    getService(Components.interfaces.nsIPrefBranch);
287
 
                bgcolor = prefService.getCharPref("browser.display.background_color");
288
 
 
289
 
                var win = content.contentWindow;
290
 
                var context = canvas.getContext("2d");
291
 
                context.globalAlpha = 0.5;
292
 
                context.drawWindow(win, win.scrollX, win.scrollY,
293
 
                                   width, height, bgcolor);
294
 
              }
295
 
              catch(ex) { };
296
 
            }
297
 
            else if (canvas) {
298
 
              canvas.parentNode.removeChild(canvas);
299
 
              this._blockingCanvas = null;
300
 
              var content = this.firstChild;
301
 
              if (content)
302
 
                content.collapsed = false;
303
 
            }
304
 
          ]]>
305
 
        </body>
306
 
      </method>
307
 
 
308
 
    </implementation>
309
 
  </binding>
310
 
 
311
 
  <binding id="notification">
312
 
    <content>
313
 
      <xul:hbox class="notification-inner outset" flex="1" xbl:inherits="type">
314
 
        <xul:hbox anonid="details" align="center" flex="1"
315
 
                  oncommand="this.parentNode.parentNode._doButtonCommand(event);">
316
 
          <xul:image anonid="messageImage" class="messageImage" xbl:inherits="src=image"/>
317
 
          <xul:description anonid="messageText" class="messageText" flex="1" xbl:inherits="xbl:text=label"/>
318
 
          <xul:spacer flex="1"/>
319
 
          <children/>
320
 
        </xul:hbox>
321
 
        <xul:toolbarbutton ondblclick="event.stopPropagation();"
322
 
                           class="messageCloseButton tabbable"
323
 
                           xbl:inherits="hidden=hideclose"
324
 
                           tooltiptext="&closeNotification.tooltip;"
325
 
                           oncommand="document.getBindingParent(this).close();"/>
326
 
      </xul:hbox>
327
 
    </content>
328
 
    <resources>
329
 
      <stylesheet src="chrome://global/skin/notification.css"/>
330
 
    </resources>
331
 
    <implementation implements="nsIAccessibleProvider">
332
 
      <property name="accessibleType" readonly="true">
333
 
        <getter>
334
 
          <![CDATA[
335
 
            return Components.interfaces.nsIAccessibleProvider.XULAlert;
336
 
          ]]>
337
 
        </getter>
338
 
      </property>
339
 
 
340
 
      <property name="label" onset="this.setAttribute('label', val); return val;"
341
 
                             onget="return this.getAttribute('label');"/>
342
 
      <property name="value" onset="this.setAttribute('value', val); return val;"
343
 
                             onget="return this.getAttribute('value');"/>
344
 
      <property name="image" onset="this.setAttribute('image', val); return val;"
345
 
                             onget="return this.getAttribute('image');"/>
346
 
      <property name="type" onset="this.setAttribute('type', val); return val;"
347
 
                            onget="return this.getAttribute('type');"/>
348
 
      <property name="priority" onget="return parseInt(this.getAttribute('priority')) || 0;"
349
 
                                onset="this.setAttribute('priority', val); return val;"/>
350
 
 
351
 
      <property name="control" readonly="true">
352
 
        <getter>
353
 
          <![CDATA[
354
 
            var parent = this.parentNode;
355
 
            while (parent) {
356
 
              if (parent.localName == "notificationbox")
357
 
                return parent;
358
 
              parent = parent.parentNode;
359
 
            }
360
 
            return null;
361
 
          ]]>
362
 
        </getter>
363
 
      </property>
364
 
 
365
 
      <method name="close">
366
 
        <body>
367
 
          <![CDATA[
368
 
            var control = this.control;
369
 
            if (control)
370
 
              control.removeNotification(this);
371
 
            else
372
 
              this.hidden = true;
373
 
          ]]>
374
 
        </body>
375
 
      </method>
376
 
 
377
 
      <method name="_doButtonCommand">
378
 
        <parameter name="aEvent"/>
379
 
        <body>
380
 
          <![CDATA[
381
 
            if (!("buttonInfo" in aEvent.target))
382
 
              return;
383
 
 
384
 
            var button = aEvent.target.buttonInfo;
385
 
            if (button.popup) {
386
 
              document.popupNode = aEvent.target;
387
 
              document.getElementById(button.popup).
388
 
                showPopup(aEvent.originalTarget, -1, -1, "popup", "bottomleft", "topleft");
389
 
              aEvent.stopPropagation();
390
 
            }
391
 
            else {
392
 
              var callback = button.callback;
393
 
              if (callback) {
394
 
                var result = callback(this, button);
395
 
                if (!result)
396
 
                  this.close();
397
 
                aEvent.stopPropagation();
398
 
              }
399
 
            }
400
 
          ]]>
401
 
        </body>
402
 
      </method>
403
 
    </implementation>
404
 
  </binding>
405
 
</bindings>