Title: [208271] trunk
Revision
208271
Author
[email protected]
Date
2016-11-02 00:58:42 -0700 (Wed, 02 Nov 2016)

Log Message

[Modern Media Controls] Media Controller: PiP support
https://bugs.webkit.org/show_bug.cgi?id=163730
<rdar://problem/27989485>

Patch by Antoine Quint <[email protected]> on 2016-11-02
Reviewed by Dean Jackson.

Source/WebCore:

We introduce the PiPSupport class which brings support for entering picture-in-picture
by clicking on the PiP button in the media controls and enabling the button only when
picture-in-picture mode is available.

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

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

LayoutTests:

Adding new picture-in-picture tests.

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

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (208270 => 208271)


--- trunk/LayoutTests/ChangeLog	2016-11-02 02:38:56 UTC (rev 208270)
+++ trunk/LayoutTests/ChangeLog	2016-11-02 07:58:42 UTC (rev 208271)
@@ -1,3 +1,20 @@
+2016-11-02  Antoine Quint  <[email protected]>
+
+        [Modern Media Controls] Media Controller: PiP support
+        https://bugs.webkit.org/show_bug.cgi?id=163730
+        <rdar://problem/27989485>
+
+        Reviewed by Dean Jackson.
+
+        Adding new picture-in-picture tests.
+
+        * media/modern-media-controls/pip-support/pip-support-click-expected.txt: Added.
+        * media/modern-media-controls/pip-support/pip-support-click.html: Added.
+        * media/modern-media-controls/pip-support/pip-support-enabled-expected.txt: Added.
+        * media/modern-media-controls/pip-support/pip-support-enabled.html: Added.
+        * platform/ios-simulator/TestExpectations:
+        * platform/mac/TestExpectations:
+
 2016-11-01  Brady Eidson  <[email protected]>
 
         IndexedDB 2.0: Support IDBIndex getAll/getAllKeys.

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


--- trunk/LayoutTests/media/modern-media-controls/pip-support/pip-support-click-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/media/modern-media-controls/pip-support/pip-support-click-expected.txt	2016-11-02 07:58:42 UTC (rev 208271)
@@ -0,0 +1,10 @@
+Testing the PiPSupport behavior when clicking the PiP button.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS media.webkitPresentationMode is "picture-in-picture"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

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


--- trunk/LayoutTests/media/modern-media-controls/pip-support/pip-support-click.html	                        (rev 0)
+++ trunk/LayoutTests/media/modern-media-controls/pip-support/pip-support-click.html	2016-11-02 07:58:42 UTC (rev 208271)
@@ -0,0 +1,58 @@
+<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>PiPSupport</code> behavior when clicking the PiP button.");
+
+iconService.directoryPath = "../../../../Source/WebCore/Modules/modern-media-controls/images";
+
+if (window.internals)
+    window.internals.settings.setAllowsPictureInPictureMediaPlayback(true);
+
+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.pipButton.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("webkitpresentationmodechanged", () => {
+    shouldBeEqualToString("media.webkitPresentationMode", "picture-in-picture");
+    container.remove();
+    media.remove();
+    finishJSTest();
+});
+
+</script>
+<script src=""
+</body>

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


--- trunk/LayoutTests/media/modern-media-controls/pip-support/pip-support-enabled-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/media/modern-media-controls/pip-support/pip-support-enabled-expected.txt	2016-11-02 07:58:42 UTC (rev 208271)
@@ -0,0 +1,12 @@
+Testing the PipSupport behavior.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS mediaController.controls.pipButton.enabled is true
+PASS mediaController.controls.pipButton.enabled is false
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

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


--- trunk/LayoutTests/media/modern-media-controls/pip-support/pip-support-enabled.html	                        (rev 0)
+++ trunk/LayoutTests/media/modern-media-controls/pip-support/pip-support-enabled.html	2016-11-02 07:58:42 UTC (rev 208271)
@@ -0,0 +1,50 @@
+<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>PipSupport</code> behavior.");
+
+iconService.directoryPath = "../../../../Source/WebCore/Modules/modern-media-controls/images";
+
+if (window.internals)
+    window.internals.settings.setAllowsPictureInPictureMediaPlayback(true);
+
+const container = document.querySelector("div#host");
+const media = document.querySelector("video");
+const mediaController = createControls(container, media, null);
+
+media.addEventListener("loadedmetadata", () => {
+    shouldBeTrue("mediaController.controls.pipButton.enabled");
+    media.src = ""
+});
+
+media.addEventListener("error", () => {
+    shouldBeFalse("mediaController.controls.pipButton.enabled");
+    debug("");
+    container.remove();
+    media.remove();
+    finishJSTest();
+});
+
+</script>
+<script src=""
+</body>

