Bug 1497837 - Progressmeter in mode=undetermined behaves very weird, r=paolo, f=paenglab
authorAlexander Surkov <surkov.alexander@gmail.com>
Tue, 16 Oct 2018 14:45:37 +0800
changeset 489721 ba4289e62b60d38f4333c79668c0eca7aac62f55
parent 489720 7a0bdd661bbce9ada9dc88bd614b9a5c706d2730
child 489722 d37fe76d61f968dc7e65327690020c6069841adb
push id247
push userfmarier@mozilla.com
push dateSat, 27 Oct 2018 01:06:44 +0000
reviewerspaolo
bugs1497837
milestone64.0a1
Bug 1497837 - Progressmeter in mode=undetermined behaves very weird, r=paolo, f=paenglab
toolkit/content/widgets/progressmeter.js
--- a/toolkit/content/widgets/progressmeter.js
+++ b/toolkit/content/widgets/progressmeter.js
@@ -70,87 +70,36 @@ class MozProgressmeter extends MozXULEle
 
   connectedCallback() {
     if (this.delayConnectedCallback()) {
       return;
     }
     this._initUI();
   }
 
-  disconnectedCallback() {
-    this.runAnimation = false;
-  }
-
   static get observedAttributes() {
     return [ "mode" ];
   }
 
   attributeChangedCallback(name, oldValue, newValue) {
     if (!this.isConnectedAndReady) {
       return;
     }
 
     if (name === "mode" && oldValue != newValue) {
       this._initUI();
     }
   }
 
   _initUI() {
-    let isUndetermined = this.isUndetermined();
-    let content = isUndetermined ?
-      `
-        <stack class="progress-remainder" flex="1" style="overflow: -moz-hidden-unscrollable;">
-          <spacer class="progress-bar" top="0" style="margin-right: -1000px;"/>
-        </stack>
-      ` :
-      `
-        <spacer class="progress-bar"/>
-        <spacer class="progress-remainder"/>
-      `;
-
-    this._stack = null;
-    this._spacer = null;
-    this._runAnimation = isUndetermined;
+    let content = `
+      <spacer class="progress-bar"/>
+      <spacer class="progress-remainder"/>
+    `;
 
     this.textContent = "";
     this.appendChild(MozXULElement.parseXULToFragment(content));
-
-    if (!isUndetermined) {
-      return;
-    }
-
-    this._stack = this.querySelector(".progress-remainder");
-    this._spacer = this.querySelector(".progress-bar");
-    this._isLTR = document.defaultView.getComputedStyle(this).direction == "ltr";
-    this._startTime = window.performance.now();
-
-    let nextStep = (t) => {
-      if (!this._runAnimation) {
-        return;
-      }
-
-      let width = this._stack.boxObject.width;
-      if (width) {
-        let elapsedTime = t - this._startTime;
-
-        // Width of chunk is 1/5 (determined by the ratio 2000:400) of the
-        // total width of the progress bar. The left edge of the chunk
-        // starts at -1 and moves all the way to 4. It covers the distance
-        // in 2 seconds.
-        let position = this._isLTR ? ((elapsedTime % 2000) / 400) - 1 :
-                                     ((elapsedTime % 2000) / -400) + 4;
-
-        width = width >> 2;
-        this._spacer.height = this._stack.boxObject.height;
-        this._spacer.width = width;
-        this._spacer.left = width * position;
-      }
-
-      window.requestAnimationFrame(nextStep);
-    };
-
-    window.requestAnimationFrame(nextStep);
   }
 }
 
 customElements.define("progressmeter", MozProgressmeter);
 
 }