Merge mozilla-inbound to mozilla-central. a=merge
authorCosmin Sabou <csabou@mozilla.com>
Wed, 26 Dec 2018 23:47:45 +0200
changeset 451940 ad6f51d4af0b91d3a4d84da55115a2a9a932347c
parent 451939 6150c08114a82b4f68a91b2a04a742cd9e34b4fe (current diff)
parent 451926 82be4a42a1d3c95c90d503ad3e25ed9a9fb6f1f3 (diff)
child 451941 105d91988991ddb4cec5915d2090046227b6b819
child 451977 1f7282fade712b51ebea617aba55438cf286b24d
push id110773
push usercsabou@mozilla.com
push dateWed, 26 Dec 2018 21:58:04 +0000
treeherdermozilla-inbound@105d91988991 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmerge
milestone66.0a1
first release with
nightly linux32
ad6f51d4af0b / 66.0a1 / 20181226215140 / files
nightly linux64
ad6f51d4af0b / 66.0a1 / 20181226215140 / files
nightly mac
ad6f51d4af0b / 66.0a1 / 20181226215140 / files
nightly win32
ad6f51d4af0b / 66.0a1 / 20181226215140 / files
nightly win64
ad6f51d4af0b / 66.0a1 / 20181226215140 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Merge mozilla-inbound to mozilla-central. a=merge
--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -4,17 +4,17 @@
    - License, v. 2.0. If a copy of the MPL was not distributed with this
    - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
 
 <bindings id="tabBrowserBindings"
           xmlns="http://www.mozilla.org/xbl"
           xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
           xmlns:xbl="http://www.mozilla.org/xbl">
 
-  <binding id="tabbrowser-arrowscrollbox" extends="chrome://global/content/bindings/scrollbox.xml#arrowscrollbox-clicktoscroll">
+  <binding id="tabbrowser-arrowscrollbox" extends="chrome://global/content/bindings/scrollbox.xml#arrowscrollbox">
     <implementation>
       <!-- Override scrollbox.xml method, since our scrollbox's children are
            inherited from the binding parent -->
       <method name="_getScrollableElements">
         <body><![CDATA[
           return Array.filter(document.getBindingParent(this).children,
                               this._canScrollToElement, this);
         ]]></body>
--- a/dom/html/test/mochitest.ini
+++ b/dom/html/test/mochitest.ini
@@ -464,17 +464,17 @@ support-files =
   file_fullscreen-svg-element.html
   file_fullscreen-table.html
   file_fullscreen-top-layer.html
   file_fullscreen-unprefix-disabled-inner.html
   file_fullscreen-unprefix-disabled.html
   file_fullscreen-utils.js
 [test_fullscreen-api-race.html]
 tags = fullscreen
-skip-if = toolkit == 'android' || (verify && debug && os == 'mac') # Android: same as test_fullscreen-api.html
+skip-if = toolkit == 'android' || (verify && debug && os == 'mac') || (os == "mac" && debug) # Android: same as test_fullscreen-api.html, 1356570
 [test_hidden.html]
 [test_html_attributes_reflection.html]
 [test_htmlcollection.html]
 [test_iframe_sandbox_general.html]
 tags = openwindow
 [test_iframe_sandbox_inheritance.html]
 tags = openwindow
 [test_iframe_sandbox_navigation.html]
--- a/toolkit/content/widgets/scrollbox.xml
+++ b/toolkit/content/widgets/scrollbox.xml
@@ -17,33 +17,39 @@
     </content>
   </binding>
 
   <binding id="arrowscrollbox" extends="chrome://global/content/bindings/general.xml#basecontrol">
     <content>
       <xul:toolbarbutton class="scrollbutton-up"
                          anonid="scrollbutton-up"
                          xbl:inherits="orient,collapsed=notoverflowing,disabled=scrolledtostart"
-                         onmouseover="_startScroll(-1);"
-                         onmouseout="_stopScroll();"/>
+                         onclick="_onButtonClick(event);"
+                         onmousedown="_onButtonMouseDown(event, -1);"
+                         onmouseup="_onButtonMouseUp(event);"
+                         onmouseover="_onButtonMouseOver(-1);"
+                         onmouseout="_onButtonMouseOut();"/>
       <xul:spacer class="arrowscrollbox-overflow-start-indicator"
                   xbl:inherits="collapsed=scrolledtostart"/>
       <xul:scrollbox class="arrowscrollbox-scrollbox"
                      anonid="scrollbox"
                      flex="1"
                      xbl:inherits="orient,align,pack,dir,smoothscroll">
         <children/>
       </xul:scrollbox>
       <xul:spacer class="arrowscrollbox-overflow-end-indicator"
                   xbl:inherits="collapsed=scrolledtoend"/>
       <xul:toolbarbutton class="scrollbutton-down"
                          anonid="scrollbutton-down"
                          xbl:inherits="orient,collapsed=notoverflowing,disabled=scrolledtoend"
