Title: [212872] trunk
Revision
212872
Author
[email protected]
Date
2017-02-22 18:55:59 -0800 (Wed, 22 Feb 2017)

Log Message

[Modern Media Controls] Clicking on the video doesn't toggle playback state in fullscreen on macOS
https://bugs.webkit.org/show_bug.cgi?id=168755
<rdar://problem/30664484>

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

Source/WebCore:

We now call super in the handleEvent() method of MacOSFullscreenMediaControls if we're not dealing
with an event type and target combination that was specifically registered in this class's scope.
We had mistakenly added the call to super.handleEvent(event) in the wrong method when fixing
https://bugs.webkit.org/show_bug.cgi?id=168515.

Test: media/modern-media-controls/media-controller/media-controller-click-on-video-background-should-pause-fullscreen.html

* Modules/modern-media-controls/controls/macos-fullscreen-media-controls.js:
(MacOSFullscreenMediaControls.prototype.handleEvent):
(MacOSFullscreenMediaControls.prototype._handleMousedown):
* Modules/modern-media-controls/controls/macos-media-controls.js:
(MacOSMediaControls.prototype.handleEvent):
(MacOSMediaControls):

LayoutTests:

Add a dedicated test for fullscreen to check that clicking on the video correctly toggles playback.

* media/modern-media-controls/media-controller/media-controller-click-on-video-background-should-pause-fullscreen-expected.txt: Added.
* media/modern-media-controls/media-controller/media-controller-click-on-video-background-should-pause-fullscreen.html: Added.
* platform/ios-simulator/TestExpectations:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (212871 => 212872)


--- trunk/LayoutTests/ChangeLog	2017-02-23 02:52:48 UTC (rev 212871)
+++ trunk/LayoutTests/ChangeLog	2017-02-23 02:55:59 UTC (rev 212872)
@@ -1,5 +1,19 @@
 2017-02-22  Antoine Quint  <[email protected]>
 
+        [Modern Media Controls] Clicking on the video doesn't toggle playback state in fullscreen on macOS
+        https://bugs.webkit.org/show_bug.cgi?id=168755
+        <rdar://problem/30664484>
+
+        Reviewed by Dean Jackson.
+
+        Add a dedicated test for fullscreen to check that clicking on the video correctly toggles playback.
+
+        * media/modern-media-controls/media-controller/media-controller-click-on-video-background-should-pause-fullscreen-expected.txt: Added.
+        * media/modern-media-controls/media-controller/media-controller-click-on-video-background-should-pause-fullscreen.html: Added.
+        * platform/ios-simulator/TestExpectations:
+
+2017-02-22  Antoine Quint  <[email protected]>
+
         [Modern Media Controls] Scrubber stops moving while scrubbing on macOS
         https://bugs.webkit.org/show_bug.cgi?id=168518
         <rdar://problem/30577637>

Added: trunk/LayoutTests/media/modern-media-controls/media-controller/media-controller-click-on-video-background-should-pause-fullscreen-expected.txt (0 => 212872)


--- trunk/LayoutTests/media/modern-media-controls/media-controller/media-controller-click-on-video-background-should-pause-fullscreen-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/media/modern-media-controls/media-controller/media-controller-click-on-video-background-should-pause-fullscreen-expected.txt	2017-02-23 02:55:59 UTC (rev 212872)
@@ -0,0 +1,18 @@
+Testing that clicking on a fullscreen video's background pauses it.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS mediaControls.querySelector('button.fullscreen') instanceof HTMLButtonElement became true
+
+Entering fullscreen
+PASS media.webkitDisplayingFullscreen is true
+PASS media.paused is false
+
+Clicking on video background
+PASS media.paused is true
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/media/modern-media-controls/media-controller/media-controller-click-on-video-background-should-pause-fullscreen.html (0 => 212872)


--- trunk/LayoutTests/media/modern-media-controls/media-controller/media-controller-click-on-video-background-should-pause-fullscreen.html	                        (rev 0)
+++ trunk/LayoutTests/media/modern-media-controls/media-controller/media-controller-click-on-video-background-should-pause-fullscreen.html	2017-02-23 02:55:59 UTC (rev 212872)
@@ -0,0 +1,44 @@
+<script src=""
+<script src="" type="text/_javascript_"></script>
+<script src="" type="text/_javascript_"></script>
+<body>
+<video src="" style="position: absolute; top: 0; left: 0; width: 800px;" controls autoplay></video>
+<script type="text/_javascript_">
+
+description("Testing that clicking on a fullscreen video's background pauses it.");
+
+window.jsTestIsAsync = true;
+
+const media = document.querySelector("video");
+const mediaControls = window.internals.shadowRoot(media);
+
+media.addEventListener("play", () => {
+    shouldBecomeEqual("mediaControls.querySelector('button.fullscreen') instanceof HTMLButtonElement", "true", () => {
+        debug("");
+        debug("Entering fullscreen");
+        pressOnElement(mediaControls.querySelector("button.fullscreen"));
+    });
+});
+
+
+media.addEventListener("webkitfullscreenchange", () => {
+    shouldBeTrue("media.webkitDisplayingFullscreen");
+    shouldBeFalse("media.paused");
+
+    const bounds = media.getBoundingClientRect();
+    debug("");
+    debug("Clicking on video background");
+    eventSender.mouseMoveTo(bounds.left + 5, bounds.top + 5);
+    eventSender.mouseDown();
+    eventSender.mouseUp();
+
+    shouldBeTrue("media.paused");
+
+    debug("");
+    media.remove();
+    finishJSTest();
+});
+
+</script>
+<script src=""
+</body>

Modified: trunk/LayoutTests/platform/ios-simulator/TestExpectations (212871 => 212872)


