Title: [208274] trunk
Revision
208274
Author
commit-qu...@webkit.org
Date
2016-11-02 03:47:44 -0700 (Wed, 02 Nov 2016)

Log Message

[Modern Media Controls] Media Controller: fullscreen toggle support
https://bugs.webkit.org/show_bug.cgi?id=163728
<rdar://problem/27989486>

Patch by Antoine Quint <grao...@apple.com> on 2016-11-02
Reviewed by Darin Adler.

Source/WebCore:

We introduce the FullscreenSupport class which brings support for entering and
exiting fullscreen by clicking on the fullscreen button in the media controls
and correctly reflecting the media's fullscreen state should it be changed
via the media API.

Tests: media/modern-media-controls/fullscreen-support/fullscreen-support-click.html
       media/modern-media-controls/fullscreen-support/fullscreen-support-enabled.html

* Modules/modern-media-controls/js-files:
* Modules/modern-media-controls/media/fullscreen-support.js: Added.
(FullscreenSupport):
(FullscreenSupport.prototype.get control):
(FullscreenSupport.prototype.get mediaEvents):
(FullscreenSupport.prototype.buttonWasClicked):
(FullscreenSupport.prototype.syncControl):
* Modules/modern-media-controls/media/media-controller.js:
(MediaController):
* WebCore.xcodeproj/project.pbxproj:

LayoutTests:

Adding new tests to check that clicking on the fullscreen button enters fullscreen and
that the fullscreen button is enabled when fullscreen is supported.

* media/modern-media-controls/fullscreen-support/fullscreen-support-click-expected.txt: Added.
* media/modern-media-controls/fullscreen-support/fullscreen-support-click.html: Added.
* media/modern-media-controls/fullscreen-support/fullscreen-support-enabled-expected.txt: Added.
* media/modern-media-controls/fullscreen-support/fullscreen-support-enabled.html: Added.
* platform/ios-simulator/TestExpectations:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (208273 => 208274)


--- trunk/LayoutTests/ChangeLog	2016-11-02 09:48:56 UTC (rev 208273)
+++ trunk/LayoutTests/ChangeLog	2016-11-02 10:47:44 UTC (rev 208274)
@@ -1,5 +1,22 @@
 2016-11-02  Antoine Quint  <grao...@apple.com>
 
+        [Modern Media Controls] Media Controller: fullscreen toggle support
+        https://bugs.webkit.org/show_bug.cgi?id=163728
+        <rdar://problem/27989486>
+
+        Reviewed by Darin Adler.
+
+        Adding new tests to check that clicking on the fullscreen button enters fullscreen and
+        that the fullscreen button is enabled when fullscreen is supported.
+
+        * media/modern-media-controls/fullscreen-support/fullscreen-support-click-expected.txt: Added.
+        * media/modern-media-controls/fullscreen-support/fullscreen-support-click.html: Added.
+        * media/modern-media-controls/fullscreen-support/fullscreen-support-enabled-expected.txt: Added.
+        * media/modern-media-controls/fullscreen-support/fullscreen-support-enabled.html: Added.
+        * platform/ios-simulator/TestExpectations:
+
+2016-11-02  Antoine Quint  <grao...@apple.com>
+
         [Modern Media Controls] Media Controller: PiP support
         https://bugs.webkit.org/show_bug.cgi?id=163730
         <rdar://problem/27989485>

Added: trunk/LayoutTests/media/modern-media-controls/fullscreen-support/fullscreen-support-click-expected.txt (0 => 208274)


--- trunk/LayoutTests/media/modern-media-controls/fullscreen-support/fullscreen-support-click-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/media/modern-media-controls/fullscreen-support/fullscreen-support-click-expected.txt	2016-11-02 10:47:44 UTC (rev 208274)
@@ -0,0 +1,10 @@
+Testing the FullscreenSupport behavior when clicking the fullscreen button.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS media.webkitDisplayingFullscreen is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/media/modern-media-controls/fullscreen-support/fullscreen-support-click.html (0 => 208274)


