REGRESSION (r228445): A big pause button shows over YouTube videos if you tap "Tap...
authorgraouts@webkit.org <graouts@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 23 Feb 2018 13:53:13 +0000 (13:53 +0000)
committergraouts@webkit.org <graouts@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 23 Feb 2018 13:53:13 +0000 (13:53 +0000)
commit65137a2aa9a35ee739d809de0e04f6f18b4bcf0f
tree5df239db2f5bb348b86ca2cc4c30d14c4da370a4
parent717f1297e620fc0a21a8d9d06ef6502c4ba553f2
REGRESSION (r228445): A big pause button shows over YouTube videos if you tap "Tap To Unmute" on iOS
https://bugs.webkit.org/show_bug.cgi?id=183074
<rdar://problem/37747028>

Reviewed by Eric Carlson.

Source/WebCore:

Test: media/modern-media-controls/start-support/start-support-disable-controls-and-re-enable-post-play.html

In the fix for webkit.org/b/182668, we made it so that when the "controls" attribute is absent from a media
element we stop listening to the bulk of media events and prevent controls from updating any DOM properties
so as to minimize the amount of CPU usage by the Web process.

An unfortunate side effect was that, if the media controls were disabled at the time the video starts playing,
the StartSupport class would thus not catch the "play" event and would not be able to set the "hasPlayed"
property to "true" on the MediaController, which would then prevent the _shouldShowStartButton() from returning
"false". As a result, if the "controls" attribute was turned back on after the media started playing, they
would default to showing the start button, which would be then in the play state, ie. showing the pause icon.

We now set the "hasPlayed" property in the "play" event handler on MediaController, which is always registered
regardless of the "controls" attribute setting. We also ensure we invalidate the "showStartButton" property on
the media controls when StartSupport is enabled, which is the case when the "controls" attribute is toggled back
to "true" from a previous "false" value.

* Modules/modern-media-controls/media/media-controller.js:
(MediaController.prototype.handleEvent):
* Modules/modern-media-controls/media/start-support.js:
(StartSupport):
(StartSupport.prototype.enable):
(StartSupport.prototype.handleEvent):
(StartSupport.prototype._updateShowsStartButton):

LayoutTests:

Add a new test that set controls on the video, then immediately removes them, plays the video and turns the controls
back on as soon as the video starts to check that the "showsStartButton" property is false on the media controls.
Prior to this patch this test would fail.

* media/modern-media-controls/start-support/start-support-disable-controls-and-re-enable-post-play-expected.txt: Added.
* media/modern-media-controls/start-support/start-support-disable-controls-and-re-enable-post-play.html: Added.
* platform/ios/TestExpectations:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@228947 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/media/modern-media-controls/start-support/start-support-disable-controls-and-re-enable-post-play-expected.txt [new file with mode: 0644]
LayoutTests/media/modern-media-controls/start-support/start-support-disable-controls-and-re-enable-post-play.html [new file with mode: 0644]
LayoutTests/platform/ios/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/Modules/modern-media-controls/media/media-controller.js
Source/WebCore/Modules/modern-media-controls/media/start-support.js