toolkit/content/widgets/progressmeter.xml

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 <?xml version="1.0"?>
     2 <!-- This Source Code Form is subject to the terms of the Mozilla Public
     3    - License, v. 2.0. If a copy of the MPL was not distributed with this
     4    - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
     7 <bindings id="progressmeterBindings"
     8    xmlns="http://www.mozilla.org/xbl"
     9    xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
    10    xmlns:xbl="http://www.mozilla.org/xbl">
    12   <binding id="progressmeter" role="xul:progressmeter">
    13     <resources>
    14       <stylesheet src="chrome://global/skin/progressmeter.css"/>
    15     </resources>
    17     <content>
    18       <xul:spacer class="progress-bar" xbl:inherits="mode"/>
    19       <xul:spacer class="progress-remainder" xbl:inherits="mode"/>
    20     </content>
    22     <implementation>
    23       <property name="mode" onset="if (this.mode != val) this.setAttribute('mode', val); return val;"
    24                             onget="return this.getAttribute('mode');"/>
    26       <property name="value" onget="return this.getAttribute('value') || '0';">
    27         <setter><![CDATA[
    28           var p = Math.round(val);
    29           var max = Math.round(this.max);
    30           if (p < 0)
    31             p = 0;
    32           else if (p > max)
    33             p = max;
    34           var c = this.value; 
    35           if (p != c) {
    36             var delta = p - c;
    37             if (delta < 0)
    38               delta = -delta;
    39             if (delta > 3 || p == 0 || p == max) {
    40               this.setAttribute("value", p);
    41               // Fire DOM event so that accessible value change events occur
    42               var event = document.createEvent('Events');
    43               event.initEvent('ValueChange', true, true);
    44               this.dispatchEvent(event);
    45             }
    46           }
    48           return val;
    49         ]]></setter>
    50       </property>
    51       <property name="max"
    52                 onget="return this.getAttribute('max') || '100';"
    53                 onset="this.setAttribute('max', isNaN(val) ? 100 : Math.max(val, 1));
    54                        this.value = this.value;
    55                        return val;" />
    56     </implementation>
    57   </binding>
    59   <binding id="progressmeter-undetermined"
    60            extends="chrome://global/content/bindings/progressmeter.xml#progressmeter">
    61     <content>
    62       <xul:stack class="progress-remainder" flex="1" anonid="stack" style="overflow: -moz-hidden-unscrollable;">
    63         <xul:spacer class="progress-bar" anonid="spacer" top="0" style="margin-right: -1000px;"/>
    64       </xul:stack>
    65     </content>
    67     <implementation>
    68       <field name="_alive">true</field>
    69       <method name="_init">
    70         <body><![CDATA[
    71           var stack =
    72             document.getAnonymousElementByAttribute(this, "anonid", "stack");
    73           var spacer =
    74             document.getAnonymousElementByAttribute(this, "anonid", "spacer");
    75           var isLTR =
    76            document.defaultView.getComputedStyle(this, null).direction == "ltr";
    77           var startTime = window.mozAnimationStartTime;
    78           var self = this;
    80           function nextStep(t) {
    81             try {
    82               var width = stack.boxObject.width;
    83               if (!width) {
    84                 // Maybe we've been removed from the document.
    85                 if (self._alive)
    86                   mozRequestAnimationFrame(nextStep);
    87                 return;
    88               }
    90               var elapsedTime = t - startTime;
    92               // Width of chunk is 1/5 (determined by the ratio 2000:400) of the
    93               // total width of the progress bar. The left edge of the chunk
    94               // starts at -1 and moves all the way to 4. It covers the distance
    95               // in 2 seconds.
    96               var position = isLTR ? ((elapsedTime % 2000) / 400) - 1 :
    97                                      ((elapsedTime % 2000) / -400) + 4;
    99               width = width >> 2;
   100               spacer.height = stack.boxObject.height;
   101               spacer.width = width;
   102               spacer.left = width * position;
   104               mozRequestAnimationFrame(nextStep);
   105             } catch (e) {
   106             }
   107           }
   108           mozRequestAnimationFrame(nextStep);
   109         ]]></body>
   110       </method>
   112       <constructor>this._init();</constructor>
   113     </implementation>
   114   </binding>
   116 </bindings>

mercurial