--- trunk/LayoutTests/media/modern-media-controls/fullscreen-support/fullscreen-support-click.html	                        (rev 0)
+++ trunk/LayoutTests/media/modern-media-controls/fullscreen-support/fullscreen-support-click.html	2016-11-02 10:47:44 UTC (rev 208274)
@@ -0,0 +1,53 @@
+<script src=""
+<script src="" type="text/_javascript_"></script>
+<body>
+<style type="text/css" media="screen">
+    
+    video, #host {
+        position: absolute;
+        top: 0;
+        left: 0;
+    }
+
+    video {
+        width: 800px;
+        height: 240px;
+    }
+    
+</style>
+<video src="" autoplay></video>
+<div id="host"></div>
+<script type="text/_javascript_">
+
+window.jsTestIsAsync = true;
+
+description("Testing the <code>FullscreenSupport</code> behavior when clicking the fullscreen button.");
+
+const container = document.querySelector("div#host");
+const media = document.querySelector("video");
+const mediaController = createControls(container, media, null);
+
+scheduler.frameDidFire = function() {
+    if (media.paused)
+        return;
+
+    const input = mediaController.controls.fullscreenButton.element;
+    const bounds = input.getBoundingClientRect();
+    const centerX = bounds.left + bounds.width / 2;
+    const centerY = bounds.top + bounds.height / 2;
+
+    eventSender.mouseMoveTo(centerX, centerY);
+    eventSender.mouseDown();
+    eventSender.mouseUp();
+};
+
+media.addEventListener("webkitfullscreenchange", () => {
+    shouldBeTrue("media.webkitDisplayingFullscreen");
+    container.remove();
+    media.remove();
+    finishJSTest();
+});
+
+</script>
+<script src=""
+</body>

Added: trunk/LayoutTests/media/modern-media-controls/fullscreen-support/fullscreen-support-enabled-expected.txt (0 => 208274)


--- trunk/LayoutTests/media/modern-media-controls/fullscreen-support/fullscreen-support-enabled-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/media/modern-media-controls/fullscreen-support/fullscreen-support-enabled-expected.txt	2016-11-02 10:47:44 UTC (rev 208274)
@@ -0,0 +1,12 @@
+Testing the FullscreenSupport behavior.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS mediaController.controls.fullscreenButton.enabled is true
+PASS mediaController.controls.fullscreenButton.enabled is false
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/media/modern-media-controls/fullscreen-support/fullscreen-support-enabled.html (0 => 208274)


--- trunk/LayoutTests/media/modern-media-controls/fullscreen-support/fullscreen-support-enabled.html	                        (rev 0)
+++ trunk/LayoutTests/media/modern-media-controls/fullscreen-support/fullscreen-support-enabled.html	2016-11-02 10:47:44 UTC (rev 208274)
@@ -0,0 +1,45 @@
+<script src=""
+<script src="" type="text/_javascript_"></script>
+<body>
+<style type="text/css" media="screen">
+    
+    video, #host {
+        position: absolute;
+        top: 0;
+        left: 0;
+    }
+
+    video {
+        width: 800px;
+        height: 240px;
+    }
+    
+</style>
+<video src=""
+<div id="host"></div>
+<script type="text/_javascript_">
+
+window.jsTestIsAsync = true;
+
+description("Testing the <code>FullscreenSupport</code> behavior.");
+
+const container = document.querySelector("div#host");
+const media = document.querySelector("video");
+const mediaController = createControls(container, media, null);
+
+media.addEventListener("loadedmetadata", () => {
+    shouldBeTrue("mediaController.controls.fullscreenButton.enabled");
+    media.src = ""
+});
+
+media.addEventListener("error", () => {
+    shouldBeFalse("mediaController.controls.fullscreenButton.enabled");
+    debug("");
+    container.remove();
+    media.remove();
+    finishJSTest();
+});
+
+</script>
+<script src=""
+</body>

Modified: trunk/LayoutTests/platform/ios-simulator/TestExpectations (208273 => 208274)


