Removing the controls attribute from a <video> element does not tear down the control...
authorgraouts@webkit.org <graouts@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 Feb 2018 01:36:22 +0000 (01:36 +0000)
committergraouts@webkit.org <graouts@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 Feb 2018 01:36:22 +0000 (01:36 +0000)
commitf0e724a15bae4d1941e97f6be7f200b46fbc1ba6
treeb6d1c7c6b5c880369793ac1e428e41d06ffcaa7f
parentdf2bf50d48531810d8d2f1599ae430c3028df933
Removing the controls attribute from a <video> element does not tear down the controls shadow DOM nor cancel event listeners.
https://bugs.webkit.org/show_bug.cgi?id=182668
Source/WebCore:

<rdar://problem/33793004>

Reviewed by Jer Noble.

When controls were turned off for inline media players, we would remove all media controls elements from the shadow root,
but we would nevertheless continue to listen to media events and, as a result, update properties of the media controls
which would lead to requestAnimationFrame() calls that would update the detached DOM nodes.

We now only listent to media events if controls are turned on.

* Modules/modern-media-controls/media/controls-visibility-support.js:
(ControlsVisibilitySupport.prototype.enable): Remove the mutation observer from ControlsVisibilitySupport since observing
changes to the controls attribute is now performed directly in MediaController. We need to make sure that we update the
controls however since fadesWhileIdle is turned off in the disable() call to ensure that the auto-hide behavior is disabled
as well.
(ControlsVisibilitySupport.prototype.disable): Disable the auto-hide controller as well.
(ControlsVisibilitySupport.prototype._updateControls): Remove code that has now been moved into MediaController._updateControlsAvailability().
* Modules/modern-media-controls/media/media-controller.js:
(MediaController): Listen to the "play" event on the media so that we call _updateControlsAvailability() in this situation to account for
shouldForceControlsDisplay on MediaControlsHost. We also register for a mutation observer to track when the controls attribute availability
changes in which case we want to call _updateControlsAvailability() as well.
(MediaController.prototype.handleEvent): Call _updateControlsAvailability() instead of _updateiOSFullscreenProperties() which has been renamed
and expanded.
(MediaController.prototype._updateControlsIfNeeded): Call _updateControlsAvailability() after controls have been updated.
(MediaController.prototype._updateControlsAvailability): We now disable supporting media controller objects when we know that controls should
be hidden in all cases except when in fullscreen on macOS.
(MediaController.prototype._updateiOSFullscreenProperties): Deleted.
* Modules/modern-media-controls/media/placard-support.js:
(PlacardSupport.prototype.disable): Only allow the media events required to track when to show placards when in fullscreen since inline media
players need to show the AirPlay and picture-in-picture placards even when controls are disabled.

LayoutTests:

Reviewed by Jer Noble.

Ensure controls are turned on for a number of tests that would fail otherwise since media events would not be handled by media
controls without it.

* http/tests/media/modern-media-controls/macos-fullscreen-media-controls/macos-fullscreen-media-controls-live-broadcast.html:
* http/tests/media/modern-media-controls/pip-support/pip-support-live-broadcast.html:
* http/tests/media/modern-media-controls/skip-back-support/skip-back-support-button-click.html:
* http/tests/media/modern-media-controls/skip-back-support/skip-back-support-live-broadcast.html:
* http/tests/media/modern-media-controls/status-support/status-support-live-broadcast.html:
* http/tests/media/modern-media-controls/status-support/status-support-loading.html:
* media/modern-media-controls/airplay-support/airplay-support.html:
* media/modern-media-controls/mute-support/mute-support-media-api.html:
* media/modern-media-controls/playback-support/playback-support-autoplay.html:
* media/modern-media-controls/playback-support/playback-support-media-api.html:
* media/modern-media-controls/start-support/start-support-error.html:
* media/modern-media-controls/start-support/start-support-lowPowerMode.html:
* media/modern-media-controls/start-support/start-support-manual-play.html:
* media/modern-media-controls/status-support/status-support-error.html:
* media/modern-media-controls/time-labels-support/elapsed-time.html:
* media/modern-media-controls/time-labels-support/remaining-time.html:
* media/modern-media-controls/tracks-support/tracks-support-audio-tracks.html:
* media/modern-media-controls/tracks-support/tracks-support-text-tracks.html:
* media/modern-media-controls/volume-support/volume-support-media-api-mute.html:
* media/modern-media-controls/volume-support/volume-support-media-api.html:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@228445 268f45cc-cd09-0410-ab3c-d52691b4dbfc
25 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/media/modern-media-controls/macos-fullscreen-media-controls/macos-fullscreen-media-controls-live-broadcast.html
LayoutTests/http/tests/media/modern-media-controls/pip-support/pip-support-live-broadcast.html
LayoutTests/http/tests/media/modern-media-controls/skip-back-support/skip-back-support-button-click.html
LayoutTests/http/tests/media/modern-media-controls/skip-back-support/skip-back-support-live-broadcast.html
LayoutTests/http/tests/media/modern-media-controls/status-support/status-support-live-broadcast.html
LayoutTests/http/tests/media/modern-media-controls/status-support/status-support-loading.html
LayoutTests/media/modern-media-controls/airplay-support/airplay-support.html
LayoutTests/media/modern-media-controls/mute-support/mute-support-media-api.html
LayoutTests/media/modern-media-controls/playback-support/playback-support-autoplay.html
LayoutTests/media/modern-media-controls/playback-support/playback-support-media-api.html
LayoutTests/media/modern-media-controls/start-support/start-support-error.html
LayoutTests/media/modern-media-controls/start-support/start-support-lowPowerMode.html
LayoutTests/media/modern-media-controls/start-support/start-support-manual-play.html
LayoutTests/media/modern-media-controls/status-support/status-support-error.html
LayoutTests/media/modern-media-controls/time-labels-support/elapsed-time.html
LayoutTests/media/modern-media-controls/time-labels-support/remaining-time.html
LayoutTests/media/modern-media-controls/tracks-support/tracks-support-audio-tracks.html
LayoutTests/media/modern-media-controls/tracks-support/tracks-support-text-tracks.html
LayoutTests/media/modern-media-controls/volume-support/volume-support-media-api-mute.html
LayoutTests/media/modern-media-controls/volume-support/volume-support-media-api.html
Source/WebCore/ChangeLog
Source/WebCore/Modules/modern-media-controls/media/controls-visibility-support.js
Source/WebCore/Modules/modern-media-controls/media/media-controller.js
Source/WebCore/Modules/modern-media-controls/media/placard-support.js