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 497178 ba4289e62b60d38f4333c79668c0eca7aac62f55
parent 497177 7a0bdd661bbce9ada9dc88bd614b9a5c706d2730
child 497179 d37fe76d61f968dc7e65327690020c6069841adb
push id9996
push userarchaeopteryx@coole-files.de
push dateThu, 18 Oct 2018 18:37:15 +0000
treeherdermozilla-beta@8efe26839243 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspaolo
bugs1497837
milestone64.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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);
 
 }