Bug 1431255 - Part IX, Remove fullscreenchange workaround for bug 718107 draft
authorTimothy Guan-tin Chien <timdream@gmail.com>
Fri, 06 Jul 2018 18:37:10 +0800
changeset 829414 c07dc4ca7e9e90f9b87e07bb6063d81e8ff08374
parent 829413 2693cf89e90daa85ec622efd59b631f96afa4213
child 829415 ed962ec1413f1b58ee5e3ad3894c7d9dafd93b43
push id118779
push usertimdream@gmail.com
push dateWed, 15 Aug 2018 23:50:47 +0000
bugs1431255, 718107
milestone63.0a1
Bug 1431255 - Part IX, Remove fullscreenchange workaround for bug 718107 Acknowledge the control bar hidden behavior caused by the bug. Also, set the cursor state before early return, because the video might not be in the same fullsreen state the last time control bar is hidden/shown. MozReview-Commit-ID: 3oN3r8dsUvH
toolkit/content/widgets/videocontrols.js
--- a/toolkit/content/widgets/videocontrols.js
+++ b/toolkit/content/widgets/videocontrols.js
@@ -639,22 +639,19 @@ this.VideoControlsImplPageWidget = class
             }
             break;
           case "dblclick":
             this.toggleFullscreen();
             break;
           case "resizevideocontrols":
             this.adjustControlSize();
             break;
-          // See comment at onFullscreenChange on bug 718107.
-          /*
           case "fullscreenchange":
             this.onFullscreenChange();
             break;
-          */
           case "keypress":
             this.keyHandler(aEvent);
             break;
           case "dragstart":
             aEvent.preventDefault(); // prevent dragging of controls image (bug 517114)
             break;
           case "input":
             switch (aEvent.currentTarget) {
@@ -1181,42 +1178,42 @@ this.VideoControlsImplPageWidget = class
           */
           animation = element.animate(animationProp.keyframes, animationProp.options);
           animation.cancel();
 
           this.animationMap.set(element, animation);
         }
 
         if (fadeIn) {
+          if (element == this.controlBar) {
+            this.controlsSpacer.removeAttribute("hideCursor");
+          }
+
           // hidden state should be controlled by adjustControlSize
           if (element.isAdjustableControl && element.hiddenByAdjustment) {
             return;
           }
 
           // No need to fade in again if the element is visible and not fading out
           if (!element.hidden && !element.classList.contains("fadeout")) {
             return;
           }
 
-          if (element == this.controlBar) {
-            this.controlsSpacer.removeAttribute("hideCursor");
-          }
-
           // Unhide
           element.hidden = false;
         } else {
+          if (element == this.controlBar && !this.hasError() &&
+              this.document.mozFullScreenElement == this.video) {
+            this.controlsSpacer.setAttribute("hideCursor", true);
+          }
+
           // No need to fade out if the element is already no visible.
           if (element.hidden) {
             return;
           }
-
-          if (element == this.controlBar && !this.hasError() &&
-              this.document.mozFullScreenElement == this.video) {
-            this.controlsSpacer.setAttribute("hideCursor", true);
-          }
         }
 
         element.classList.toggle("fadeout", !fadeIn);
         element.classList.toggle("fadein", fadeIn);
         let finishedPromise;
         if (!immediate) {
           animation.playbackRate = fadeIn ? 1 : -1;
           animation.play();
@@ -1302,44 +1299,25 @@ this.VideoControlsImplPageWidget = class
 
         if (this.isVideoInFullScreen) {
           this.fullscreenButton.setAttribute("fullscreened", "true");
         } else {
           this.fullscreenButton.removeAttribute("fullscreened");
         }
       },
 
-      // XXX This should be the place where we update the control states and
-      // screen orientation upon entering/leaving fullscreen.
-      // Sadly because of bug 718107 as soon as this function exits
-      // the attached binding gets destructored and a new binding is then created.
-      // We therefore don't do anything here and leave it to the new binding to
-      // set state correctly from its constructor.
-      /*
       onFullscreenChange() {
-        // Constructor and destructor will lock/unlock the orientation exactly
-        // once. Doing so here again will cause the videocontrols to
-        // lock-unlock-lock the orientation when entering the fullscreen.
         this.updateOrientationState(this.isVideoInFullScreen);
 
-        // This is already broken by bug 718107 (controls will be hidden
-        // as soon as the video enters fullscreen).
-        // We can think about restoring the behavior here once the bug is
-        // fixed, or we could simply acknowledge the current behavior
-        // after-the-fact and try not to fix this.
         if (this.isVideoInFullScreen) {
-          this._hideControlsTimeout =
-            this.window.setTimeout(() => this._hideControlsFn(), this.HIDE_CONTROLS_TIMEOUT_MS);
+          this.startFadeOut(this.controlBar, true);
         }
 
-        // Constructor will handle this correctly on the new DOM content in
-        // the new binding.
         this.setFullscreenButtonState();
       },
-      */
 
       updateOrientationState(lock) {
         if (!this.video.mozOrientationLockEnabled) {
           return;
         }
         if (lock) {
           if (this.video.mozIsOrientationLocked) {
             return;
@@ -1945,18 +1923,17 @@ this.VideoControlsImplPageWidget = class
           // the control bar, instead of playing the video or toggle fullscreen.
           { el: this.controlsSpacer, type: "click", nonTouchOnly: true },
           { el: this.controlsSpacer, type: "dblclick", nonTouchOnly: true },
 
           { el: this.textTrackList, type: "click" },
 
           { el: this.videocontrols, type: "resizevideocontrols" },
 
-          // See comment at onFullscreenChange on bug 718107.
-          // { el: this.document, type: "fullscreenchange" },
+          { el: this.document, type: "fullscreenchange" },
           { el: this.video, type: "keypress", capture: true },
 
           // Prevent any click event within media controls from dispatching through to video.
           { el: this.videocontrols, type: "click", mozSystemGroup: false },
 
           // prevent dragging of controls image (bug 517114)
           { el: this.videocontrols, type: "dragstart" },