-                         onmouseover="_startScroll(1);"
-                         onmouseout="_stopScroll();"/>
+                         onclick="_onButtonClick(event);"
+                         onmousedown="_onButtonMouseDown(event, 1);"
+                         onmouseup="_onButtonMouseUp(event);"
+                         onmouseover="_onButtonMouseOver(1);"
+                         onmouseout="_onButtonMouseOut();"/>
     </content>
 
     <implementation>
       <constructor><![CDATA[
         if (!this.hasAttribute("smoothscroll")) {
           this.smoothScroll = this._prefBranch
                                   .getBoolPref("toolkit.scrollbox.smoothScroll", true);
         }
@@ -65,16 +71,59 @@
       </field>
       <field name="_scrollButtonUp">
         document.getAnonymousElementByAttribute(this, "anonid", "scrollbutton-up");
       </field>
       <field name="_scrollButtonDown">
         document.getAnonymousElementByAttribute(this, "anonid", "scrollbutton-down");
       </field>
 
+      <field name="_scrollIndex">0</field>
+
+      <field name="_arrowScrollAnim"><![CDATA[({
+        scrollbox: this,
+        requestHandle: 0, /* 0 indicates there is no pending request */
+        start: function arrowSmoothScroll_start() {
+          this.lastFrameTime = window.performance.now();
+          if (!this.requestHandle)
+            this.requestHandle = window.requestAnimationFrame(this.sample.bind(this));
+        },
+        stop: function arrowSmoothScroll_stop() {
+          window.cancelAnimationFrame(this.requestHandle);
+          this.requestHandle = 0;
+        },
+        sample: function arrowSmoothScroll_handleEvent(timeStamp) {
+          const scrollIndex = this.scrollbox._scrollIndex;
+          const timePassed = timeStamp - this.lastFrameTime;
+          this.lastFrameTime = timeStamp;
+
+          const scrollDelta = 0.5 * timePassed * scrollIndex;
+          this.scrollbox.scrollByPixels(scrollDelta, true);
+          this.requestHandle = window.requestAnimationFrame(this.sample.bind(this));
+        },
+      })]]></field>
+
+      <property name="_clickToScroll" readonly="true">
+        <getter><![CDATA[
+          return this.hasAttribute("clicktoscroll");
+        ]]></getter>
+      </property>
+
+      <property name="_scrollDelay" readonly="true">
+        <getter><![CDATA[
+          if (this._clickToScroll) {
+            return this._prefBranch.getIntPref(
+                            "toolkit.scrollbox.clickToScroll.scrollDelay", 150);
+          }
+
+          // Use the same REPEAT_DELAY as "nsRepeatService.h".
+          return /Mac/.test(navigator.platform) ? 25 : 50;
+        ]]></getter>
+      </property>
+
       <field name="__prefBranch">null</field>
       <property name="_prefBranch" readonly="true">
         <getter><![CDATA[
           if (this.__prefBranch === null) {
             this.__prefBranch = Cc["@mozilla.org/preferences-service;1"]
                                   .getService(Ci.nsIPrefBranch);
           }
           return this.__prefBranch;
@@ -153,16 +202,66 @@
         this.orient == "vertical" ? ["top", "bottom"] : ["left", "right"];
       ]]></field>
 
       <field name="_isRTLScrollbox"><![CDATA[
         this.orient != "vertical" &&
         document.defaultView.getComputedStyle(this._scrollbox).direction == "rtl";
       ]]></field>
 
+      <method name="_onButtonClick">
+        <parameter name="event"/>
+        <body><![CDATA[
+          if (this._clickToScroll) {
+            this._distanceScroll(event);
+          }
+        ]]></body>
+      </method>
+
+      <method name="_onButtonMouseDown">
+        <parameter name="event"/>
+        <parameter name="index"/>
+        <body><![CDATA[
+          if (this._clickToScroll && event.button == 0) {
+            this._startScroll(index);
+          }
+        ]]></body>
+      </method>
+
+      <method name="_onButtonMouseUp">
+        <parameter name="event"/>
+        <body><![CDATA[
+          if (this._clickToScroll && event.button == 0) {
+            this._stopScroll();
+          }
+        ]]></body>
+      </method>
+
+      <method name="_onButtonMouseOver">
+        <parameter name="index"/>
+        <body><![CDATA[
+          if (this._clickToScroll) {
+            this._continueScroll(index);
+          } else {
+            this._startScroll(index);
+          }
+        ]]></body>
+      </method>
+
+      <method name="_onButtonMouseOut">
+        <parameter name="index"/>
+        <body><![CDATA[
+          if (this._clickToScroll) {
+            this._pauseScroll();
+          } else {
+            this._stopScroll();
+          }
+        ]]></body>
+      </method>
+
       <method name="_boundsWithoutFlushing">
         <parameter name="element"/>
         <body><![CDATA[
           if (!("_DOMWindowUtils" in this)) {
             this._DOMWindowUtils = window.windowUtils;
           }
 
           return this._DOMWindowUtils ?
@@ -303,38 +402,138 @@
 
       <method name="_startScroll">
         <parameter name="index"/>
         <body><![CDATA[
           if (this._isRTLScrollbox) {
             index *= -1;
           }
 
+          if (this._clickToScroll) {
+            this._scrollIndex = index;
+            this._mousedown = true;
+
+            if (this.smoothScroll) {
+              this._arrowScrollAnim.start();
+              return;
+            }
+          }
+
           if (!this._scrollTimer) {
             this._scrollTimer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
           } else {
             this._scrollTimer.cancel();
           }
 
-          let callback = () => this.scrollByPixels(this.scrollIncrement * index);
+          let callback;
+          if (this._clickToScroll) {
+            callback = () => {
+              if (!document && this._scrollTimer) {
+                this._scrollTimer.cancel();
+              }
+              this.scrollByIndex(this._scrollIndex);
+            };
+          } else {
+            callback = () => this.scrollByPixels(this.scrollIncrement * index);
+          }
 
-          // Use the same REPEAT_DELAY as "nsRepeatService.h".
-          let scrollDelay = /Mac/.test(navigator.platform) ? 25 : 50;
+          this._scrollTimer.initWithCallback(callback, this._scrollDelay,
+                                             Ci.nsITimer.TYPE_REPEATING_SLACK);
 
-          this._scrollTimer.initWithCallback(callback, scrollDelay,
-                                             Ci.nsITimer.TYPE_REPEATING_SLACK);
           callback();
         ]]>
         </body>
       </method>
 
       <method name="_stopScroll">
         <body><![CDATA[
           if (this._scrollTimer)
             this._scrollTimer.cancel();
+
+          if (this._clickToScroll) {
+            this._mousedown = false;
+            if (!this._scrollIndex || !this.smoothScroll)
+              return;
+
+            this.scrollByIndex(this._scrollIndex);
+            this._scrollIndex = 0;
+
+            this._arrowScrollAnim.stop();
+          }
+        ]]></body>
+      </method>
+
+      <method name="_pauseScroll">
+        <body><![CDATA[
+          if (this._mousedown) {
+            this._stopScroll();
+            this._mousedown = true;
+            document.addEventListener("mouseup", this);
+            document.addEventListener("blur", this, true);
+          }
+        ]]></body>
+      </method>
+
+      <method name="_continueScroll">
+        <parameter name="index"/>
+        <body><![CDATA[
+          if (this._mousedown)
+            this._startScroll(index);
+        ]]></body>
+      </method>
+
+      <method name="_distanceScroll">
+        <parameter name="aEvent"/>
+        <body><![CDATA[
+          if (aEvent.detail < 2 || aEvent.detail > 3)
+            return;
+
+          var scrollBack = (aEvent.originalTarget == this._scrollButtonUp);
+          var scrollLeftOrUp = this._isRTLScrollbox ? !scrollBack : scrollBack;
+          var targetElement;
+
+          if (aEvent.detail == 2) {
+            // scroll by the size of the scrollbox
+            let [start, end] = this._startEndProps;
+            let x;
+            if (scrollLeftOrUp)
+              x = this.scrollClientRect[start] - this.scrollClientSize;
+            else
+              x = this.scrollClientRect[end] + this.scrollClientSize;
+            targetElement = this._elementFromPoint(x, scrollLeftOrUp ? -1 : 1);
+
+            // the next partly-hidden element will become fully visible,
+            // so don't scroll too far
+            if (targetElement)
+              targetElement = scrollBack ?
+                              targetElement.nextElementSibling :
+                              targetElement.previousElementSibling;
+          }
+
+          if (!targetElement) {
+            // scroll to the first resp. last element
+            let elements = this._getScrollableElements();
+            targetElement = scrollBack ?
+                            elements[0] :
+                            elements[elements.length - 1];
+          }
+
+          this.ensureElementIsVisible(targetElement);
+        ]]></body>
+      </method>
+
+      <method name="handleEvent">
+        <parameter name="aEvent"/>
+        <body><![CDATA[
+          if (aEvent.type == "mouseup" ||
+              aEvent.type == "blur" && aEvent.target == document) {
+            this._mousedown = false;
+            document.removeEventListener("mouseup", this);
+            document.removeEventListener("blur", this, true);
+          }
         ]]></body>
       </method>
 
       <method name="scrollByPixels">
         <parameter name="aPixels"/>
         <parameter name="aInstant"/>
         <body><![CDATA[
           let scrollOptions = { behavior: aInstant ? "instant" : "auto" };
@@ -574,202 +773,9 @@
 
       <handler event="scrollend"><![CDATA[
         this._isScrolling = false;
         this._destination = 0;
         this._direction = 0;
       ]]></handler>
     </handlers>
   </binding>
-
-  <binding id="arrowscrollbox-clicktoscroll" extends="chrome://global/content/bindings/scrollbox.xml#arrowscrollbox">
-    <content>
-      <xul:toolbarbutton class="scrollbutton-up"
-                         xbl:inherits="orient,collapsed=notoverflowing,disabled=scrolledtostart"
-                         anonid="scrollbutton-up"
-                         onclick="_distanceScroll(event);"
-                         onmousedown="if (event.button == 0) _startScroll(-1);"
-                         onmouseup="if (event.button == 0) _stopScroll();"
-                         onmouseover="_continueScroll(-1);"
-                         onmouseout="_pauseScroll();"/>
-      <xul:spacer class="arrowscrollbox-overflow-start-indicator"
-                  xbl:inherits="collapsed=scrolledtostart"/>
-      <xul:scrollbox class="arrowscrollbox-scrollbox"
-                     anonid="scrollbox"
-                     flex="1"
-                     xbl:inherits="orient,align,pack,dir,smoothscroll">
-        <children/>
-      </xul:scrollbox>
-      <xul:spacer class="arrowscrollbox-overflow-end-indicator"
-                  xbl:inherits="collapsed=scrolledtoend"/>
-      <xul:toolbarbutton class="scrollbutton-down"
-                         xbl:inherits="orient,collapsed=notoverflowing,disabled=scrolledtoend"
-                         anonid="scrollbutton-down"
-                         onclick="_distanceScroll(event);"
-                         onmousedown="if (event.button == 0) _startScroll(1);"
-                         onmouseup="if (event.button == 0) _stopScroll();"
-                         onmouseover="_continueScroll(1);"
-                         onmouseout="_pauseScroll();"/>
-    </content>
-    <implementation>
-      <constructor><![CDATA[
-        this._scrollDelay =
-          this._prefBranch.getIntPref("toolkit.scrollbox.clickToScroll.scrollDelay",
-                                      this._scrollDelay);
-      ]]></constructor>
-
-      <destructor><![CDATA[
-        // Release timer to avoid reference cycles.
-        if (this._scrollTimer) {
-          this._scrollTimer.cancel();
-          this._scrollTimer = null;
-        }
-      ]]></destructor>
-
-      <field name="_scrollIndex">0</field>
-      <field name="_scrollDelay">150</field>
-
-      <field name="_arrowScrollAnim"><![CDATA[({
-        scrollbox: this,
-        requestHandle: 0, /* 0 indicates there is no pending request */
-        start: function arrowSmoothScroll_start() {
-          this.lastFrameTime = window.performance.now();
-          if (!this.requestHandle)
-            this.requestHandle = window.requestAnimationFrame(this.sample.bind(this));
-        },
-        stop: function arrowSmoothScroll_stop() {
-          window.cancelAnimationFrame(this.requestHandle);
-          this.requestHandle = 0;
-        },
-        sample: function arrowSmoothScroll_handleEvent(timeStamp) {
-          const scrollIndex = this.scrollbox._scrollIndex;
-          const timePassed = timeStamp - this.lastFrameTime;
-          this.lastFrameTime = timeStamp;
-
-          const scrollDelta = 0.5 * timePassed * scrollIndex;
-          this.scrollbox.scrollByPixels(scrollDelta, true);
-          this.requestHandle = window.requestAnimationFrame(this.sample.bind(this));
-        },
-      })]]></field>
-
-      <method name="_startScroll">
-        <parameter name="index"/>
-        <body><![CDATA[
-          if (this._isRTLScrollbox)
-            index *= -1;
-          this._scrollIndex = index;
-          this._mousedown = true;
-
-          if (this.smoothScroll) {
-            this._arrowScrollAnim.start();
-            return;
-          }
-
-          if (!this._scrollTimer)
-            this._scrollTimer =
-              Cc["@mozilla.org/timer;1"]
-                .createInstance(Ci.nsITimer);
-          else
-            this._scrollTimer.cancel();
-
-          let callback = () => {
-            if (!document && this._scrollTimer) {
-              this._scrollTimer.cancel();
-            }
-            this.scrollByIndex(this._scrollIndex);
-          };
-
-          this._scrollTimer.initWithCallback(callback, this._scrollDelay,
-                                             this._scrollTimer.TYPE_REPEATING_SLACK);
-          callback();
-        ]]>
-        </body>
-      </method>
-
-      <method name="_stopScroll">
-        <body><![CDATA[
-          if (this._scrollTimer)
-            this._scrollTimer.cancel();
-          this._mousedown = false;
-          if (!this._scrollIndex || !this.smoothScroll)
-            return;
-
-          this.scrollByIndex(this._scrollIndex);
-          this._scrollIndex = 0;
-
-          this._arrowScrollAnim.stop();
-        ]]></body>
-      </method>
-
-      <method name="_pauseScroll">
-        <body><![CDATA[
-          if (this._mousedown) {
-            this._stopScroll();
-            this._mousedown = true;
-            document.addEventListener("mouseup", this);
-            document.addEventListener("blur", this, true);
-          }
-        ]]></body>
-      </method>
-
-      <method name="_continueScroll">
-        <parameter name="index"/>
-        <body><![CDATA[
-          if (this._mousedown)
-            this._startScroll(index);
-        ]]></body>
-      </method>
-
-      <method name="handleEvent">
-        <parameter name="aEvent"/>
-        <body><![CDATA[
-          if (aEvent.type == "mouseup" ||
-              aEvent.type == "blur" && aEvent.target == document) {
-            this._mousedown = false;
-            document.removeEventListener("mouseup", this);
-            document.removeEventListener("blur", this, true);
-          }
-        ]]></body>
-      </method>
-
-      <method name="_distanceScroll">
-        <parameter name="aEvent"/>
-        <body><![CDATA[
-          if (aEvent.detail < 2 || aEvent.detail > 3)
-            return;
-
-          var scrollBack = (aEvent.originalTarget == this._scrollButtonUp);
-          var scrollLeftOrUp = this._isRTLScrollbox ? !scrollBack : scrollBack;
-          var targetElement;
-
-          if (aEvent.detail == 2) {
-            // scroll by the size of the scrollbox
-            let [start, end] = this._startEndProps;
-            let x;
-            if (scrollLeftOrUp)
-              x = this.scrollClientRect[start] - this.scrollClientSize;
-            else
-              x = this.scrollClientRect[end] + this.scrollClientSize;
-            targetElement = this._elementFromPoint(x, scrollLeftOrUp ? -1 : 1);
-
-            // the next partly-hidden element will become fully visible,
-            // so don't scroll too far
-            if (targetElement)
-              targetElement = scrollBack ?
-                              targetElement.nextElementSibling :
-                              targetElement.previousElementSibling;
-          }
-
-          if (!targetElement) {
-            // scroll to the first resp. last element
-            let elements = this._getScrollableElements();
-            targetElement = scrollBack ?
-                            elements[0] :
-                            elements[elements.length - 1];
-          }
-
-          this.ensureElementIsVisible(targetElement);
-        ]]></body>
-      </method>
-
-    </implementation>
-  </binding>
 </bindings>
--- a/toolkit/content/xul.css
+++ b/toolkit/content/xul.css
@@ -673,20 +673,16 @@ scrollbox {
 scrollbox[smoothscroll=true] {
   scroll-behavior: smooth;
 }
 
 arrowscrollbox {
   -moz-binding: url("chrome://global/content/bindings/scrollbox.xml#arrowscrollbox");
 }
 
-arrowscrollbox[clicktoscroll="true"] {
-  -moz-binding: url("chrome://global/content/bindings/scrollbox.xml#arrowscrollbox-clicktoscroll");
-}
-
 /********** stringbundle **********/
 
 stringbundle,
 stringbundleset {
   display: none;
 }
 
 /********** dialog **********/