--- trunk/LayoutTests/platform/ios-simulator/TestExpectations	2017-02-23 02:52:48 UTC (rev 212871)
+++ trunk/LayoutTests/platform/ios-simulator/TestExpectations	2017-02-23 02:55:59 UTC (rev 212872)
@@ -2812,6 +2812,7 @@
 media/modern-media-controls/media-documents/click-on-video-should-not-pause.html [ Skip ]
 media/modern-media-controls/media-documents/click-on-video-should-not-pause.html [ Skip ]
 media/modern-media-controls/media-controller/media-controller-click-on-video-background-should-pause.html [ Skip ]
+media/modern-media-controls/media-controller/media-controller-click-on-video-background-should-pause-fullscreen.html [ Skip ]
 media/modern-media-controls/media-controller/media-controller-click-on-video-background-to-dismiss-tracks-panel-should-not-toggle-playback.html [ Skip ]
 media/modern-media-controls/media-controller/media-controller-click-on-video-controls-should-not-pause.html [ Skip ]
 

Modified: trunk/Source/WebCore/ChangeLog (212871 => 212872)


--- trunk/Source/WebCore/ChangeLog	2017-02-23 02:52:48 UTC (rev 212871)
+++ trunk/Source/WebCore/ChangeLog	2017-02-23 02:55:59 UTC (rev 212872)
@@ -1,5 +1,27 @@
 2017-02-22  Antoine Quint  <[email protected]>
 
+        [Modern Media Controls] Clicking on the video doesn't toggle playback state in fullscreen on macOS
+        https://bugs.webkit.org/show_bug.cgi?id=168755
+        <rdar://problem/30664484>
+
+        Reviewed by Dean Jackson.
+
+        We now call super in the handleEvent() method of MacOSFullscreenMediaControls if we're not dealing
+        with an event type and target combination that was specifically registered in this class's scope.
+        We had mistakenly added the call to super.handleEvent(event) in the wrong method when fixing
+        https://bugs.webkit.org/show_bug.cgi?id=168515.
+
+        Test: media/modern-media-controls/media-controller/media-controller-click-on-video-background-should-pause-fullscreen.html
+
+        * Modules/modern-media-controls/controls/macos-fullscreen-media-controls.js:
+        (MacOSFullscreenMediaControls.prototype.handleEvent):
+        (MacOSFullscreenMediaControls.prototype._handleMousedown):
+        * Modules/modern-media-controls/controls/macos-media-controls.js:
+        (MacOSMediaControls.prototype.handleEvent):
+        (MacOSMediaControls):
+
+2017-02-22  Antoine Quint  <[email protected]>
+
         [Modern Media Controls] Scrubber stops moving while scrubbing on macOS
         https://bugs.webkit.org/show_bug.cgi?id=168518
         <rdar://problem/30577637>

Modified: trunk/Source/WebCore/Modules/modern-media-controls/controls/macos-fullscreen-media-controls.js (212871 => 212872)


--- trunk/Source/WebCore/Modules/modern-media-controls/controls/macos-fullscreen-media-controls.js	2017-02-23 02:52:48 UTC (rev 212871)
+++ trunk/Source/WebCore/Modules/modern-media-controls/controls/macos-fullscreen-media-controls.js	2017-02-23 02:55:59 UTC (rev 212872)
@@ -73,7 +73,7 @@
 
         this.controlsBar.children = [new BackgroundTint, this._leftContainer, this._centerContainer, this._rightContainer, this.timeControl];
 
-        this.element.addEventListener("mousedown", this);
+        this.controlsBar.element.addEventListener("mousedown", this);
     }
 
     // Public
@@ -91,17 +91,14 @@
 
     handleEvent(event)
     {
-        switch (event.type) {
-        case "mousedown":
+        if (event.type === "mousedown" && event.currentTarget === this.controlsBar.element)
             this._handleMousedown(event);
-            break;
-        case "mousemove":
+        else if (event.type === "mousemove" && event.currentTarget === this.element)
             this._handleMousemove(event);
-            break;
-        case "mouseup":
+        else if (event.type === "mouseup" && event.currentTarget === this.element)
             this._handleMouseup(event);
-            break;
-        }
+        else
+            super.handleEvent(event);
     }
 
     layout()
@@ -128,12 +125,8 @@
 
     _handleMousedown(event)
     {
-        super.handleEvent(event);
-
-        if (event.target !== this.controlsBar.element)
-            return;
-
         event.preventDefault();
+        event.stopPropagation();
 
         this._lastDragPoint = this._pointForEvent(event);
 

Modified: trunk/Source/WebCore/Modules/modern-media-controls/controls/macos-media-controls.js (212871 => 212872)


--- trunk/Source/WebCore/Modules/modern-media-controls/controls/macos-media-controls.js	2017-02-23 02:52:48 UTC (rev 212871)
+++ trunk/Source/WebCore/Modules/modern-media-controls/controls/macos-media-controls.js	2017-02-23 02:55:59 UTC (rev 212872)
@@ -68,8 +68,9 @@
 
         // Only notify that the background was clicked when the "mousedown" event
         // was also received, which wouldn't happen if the "mousedown" event caused
-        // the tracks panel to be hidden.
-        if (event.type === "mousedown")
+        // the tracks panel to be hidden, unless we're in fullscreen in which case
+        // we can simply check that the panel is not currently presented.
+        if (event.type === "mousedown" && !this.tracksPanel.presented)
             this._receivedMousedown = true;
         else if (event.type === "click") {
             if (this._receivedMousedown && event.target === this.element && this.delegate && typeof this.delegate.macOSControlsBackgroundWasClicked === "function")
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to