Modified: trunk/LayoutTests/platform/ios-simulator/TestExpectations (208270 => 208271)


--- trunk/LayoutTests/platform/ios-simulator/TestExpectations	2016-11-02 02:38:56 UTC (rev 208270)
+++ trunk/LayoutTests/platform/ios-simulator/TestExpectations	2016-11-02 07:58:42 UTC (rev 208271)
@@ -2743,5 +2743,6 @@
 fast/layers/prevent-hit-test-during-layout.html [ Skip ]
 
 # Internal APIs to test PiP and AirPlay are not available on iOS.
+media/modern-media-controls/airplay-support/airplay-support.html [ Skip ]
+media/modern-media-controls/pip-support [ Skip ]
 media/modern-media-controls/placard-support [ Skip ]
-media/modern-media-controls/airplay-support/airplay-support.html [ Skip ]

Modified: trunk/LayoutTests/platform/mac/TestExpectations (208270 => 208271)


--- trunk/LayoutTests/platform/mac/TestExpectations	2016-11-02 02:38:56 UTC (rev 208270)
+++ trunk/LayoutTests/platform/mac/TestExpectations	2016-11-02 07:58:42 UTC (rev 208271)
@@ -1452,7 +1452,8 @@
 webkit.org/b/164088 [ Yosemite ] media/modern-media-controls/scrubber-support/scrubber-support-drag.html [ Skip ]
 
 # Internal APIs to test PiP and AirPlay are not available on Yosemite.
+[ Yosemite ] media/modern-media-controls/airplay-support/airplay-support.html [ Skip ]
+[ Yosemite ] media/modern-media-controls/pip-support [ Skip ]
 [ Yosemite ] media/modern-media-controls/placard-support [ Skip ]
-[ Yosemite ] media/modern-media-controls/airplay-support/airplay-support.html [ Skip ]
 
 webkit.org/b/164277 fast/preloader/image-srcset.html [ Pass Failure ]
\ No newline at end of file

Modified: trunk/Source/WebCore/ChangeLog (208270 => 208271)


--- trunk/Source/WebCore/ChangeLog	2016-11-02 02:38:56 UTC (rev 208270)
+++ trunk/Source/WebCore/ChangeLog	2016-11-02 07:58:42 UTC (rev 208271)
@@ -1,3 +1,29 @@
+2016-11-02  Antoine Quint  <[email protected]>
+
+        [Modern Media Controls] Media Controller: PiP support
+        https://bugs.webkit.org/show_bug.cgi?id=163730
+        <rdar://problem/27989485>
+
+        Reviewed by Dean Jackson.
+
+        We introduce the PiPSupport class which brings support for entering picture-in-picture
+        by clicking on the PiP button in the media controls and enabling the button only when
+        picture-in-picture mode is available.
+
+        Tests: media/modern-media-controls/pip-support/pip-support-click.html
+               media/modern-media-controls/pip-support/pip-support-enabled.html
+
+        * Modules/modern-media-controls/js-files:
+        * Modules/modern-media-controls/media/media-controller.js:
+        (MediaController):
+        * Modules/modern-media-controls/media/pip-support.js: Added.
+        (PiPSupport.prototype.get control):
+        (PiPSupport.prototype.get mediaEvents):
+        (PiPSupport.prototype.buttonWasClicked):
+        (PiPSupport.prototype.syncControl):
+        (PiPSupport):
+        * WebCore.xcodeproj/project.pbxproj:
+
 2016-11-01  Dave Hyatt  <[email protected]>
 
         [CSS Parser] Support the shadow DOM

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


--- trunk/Source/WebCore/Modules/modern-media-controls/js-files	2016-11-02 02:38:56 UTC (rev 208270)
+++ trunk/Source/WebCore/Modules/modern-media-controls/js-files	2016-11-02 07:58:42 UTC (rev 208271)
@@ -31,6 +31,7 @@
 media/airplay-support.js
 media/elapsed-time-support.js
 media/mute-support.js
+media/pip-support.js
 media/placard-support.js
 media/playback-support.js
 media/remaining-time-support.js

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


--- trunk/Source/WebCore/Modules/modern-media-controls/media/media-controller.js	2016-11-02 02:38:56 UTC (rev 208270)
+++ trunk/Source/WebCore/Modules/modern-media-controls/media/media-controller.js	2016-11-02 07:58:42 UTC (rev 208271)
@@ -41,6 +41,7 @@
         new AirplaySupport(this);
         new ElapsedTimeSupport(this);
         new MuteSupport(this);
+        new PiPSupport(this);
         new PlacardSupport(this);
         new PlaybackSupport(this);
         new RemainingTimeSupport(this);