--- trunk/LayoutTests/platform/ios-simulator/TestExpectations	2016-11-02 09:48:56 UTC (rev 208273)
+++ trunk/LayoutTests/platform/ios-simulator/TestExpectations	2016-11-02 10:47:44 UTC (rev 208274)
@@ -2709,6 +2709,7 @@
 webkit.org/b/164160 media/modern-media-controls/volume-support/volume-support-click.html [ Skip ]
 webkit.org/b/164160 media/modern-media-controls/volume-support/volume-support-drag.html [ Skip ]
 webkit.org/b/164250 media/modern-media-controls/volume-support/volume-support-media-api.html [ Skip ]
+webkit.org/b/164314 media/modern-media-controls/fullscreen-support/fullscreen-support-click.html [ Skip ]
 
 # This variation font test requires Skia which isn't available on iOS.
 webkit.org/b/163093 fast/text/variations/advances.html [ Failure ]

Modified: trunk/Source/WebCore/ChangeLog (208273 => 208274)


--- trunk/Source/WebCore/ChangeLog	2016-11-02 09:48:56 UTC (rev 208273)
+++ trunk/Source/WebCore/ChangeLog	2016-11-02 10:47:44 UTC (rev 208274)
@@ -1,5 +1,32 @@
 2016-11-02  Antoine Quint  <grao...@apple.com>
 
+        [Modern Media Controls] Media Controller: fullscreen toggle support
+        https://bugs.webkit.org/show_bug.cgi?id=163728
+        <rdar://problem/27989486>
+
+        Reviewed by Darin Adler.
+
+        We introduce the FullscreenSupport class which brings support for entering and
+        exiting fullscreen by clicking on the fullscreen button in the media controls
+        and correctly reflecting the media's fullscreen state should it be changed
+        via the media API.
+
+        Tests: media/modern-media-controls/fullscreen-support/fullscreen-support-click.html
+               media/modern-media-controls/fullscreen-support/fullscreen-support-enabled.html
+
+        * Modules/modern-media-controls/js-files:
+        * Modules/modern-media-controls/media/fullscreen-support.js: Added.
+        (FullscreenSupport):
+        (FullscreenSupport.prototype.get control):
+        (FullscreenSupport.prototype.get mediaEvents):
+        (FullscreenSupport.prototype.buttonWasClicked):
+        (FullscreenSupport.prototype.syncControl):
+        * Modules/modern-media-controls/media/media-controller.js:
+        (MediaController):
+        * WebCore.xcodeproj/project.pbxproj:
+
+2016-11-02  Antoine Quint  <grao...@apple.com>
+
         [Modern Media Controls] Media Controller: PiP support
         https://bugs.webkit.org/show_bug.cgi?id=163730
         <rdar://problem/27989485>

Modified: trunk/Source/WebCore/Modules/modern-media-controls/js-files (208273 => 208274)


--- trunk/Source/WebCore/Modules/modern-media-controls/js-files	2016-11-02 09:48:56 UTC (rev 208273)
+++ trunk/Source/WebCore/Modules/modern-media-controls/js-files	2016-11-02 10:47:44 UTC (rev 208274)
@@ -30,6 +30,7 @@
 media/media-controller-support.js
 media/airplay-support.js
 media/elapsed-time-support.js
+media/fullscreen-support.js
 media/mute-support.js
 media/pip-support.js
 media/placard-support.js

Copied: trunk/Source/WebCore/Modules/modern-media-controls/media/fullscreen-support.js (from rev 208273, trunk/Source/WebCore/Modules/modern-media-controls/media/media-controller.js) (0 => 208274)


