Bug 1233198 - Remove preprocessing from toolkit/content/widgets/videocontrols.xml. r?gijs,bwu draft
authorJared Wein <jwein@mozilla.com>
Sat, 13 Aug 2016 18:40:26 -0400
changeset 400471 db1fcda826ace45c62720f1d1243603ebf84596e
parent 400469 f944299e1f561477b82861fdd70435b0dd8c4ac3
child 528209 f5721d2fde984f6f1386be1e7a1ee0aedb78ce20
push id26153
push userjwein@mozilla.com
push dateSat, 13 Aug 2016 22:40:59 +0000
reviewersgijs, bwu
bugs1233198
milestone51.0a1
Bug 1233198 - Remove preprocessing from toolkit/content/widgets/videocontrols.xml. r?gijs,bwu MozReview-Commit-ID: LXAxCTf4OEg
.eslintignore
b2g/chrome/content/content.css
toolkit/content/jar.mn
toolkit/content/widgets/videocontrols.xml
--- a/.eslintignore
+++ b/.eslintignore
@@ -232,17 +232,16 @@ toolkit/modules/tests/xpcshell/test_task
 toolkit/components/osfile/**
 
 # External code:
 toolkit/components/microformats/test/**
 toolkit/components/reader/Readability.js
 toolkit/components/reader/JSDOMParser.js
 
 # Uses preprocessing
-toolkit/content/widgets/videocontrols.xml
 toolkit/content/widgets/wizard.xml
 toolkit/components/jsdownloads/src/DownloadIntegration.jsm
 toolkit/components/search/nsSearchService.js
 toolkit/components/url-classifier/**
 toolkit/components/urlformatter/nsURLFormatter.js
 toolkit/identity/FirefoxAccounts.jsm
 toolkit/modules/AppConstants.jsm
 toolkit/mozapps/downloads/nsHelperAppDlg.js
--- a/b2g/chrome/content/content.css
+++ b/b2g/chrome/content/content.css
@@ -90,17 +90,17 @@ xul|thumb {
 
 xul|scrollbarbutton {
   background-image: none !important;
 }
 
 %ifndef MOZ_GRAPHENE
 /* -moz-touch-enabled? media elements */
 :-moz-any(video, audio) > xul|videocontrols {
-  -moz-binding: url("chrome://global/content/bindings/videocontrols.xml#touchControls");
+  -moz-binding: url("chrome://global/content/bindings/videocontrols.xml#touchControlsGonk");
 }
 
 select:not([size]):not([multiple]) > xul|scrollbar,
 select[size="1"] > xul|scrollbar,
 select:not([size]):not([multiple]) xul|scrollbarbutton,
 select[size="1"] xul|scrollbarbutton {
   display: block;
   margin-left: 0;
--- a/toolkit/content/jar.mn
+++ b/toolkit/content/jar.mn
@@ -97,15 +97,15 @@ toolkit.jar:
    content/global/bindings/spinbuttons.xml     (widgets/spinbuttons.xml)
    content/global/bindings/stringbundle.xml    (widgets/stringbundle.xml)
 *  content/global/bindings/tabbox.xml          (widgets/tabbox.xml)
    content/global/bindings/text.xml            (widgets/text.xml)
 *  content/global/bindings/textbox.xml         (widgets/textbox.xml)
    content/global/bindings/toolbar.xml         (widgets/toolbar.xml)
    content/global/bindings/toolbarbutton.xml   (widgets/toolbarbutton.xml)
 *  content/global/bindings/tree.xml            (widgets/tree.xml)
-*  content/global/bindings/videocontrols.xml   (widgets/videocontrols.xml)
+   content/global/bindings/videocontrols.xml   (widgets/videocontrols.xml)
    content/global/bindings/videocontrols.css   (widgets/videocontrols.css)
 *  content/global/bindings/wizard.xml          (widgets/wizard.xml)
 #ifdef XP_MACOSX
    content/global/macWindowMenu.js
 #endif
    content/global/svg/svgBindings.xml          (/layout/svg/resources/content/svgBindings.xml)
--- a/toolkit/content/widgets/videocontrols.xml
+++ b/toolkit/content/widgets/videocontrols.xml
@@ -125,17 +125,17 @@
             // just calls the videocontrol's seekToPosition() method directly.
             switch (which) {
               case "curpos":
                 if (this.type == "scrubber") {
                     // Update the time shown in the thumb.
                     this.thumb.setTime(newValue);
                     this.Utils.positionLabel.setAttribute("value", this.thumb.timeLabel.value);
                     // Update the value bar to match the thumb position.
-                    var percent = newValue / this.max;
+                    let percent = newValue / this.max;
                     this.valueBar.value = Math.round(percent * 10000); // has max=10000
                 }
 
                 // The value of userChanged is true when changing the position with the mouse,
                 // but not when pressing an arrow key. However, the base binding sets
                 // ._userChanged in its keypress handlers, so we just need to check both.
                 if (!userChanged && !this._userChanged)
                   return;
@@ -149,17 +149,17 @@
 
               case "minpos":
                 this.setAttribute("min", newValue);
                 break;
 
               case "maxpos":
                 if (this.type == "scrubber") {
                     // Update the value bar to match the thumb position.
-                    var percent = this.value / newValue;
+                    let percent = this.value / newValue;
                     this.valueBar.value = Math.round(percent * 10000); // has max=10000
                 }
                 this.setAttribute("max", newValue);
                 break;
             }
           ]]>
           </body>
       </method>