Copied: trunk/Source/WebCore/Modules/modern-media-controls/media/pip-support.js (from rev 208270, trunk/Source/WebCore/Modules/modern-media-controls/media/media-controller.js) (0 => 208271)


--- trunk/Source/WebCore/Modules/modern-media-controls/media/pip-support.js	                        (rev 0)
+++ trunk/Source/WebCore/Modules/modern-media-controls/media/pip-support.js	2016-11-02 07:58:42 UTC (rev 208271)
@@ -0,0 +1,56 @@
+/*
+ * 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.
+ */
+
+const PiPMode = "picture-in-picture";
+const InlineMode = "inline";
+
+class PiPSupport extends MediaControllerSupport
+{
+
+    // Protected
+
+    get control()
+    {
+        return this.mediaController.controls.pipButton;
+    }
+
+    get mediaEvents()
+    {
+        return ["loadedmetadata", "error", "webkitpresentationmodechanged", "webkitcurrentplaybacktargetiswirelesschanged"];
+    }
+
+    buttonWasClicked(control)
+    {
+        const media = this.mediaController.media;
+        media.webkitSetPresentationMode(media.webkitPresentationMode === PiPMode ? InlineMode : PiPMode);
+    }
+
+    syncControl()
+    {
+        const media = this.mediaController.media;
+        this.control.enabled = media instanceof HTMLVideoElement && media.webkitSupportsPresentationMode && media.webkitSupportsPresentationMode(PiPMode) && !media.webkitCurrentPlaybackTargetIsWireless;
+    }
+
+}

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (208270 => 208271)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2016-11-02 02:38:56 UTC (rev 208270)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2016-11-02 07:58:42 UTC (rev 208271)
@@ -7446,8 +7446,8 @@
 		0F87166E1C869D83004FF0DE /* LengthPoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LengthPoint.h; sourceTree = "<group>"; };
 		0F8B456F1DC3FB1000443C3F /* IntersectionObserverCallback.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = IntersectionObserverCallback.idl; sourceTree = "<group>"; };
 		0F8B45711DC3FBA300443C3F /* IntersectionObserverCallback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IntersectionObserverCallback.h; sourceTree = "<group>"; };
-		0F8B45731DC41DBA00443C3F /* JSIntersectionObserverCallback.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = JSIntersectionObserverCallback.cpp; path = JSIntersectionObserverCallback.cpp; sourceTree = "<group>"; };
-		0F8B45741DC41DBA00443C3F /* JSIntersectionObserverCallback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = JSIntersectionObserverCallback.h; path = JSIntersectionObserverCallback.h; sourceTree = "<group>"; };
+		0F8B45731DC41DBA00443C3F /* JSIntersectionObserverCallback.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSIntersectionObserverCallback.cpp; sourceTree = "<group>"; };
+		0F8B45741DC41DBA00443C3F /* JSIntersectionObserverCallback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSIntersectionObserverCallback.h; sourceTree = "<group>"; };
 		0F97A657155DA81E00FADD4C /* DisplayRefreshMonitorIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DisplayRefreshMonitorIOS.mm; sourceTree = "<group>"; };
 		0FA24D77162DF91900A3F4C0 /* GraphicsLayerUpdater.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GraphicsLayerUpdater.cpp; sourceTree = "<group>"; };
 		0FA24D78162DF91900A3F4C0 /* GraphicsLayerUpdater.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GraphicsLayerUpdater.h; sourceTree = "<group>"; };
@@ -9863,6 +9863,7 @@
 		7118FED215685CC60030B79A /* JSSVGViewSpec.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSSVGViewSpec.cpp; sourceTree = "<group>"; };
 		7118FED315685CC60030B79A /* JSSVGViewSpec.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSSVGViewSpec.h; sourceTree = "<group>"; };
 		711FB0751DC7688F00C4C708 /* placard-support.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode._javascript_; path = "placard-support.js"; sourceTree = "<group>"; };
+		7130141D1DC9C08600CA3A88 /* pip-support.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode._javascript_; path = "pip-support.js"; sourceTree = "<group>"; };
 		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>"; };
@@ -17875,6 +17876,7 @@
 				7177E2461DB80D2F00919A0B /* media-controller-support.js */,
 				71D02D921DB55C4E00DD5CF5 /* media-controller.js */,
 				7177E2471DB80D2F00919A0B /* mute-support.js */,
+				7130141D1DC9C08600CA3A88 /* pip-support.js */,
 				711FB0751DC7688F00C4C708 /* placard-support.js */,
 				71004B9D1DC1398800A52A38 /* playback-support.js */,
 				71004B9B1DC1109300A52A38 /* remaining-time-support.js */,
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to