--- trunk/Source/WebCore/Modules/modern-media-controls/media/fullscreen-support.js	                        (rev 0)
+++ trunk/Source/WebCore/Modules/modern-media-controls/media/fullscreen-support.js	2016-11-02 10:47:44 UTC (rev 208274)
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2016 Apple Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+class FullscreenSupport extends MediaControllerSupport
+{
+
+    constructor(mediaController)
+    {
+        super(mediaController);
+
+        const videoTracks = mediaController.media.videoTracks;
+        for (let eventType of ["change", "addtrack", "removetrack"])
+            videoTracks.addEventListener(eventType, this);
+    }
+
+    // Protected
+
+    get control()
+    {
+        return this.mediaController.controls.fullscreenButton;
+    }
+
+    get mediaEvents()
+    {
+        return ["loadedmetadata", "error"];
+    }
+
+    buttonWasClicked(control)
+    {
+        const media = this.mediaController.media;
+        if (media.webkitDisplayingFullscreen)
+            media.webkitExitFullscreen();
+        else
+            media.webkitEnterFullscreen();
+    }
+
+    syncControl()
+    {
+        const control = this.control;
+        const media = this.mediaController.media;
+        control.enabled = media.webkitSupportsFullscreen;
+        control.isFullScreen = media.webkitDisplayingFullscreen;
+    }
+
+}

Modified: trunk/Source/WebCore/Modules/modern-media-controls/media/media-controller.js (208273 => 208274)


--- trunk/Source/WebCore/Modules/modern-media-controls/media/media-controller.js	2016-11-02 09:48:56 UTC (rev 208273)
+++ trunk/Source/WebCore/Modules/modern-media-controls/media/media-controller.js	2016-11-02 10:47:44 UTC (rev 208274)
@@ -40,6 +40,7 @@
 
         new AirplaySupport(this);
         new ElapsedTimeSupport(this);
+        new FullscreenSupport(this);
         new MuteSupport(this);
         new PiPSupport(this);
         new PlacardSupport(this);

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (208273 => 208274)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2016-11-02 09:48:56 UTC (rev 208273)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2016-11-02 10:47:44 UTC (rev 208274)
@@ -9867,6 +9867,8 @@
 		7134496B146941B300720312 /* SVGLengthContext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGLengthContext.cpp; sourceTree = "<group>"; };
 		7134496C146941B300720312 /* SVGLengthContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGLengthContext.h; sourceTree = "<group>"; };
 		713E70AF1733E8B300A22D00 /* plugIns.js */ = {isa = PBXFileReference; lastKnownFileType = sourcecode._javascript_; path = plugIns.js; sourceTree = "<group>"; };
+		714131471DC9D6AF00336107 /* fullscreen-support.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode._javascript_; path = "fullscreen-support.js"; sourceTree = "<group>"; };
+		714131481DC9D6EF00336107 /* js-files */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "js-files"; sourceTree = "<group>"; };
 		715379FE146BD9D6008BD615 /* SVGPathData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGPathData.cpp; sourceTree = "<group>"; };
 		715379FF146BD9D6008BD615 /* SVGPathData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGPathData.h; sourceTree = "<group>"; };
 		7157E3D11DC1EE4B0094550E /* scrubbing-support.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode._javascript_; path = "scrubbing-support.js"; sourceTree = "<group>"; };
@@ -17873,6 +17875,7 @@
 			children = (
 				717F90581DC4BB600006F520 /* airplay-support.js */,
 				71004B9A1DC1109300A52A38 /* elapsed-time-support.js */,
+				714131471DC9D6AF00336107 /* fullscreen-support.js */,
 				7177E2461DB80D2F00919A0B /* media-controller-support.js */,
 				71D02D921DB55C4E00DD5CF5 /* media-controller.js */,
 				7177E2471DB80D2F00919A0B /* mute-support.js */,
@@ -17891,10 +17894,11 @@
 		71D6AA391DA4EAF700B23969 /* modern-media-controls */ = {
 			isa = PBXGroup;
 			children = (
+				714131481DC9D6EF00336107 /* js-files */,
+				71D02D901DB55C4E00DD5CF5 /* main.js */,
 				716FA0D71DB26591007323CC /* controls */,
 				71D6AA6F1DA4EAF700B23969 /* images */,
 				71D02D911DB55C4E00DD5CF5 /* media */,
-				71D02D901DB55C4E00DD5CF5 /* main.js */,
 			);
 			path = "modern-media-controls";
 			sourceTree = "<group>";
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to