Refactor script that updates fullscreen buttons.
authoradachan@apple.com <adachan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 24 Feb 2016 00:30:48 +0000 (00:30 +0000)
committeradachan@apple.com <adachan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 24 Feb 2016 00:30:48 +0000 (00:30 +0000)
https://bugs.webkit.org/show_bug.cgi?id=154562

Reviewed by Dean Jackson.

Also expose extra property and element in getCurrentControlsStatus() for future testing.

* Modules/mediacontrols/mediaControlsApple.js:
(Controller.prototype.updatePictureInPictureButton):
(Controller.prototype.updateFullscreenButtons):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@197005 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/Modules/mediacontrols/mediaControlsApple.js

index dcc9ae6..4d496bc 100644 (file)
@@ -1,3 +1,16 @@
+2016-02-22  Ada Chan  <adachan@apple.com>
+
+        Refactor script that updates fullscreen buttons.
+        https://bugs.webkit.org/show_bug.cgi?id=154562
+
+        Reviewed by Dean Jackson.
+
+        Also expose extra property and element in getCurrentControlsStatus() for future testing.
+
+        * Modules/mediacontrols/mediaControlsApple.js:
+        (Controller.prototype.updatePictureInPictureButton):
+        (Controller.prototype.updateFullscreenButtons):
+
 2016-02-22  Ryosuke Niwa  <rniwa@webkit.org>
 
         Calling importNode on shadow root causes a crash
index 1885c38..43cfebc 100644 (file)
@@ -818,9 +818,14 @@ Controller.prototype = {
 
     updatePictureInPictureButton: function()
     {
-        var shouldShowPictureInPictureButton = Controller.gSimulatePictureInPictureAvailable || ('webkitSupportsPresentationMode' in this.video && this.video.webkitSupportsPresentationMode('picture-in-picture'));
+        var shouldShowPictureInPictureButton = (Controller.gSimulatePictureInPictureAvailable || ('webkitSupportsPresentationMode' in this.video && this.video.webkitSupportsPresentationMode('picture-in-picture'))) && this.hasVideo();
         if (shouldShowPictureInPictureButton) {
-            this.controls.panel.appendChild(this.controls.pictureInPictureButton);
+            if (!this.controls.pictureInPictureButton.parentElement) {
+                if (this.controls.fullscreenButton.parentElement == this.controls.panel)
+                    this.controls.panel.insertBefore(this.controls.pictureInPictureButton, this.controls.fullscreenButton);
+                else
+                    this.controls.panel.appendChild(this.controls.pictureInPictureButton);
+            }
             this.controls.pictureInPictureButton.classList.remove(this.ClassNames.hidden);
         } else
             this.controls.pictureInPictureButton.classList.add(this.ClassNames.hidden);
@@ -1138,7 +1143,7 @@ Controller.prototype = {
     {
         var shouldBeHidden = !this.video.webkitSupportsFullscreen || !this.hasVideo();
         this.controls.fullscreenButton.classList.toggle(this.ClassNames.hidden, shouldBeHidden && !this.isFullScreen());
-        this.controls.pictureInPictureButton.classList.toggle(this.ClassNames.hidden, shouldBeHidden);
+        this.updatePictureInPictureButton();
         this.setNeedsUpdateForDisplayedWidth();
         this.updateLayoutForDisplayedWidth();
     },
@@ -2248,12 +2253,17 @@ Controller.prototype = {
             },
             {
                 name: "Picture-in-picture Button",
-                object: this.controls.pictureInPictureButton
+                object: this.controls.pictureInPictureButton,
+                extraProperties: ["parentElement"],
             },
             {
                 name: "Track Menu",
                 object: this.captionMenu
             },
+            {
+                name: "Inline playback placeholder",
+                object: this.controls.inlinePlaybackPlaceholder,
+            },
         ];
 
         elements.forEach(function (element) {