@@ -768,24 +768,24 @@
                     // the arrow-keys.
                     //this.scrubber.increment = duration / 50;
                     this.scrubber.pageIncrement = Math.round(duration / 10);
                 },
 
                 seekToPosition : function(newPosition) {
                     newPosition /= 1000; // convert from ms
                     this.log("+++ seeking to " + newPosition);
-#ifdef MOZ_WIDGET_GONK
-                    // We use fastSeek() on B2G, and an accurate (but slower)
-                    // seek on other platforms (that are likely to be higher
-                    // perf).
-                    this.video.fastSeek(newPosition);
-#else
-                    this.video.currentTime = newPosition;
-#endif
+                    if (this.isGonk) {
+                        // We use fastSeek() on B2G, and an accurate (but slower)
+                        // seek on other platforms (that are likely to be higher
+                        // perf).
+                        this.video.fastSeek(newPosition);
+                    } else {
+                        this.video.currentTime = newPosition;
+                    }
                 },
 
                 setVolume : function(newVolume) {
                     this.log("*** setting volume to " + newVolume);
                     this.video.volume = newVolume;
                     this.video.muted = false;
                 },
 
@@ -1137,42 +1137,41 @@
                       this.muteButton.removeAttribute("muted");
 
                   var attrName = muted ? "unmutelabel" : "mutelabel";
                   var value = this.muteButton.getAttribute(attrName);
                   this.muteButton.setAttribute("aria-label", value);
                 },
 
                 _getComputedPropertyValueAsInt : function(element, property) {
-                  let value = window.getComputedStyle(element, null).getPropertyValue(property);
+                  let value = getComputedStyle(element, null).getPropertyValue(property);
                   return parseInt(value, 10);
                 },
 
                 keyHandler : function(event) {
                     // Ignore keys when content might be providing its own.
                     if (!this.video.hasAttribute("controls"))
                         return;
 
                     var keystroke = "";
                     if (event.altKey)
                         keystroke += "alt-";
                     if (event.shiftKey)
                         keystroke += "shift-";
-#ifdef XP_MACOSX
-                    if (event.metaKey)
-                        keystroke += "accel-";
-                    if (event.ctrlKey)
-                        keystroke += "control-";
-#else
-                    if (event.metaKey)
-                        keystroke += "meta-";
-                    if (event.ctrlKey)
-                        keystroke += "accel-";
-#endif
-
+                    if (navigator.platform.startsWith("Mac")) {
+                        if (event.metaKey)
+                            keystroke += "accel-";
+                        if (event.ctrlKey)
+                            keystroke += "control-";
+                    } else {
+                        if (event.metaKey)
+                            keystroke += "meta-";
+                        if (event.ctrlKey)
+                            keystroke += "accel-";
+                    }
                     switch (event.keyCode) {
                         case KeyEvent.DOM_VK_UP:
                             keystroke += "upArrow";
                             break;
                         case KeyEvent.DOM_VK_DOWN:
                             keystroke += "downArrow";
                             break;
                         case KeyEvent.DOM_VK_LEFT:
@@ -1240,17 +1239,17 @@
                                 break;
                             case "end": /* Seek to end */
                                 if (this.video.currentTime != this.video.duration)
                                     this.video.currentTime = (this.video.duration || this.maxCurrentTimeSeen / 1000);
                                 break;
                             default:
                                 return;
                         }
-                    } catch(e) { /* ignore any exception from setting .currentTime */ }
+                    } catch (e) { /* ignore any exception from setting .currentTime */ }
 
                     event.preventDefault(); // Prevent page scrolling
                 },
 
                 isSupportedTextTrack : function(textTrack) {
                   return textTrack.kind == "subtitles" ||
                          textTrack.kind == "captions";
                 },
@@ -1352,18 +1351,18 @@
                 onControlBarTransitioned : function () {
                   this.textTrackList.setAttribute("hidden", "true");
                   this.video.dispatchEvent(new CustomEvent("controlbarchange"));
                 },
 
                 toggleClosedCaption : function () {
                   if (this.overlayableTextTracks.length === 1) {
                     const lastTTIdx = this.overlayableTextTracks[0].index;
-
-                    return this.changeTextTrack(this.isClosedCaptionOn() ? 0 : lastTTIdx);
+                    this.changeTextTrack(this.isClosedCaptionOn() ? 0 : lastTTIdx);
+                    return;
                   }
 
                   if (this.textTrackList.hasAttribute("hidden")) {
                     this.textTrackList.removeAttribute("hidden");
                   } else {
                     this.textTrackList.setAttribute("hidden", "true");
                   }
 
@@ -1871,26 +1870,34 @@
           delete this.randomID;
           ]]>
       </destructor>
 
     </implementation>
 
     <handlers>
         <handler event="mouseup">
-          if(event.originalTarget.nodeName == "vbox") {
+          if (event.originalTarget.nodeName == "vbox") {
             if (this.TouchUtils.firstShow)
               this.Utils.video.play();
             this.TouchUtils.toggleControls();
           }
         </handler>
     </handlers>
 
   </binding>
 
+  <binding id="touchControlsGonk" extends="chrome://global/content/bindings/videoControls.xml#touchControls">
+    <implementation>
+      <field name="isGonk" readonly="true">
+        true
+      </field>
+    </implementation>
+  </binding>
+
   <binding id="noControls">
 
     <resources>
         <stylesheet src="chrome://global/content/bindings/videocontrols.css"/>
         <stylesheet src="chrome://global/skin/media/videocontrols.css"/>
     </resources>
 
     <xbl:content xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" class="mediaControlsFrame">