[Modern Media Controls] Media Controller: click-to-start support
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 19 Oct 2016 19:04:35 +0000 (19:04 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 19 Oct 2016 19:04:35 +0000 (19:04 +0000)
https://bugs.webkit.org/show_bug.cgi?id=163659
<rdar://problem/28845656>

Patch by Antoine Quint <graouts@apple.com> on 2016-10-19
Reviewed by Dean Jackson.

Source/WebCore:

We introduce the MediaControllerSupport class which will allow a number of media controller
features to be implemented by subclasses each devoted to implementing a specific subset of
media controller features. With this bug, we add the correct behavior for click-to-start,
only showing the start button under the right circumstances.

A MediaController object indicates which media control to attach click event listeners to
through the `control` property, and a list of media events it should register on the media
element through the `mediaEvents` property. Then, as the user interacts with the specified
control and the media, the Button delegation method `buttonWasClicked()` and the `syncControl()`
methods are called to allow for the media state to be correctly set and represented in the
media controls. Custom event handling for the specified events can also be achieved by
subclassing the `handleEvent()` method.

Tests: media/modern-media-controls/start-support/start-support-audio.html
       media/modern-media-controls/start-support/start-support-autoplay.html
       media/modern-media-controls/start-support/start-support-click-to-start.html
       media/modern-media-controls/start-support/start-support-error.html
       media/modern-media-controls/start-support/start-support-fullscreen.html
       media/modern-media-controls/start-support/start-support-manual-play.html
       media/modern-media-controls/start-support/start-support-no-source.html

* Modules/modern-media-controls/media/media-controller-support.js: Added.
(MediaControllerSupport):
(MediaControllerSupport.prototype.get control):
(MediaControllerSupport.prototype.get mediaEvents):
(MediaControllerSupport.prototype.buttonWasClicked):
(MediaControllerSupport.prototype.handleEvent):
(MediaControllerSupport.prototype.syncControl):
* Modules/modern-media-controls/media/media-controller.js:
(MediaController):
(MediaController.prototype.buttonWasClicked): Deleted.
* Modules/modern-media-controls/media/start-support.js: Added.
(StartSupport.prototype.get control):
(StartSupport.prototype.get mediaEvents):
(StartSupport.prototype.buttonWasClicked):
(StartSupport.prototype.handleEvent):
(StartSupport.prototype.syncControl):
(StartSupport.prototype._shouldShowStartButton):
(StartSupport):

LayoutTests:

New test coverage for the StartSupport class.

* media/modern-media-controls/media-controller/media-controller-constructor.html:
* media/modern-media-controls/media-controller/media-controller-resize.html:
* media/modern-media-controls/start-support/start-support-audio-expected.txt: Added.
* media/modern-media-controls/start-support/start-support-audio.html: Added.
* media/modern-media-controls/start-support/start-support-autoplay-expected.txt: Added.
* media/modern-media-controls/start-support/start-support-autoplay.html: Added.
* media/modern-media-controls/start-support/start-support-click-to-start-expected.txt: Renamed from LayoutTests/media/modern-media-controls/media-controller/media-controller-click-to-start-expected.txt.
* media/modern-media-controls/start-support/start-support-click-to-start.html: Renamed from LayoutTests/media/modern-media-controls/media-controller/media-controller-click-to-start.html.
* media/modern-media-controls/start-support/start-support-error-expected.txt: Added.
* media/modern-media-controls/start-support/start-support-error.html: Added.
* media/modern-media-controls/start-support/start-support-fullscreen-expected.txt: Added.
* media/modern-media-controls/start-support/start-support-fullscreen.html: Added.
* media/modern-media-controls/start-support/start-support-manual-play-expected.txt: Added.
* media/modern-media-controls/start-support/start-support-manual-play.html: Added.
* media/modern-media-controls/start-support/start-support-no-source-expected.txt: Added.
* media/modern-media-controls/start-support/start-support-no-source.html: Added.
* platform/ios-simulator/TestExpectations:

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

22 files changed:
LayoutTests/ChangeLog
LayoutTests/media/modern-media-controls/media-controller/media-controller-constructor.html
LayoutTests/media/modern-media-controls/media-controller/media-controller-resize.html
LayoutTests/media/modern-media-controls/start-support/start-support-audio-expected.txt [new file with mode: 0644]
LayoutTests/media/modern-media-controls/start-support/start-support-audio.html [new file with mode: 0644]
LayoutTests/media/modern-media-controls/start-support/start-support-autoplay-expected.txt [new file with mode: 0644]
LayoutTests/media/modern-media-controls/start-support/start-support-autoplay.html [moved from LayoutTests/media/modern-media-controls/media-controller/media-controller-click-to-start.html with 92% similarity]
LayoutTests/media/modern-media-controls/start-support/start-support-click-to-start-expected.txt [moved from LayoutTests/media/modern-media-controls/media-controller/media-controller-click-to-start-expected.txt with 100% similarity]
LayoutTests/media/modern-media-controls/start-support/start-support-click-to-start.html [new file with mode: 0644]
LayoutTests/media/modern-media-controls/start-support/start-support-error-expected.txt [new file with mode: 0644]
LayoutTests/media/modern-media-controls/start-support/start-support-error.html [new file with mode: 0644]
LayoutTests/media/modern-media-controls/start-support/start-support-fullscreen-expected.txt [new file with mode: 0644]
LayoutTests/media/modern-media-controls/start-support/start-support-fullscreen.html [new file with mode: 0644]
LayoutTests/media/modern-media-controls/start-support/start-support-manual-play-expected.txt [new file with mode: 0644]
LayoutTests/media/modern-media-controls/start-support/start-support-manual-play.html [new file with mode: 0644]
LayoutTests/media/modern-media-controls/start-support/start-support-no-source-expected.txt [new file with mode: 0644]
LayoutTests/media/modern-media-controls/start-support/start-support-no-source.html [new file with mode: 0644]
LayoutTests/platform/ios-simulator/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/Modules/modern-media-controls/media/media-controller-support.js [new file with mode: 0644]
Source/WebCore/Modules/modern-media-controls/media/media-controller.js
Source/WebCore/Modules/modern-media-controls/media/start-support.js [new file with mode: 0644]

index 8de350a..d6b0790 100644 (file)
@@ -1,3 +1,31 @@
+2016-10-19  Antoine Quint  <graouts@apple.com>
+
+        [Modern Media Controls] Media Controller: click-to-start support
+        https://bugs.webkit.org/show_bug.cgi?id=163659
+        <rdar://problem/28845656>
+
+        Reviewed by Dean Jackson.
+
+        New test coverage for the StartSupport class.
+
+        * media/modern-media-controls/media-controller/media-controller-constructor.html:
+        * media/modern-media-controls/media-controller/media-controller-resize.html:
+        * media/modern-media-controls/start-support/start-support-audio-expected.txt: Added.
+        * media/modern-media-controls/start-support/start-support-audio.html: Added.
+        * media/modern-media-controls/start-support/start-support-autoplay-expected.txt: Added.
+        * media/modern-media-controls/start-support/start-support-autoplay.html: Added.
+        * media/modern-media-controls/start-support/start-support-click-to-start-expected.txt: Renamed from LayoutTests/media/modern-media-controls/media-controller/media-controller-click-to-start-expected.txt.
+        * media/modern-media-controls/start-support/start-support-click-to-start.html: Renamed from LayoutTests/media/modern-media-controls/media-controller/media-controller-click-to-start.html.
+        * media/modern-media-controls/start-support/start-support-error-expected.txt: Added.
+        * media/modern-media-controls/start-support/start-support-error.html: Added.
+        * media/modern-media-controls/start-support/start-support-fullscreen-expected.txt: Added.
+        * media/modern-media-controls/start-support/start-support-fullscreen.html: Added.
+        * media/modern-media-controls/start-support/start-support-manual-play-expected.txt: Added.
+        * media/modern-media-controls/start-support/start-support-manual-play.html: Added.
+        * media/modern-media-controls/start-support/start-support-no-source-expected.txt: Added.
+        * media/modern-media-controls/start-support/start-support-no-source.html: Added.
+        * platform/ios-simulator/TestExpectations:
+
 2016-10-19  Aaron Chu  <aaron_chu@apple.com>
 
         Web Inspector: AXI: expose computed tree node and heading level
index 15f40c5..4a53339 100644 (file)
@@ -26,6 +26,8 @@
 <script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/macos-media-controls.js" type="text/javascript"></script>
 <script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/macos-inline-media-controls.js" type="text/javascript"></script>
 <script src="../../../../Source/WebCore/Modules/modern-media-controls/media/media-controller.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/media/media-controller-support.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/media/start-support.js" type="text/javascript"></script>
 <script src="../../../../Source/WebCore/Modules/modern-media-controls/main.js" type="text/javascript"></script>
 <body>
 <video src="../../content/test.mp4"></video>
index 7065642..486d2b7 100644 (file)
@@ -26,6 +26,8 @@
 <script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/macos-media-controls.js" type="text/javascript"></script>
 <script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/macos-inline-media-controls.js" type="text/javascript"></script>
 <script src="../../../../Source/WebCore/Modules/modern-media-controls/media/media-controller.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/media/media-controller-support.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/media/start-support.js" type="text/javascript"></script>
 <script src="../../../../Source/WebCore/Modules/modern-media-controls/main.js" type="text/javascript"></script>
 <body>
 <video src="../../content/test.mp4" style="width: 320px; height: 240px;"></video>
diff --git a/LayoutTests/media/modern-media-controls/start-support/start-support-audio-expected.txt b/LayoutTests/media/modern-media-controls/start-support/start-support-audio-expected.txt
new file mode 100644 (file)
index 0000000..d1f4e79
--- /dev/null
@@ -0,0 +1,10 @@
+Testing the StartSupport behavior with an audio element.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS mediaController.controls.showsStartButton is false
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/media/modern-media-controls/start-support/start-support-audio.html b/LayoutTests/media/modern-media-controls/start-support/start-support-audio.html
new file mode 100644 (file)
index 0000000..210cb88
--- /dev/null
@@ -0,0 +1,52 @@
+<script src="../../../resources/js-test-pre.js"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/scheduler.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/layout-node.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/layout-item.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/button.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/buttons-container.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/icon-service.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/start-button.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/icon-button.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/play-pause-button.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/skip-back-button.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/airplay-button.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/pip-button.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/fullscreen-button.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/mute-button.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/tracks-button.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/slider.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/volume-slider.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/scrubber.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/time-label.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/time-control.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/placard.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/airplay-placard.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/pip-placard.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/media-controls.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/macos-media-controls.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/macos-inline-media-controls.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/media/media-controller.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/media/media-controller-support.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/media/start-support.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/main.js" type="text/javascript"></script>
+<body>
+<audio src="../../content/test.mp4" style="width: 320px; height: 240px;"></audio>
+<div id="shadow"></div>
+<script type="text/javascript">
+
+description("Testing the <code>StartSupport</code> behavior with an audio element.");
+
+iconService.directoryPath = "../../../../Source/WebCore/Modules/modern-media-controls/images";
+
+const shadowRoot = document.querySelector("div#shadow").attachShadow({ mode: "open" });
+const media = document.querySelector("audio");
+const mediaController = createControls(shadowRoot, media, null);
+
+shouldBeFalse("mediaController.controls.showsStartButton");
+
+shadowRoot.host.remove();
+media.remove();
+
+</script>
+<script src="../../../resources/js-test-post.js"></script>
+</body>
diff --git a/LayoutTests/media/modern-media-controls/start-support/start-support-autoplay-expected.txt b/LayoutTests/media/modern-media-controls/start-support/start-support-autoplay-expected.txt
new file mode 100644 (file)
index 0000000..a781ba8
--- /dev/null
@@ -0,0 +1,12 @@
+Testing the StartSupport behavior with autoplay.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Media is playing
+PASS mediaController.controls.showsStartButton is false
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
 <script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/macos-media-controls.js" type="text/javascript"></script>
 <script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/macos-inline-media-controls.js" type="text/javascript"></script>
 <script src="../../../../Source/WebCore/Modules/modern-media-controls/media/media-controller.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/media/media-controller-support.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/media/start-support.js" type="text/javascript"></script>
 <script src="../../../../Source/WebCore/Modules/modern-media-controls/main.js" type="text/javascript"></script>
 <body>
-<video src="../../content/test.mp4" style="width: 320px; height: 240px;"></video>
+<video src="../../content/test.mp4" style="width: 320px; height: 240px;" autoplay></video>
 <div id="shadow"></div>
 <script type="text/javascript">
 
 window.jsTestIsAsync = true;
 
-description("Testing the <code>MediaController</code> click-to-start behavior.");
+description("Testing the <code>StartSupport</code> behavior with autoplay.");
 
 iconService.directoryPath = "../../../../Source/WebCore/Modules/modern-media-controls/images";
 
@@ -42,8 +44,6 @@ const shadowRoot = document.querySelector("div#shadow").attachShadow({ mode: "op
 const media = document.querySelector("video");
 const mediaController = createControls(shadowRoot, media, null);
 
-shouldBeTrue("mediaController.controls.showsStartButton");
-
 media.addEventListener("play", function() {
     debug("Media is playing");
     shouldBeFalse("mediaController.controls.showsStartButton");
@@ -53,10 +53,6 @@ media.addEventListener("play", function() {
     finishJSTest();
 });
 
-debug("");
-debug("Dispatching click event to the start button");
-mediaController.controls.startButton.element.click();
-
 </script>
 <script src="../../../resources/js-test-post.js"></script>
 </body>
diff --git a/LayoutTests/media/modern-media-controls/start-support/start-support-click-to-start.html b/LayoutTests/media/modern-media-controls/start-support/start-support-click-to-start.html
new file mode 100644 (file)
index 0000000..9eb17c6
--- /dev/null
@@ -0,0 +1,66 @@
+<script src="../../../resources/js-test-pre.js"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/scheduler.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/layout-node.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/layout-item.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/button.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/buttons-container.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/icon-service.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/start-button.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/icon-button.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/play-pause-button.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/skip-back-button.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/airplay-button.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/pip-button.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/fullscreen-button.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/mute-button.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/tracks-button.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/slider.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/volume-slider.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/scrubber.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/time-label.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/time-control.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/placard.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/airplay-placard.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/pip-placard.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/media-controls.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/macos-media-controls.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/macos-inline-media-controls.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/media/media-controller.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/media/media-controller-support.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/media/start-support.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/main.js" type="text/javascript"></script>
+<body>
+<video src="../../content/test.mp4" style="width: 320px; height: 240px;"></video>
+<div id="shadow"></div>
+<script type="text/javascript">
+
+window.jsTestIsAsync = true;
+
+description("Testing the <code>MediaController</code> click-to-start behavior.");
+
+iconService.directoryPath = "../../../../Source/WebCore/Modules/modern-media-controls/images";
+
+const shadowRoot = document.querySelector("div#shadow").attachShadow({ mode: "open" });
+const media = document.querySelector("video");
+const mediaController = createControls(shadowRoot, media, null);
+
+media.addEventListener("loadedmetadata", function() {
+    shouldBeTrue("mediaController.controls.showsStartButton");
+    debug("");
+    debug("Dispatching click event to the start button");
+    mediaController.controls.startButton.element.click();
+});
+
+media.addEventListener("play", function() {
+    debug("Media is playing");
+    shouldBeFalse("mediaController.controls.showsStartButton");
+    debug("");
+    shadowRoot.host.remove();
+    media.remove();
+    finishJSTest();
+});
+
+
+</script>
+<script src="../../../resources/js-test-post.js"></script>
+</body>
diff --git a/LayoutTests/media/modern-media-controls/start-support/start-support-error-expected.txt b/LayoutTests/media/modern-media-controls/start-support/start-support-error-expected.txt
new file mode 100644 (file)
index 0000000..848b72d
--- /dev/null
@@ -0,0 +1,11 @@
+Testing the StartSupport behavior with an error.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS mediaController.controls.showsStartButton is false
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/media/modern-media-controls/start-support/start-support-error.html b/LayoutTests/media/modern-media-controls/start-support/start-support-error.html
new file mode 100644 (file)
index 0000000..b7f0028
--- /dev/null
@@ -0,0 +1,57 @@
+<script src="../../../resources/js-test-pre.js"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/scheduler.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/layout-node.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/layout-item.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/button.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/buttons-container.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/icon-service.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/start-button.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/icon-button.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/play-pause-button.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/skip-back-button.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/airplay-button.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/pip-button.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/fullscreen-button.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/mute-button.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/tracks-button.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/slider.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/volume-slider.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/scrubber.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/time-label.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/time-control.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/placard.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/airplay-placard.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/pip-placard.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/media-controls.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/macos-media-controls.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/macos-inline-media-controls.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/media/media-controller.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/media/media-controller-support.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/media/start-support.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/main.js" type="text/javascript"></script>
+<body>
+<video src="404.mp4" style="width: 320px; height: 240px;"></video>
+<div id="shadow"></div>
+<script type="text/javascript">
+
+window.jsTestIsAsync = true;
+
+description("Testing the <code>StartSupport</code> behavior with an error.");
+
+iconService.directoryPath = "../../../../Source/WebCore/Modules/modern-media-controls/images";
+
+const shadowRoot = document.querySelector("div#shadow").attachShadow({ mode: "open" });
+const media = document.querySelector("video");
+const mediaController = createControls(shadowRoot, media, null);
+
+media.addEventListener("error", function() {
+    shouldBeFalse("mediaController.controls.showsStartButton");
+    debug("");
+    shadowRoot.host.remove();
+    media.remove();
+    finishJSTest();
+});
+
+</script>
+<script src="../../../resources/js-test-post.js"></script>
+</body>
diff --git a/LayoutTests/media/modern-media-controls/start-support/start-support-fullscreen-expected.txt b/LayoutTests/media/modern-media-controls/start-support/start-support-fullscreen-expected.txt
new file mode 100644 (file)
index 0000000..7b8c4a5
--- /dev/null
@@ -0,0 +1,12 @@
+Testing the StartSupport behavior with no source.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Media entered fullscreen
+PASS mediaController.controls.showsStartButton is false
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/media/modern-media-controls/start-support/start-support-fullscreen.html b/LayoutTests/media/modern-media-controls/start-support/start-support-fullscreen.html
new file mode 100644 (file)
index 0000000..70a810b
--- /dev/null
@@ -0,0 +1,79 @@
+<script src="../../../resources/js-test-pre.js"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/scheduler.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/layout-node.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/layout-item.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/button.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/buttons-container.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/icon-service.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/start-button.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/icon-button.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/play-pause-button.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/skip-back-button.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/airplay-button.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/pip-button.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/fullscreen-button.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/mute-button.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/tracks-button.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/slider.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/volume-slider.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/scrubber.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/time-label.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/time-control.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/placard.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/airplay-placard.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/pip-placard.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/media-controls.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/macos-media-controls.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/macos-inline-media-controls.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/media/media-controller.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/media/media-controller-support.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/media/start-support.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/main.js" type="text/javascript"></script>
+<body>
+<video src="../../content/test.mp4" style="width: 320px; height: 240px;"></video>
+<div id="shadow"></div>
+<script type="text/javascript">
+
+window.jsTestIsAsync = true;
+
+description("Testing the <code>StartSupport</code> behavior with no source.");
+
+iconService.directoryPath = "../../../../Source/WebCore/Modules/modern-media-controls/images";
+
+const shadowRoot = document.querySelector("div#shadow").attachShadow({ mode: "open" });
+const media = document.querySelector("video");
+const mediaController = createControls(shadowRoot, media, null);
+
+const button = document.body.appendChild(document.createElement("button"));
+button.addEventListener("click", event => {
+    try {
+        media.webkitEnterFullscreen();
+    } catch(e) {
+        debug("Calling media.webkitEnterFullscreen() failed");
+        finishJSTest();
+    }
+});
+
+media.addEventListener("webkitfullscreenchange", function() {
+    debug("Media entered fullscreen");
+    shouldBeFalse("mediaController.controls.showsStartButton");
+    debug("");
+    shadowRoot.host.remove();
+    media.remove();
+    button.remove();
+    finishJSTest();
+});
+
+media.addEventListener("loadedmetadata", event => {
+    if ("eventSender" in window) {
+        // Click the button so that we may enter fullscreen.
+        eventSender.mouseMoveTo(button.offsetLeft + 1, button.offsetTop + 1);
+        eventSender.mouseDown();
+        eventSender.mouseUp();
+    } else
+        debug("This test is designed to run in DRT");
+});
+
+</script>
+<script src="../../../resources/js-test-post.js"></script>
+</body>
diff --git a/LayoutTests/media/modern-media-controls/start-support/start-support-manual-play-expected.txt b/LayoutTests/media/modern-media-controls/start-support/start-support-manual-play-expected.txt
new file mode 100644 (file)
index 0000000..81f4a92
--- /dev/null
@@ -0,0 +1,15 @@
+Testing the StartSupport behavior with manual play.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Media is playing
+PASS mediaController.controls.showsStartButton is false
+
+Media is paused
+PASS mediaController.controls.showsStartButton is false
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/media/modern-media-controls/start-support/start-support-manual-play.html b/LayoutTests/media/modern-media-controls/start-support/start-support-manual-play.html
new file mode 100644 (file)
index 0000000..428af8f
--- /dev/null
@@ -0,0 +1,69 @@
+<script src="../../../resources/js-test-pre.js"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/scheduler.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/layout-node.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/layout-item.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/button.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/buttons-container.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/icon-service.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/start-button.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/icon-button.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/play-pause-button.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/skip-back-button.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/airplay-button.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/pip-button.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/fullscreen-button.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/mute-button.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/tracks-button.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/slider.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/volume-slider.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/scrubber.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/time-label.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/time-control.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/placard.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/airplay-placard.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/pip-placard.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/media-controls.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/macos-media-controls.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/macos-inline-media-controls.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/media/media-controller.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/media/media-controller-support.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/media/start-support.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/main.js" type="text/javascript"></script>
+<body>
+<video src="../../content/test.mp4" style="width: 320px; height: 240px;"></video>
+<div id="shadow"></div>
+<script type="text/javascript">
+
+window.jsTestIsAsync = true;
+
+description("Testing the <code>StartSupport</code> behavior with manual play.");
+
+iconService.directoryPath = "../../../../Source/WebCore/Modules/modern-media-controls/images";
+
+const shadowRoot = document.querySelector("div#shadow").attachShadow({ mode: "open" });
+const media = document.querySelector("video");
+const mediaController = createControls(shadowRoot, media, null);
+
+media.addEventListener("play", function() {
+    debug("Media is playing");
+    shouldBeFalse("mediaController.controls.showsStartButton");
+
+    media.addEventListener("pause", function() {
+        debug("");
+        debug("Media is paused");
+        shouldBeFalse("mediaController.controls.showsStartButton");
+        debug("");
+        shadowRoot.host.remove();
+        media.remove();
+        finishJSTest();
+    });
+
+    media.autoplay = false;
+    media.pause();
+});
+
+media.play();
+
+</script>
+<script src="../../../resources/js-test-post.js"></script>
+</body>
diff --git a/LayoutTests/media/modern-media-controls/start-support/start-support-no-source-expected.txt b/LayoutTests/media/modern-media-controls/start-support/start-support-no-source-expected.txt
new file mode 100644 (file)
index 0000000..3b0f2c7
--- /dev/null
@@ -0,0 +1,10 @@
+Testing the StartSupport behavior with no source.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS mediaController.controls.showsStartButton is false
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/media/modern-media-controls/start-support/start-support-no-source.html b/LayoutTests/media/modern-media-controls/start-support/start-support-no-source.html
new file mode 100644 (file)
index 0000000..aa35f49
--- /dev/null
@@ -0,0 +1,52 @@
+<script src="../../../resources/js-test-pre.js"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/scheduler.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/layout-node.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/layout-item.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/button.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/buttons-container.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/icon-service.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/start-button.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/icon-button.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/play-pause-button.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/skip-back-button.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/airplay-button.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/pip-button.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/fullscreen-button.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/mute-button.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/tracks-button.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/slider.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/volume-slider.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/scrubber.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/time-label.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/time-control.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/placard.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/airplay-placard.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/pip-placard.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/media-controls.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/macos-media-controls.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/macos-inline-media-controls.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/media/media-controller.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/media/media-controller-support.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/media/start-support.js" type="text/javascript"></script>
+<script src="../../../../Source/WebCore/Modules/modern-media-controls/main.js" type="text/javascript"></script>
+<body>
+<video style="width: 320px; height: 240px;"></video>
+<div id="shadow"></div>
+<script type="text/javascript">
+
+description("Testing the <code>StartSupport</code> behavior with no source.");
+
+iconService.directoryPath = "../../../../Source/WebCore/Modules/modern-media-controls/images";
+
+const shadowRoot = document.querySelector("div#shadow").attachShadow({ mode: "open" });
+const media = document.querySelector("video");
+const mediaController = createControls(shadowRoot, media, null);
+
+shouldBeFalse("mediaController.controls.showsStartButton");
+
+shadowRoot.host.remove();
+media.remove();
+
+</script>
+<script src="../../../resources/js-test-post.js"></script>
+</body>
index b4368cf..14330d2 100644 (file)
@@ -2692,6 +2692,7 @@ webkit.org/b/162739 fast/images/gif-loop-count.html [ Pass ImageOnlyFailure ]
 
 webkit.org/b/163009 media/modern-media-controls/icon-button/icon-button-active-state.html [ Failure ]
 webkit.org/b/163357 media/modern-media-controls/volume-slider/volume-slider-value.html [ Skip ]
+webkit.org/b/163669 media/modern-media-controls/start-support/start-support-fullscreen.html [ Skip ]
 
 # This variation font test requires Skia which isn't available on iOS.
 webkit.org/b/163093 fast/text/variations/advances.html [ Failure ]
index a8337b6..2d97a8f 100644 (file)
@@ -1,3 +1,51 @@
+2016-10-19  Antoine Quint  <graouts@apple.com>
+
+        [Modern Media Controls] Media Controller: click-to-start support
+        https://bugs.webkit.org/show_bug.cgi?id=163659
+        <rdar://problem/28845656>
+
+        Reviewed by Dean Jackson.
+
+        We introduce the MediaControllerSupport class which will allow a number of media controller
+        features to be implemented by subclasses each devoted to implementing a specific subset of
+        media controller features. With this bug, we add the correct behavior for click-to-start,
+        only showing the start button under the right circumstances.
+
+        A MediaController object indicates which media control to attach click event listeners to
+        through the `control` property, and a list of media events it should register on the media
+        element through the `mediaEvents` property. Then, as the user interacts with the specified
+        control and the media, the Button delegation method `buttonWasClicked()` and the `syncControl()`
+        methods are called to allow for the media state to be correctly set and represented in the
+        media controls. Custom event handling for the specified events can also be achieved by
+        subclassing the `handleEvent()` method.
+
+        Tests: media/modern-media-controls/start-support/start-support-audio.html
+               media/modern-media-controls/start-support/start-support-autoplay.html
+               media/modern-media-controls/start-support/start-support-click-to-start.html
+               media/modern-media-controls/start-support/start-support-error.html
+               media/modern-media-controls/start-support/start-support-fullscreen.html
+               media/modern-media-controls/start-support/start-support-manual-play.html
+               media/modern-media-controls/start-support/start-support-no-source.html
+
+        * Modules/modern-media-controls/media/media-controller-support.js: Added.
+        (MediaControllerSupport):
+        (MediaControllerSupport.prototype.get control):
+        (MediaControllerSupport.prototype.get mediaEvents):
+        (MediaControllerSupport.prototype.buttonWasClicked):
+        (MediaControllerSupport.prototype.handleEvent):
+        (MediaControllerSupport.prototype.syncControl):
+        * Modules/modern-media-controls/media/media-controller.js:
+        (MediaController):
+        (MediaController.prototype.buttonWasClicked): Deleted.
+        * Modules/modern-media-controls/media/start-support.js: Added.
+        (StartSupport.prototype.get control):
+        (StartSupport.prototype.get mediaEvents):
+        (StartSupport.prototype.buttonWasClicked):
+        (StartSupport.prototype.handleEvent):
+        (StartSupport.prototype.syncControl):
+        (StartSupport.prototype._shouldShowStartButton):
+        (StartSupport):
+
 2016-10-19  Aaron Chu  <aaron_chu@apple.com>
 
         Web Inspector: AXI: expose computed tree node and heading level
diff --git a/Source/WebCore/Modules/modern-media-controls/media/media-controller-support.js b/Source/WebCore/Modules/modern-media-controls/media/media-controller-support.js
new file mode 100644 (file)
index 0000000..3d4e1a7
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ * 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 MediaControllerSupport
+{
+
+    constructor(mediaController)
+    {
+        this.mediaController = mediaController;
+
+        for (let eventType of this.mediaEvents)
+            mediaController.media.addEventListener(eventType, this);
+
+        if (!this.control)
+            return;
+
+        this.control.uiDelegate = this;
+
+        this.syncControl();
+    }
+
+    // Protected
+
+    get control()
+    {
+        // Implemented by subclasses.
+    }
+
+    get mediaEvents()
+    {
+        // Implemented by subclasses.
+        return [];
+    }
+
+    buttonWasClicked(control)
+    {
+        // Implemented by subclasses.
+    }
+
+    handleEvent(event)
+    {
+        // Implemented by subclasses.
+        if (this.control)
+            this.syncControl();
+    }
+
+    syncControl()
+    {
+        // Implemented by subclasses.
+    }
+}
index e350dea..878ef63 100644 (file)
@@ -30,6 +30,7 @@ class MediaController
     {
         this.shadowRoot = shadowRoot;
         this.media = media;
+        this.host = host;
 
         // FIXME: This should get set dynamically based on the current environment.
         this.layoutTraits = LayoutTraits.macOS;
@@ -37,8 +38,7 @@ class MediaController
         this.controls = new MacOSInlineMediaControls
         shadowRoot.appendChild(this.controls.element);        
 
-        this.controls.startButton.uiDelegate = this;
-        this.controls.showsStartButton = true;
+        new StartSupport(this);
 
         this._updateControlsSize();
         media.addEventListener("resize", this);
@@ -62,15 +62,6 @@ class MediaController
             this._updateControlsSize();
     }
 
-    buttonWasClicked(button)
-    {
-        if (button !== this.controls.startButton)
-            return;
-
-        this.controls.showsStartButton = false;
-        this.media.play();
-    }
-
     // Private
 
     _updateControlsSize()
diff --git a/Source/WebCore/Modules/modern-media-controls/media/start-support.js b/Source/WebCore/Modules/modern-media-controls/media/start-support.js
new file mode 100644 (file)
index 0000000..ea35f86
--- /dev/null
@@ -0,0 +1,93 @@
+/*
+ * 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 StartSupport extends MediaControllerSupport
+{
+
+    // Protected
+
+    get control()
+    {
+        return this.mediaController.controls.startButton;
+    }
+
+    get mediaEvents()
+    {
+        return ["loadedmetadata", "play", "error", "webkitfullscreenchange"];
+    }
+
+    buttonWasClicked(control)
+    {
+        this.mediaController.media.play();
+    }
+
+    handleEvent(event)
+    {
+        if (event.type === "play")
+            this._hasPlayed = true;
+
+        super.handleEvent(event);
+    }
+
+    syncControl()
+    {
+        this.mediaController.controls.showsStartButton = this._shouldShowStartButton();
+    }
+
+    // Private
+
+    _shouldShowStartButton()
+    {
+        const media = this.mediaController.media;
+
+        if (this._hasPlayed)
+            return false;
+
+        if (!media.paused)
+            return false;
+
+        if (media.autoplay)
+            return false;
+
+        if (media instanceof HTMLAudioElement)
+            return false;
+
+        if (media.webkitDisplayingFullscreen)
+            return false;
+
+        if (!media.currentSrc)
+            return false;
+
+        if (media.error)
+            return false;
+
+        const host = this.mediaController.host;
+        if (!media.controls && host && host.allowsInlineMediaPlayback)
+            return false;
+
+        return true;
+    }
+
+}