Commit Graph

1725 Commits

Author SHA1 Message Date
Jean-Yves Avenard 852e333a23 Implement API to ensure MediaRemote key mapping is correct
https://bugs.webkit.org/show_bug.cgi?id=229070
<rdar://problem/81894480>

Reviewed by Eric Carlson.

Source/WebCore:

This change adds Internals entries to test bug 229068.
While we do not mock the MediaRemote service, we still go one step further in
ensuring that the mappings between MediaSession action handlers and
PlatformMediaSession are correct.

Test: media/media-session/actionHandlerInternalMappings.html

* platform/NowPlayingManager.cpp:
(WebCore::NowPlayingManager::supportedCommands const):
* platform/NowPlayingManager.h:
* platform/audio/PlatformMediaSession.h:
* platform/audio/PlatformMediaSessionManager.h:
(WebCore::PlatformMediaSessionManager::supportedCommands const):
* platform/audio/cocoa/MediaSessionManagerCocoa.h:
* platform/audio/cocoa/MediaSessionManagerCocoa.mm:
(WebCore::MediaSessionManagerCocoa::supportedCommands const):
* testing/Internals.cpp:
(WebCore::Internals::platformSupportedCommands const):
* testing/Internals.h:
* testing/Internals.idl:

LayoutTests:

* media/media-session/actionHandlerInternalMappings-expected.txt: Added.
* media/media-session/actionHandlerInternalMappings.html: Added.


Canonical link: https://commits.webkit.org/240588@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@281134 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-08-17 13:09:28 +00:00
Dean Jackson b48f5080e1 [Media Controls] Add an option for having no scrubber on the time control and parameterize margin
https://bugs.webkit.org/show_bug.cgi?id=228633
rdar://81314458

Reviewed by Tim Horton.

Source/WebCore:

Add support for a scrubber bar that does not have a knob (or, to be clear, an
invisible knob). While here, move the constant for the margin into a custom
CSS property so it can be easily overridden.

* Modules/modern-media-controls/controls/media-controls.css:
(*): Add --scrubber-margin custom property.
* Modules/modern-media-controls/controls/slider.css:
(.slider > .custom-slider > .knob.none): Add style for a "none" knob.
* Modules/modern-media-controls/controls/slider.js:
(Slider.prototype.commit): Support "none".
* Modules/modern-media-controls/controls/time-control.js: Get the margin from
the new custom property.
(TimeControl.prototype.get minimumWidth):
(TimeControl.prototype.get idealMinimumWidth):
(TimeControl.prototype.layout):
(TimeControl.prototype._performIdealLayout):

LayoutTests:

Make sure the TimeControls element is in the document so its computed style
can be read.

* media/modern-media-controls/time-control/time-control.html:

Canonical link: https://commits.webkit.org/240112@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280477 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-07-30 16:21:43 +00:00
Tomoki Imai 8c01c82de4 Missing playing events when the ready state becomes HAVE_FUTURE_DATA/HAVE_ENOUGH_DATA from HAVE_METADATA state
https://bugs.webkit.org/show_bug.cgi?id=228531

Reviewed by Eric Carlson.

Source/WebCore:

The main issue is that missing playing event when the ready state becomes HAVE_FUTURE_DATA or HAVE_ENOUGH_DATA from HAVE_METADATA.
According to the specification, we need to "notify about playing" in the following cases:
- If the previous ready state was HAVE_CURRENT_DATA or less, and the new ready state is HAVE_FUTURE_DATA, and it's not paused.
- If the new ready state is HAVE_ENOUGH_DATA, and it's eligible for autoplay
The implementation didn't cover these cases and had web compatibility issues.

We also should move scheduleNotifyAboutPlaying from setPlaying to playInternal and checks the ready state.
- Without this change, playing event is fired twice. The first one is fired by setReadyState, and the second is called from setPlaying.
- According to the specification, scheduleNotifyAboutPlaying should be in  "internal play steps" and check the ready state.
  Checking ready state fixes the issue where playing event is fired twice.

Test: media/media-source/media-source-monitor-playing-event.html

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::setReadyState): Added missing scheduleNotifyAboutPlaying calls. Added do-while to make the implementation similar to the specification text
(WebCore::HTMLMediaElement::playInternal): Added scheduleNotifyAboutPlaying call.
                                           According to the specification, "internal play steps" should "notify about playing" when
                                           the ready state is HAVE_FUTURE_DATA or HAVE_ENOUGH_DATA.
(WebCore::HTMLMediaElement::setPlaying): Removed scheduleNotifyAboutPlaying call because playInternal now calls scheduleNotifyAboutPlaying instead.

Reference:
- https://html.spec.whatwg.org/multipage/media.html#internal-play-steps
- https://html.spec.whatwg.org/multipage/media.html#ready-states

LayoutTests:

Added the testcase to checks if the playing event is fired correctly on the ready state changes.

* media/media-source/media-source-monitor-playing-event-expected.txt: Added.
* media/media-source/media-source-monitor-playing-event.html: Added.


Canonical link: https://commits.webkit.org/240103@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280468 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-07-30 06:43:48 +00:00
Devin Rousso d5bda802aa [Modern Media Controls] [macOS] Overflow button still shows as `on` even after contextmenu is dismissed
https://bugs.webkit.org/show_bug.cgi?id=228310
<rdar://problem/81124786>

Reviewed by Wenson Hsieh.

Source/WebCore:

Test: media/modern-media-controls/overflow-support/button-state.html

* page/ContextMenuController.h:
* page/ContextMenuController.cpp:
(WebCore::ContextMenuController::didDismissContextMenu): Added.
* page/ContextMenuProvider.h:
(WebCore::ContextMenuProvider::didDismissContextMenu): Added.
Add plumbing from WebKit to the `ContextMenuProvider` for when the contextmenu is dismissed.

* Modules/mediacontrols/MediaControlsHost.cpp:
(WebCore::MediaControlsContextMenuProvider::didDismissContextMenu): Added.
When the contextmenu is dismissed, invoke the callback provided to `MediaControlsHost::showMediaControlsContextMenu`
as that's the signal to the `MediaController` that the contextmenu interaction is over,
which adjusts the `on` state of the `Button`.

Source/WebKit:

Pipe along the `-[NSMenuDelegate menuDidClose:]` signal to the WebProcess so the `WebCore::ContextMenuProvider`
can handle it if needed.

* UIProcess/WebContextMenuProxy.cpp:
(WebKit::WebContextMenuProxy::useContextMenuItems):
* UIProcess/mac/WebContextMenuProxyMac.mm:
(-[WKMenuDelegate menuWillOpen:]):
(-[WKMenuDelegate menuDidClose:]):

* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::showContextMenu):
(WebKit::WebPageProxy::didShowContextMenu):
(WebKit::WebPageProxy::didDismissContextMenu): Added.

* WebProcess/WebPage/WebContextMenu.cpp:
(WebKit::WebContextMenu::show):

* WebProcess/WebPage/WebPage.messages.in:
* WebProcess/WebPage/WebPage.h:
(WebKit::WebPage::startWaitingForContextMenuToShow): Added.
(WebKit::WebPage::contextMenuShowing): Deleted.
(WebKit::WebPage::contextMenuHidden): Deleted.
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::didShowContextMenu): Added.
(WebKit::WebPage::didDismissContextMenu): Added.
(WebKit::WebPage::mouseEvent):
Drive-by: Rename `m_contextMenuShowing` to `m_waitingForContextMenuToShow` for clarity.

Tools:

* WebKitTestRunner/cocoa/TestRunnerWKWebView.mm:
(-[TestRunnerWKWebView dismissActiveMenu]):
(-[TestRunnerWKWebView immediatelyDismissContextMenuIfNeeded]):
(-[TestRunnerWKWebView _dismissAllContextMenuInteractions]): Added.

LayoutTests:

* media/modern-media-controls/overflow-support/button-state.html: Added.
* media/modern-media-controls/overflow-support/button-state-expected.txt: Added.

* media/modern-media-controls/overflow-support/playback-speed.html:
* media/modern-media-controls/tracks-support/click-track-in-contextmenu.html:
Adjust how these tests wait for and dismiss the contextmenu.


Canonical link: https://commits.webkit.org/240018@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280374 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-07-28 03:56:44 +00:00
Jean-Yves Avenard 9fd37d48df Video pauses after scrubbing with Touch Bar
https://bugs.webkit.org/show_bug.cgi?id=228277
rdar://80606886

Reviewed by Jer Noble.

Source/WebCore:

In https://trac.webkit.org/r206487 ; in order to ensure that the playback state
was properly reflected following a seek using the touch bar, the element was paused.
It's unclear if that workaround is still required, but for now we will record if the
element was playing before the seek and if so, resume playback once the seek completes.
Now that the touch bar and Now Playing are hooked to the Media Session action handlers
the behaviour change will occur for all those components.

Test: media/media-session/play-after-seek.html

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::HTMLMediaElement): Initialize new member in constructor.
(WebCore::HTMLMediaElement::clearSeeking):
(WebCore::HTMLMediaElement::finishSeek): Call play() once seek completes if the element
was playing before.
(WebCore::HTMLMediaElement::pause): Ensure that if pause() is called before the seek
completes, the element stays paused.
(WebCore::HTMLMediaElement::handleSeekToPlaybackPosition): Record playing state before
pausing the element.
* html/HTMLMediaElement.h: Add new boolean member.

LayoutTests:

* media/media-session/play-after-seek-expected.txt: Added.
* media/media-session/play-after-seek.html: Added.


Canonical link: https://commits.webkit.org/239977@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280330 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-07-27 00:25:42 +00:00
Jer Noble 32d38133cc [Cocoa] Playback stalls on bilibili.com
https://bugs.webkit.org/show_bug.cgi?id=228239
<rdar://80419477>

Reviewed by Eric Carlson.

Source/WebCore:

Test: media/media-source/media-source-effectiveplaybackrate.html

bilibili.com will attempt to detect playback stalls by detecting when video.currentTime
returns the same value while video.paused is false. When the GPU process is enabled, we use
a heuristic to provide the answer to currentTime to avoid making synchronous calls to the
GPU process. This heuristic uses the reported playback rate of the MediaPlayerPrivate to
derive the currentTime. However, MediaPlayerPrivateAVFoundationObjC does not override the
default implementation of rate(), and so always returns a reported rate of zero.

To make the call less ambiguous, add a MediaPlayer and MediaPlayerPrivate effectiveRate()
method, which by default will just return rate(), as some ports only report the
requested rate and not the effective rate. Then add overrides for both rate() and
effectiveRate() on both MediaPlayerPrivateAVFoundationObjC and
MediaPlayerPrivateMediaSourceAVFObjC.

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::updatePlaybackRate):
(WebCore::HTMLMediaElement::mediaPlayerRateChanged):
* platform/graphics/MediaPlayer.cpp:
(WebCore::MediaPlayer::effectiveRate const):
* platform/graphics/MediaPlayer.h:
* platform/graphics/MediaPlayerPrivate.h:
(WebCore::MediaPlayerPrivateInterface::effectiveRate const):
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::MediaPlayerPrivateAVFoundationObjC::rate const):
(WebCore::MediaPlayerPrivateAVFoundationObjC::effectiveRate const):
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h:
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::rate const):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::effectiveRate const):
* testing/Internals.cpp:
(WebCore::Internals::isMediaElementHidden):
(WebCore::Internals::elementEffectivePlaybackRate):
* testing/Internals.h:
* testing/Internals.idl:

Source/WebKit:

Replace rate() -> effectiveRate().

* GPUProcess/media/RemoteMediaPlayerProxy.cpp:
(WebKit::RemoteMediaPlayerProxy::mediaPlayerRateChanged):

LayoutTests:

* media/media-source/media-source-effectiveplaybackrate-expected.txt: Added.
* media/media-source/media-source-effectiveplaybackrate.html: Added.


Canonical link: https://commits.webkit.org/239958@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280308 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-07-26 19:36:50 +00:00
Jer Noble f8247a6613 [iOS] All home screen web apps resume when any home screen web app is foregrounded
https://bugs.webkit.org/show_bug.cgi?id=228246
<rdar://72949281>

Reviewed by Eric Carlson.

Source/WebCore:

Test: media/video-page-visibility-restriction.html

On iOS, home screen web apps all run from the same UIProcess, SafariViewService. So when
one Web App is foregrounded, the SafariViewService itself is foregrounded, and all WKWebViews
(one for each Web App) are foregrounded as well, allowing all Web Apps to resume audio
playback. This is not ideal; ideally, all Web Apps will be allowed to continue to play
audio in the background. But until we can fix that bug, the current behavior of pausing
audio from Web App A when A is backgrounded, and resuming audio from A when Web App B is
foregrounded feels super broken.

Add a new WKPreference/WebPreference/Setting and matching MediaElementSession restriction
that will block playback of audible media elements when the media element's page is not
visible. When adopted by SafariViewService, this would keep multiple Web Apps (and indeed
SafariViewController pages) from starting playback when any other is foregrounded.

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::initializeMediaSession):
(WebCore::HTMLMediaElement::visibilityStateChanged):
* html/MediaElementSession.cpp:
(WebCore::MediaElementSession::visibilityChanged):
(WebCore::MediaElementSession::playbackStateChangePermitted const):
* html/MediaElementSession.h:
* platform/audio/PlatformMediaSession.h:
* testing/Internals.cpp:
(WebCore::Internals::setMediaElementRestrictions):

Source/WebKit:

Add a private WKPreference for setting the new WebPreference.

* UIProcess/API/Cocoa/WKPreferences.mm:
(-[WKPreferences _requiresPageVisibilityToPlayAudio]):
(-[WKPreferences _setRequiresPageVisibilityToPlayAudio:]):
* UIProcess/API/Cocoa/WKPreferencesPrivate.h:

Source/WTF:

* Scripts/Preferences/WebPreferences.yaml:

LayoutTests:

* media/video-page-visibility-restriction-expected.txt: Added.
* media/video-page-visibility-restriction.html: Added.


Canonical link: https://commits.webkit.org/239951@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280298 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-07-26 17:51:09 +00:00
Devin Rousso 2e37a2d522 [Modern Media Controls] [macOS] Only show total duration when the elapsed time is visible
https://bugs.webkit.org/show_bug.cgi?id=228191
<rdar://problem/80529918>

Reviewed by Eric Carlson.

Source/WebCore:

When a `<video>` is narrow (~250px) WebKit will drop the elapsed time, meaning that only the
scrubber and duration are visible. It's not very helpful to show just the duration because
it never changes, requiring the user to do the mental math of dividing the scrubber width
by the total duration to figure out how much time is left (and has elapsed). Showing the
remaining time is better because it at least helps the user not have to figure out how much
longer the `<video>` will play (which is more useful/actionable than knowing the duration).

Test: media/modern-media-controls/time-control/time-control.html

* Modules/modern-media-controls/controls/time-control.js:
(TimeControl):
(TimeControl.prototype.handleEvent):
(TimeControl.prototype.get _canShowDurationTimeLabel): Added.
(TimeControl.prototype._durationOrRemainingTimeLabel):
(TimeControl.prototype._performIdealLayout):
Rename `_showDurationTimeLabel` to `_shouldShowDurationTimeLabel` and add another private
getter `_canShowDurationTimeLabel` that only is true when `this.elapsedTimeLabel.visible`.
Use both to decide whether duration or remaining is shown/updated/etc..

LayoutTests:

* media/modern-media-controls/time-control/time-control.html:
* media/modern-media-controls/time-control/time-control-expected.txt:


Canonical link: https://commits.webkit.org/239910@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280242 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-07-23 11:39:35 +00:00
Truitt Savell 8415b085c3 Migrate Monterey expectations to OpenSource and bump version numbers
https://bugs.webkit.org/show_bug.cgi?id=228090

Reviewed by Ryan Haddad.

Tools:

* Scripts/webkitpy/port/mac.py:
(MacPort):
* Scripts/webkitpy/port/mac_unittest.py:
(MacTest.test_monterey_baseline_search_path):
(MacTest.test_big_sur_baseline_search_path): Deleted.

LayoutTests:

* TestExpectations:
* media/media-source/content/test-vp8-malformed-header-manifest.json: Renamed from LayoutTests/platform/mac-bigsur/media/media-source/content/test-vp8-malformed-header-manifest.json.
* media/media-source/content/test-vp8-malformed-header.webm: Renamed from LayoutTests/platform/mac-bigsur/media/media-source/content/test-vp8-malformed-header.webm.
* media/media-source/media-source-webm-vp8-malformed-header-expected.txt: Renamed from LayoutTests/platform/mac-bigsur/media/media-source/media-source-webm-vp8-malformed-header-expected.txt.
* media/media-source/media-source-webm-vp8-malformed-header.html: Renamed from LayoutTests/platform/mac-bigsur/media/media-source/media-source-webm-vp8-malformed-header.html.
* media/media-webm-no-duration-expected.txt: Renamed from LayoutTests/platform/mac-bigsur/media/media-webm-no-duration-expected.txt.
* media/media-webm-no-duration.html: Renamed from LayoutTests/platform/mac-bigsur/media/media-webm-no-duration.html.
* platform/mac-bigsur-wk1/editing/mac/attributed-string/anchor-element-expected.txt: Copied from LayoutTests/platform/mac-wk1/editing/mac/attributed-string/anchor-element-expected.txt.
* platform/mac-bigsur-wk1/editing/mac/attributed-string/attrib-string-colors-with-color-filter-expected.txt: Copied from LayoutTests/platform/mac-wk1/editing/mac/attributed-string/attrib-string-colors-with-color-filter-expected.txt.
* platform/mac-bigsur-wk1/editing/mac/attributed-string/attribute-string-for-copy-with-color-filter-expected.txt: Copied from LayoutTests/platform/mac-wk1/editing/mac/attributed-string/attribute-string-for-copy-with-color-filter-expected.txt.
* platform/mac-bigsur-wk1/editing/mac/attributed-string/attributed-string-across-shadow-boundaries-1-expected.txt: Copied from LayoutTests/platform/mac-wk1/editing/mac/attributed-string/attributed-string-across-shadow-boundaries-1-expected.txt.
* platform/mac-bigsur-wk1/editing/mac/attributed-string/attributed-string-across-shadow-boundaries-2-expected.txt: Copied from LayoutTests/platform/mac-wk1/editing/mac/attributed-string/attributed-string-across-shadow-boundaries-2-expected.txt.
* platform/mac-bigsur-wk1/editing/mac/attributed-string/attributed-string-across-shadow-boundaries-3-expected.txt: Copied from LayoutTests/platform/mac-wk1/editing/mac/attributed-string/attributed-string-across-shadow-boundaries-3-expected.txt.
* platform/mac-bigsur-wk1/editing/mac/attributed-string/attributed-string-across-shadow-boundaries-4-expected.txt: Copied from LayoutTests/platform/mac-wk1/editing/mac/attributed-string/attributed-string-across-shadow-boundaries-4-expected.txt.
* platform/mac-bigsur-wk1/editing/mac/attributed-string/attributed-string-across-shadow-boundaries-5-expected.txt: Copied from LayoutTests/platform/mac-wk1/editing/mac/attributed-string/attributed-string-across-shadow-boundaries-5-expected.txt.
* platform/mac-bigsur-wk1/editing/mac/attributed-string/attributed-string-across-shadow-boundaries-with-style-1-expected.txt: Copied from LayoutTests/platform/mac-wk1/editing/mac/attributed-string/attributed-string-across-shadow-boundaries-with-style-1-expected.txt.
* platform/mac-bigsur-wk1/editing/mac/attributed-string/attributed-string-across-shadow-boundaries-with-style-2-expected.txt: Copied from LayoutTests/platform/mac-wk1/editing/mac/attributed-string/attributed-string-across-shadow-boundaries-with-style-2-expected.txt.
* platform/mac-bigsur-wk1/editing/mac/attributed-string/attributed-string-for-typing-expected.txt: Copied from LayoutTests/platform/mac-wk1/editing/mac/attributed-string/attributed-string-for-typing-expected.txt.
* platform/mac-bigsur-wk1/editing/mac/attributed-string/attributed-string-for-typing-with-color-filter-expected.txt: Copied from LayoutTests/platform/mac-wk1/editing/mac/attributed-string/attributed-string-for-typing-with-color-filter-expected.txt.
* platform/mac-bigsur-wk1/editing/mac/attributed-string/basic-expected.txt: Copied from LayoutTests/platform/mac-wk1/editing/mac/attributed-string/basic-expected.txt.
* platform/mac-bigsur-wk1/editing/mac/attributed-string/comment-cdata-section-expected.txt: Copied from LayoutTests/platform/mac-wk1/editing/mac/attributed-string/comment-cdata-section-expected.txt.
* platform/mac-bigsur-wk1/editing/mac/attributed-string/font-size-expected.txt: Copied from LayoutTests/platform/mac-wk1/editing/mac/attributed-string/font-size-expected.txt.
* platform/mac-bigsur-wk1/editing/mac/attributed-string/font-style-variant-effect-expected.txt: Copied from LayoutTests/platform/mac-wk1/editing/mac/attributed-string/font-style-variant-effect-expected.txt.
* platform/mac-bigsur-wk1/editing/mac/attributed-string/font-weight-expected.txt: Copied from LayoutTests/platform/mac-wk1/editing/mac/attributed-string/font-weight-expected.txt.
* platform/mac-bigsur-wk1/editing/mac/attributed-string/letter-spacing-expected.txt: Copied from LayoutTests/platform/mac-wk1/editing/mac/attributed-string/letter-spacing-expected.txt.
* platform/mac-bigsur-wk1/editing/mac/attributed-string/text-decorations-expected.txt: Copied from LayoutTests/platform/mac-wk1/editing/mac/attributed-string/text-decorations-expected.txt.
* platform/mac-bigsur-wk1/editing/mac/attributed-string/vertical-align-expected.txt: Copied from LayoutTests/platform/mac-wk1/editing/mac/attributed-string/vertical-align-expected.txt.
* platform/mac-bigsur-wk1/fast/scrolling/latching/iframe-latch-small-deltas-expected.txt: Copied from LayoutTests/platform/mac-wk1/fast/scrolling/latching/iframe-latch-small-deltas-expected.txt.
* platform/mac-bigsur-wk2/fast/events/contextmenu-lookup-action-for-image-expected.txt: Added.
* platform/mac-bigsur-wk2/http/tests/security/mixedContent/websocket/insecure-websocket-in-iframe-expected.txt: Added.
* platform/mac-bigsur-wk2/http/tests/security/mixedContent/websocket/insecure-websocket-in-main-frame-expected.txt: Added.
* platform/mac-bigsur-wk2/imported/w3c/web-platform-tests/media-source/mediasource-invalid-codec-expected.txt: Added.
* platform/mac-bigsur-wk2/imported/w3c/web-platform-tests/service-workers/service-worker/websocket-in-service-worker.https-expected.txt: Added.
* platform/mac-bigsur-wk2/imported/w3c/web-platform-tests/service-workers/service-worker/websocket.https-expected.txt: Added.
* platform/mac-bigsur-wk2/imported/w3c/web-platform-tests/websockets/Send-65K-data.any-expected.txt: Added.
* platform/mac-bigsur-wk2/imported/w3c/web-platform-tests/websockets/Send-binary-65K-arraybuffer.any-expected.txt: Added.
* platform/mac-bigsur-wk2/imported/w3c/web-platform-tests/websockets/Send-binary-arraybuffer.any-expected.txt: Added.
* platform/mac-bigsur-wk2/imported/w3c/web-platform-tests/websockets/Send-data.any-expected.txt: Added.
* platform/mac-bigsur-wk2/imported/w3c/web-platform-tests/websockets/Send-paired-surrogates.any-expected.txt: Added.
* platform/mac-bigsur-wk2/imported/w3c/web-platform-tests/websockets/basic-auth.any-expected.txt: Added.
* platform/mac-bigsur-wk2/imported/w3c/web-platform-tests/websockets/basic-auth.any.worker-expected.txt: Added.
* platform/mac-bigsur-wk2/imported/w3c/web-platform-tests/websockets/interfaces/WebSocket/bufferedAmount/bufferedAmount-arraybuffer-expected.txt: Added.
* platform/mac-bigsur-wk2/imported/w3c/web-platform-tests/websockets/interfaces/WebSocket/bufferedAmount/bufferedAmount-blob-expected.txt: Added.
* platform/mac-bigsur-wk2/imported/w3c/web-platform-tests/websockets/interfaces/WebSocket/bufferedAmount/bufferedAmount-getting-expected.txt: Added.
* platform/mac-bigsur-wk2/imported/w3c/web-platform-tests/websockets/interfaces/WebSocket/bufferedAmount/bufferedAmount-large-expected.txt: Added.
* platform/mac-bigsur-wk2/imported/w3c/web-platform-tests/websockets/interfaces/WebSocket/bufferedAmount/bufferedAmount-unicode-expected.txt: Added.
* platform/mac-bigsur-wk2/imported/w3c/web-platform-tests/websockets/remove-own-iframe-during-onerror.window-expected.txt: Added.
* platform/mac-bigsur/fast/forms/button-sizes-expected.txt: Copied from LayoutTests/platform/mac/fast/forms/button-sizes-expected.txt.
* platform/mac-bigsur/fast/forms/input-appearance-spinbutton-expected.txt: Copied from LayoutTests/platform/mac/fast/forms/input-appearance-spinbutton-expected.txt.
* platform/mac-bigsur/fast/forms/number/number-appearance-spinbutton-disabled-readonly-expected.txt: Copied from LayoutTests/platform/mac/fast/forms/number/number-appearance-spinbutton-disabled-readonly-expected.txt.
* platform/mac-bigsur/fast/forms/select/optgroup-rendering-expected.txt: Copied from LayoutTests/platform/mac/fast/forms/select/optgroup-rendering-expected.txt.
* platform/mac-bigsur/fast/text/basic/014-expected.txt: Copied from LayoutTests/platform/mac/fast/text/basic/014-expected.txt.
* platform/mac-bigsur/fast/text/capitalize-boundaries-expected.txt: Copied from LayoutTests/platform/mac/fast/text/capitalize-boundaries-expected.txt.
* platform/mac-bigsur/fast/text/hyphenate-avoid-orphaned-word-expected.txt: Copied from LayoutTests/platform/mac/fast/text/hyphenate-avoid-orphaned-word-expected.txt.
* platform/mac-bigsur/fast/text/hyphenate-character-expected.txt: Copied from LayoutTests/platform/mac/fast/text/hyphenate-character-expected.txt.
* platform/mac-bigsur/fast/text/hyphenate-first-word-expected.txt: Copied from LayoutTests/platform/mac/fast/text/hyphenate-first-word-expected.txt.
* platform/mac-bigsur/fast/text/hyphenate-limit-before-after-expected.txt: Copied from LayoutTests/platform/mac/fast/text/hyphenate-limit-before-after-expected.txt.
* platform/mac-bigsur/fast/text/hyphenate-limit-lines-expected.txt: Copied from LayoutTests/platform/mac/fast/text/hyphenate-limit-lines-expected.txt.
* platform/mac-bigsur/fast/text/hyphenate-locale-expected.txt: Copied from LayoutTests/platform/mac/fast/text/hyphenate-locale-expected.txt.
* platform/mac-bigsur/fast/text/hyphens-expected.txt: Copied from LayoutTests/platform/mac/fast/text/hyphens-expected.txt.
* platform/mac-bigsur/fast/text/midword-break-after-breakable-char-expected.txt: Copied from LayoutTests/platform/mac/fast/text/midword-break-after-breakable-char-expected.txt.
* platform/mac-bigsur/inspector/css/get-system-fonts-expected.txt: Added.
* platform/mac-bigsur/media/media-source/mediasource-addsourcebuffer-expected.txt: Added.
* platform/mac-bigsur/media/media-source/mediasource-invalid-codec-expected.txt: Added.
* platform/mac-bigsur/platform/mac/fast/loader/file-url-mimetypes-3-expected.txt: Added.
* platform/mac-bigsur/platform/mac/fast/text/international/Geeza-Pro-vertical-metrics-adjustment-expected.txt: Added.
* platform/mac-catalina-wk1/editing/mac/attributed-string/anchor-element-expected.txt: Copied from LayoutTests/platform/mac-wk1/editing/mac/attributed-string/anchor-element-expected.txt.
* platform/mac-catalina-wk1/editing/mac/attributed-string/attrib-string-colors-with-color-filter-expected.txt: Copied from LayoutTests/platform/mac-wk1/editing/mac/attributed-string/attrib-string-colors-with-color-filter-expected.txt.
* platform/mac-catalina-wk1/editing/mac/attributed-string/attribute-string-for-copy-with-color-filter-expected.txt: Copied from LayoutTests/platform/mac-wk1/editing/mac/attributed-string/attribute-string-for-copy-with-color-filter-expected.txt.
* platform/mac-catalina-wk1/editing/mac/attributed-string/attributed-string-across-shadow-boundaries-1-expected.txt: Copied from LayoutTests/platform/mac-wk1/editing/mac/attributed-string/attributed-string-across-shadow-boundaries-1-expected.txt.
* platform/mac-catalina-wk1/editing/mac/attributed-string/attributed-string-across-shadow-boundaries-2-expected.txt: Copied from LayoutTests/platform/mac-wk1/editing/mac/attributed-string/attributed-string-across-shadow-boundaries-2-expected.txt.
* platform/mac-catalina-wk1/editing/mac/attributed-string/attributed-string-across-shadow-boundaries-3-expected.txt: Copied from LayoutTests/platform/mac-wk1/editing/mac/attributed-string/attributed-string-across-shadow-boundaries-3-expected.txt.
* platform/mac-catalina-wk1/editing/mac/attributed-string/attributed-string-across-shadow-boundaries-4-expected.txt: Copied from LayoutTests/platform/mac-wk1/editing/mac/attributed-string/attributed-string-across-shadow-boundaries-4-expected.txt.
* platform/mac-catalina-wk1/editing/mac/attributed-string/attributed-string-across-shadow-boundaries-5-expected.txt: Copied from LayoutTests/platform/mac-wk1/editing/mac/attributed-string/attributed-string-across-shadow-boundaries-5-expected.txt.
* platform/mac-catalina-wk1/editing/mac/attributed-string/attributed-string-across-shadow-boundaries-with-style-1-expected.txt: Copied from LayoutTests/platform/mac-wk1/editing/mac/attributed-string/attributed-string-across-shadow-boundaries-with-style-1-expected.txt.
* platform/mac-catalina-wk1/editing/mac/attributed-string/attributed-string-across-shadow-boundaries-with-style-2-expected.txt: Copied from LayoutTests/platform/mac-wk1/editing/mac/attributed-string/attributed-string-across-shadow-boundaries-with-style-2-expected.txt.
* platform/mac-catalina-wk1/editing/mac/attributed-string/attributed-string-for-typing-expected.txt: Copied from LayoutTests/platform/mac-wk1/editing/mac/attributed-string/attributed-string-for-typing-expected.txt.
* platform/mac-catalina-wk1/editing/mac/attributed-string/attributed-string-for-typing-with-color-filter-expected.txt: Copied from LayoutTests/platform/mac-wk1/editing/mac/attributed-string/attributed-string-for-typing-with-color-filter-expected.txt.
* platform/mac-catalina-wk1/editing/mac/attributed-string/basic-expected.txt: Copied from LayoutTests/platform/mac-wk1/editing/mac/attributed-string/basic-expected.txt.
* platform/mac-catalina-wk1/editing/mac/attributed-string/comment-cdata-section-expected.txt: Copied from LayoutTests/platform/mac-wk1/editing/mac/attributed-string/comment-cdata-section-expected.txt.
* platform/mac-catalina-wk1/editing/mac/attributed-string/font-size-expected.txt: Copied from LayoutTests/platform/mac-wk1/editing/mac/attributed-string/font-size-expected.txt.
* platform/mac-catalina-wk1/editing/mac/attributed-string/font-style-variant-effect-expected.txt: Copied from LayoutTests/platform/mac-wk1/editing/mac/attributed-string/font-style-variant-effect-expected.txt.
* platform/mac-catalina-wk1/editing/mac/attributed-string/font-weight-expected.txt: Copied from LayoutTests/platform/mac-wk1/editing/mac/attributed-string/font-weight-expected.txt.
* platform/mac-catalina-wk1/editing/mac/attributed-string/letter-spacing-expected.txt: Copied from LayoutTests/platform/mac-wk1/editing/mac/attributed-string/letter-spacing-expected.txt.
* platform/mac-catalina-wk1/editing/mac/attributed-string/text-decorations-expected.txt: Copied from LayoutTests/platform/mac-wk1/editing/mac/attributed-string/text-decorations-expected.txt.
* platform/mac-catalina-wk1/editing/mac/attributed-string/vertical-align-expected.txt: Copied from LayoutTests/platform/mac-wk1/editing/mac/attributed-string/vertical-align-expected.txt.
* platform/mac-catalina-wk1/fast/scrolling/latching/iframe-latch-small-deltas-expected.txt: Copied from LayoutTests/platform/mac-wk1/fast/scrolling/latching/iframe-latch-small-deltas-expected.txt.
* platform/mac-catalina-wk2/fast/events/contextmenu-lookup-action-for-image-expected.txt: Added.
* platform/mac-catalina-wk2/http/tests/security/mixedContent/websocket/insecure-websocket-in-iframe-expected.txt: Added.
* platform/mac-catalina-wk2/http/tests/security/mixedContent/websocket/insecure-websocket-in-main-frame-expected.txt: Added.
* platform/mac-catalina-wk2/imported/w3c/web-platform-tests/media-source/mediasource-invalid-codec-expected.txt: Added.
* platform/mac-catalina-wk2/imported/w3c/web-platform-tests/service-workers/service-worker/websocket-in-service-worker.https-expected.txt: Added.
* platform/mac-catalina-wk2/imported/w3c/web-platform-tests/service-workers/service-worker/websocket.https-expected.txt: Added.
* platform/mac-catalina-wk2/imported/w3c/web-platform-tests/websockets/Send-65K-data.any-expected.txt: Added.
* platform/mac-catalina-wk2/imported/w3c/web-platform-tests/websockets/Send-binary-65K-arraybuffer.any-expected.txt: Added.
* platform/mac-catalina-wk2/imported/w3c/web-platform-tests/websockets/Send-binary-arraybuffer.any-expected.txt: Added.
* platform/mac-catalina-wk2/imported/w3c/web-platform-tests/websockets/Send-data.any-expected.txt: Added.
* platform/mac-catalina-wk2/imported/w3c/web-platform-tests/websockets/Send-paired-surrogates.any-expected.txt: Added.
* platform/mac-catalina-wk2/imported/w3c/web-platform-tests/websockets/basic-auth.any-expected.txt: Added.
* platform/mac-catalina-wk2/imported/w3c/web-platform-tests/websockets/basic-auth.any.worker-expected.txt: Added.
* platform/mac-catalina-wk2/imported/w3c/web-platform-tests/websockets/interfaces/WebSocket/bufferedAmount/bufferedAmount-arraybuffer-expected.txt: Added.
* platform/mac-catalina-wk2/imported/w3c/web-platform-tests/websockets/interfaces/WebSocket/bufferedAmount/bufferedAmount-blob-expected.txt: Added.
* platform/mac-catalina-wk2/imported/w3c/web-platform-tests/websockets/interfaces/WebSocket/bufferedAmount/bufferedAmount-getting-expected.txt: Added.
* platform/mac-catalina-wk2/imported/w3c/web-platform-tests/websockets/interfaces/WebSocket/bufferedAmount/bufferedAmount-large-expected.txt: Added.
* platform/mac-catalina-wk2/imported/w3c/web-platform-tests/websockets/interfaces/WebSocket/bufferedAmount/bufferedAmount-unicode-expected.txt: Added.
* platform/mac-catalina-wk2/imported/w3c/web-platform-tests/websockets/remove-own-iframe-during-onerror.window-expected.txt: Added.
* platform/mac-catalina/fast/text/basic/014-expected.txt: Copied from LayoutTests/platform/mac/fast/text/basic/014-expected.txt.
* platform/mac-catalina/fast/text/capitalize-boundaries-expected.txt: Copied from LayoutTests/platform/mac/fast/text/capitalize-boundaries-expected.txt.
* platform/mac-catalina/fast/text/hyphenate-avoid-orphaned-word-expected.txt: Copied from LayoutTests/platform/mac/fast/text/hyphenate-avoid-orphaned-word-expected.txt.
* platform/mac-catalina/fast/text/hyphenate-character-expected.txt: Copied from LayoutTests/platform/mac/fast/text/hyphenate-character-expected.txt.
* platform/mac-catalina/fast/text/hyphenate-first-word-expected.txt: Copied from LayoutTests/platform/mac/fast/text/hyphenate-first-word-expected.txt.
* platform/mac-catalina/fast/text/hyphenate-limit-before-after-expected.txt: Copied from LayoutTests/platform/mac/fast/text/hyphenate-limit-before-after-expected.txt.
* platform/mac-catalina/fast/text/hyphenate-limit-lines-expected.txt: Copied from LayoutTests/platform/mac/fast/text/hyphenate-limit-lines-expected.txt.
* platform/mac-catalina/fast/text/hyphenate-locale-expected.txt: Copied from LayoutTests/platform/mac/fast/text/hyphenate-locale-expected.txt.
* platform/mac-catalina/fast/text/hyphens-expected.txt: Copied from LayoutTests/platform/mac/fast/text/hyphens-expected.txt.
* platform/mac-catalina/fast/text/midword-break-after-breakable-char-expected.txt: Copied from LayoutTests/platform/mac/fast/text/midword-break-after-breakable-char-expected.txt.
* platform/mac-catalina/imported/w3c/web-platform-tests/media-source/mediasource-addsourcebuffer-expected.txt: Added.
* platform/mac-catalina/imported/w3c/web-platform-tests/media-source/mediasource-invalid-codec-expected.txt: Added.
* platform/mac-catalina/inspector/css/get-system-fonts-expected.txt: Added.
* platform/mac-catalina/platform/mac/fast/loader/file-url-mimetypes-3-expected.txt: Added.
* platform/mac-catalina/platform/mac/fast/text/international/Geeza-Pro-vertical-metrics-adjustment-expected.txt: Added.
* platform/mac-wk1/TestExpectations:
* platform/mac-wk1/editing/mac/attributed-string/anchor-element-expected.txt:
* platform/mac-wk1/editing/mac/attributed-string/attrib-string-colors-with-color-filter-expected.txt:
* platform/mac-wk1/editing/mac/attributed-string/attribute-string-for-copy-with-color-filter-expected.txt:
* platform/mac-wk1/editing/mac/attributed-string/attributed-string-across-shadow-boundaries-1-expected.txt:
* platform/mac-wk1/editing/mac/attributed-string/attributed-string-across-shadow-boundaries-2-expected.txt:
* platform/mac-wk1/editing/mac/attributed-string/attributed-string-across-shadow-boundaries-3-expected.txt:
* platform/mac-wk1/editing/mac/attributed-string/attributed-string-across-shadow-boundaries-4-expected.txt:
* platform/mac-wk1/editing/mac/attributed-string/attributed-string-across-shadow-boundaries-5-expected.txt:
* platform/mac-wk1/editing/mac/attributed-string/attributed-string-across-shadow-boundaries-with-style-1-expected.txt:
* platform/mac-wk1/editing/mac/attributed-string/attributed-string-across-shadow-boundaries-with-style-2-expected.txt:
* platform/mac-wk1/editing/mac/attributed-string/attributed-string-for-typing-expected.txt:
* platform/mac-wk1/editing/mac/attributed-string/attributed-string-for-typing-with-color-filter-expected.txt:
* platform/mac-wk1/editing/mac/attributed-string/basic-expected.txt:
* platform/mac-wk1/editing/mac/attributed-string/comment-cdata-section-expected.txt:
* platform/mac-wk1/editing/mac/attributed-string/font-size-expected.txt:
* platform/mac-wk1/editing/mac/attributed-string/font-style-variant-effect-expected.txt:
* platform/mac-wk1/editing/mac/attributed-string/font-weight-expected.txt:
* platform/mac-wk1/editing/mac/attributed-string/letter-spacing-expected.txt:
* platform/mac-wk1/editing/mac/attributed-string/text-decorations-expected.txt:
* platform/mac-wk1/editing/mac/attributed-string/vertical-align-expected.txt:
* platform/mac-wk1/fast/scrolling/latching/iframe-latch-small-deltas-expected.txt:
* platform/mac-wk2/TestExpectations:
* platform/mac-wk2/fast/events/contextmenu-lookup-action-for-image-expected.txt: Added.
* platform/mac-wk2/http/tests/security/mixedContent/websocket/insecure-websocket-in-iframe-expected.txt: Added.
* platform/mac-wk2/http/tests/security/mixedContent/websocket/insecure-websocket-in-main-frame-expected.txt: Added.
* platform/mac-wk2/imported/w3c/web-platform-tests/media-source/mediasource-invalid-codec-expected.txt: Added.
* platform/mac-wk2/imported/w3c/web-platform-tests/service-workers/service-worker/websocket-in-service-worker.https-expected.txt: Added.
* platform/mac-wk2/imported/w3c/web-platform-tests/service-workers/service-worker/websocket.https-expected.txt: Added.
* platform/mac-wk2/imported/w3c/web-platform-tests/websockets/Send-65K-data.any-expected.txt: Added.
* platform/mac-wk2/imported/w3c/web-platform-tests/websockets/Send-binary-65K-arraybuffer.any-expected.txt: Added.
* platform/mac-wk2/imported/w3c/web-platform-tests/websockets/Send-binary-arraybuffer.any-expected.txt: Added.
* platform/mac-wk2/imported/w3c/web-platform-tests/websockets/Send-data.any-expected.txt: Added.
* platform/mac-wk2/imported/w3c/web-platform-tests/websockets/Send-paired-surrogates.any-expected.txt: Added.
* platform/mac-wk2/imported/w3c/web-platform-tests/websockets/basic-auth.any-expected.txt: Added.
* platform/mac-wk2/imported/w3c/web-platform-tests/websockets/basic-auth.any.worker-expected.txt: Added.
* platform/mac-wk2/imported/w3c/web-platform-tests/websockets/interfaces/WebSocket/bufferedAmount/bufferedAmount-arraybuffer-expected.txt: Added.
* platform/mac-wk2/imported/w3c/web-platform-tests/websockets/interfaces/WebSocket/bufferedAmount/bufferedAmount-blob-expected.txt: Added.
* platform/mac-wk2/imported/w3c/web-platform-tests/websockets/interfaces/WebSocket/bufferedAmount/bufferedAmount-getting-expected.txt: Added.
* platform/mac-wk2/imported/w3c/web-platform-tests/websockets/interfaces/WebSocket/bufferedAmount/bufferedAmount-large-expected.txt: Added.
* platform/mac-wk2/imported/w3c/web-platform-tests/websockets/interfaces/WebSocket/bufferedAmount/bufferedAmount-unicode-expected.txt: Added.
* platform/mac-wk2/imported/w3c/web-platform-tests/websockets/remove-own-iframe-during-onerror.window-expected.txt: Added.
* platform/mac/TestExpectations:
* platform/mac/fast/forms/button-sizes-expected.txt:
* platform/mac/fast/forms/input-appearance-spinbutton-expected.txt:
* platform/mac/fast/forms/number/number-appearance-spinbutton-disabled-readonly-expected.txt:
* platform/mac/fast/forms/select/optgroup-rendering-expected.txt:
* platform/mac/fast/text/basic/014-expected.txt:
* platform/mac/fast/text/capitalize-boundaries-expected.txt:
* platform/mac/fast/text/hyphenate-avoid-orphaned-word-expected.txt:
* platform/mac/fast/text/hyphenate-character-expected.txt:
* platform/mac/fast/text/hyphenate-first-word-expected.txt:
* platform/mac/fast/text/hyphenate-limit-before-after-expected.txt:
* platform/mac/fast/text/hyphenate-limit-lines-expected.txt:
* platform/mac/fast/text/hyphenate-locale-expected.txt:
* platform/mac/fast/text/hyphens-expected.txt:
* platform/mac/fast/text/midword-break-after-breakable-char-expected.txt:
* platform/mac/inspector/css/get-system-fonts-expected.txt: Added.
* platform/mac/media/media-source/media-source-webm-vp8-malformed-header-expected.png: Added.
* platform/mac/platform/mac/fast/loader/file-url-mimetypes-3-expected.txt: Added.


Canonical link: https://commits.webkit.org/239884@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280196 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-07-22 20:59:06 +00:00
Jean-Yves Avenard ed1ef371c5 [MSE] sequence mode is broken if GPU Process is enabled
https://bugs.webkit.org/show_bug.cgi?id=227864
<rdar://problem/80445041>

Reviewed by Jer Noble.

Source/WebCore:

When the source buffer's mode is set to sequence, the timestampOffset attribute
should be updated after each appendBuffer operation. However, when the GPU process
is enabled, the timestampOffset calculations are all done in the GPU process and
its result wasn't communicated back to the WebContent process leading its value
to always be 0 on read.
Fly-by fix: the timestamp offset calculation was incorrect, per spec
https://w3c.github.io/media-source/#sourcebuffer-coded-frame-processing
step 3.5.8.3.1 we read:
// Set timestampOffset equal to group start timestamp - presentation timestamp.
but the code did otherwise.

Test: media/media-source/media-mp4-h264-sequence-mode.html

* platform/graphics/SourceBufferPrivate.cpp:
(WebCore::SourceBufferPrivate::didReceiveSample): Offset m_timestampOffset by
the sample's presentation timestamp

Source/WebKit:

 When the source buffer's mode is set to sequence, the timestampOffset attribute
should be updated after each appendBuffer operation. However, when the GPU process
is enabled, the timestampOffset calculations are all done in the GPU process and
its result wasn't communicated back to the WebContent process leading its value
to always be 0 on read.

* GPUProcess/media/RemoteSourceBufferProxy.cpp:
(WebKit::RemoteSourceBufferProxy::sourceBufferPrivateAppendComplete): Add value of
the potentially updated timestamp offset back to the content process.
* WebProcess/GPU/media/SourceBufferPrivateRemote.cpp:
(WebKit::SourceBufferPrivateRemote::sourceBufferPrivateAppendComplete):
* WebProcess/GPU/media/SourceBufferPrivateRemote.h:
* WebProcess/GPU/media/SourceBufferPrivateRemote.messages.in: Add extra timestampOffset
parameter.

LayoutTests:

Note: we had tests checking on the correctness of the operation; however it's
using a mock SourceBuffer which doesn't run in the GPU process. Doing bug 225367
should be a priority so we get better code coverage and such bugs don't skip
under the radar.
To get around this issue, we write a new test that uses a mp4 and a h264 video track.

* media/media-source/media-mp4-h264-sequence-mode-expected.txt: Added.
* media/media-source/media-mp4-h264-sequence-mode.html: Added.


Canonical link: https://commits.webkit.org/239716@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@279973 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-07-16 02:07:47 +00:00
Jean-Yves Avenard c97efacbca SourceBuffer.abort() doesn't go back to state WAITING_FOR_SEGMENT properly
https://bugs.webkit.org/show_bug.cgi?id=227559
<rdar://problem/79996056>

Reviewed by Jer Noble.

Source/WebCore:

Per spec, calling sourcebuffer.abort method should allow you to add a new segment
immediately after, as abort moves the append state back to WAITING_FOR_SEGMENT.
A segment can be either an init segment or a media segment.
We used to discard all further content until an init segment was encountered.
This could be problematic due to the typical use case of abort:
1- Seek to a location
2- Append a partial media segment long enough to finish seeking and display the
 new content at the new position.
If multiple seeks were done in rapid succession, abort() is called right after
before starting the new seek so that we can add the new segment, regardless of what
was appended before.
YouTube applies a workaround for Safari where it will always append an init segment
after calling abort, this is different to what they do with Firefox (and likely Chrome).
To be able to resume after appending a partial media segment we must ensure that the
SourceBufferParser is always left in a sane context, and not be interrupted at some
random points. The abort() call used to interrupt the buffer parsing on the fly and
then reset things which would require a new init segment to restart.
Instead we always fully parse the pending buffer received befofe the call to abort
and drop all demuxed samples.
The SourceBufferParserAVFObjC could already properly deal with discontinuity unlike
SourceBufferParserWebM.
To ensure that buffers sent after the call to abort() are only ever processed once
the pending ones have been parsed, and in order to avoid having blocking calls
we play with the order in which tasks are scheduled.

Fly-by fixes:
- The SourceBufferParser handle two type of parser: SourceBufferParser and the
platform specific AVStreamDataParser. Rename the accessor method to more clearly
differentate which parser we are dealing with.
- The SourceBufferParserWebM and SourceBufferPrivateAVFObjC used different task dispatching
mechanisms. We make them both share the same one now found in the base class.
- If SourceBufferPrivateAVFObjC::m_hasPendingAppendCompletedCallback had been set prior an
abort() it wouldn't have been reset, causing the need for a new init segment.
- If abort() had been called while samples were pending, the source buffer content was
undefined if timestamp offset or append windows start/end were changed immediately after.
- When an error occurs during the Segment Parser Loop, we should abort and run the append
error algorithm. We instead fired an error event for each sample found in the media segment.
In a debug built it was have asserted. We can't actually abort, so instead we ignore all
further samples once an error is encountered.

Tests: media/media-source/media-mp4-h264-partial-abort.html
       media/media-source/media-webm-opus-partial-abort.html

* platform/graphics/avfoundation/objc/CDMSessionAVContentKeySession.mm:
(WebCore::CDMSessionAVContentKeySession::~CDMSessionAVContentKeySession): rename method.
* platform/graphics/avfoundation/objc/CDMSessionAVStreamSession.mm:
(WebCore::CDMSessionAVStreamSession::~CDMSessionAVStreamSession): rename method.
(WebCore::CDMSessionAVStreamSession::update): rename method.
* platform/graphics/avfoundation/objc/CDMSessionMediaSourceAVFObjC.mm: rename method.
(WebCore::CDMSessionMediaSourceAVFObjC::addSourceBuffer): rename method.
(WebCore::CDMSessionMediaSourceAVFObjC::removeSourceBuffer): rename method.
* platform/graphics/avfoundation/objc/SourceBufferParserAVFObjC.h: rename method, remove
now unused member.
* platform/graphics/avfoundation/objc/SourceBufferParserAVFObjC.mm:
(WebCore::SourceBufferPrivateAVFObjC::removeCodedFrames): Postpone call to ensure
we are running the remove frame algorithm once all pending frames have been processed.
(WebCore::SourceBufferParserAVFObjC::resetParserState): Remove use of m_discardSamplesUntilNextInitializationSegment.
(WebCore::SourceBufferParserAVFObjC::didParseStreamDataAsAsset): Change to base dispatch method.
(WebCore::SourceBufferParserAVFObjC::didFailToParseStreamDataWithError): Change to base dispatch method.
(WebCore::SourceBufferParserAVFObjC::didProvideMediaDataForTrackID): Change to base dispatch method.
* platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h: Rename methods. Remove no longer used
members.
* platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:
(WebCore::SourceBufferPrivateAVFObjC::~SourceBufferPrivateAVFObjC):
(WebCore::SourceBufferPrivateAVFObjC::didParseInitializationData): No longer use a Cancellable task
as we never cancel it anymore.
(WebCore::SourceBufferPrivateAVFObjC::append): re-schedule the append task immediately to ensure
that processed packets flushed on the parser queue during abort are handled in the right order on
the main thread.
(WebCore::SourceBufferPrivateAVFObjC::appendCompleted): Check that abort wasn't called since append started
to ensure that no updateend event is incorrectly fired twice.
(WebCore::SourceBufferPrivateAVFObjC::abort): Abort is now a no-op that only set the m_abortCalled member.
(WebCore::SourceBufferPrivateAVFObjC::resetParserState): Change the order of operations so that the
SourceBufferParser is only reset after it has finished processing its data.
(WebCore::SourceBufferPrivateAVFObjC::destroyStreamDataParser): Use rename method.
(WebCore::SourceBufferPrivateAVFObjC::removedFromMediaSource): Use rename method.
(WebCore::SourceBufferPrivateAVFObjC::streamDataParser const): Renamed method from "parser"
(WebCore::SourceBufferPrivateAVFObjC::attemptToDecrypt): Use renamed method.
* platform/graphics/cocoa/SourceBufferParser.cpp:
(WebCore::callOnMainThreadCallback): Move dispatch method from SourceBufferParserWebM
(WebCore::SourceBufferParser::setCallOnClientThreadCallback):
(WebCore::SourceBufferParser::SourceBufferParser):
* platform/graphics/cocoa/SourceBufferParser.h:
* platform/graphics/cocoa/SourceBufferParserWebM.cpp:
(WebCore::SourceBufferParserWebM::SourceBufferParserWebM):
(WebCore::SourceBufferParserWebM::resetParserState): Don't clear the data set by parsing
the previous init segment. Set the parsing state to waiting for a new segment if an
init segment has been fully parsed.
(WebCore::SourceBufferParserWebM::OnElementEnd):
(WebCore::SourceBufferParserWebM::OnEbml):
(WebCore::SourceBufferParserWebM::VideoTrackData::reset):
(WebCore::SourceBufferParserWebM::VideoTrackData::consumeFrameData):
(WebCore::SourceBufferParserWebM::AudioTrackData::reset):
* platform/graphics/cocoa/SourceBufferParserWebM.h:

LayoutTests:

* media/media-source/content/test-fragmented-video-manifest.json: Added.
* media/media-source/content/test-fragmented-video.mp4: Added.
* media/media-source/media-mp4-h264-partial-abort-expected.txt: Added.
* media/media-source/media-mp4-h264-partial-abort.html: Added.
* media/media-source/media-webm-opus-partial-abort-expected.txt: Added.
* media/media-source/media-webm-opus-partial-abort.html: Added.
* media/media-source/media-webm-opus-partial.html: fix title.
* media/media-source/media-webm-vorbis-partial.html: fix title.
* platform/mac/TestExpectations:


Canonical link: https://commits.webkit.org/239653@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@279904 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-07-14 05:12:26 +00:00
Truitt Savell b10ffd0526 Unreviewed, reverting r279542.
Casued 4 test crashes

Reverted changeset:

"SourceBuffer.abort() doesn't go back to state
WAITING_FOR_SEGMENT properly"
https://bugs.webkit.org/show_bug.cgi?id=227559
https://commits.webkit.org/r279542

Canonical link: https://commits.webkit.org/239440@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@279622 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-07-06 21:35:53 +00:00
Eric Carlson 4f5da1a2d4 WebAudio auto-play policy should come from top document
https://bugs.webkit.org/show_bug.cgi?id=227593
rdar://76920375

Reviewed by Chris Dumez.

Source/WebCore:

Tests: media/auto-play-video-in-about-blank-iframe.html
       media/auto-play-web-audio-in-about-blank-iframe.html

* Modules/webaudio/AudioContext.cpp:
(WebCore::AudioContext::constructCommon): Get auto-play policy from document()->topDocument().

* testing/Internals.cpp:
(WebCore::Internals::setDocumentAutoplayPolicy): New method to test auto-play policy.
* testing/Internals.h:
* testing/Internals.idl:

LayoutTests:

* media/auto-play-video-in-about-blank-iframe-expected.txt: Added.
* media/auto-play-video-in-about-blank-iframe.html: Added.
* media/auto-play-web-audio-in-about-blank-iframe-expected.txt: Added.
* media/auto-play-web-audio-in-about-blank-iframe.html: Added.

* media/video-test.js:
(waitForEventWithTimeout): Return event.


Canonical link: https://commits.webkit.org/239386@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@279550 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-07-04 16:53:08 +00:00
Dean Jackson e5168936a7 Move BottomControlsBarHeight and InsideMargin to be computed at runtime
https://bugs.webkit.org/show_bug.cgi?id=227505
<rdar://problem/79932256>

Reviewed by Devin Rousso.

Rather than having two JS constants that have to be kept in sync
with CSS, simply retrieve the value from the computed style.

No change in behaviour.

* Modules/modern-media-controls/controls/inline-media-controls.js:
(InlineMediaControls.prototype.layout):
* Modules/modern-media-controls/controls/media-controls.css:
(:host(audio), :host(video.media-document.audio), *):
* Modules/modern-media-controls/controls/layout-node.js: Add two helpers to
retrieve computed style values.

Canonical link: https://commits.webkit.org/239383@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@279547 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-07-03 21:29:20 +00:00
Jean-Yves Avenard 5713fc6614 SourceBuffer.abort() doesn't go back to state WAITING_FOR_SEGMENT properly
https://bugs.webkit.org/show_bug.cgi?id=227559
<rdar://problem/79996056>

Reviewed by Eric Carlson.

Source/WebCore:

Per spec, calling sourcebuffer.abort method should allow you to add a new segment
immediately after, as abort moves the append state back to WAITING_FOR_SEGMENT.
A segment can be either an init segment or a media segment.
We used to discard all further content until an init segment was encountered.
This could be problematic due to the typical use case of abort:
1- Seek to a location
2- Append a partial media segment long enough to finish seeking and display the
 new content at the new position.
If multiple seeks were done in rapid succession, abort() is called right after
before starting the new seek so that we can add the new segment, regardless of what
was appended before.
YouTube applies a workaround for Safari where it will always append an init segment
after calling abort, this is different to what they do with Firefox (and likely Chrome).
To be able to resume after appending a partial media segment we must ensure that the
SourceBufferParser is always left in a sane context, and not be interrupted at some
random points. The abort() call used to interrupt the buffer parsing on the fly and
then reset things which would require a new init segment to restart.
Instead we always fully parse the pending buffer received befofe the call to abort.
The SourceBufferParserAVFObjC could already properly deal with discontinuity unlike
SourceBufferParserWebM.
To ensure that buffers sent after the call to abort() are only ever processed once
the pending ones have been parsed, and in order to avoid having blocking calls
we play with the order in which tasks are scheduled.

Fly-by fixes:
- The SourceBufferParser handle two types of parser: SourceBufferParser and the
platform specific AVStreamDataParser. Rename the accessor method to more clearly
differentate which parser we are dealing with.
- The SourceBufferParserWebM and SourceBufferPrivateAVFObjC used different task dispatching
mechanisms. We make them both share the same one now found in the base class.

Tests: media/media-source/media-mp4-h264-partial-abort.html
       media/media-source/media-webm-opus-partial-abort.html

* platform/graphics/avfoundation/objc/CDMSessionAVContentKeySession.mm:
(WebCore::CDMSessionAVContentKeySession::~CDMSessionAVContentKeySession): rename method.
* platform/graphics/avfoundation/objc/CDMSessionAVStreamSession.mm:
(WebCore::CDMSessionAVStreamSession::~CDMSessionAVStreamSession): rename method.
(WebCore::CDMSessionAVStreamSession::update): rename method.
* platform/graphics/avfoundation/objc/CDMSessionMediaSourceAVFObjC.mm: rename method.
(WebCore::CDMSessionMediaSourceAVFObjC::addSourceBuffer): rename method.
(WebCore::CDMSessionMediaSourceAVFObjC::removeSourceBuffer): rename method.
* platform/graphics/avfoundation/objc/SourceBufferParserAVFObjC.h: rename method, remove
now unused member.
* platform/graphics/avfoundation/objc/SourceBufferParserAVFObjC.mm:
(WebCore::SourceBufferPrivateAVFObjC::removeCodedFrames): Postpone call to ensure
we are running the remove frame algorithm once all pending frames have been processed.
(WebCore::SourceBufferParserAVFObjC::resetParserState): Remove use of m_discardSamplesUntilNextInitializationSegment.
(WebCore::SourceBufferParserAVFObjC::didParseStreamDataAsAsset): Change to base dispatch method.
(WebCore::SourceBufferParserAVFObjC::didFailToParseStreamDataWithError): Change to base dispatch method.
(WebCore::SourceBufferParserAVFObjC::didProvideMediaDataForTrackID): Change to base dispatch method.
* platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h: Rename methods. Remove no longer used
members.
* platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:
(WebCore::SourceBufferPrivateAVFObjC::~SourceBufferPrivateAVFObjC):
(WebCore::SourceBufferPrivateAVFObjC::didParseInitializationData): No longer use a Cancellable task
as we never cancel it anymore.
(WebCore::SourceBufferPrivateAVFObjC::append): re-schedule the append task immediately to ensure
that processed packets flushed on the parser queue during abort are handled in the right order on
the main thread.
(WebCore::SourceBufferPrivateAVFObjC::appendCompleted): Check that abort wasn't called since append started
to ensure that no updateend event is incorrectly fired twice.
(WebCore::SourceBufferPrivateAVFObjC::abort): Abort is now a no-op that only set the m_abortCalled member.
(WebCore::SourceBufferPrivateAVFObjC::resetParserState): Change the order of operations so that the
SourceBufferParser is only reset after it has finished processing its data.
(WebCore::SourceBufferPrivateAVFObjC::destroyStreamDataParser): Use rename method.
(WebCore::SourceBufferPrivateAVFObjC::removedFromMediaSource): Use rename method.
(WebCore::SourceBufferPrivateAVFObjC::streamDataParser const): Renamed method from "parser"
(WebCore::SourceBufferPrivateAVFObjC::attemptToDecrypt): Use renamed method.
* platform/graphics/cocoa/SourceBufferParser.cpp:
(WebCore::callOnMainThreadCallback): Move dispatch method from SourceBufferParserWebM
(WebCore::SourceBufferParser::setCallOnClientThreadCallback):
(WebCore::SourceBufferParser::SourceBufferParser):
* platform/graphics/cocoa/SourceBufferParser.h:
* platform/graphics/cocoa/SourceBufferParserWebM.cpp:
(WebCore::SourceBufferParserWebM::SourceBufferParserWebM):
(WebCore::SourceBufferParserWebM::resetParserState): Don't clear the data set by parsing
the previous init segment. Set the parsing state to waiting for a new segment if an
init segment has been fully parsed.
(WebCore::SourceBufferParserWebM::OnElementEnd):
(WebCore::SourceBufferParserWebM::OnEbml):
(WebCore::SourceBufferParserWebM::VideoTrackData::reset):
(WebCore::SourceBufferParserWebM::VideoTrackData::consumeFrameData):
(WebCore::SourceBufferParserWebM::AudioTrackData::reset):
* platform/graphics/cocoa/SourceBufferParserWebM.h:

LayoutTests:

* media/media-source/content/test-fragmented-video-manifest.json: Added.
* media/media-source/content/test-fragmented-video.mp4: Added.
* media/media-source/media-mp4-h264-partial-abort-expected.txt: Added.
* media/media-source/media-mp4-h264-partial-abort.html: Added.
* media/media-source/media-webm-opus-partial-abort-expected.txt: Added.
* media/media-source/media-webm-opus-partial-abort.html: Added.
* media/media-source/media-webm-opus-partial.html: fix title.
* media/media-source/media-webm-vorbis-partial.html: fix title.
* platform/mac/TestExpectations:


Canonical link: https://commits.webkit.org/239378@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@279542 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-07-03 07:01:52 +00:00
Commit Queue fb89cc611a Unreviewed, reverting r279487.
https://bugs.webkit.org/show_bug.cgi?id=227626

Added broken ios-wk2 test

Reverted changeset:

"WebAudio auto-play policy should come from top document"
https://bugs.webkit.org/show_bug.cgi?id=227593
https://commits.webkit.org/r279487

Canonical link: https://commits.webkit.org/239355@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@279503 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-07-02 14:45:56 +00:00
Jean-Yves Avenard e5ad37857b [Cocoa] Last few seconds of 'audio/webm; codecs=vorbis' appended to a SampleBuffer are not played
https://bugs.webkit.org/show_bug.cgi?id=226069
Source/WebCore:

rdar://79951528

Reviewed by Jer Noble.

Source/WebCore:

When parsing samples from a WebM file, the samples emitted by the parser can be very short in
duration, which is ineffecient both in storage costs in our SampleMap, as well as in decoding
CPU costs, as each sample must be fed into the decoder separately. So the parser will group
together these small samples into a larger "meta sample" with a duration no shorter than 2s.

However, at the end of a file, no more sample data will be appended, up to 2s of audio data
will not be emitted from the parser.

At the end of an append, always flush audio track data to ensure that all parsed samples are
emitted, regardless of their collective duration.

Drive-by Fixes:

- The logic to handle a partial frame was incorrect. libwebm will always progress and call
Callback's OnFrame even with partial content as soon as the frame size has been determined.
bytesRemaining actually contains how many bytes there are available to read and that the
Callback should attempt to fetch.
The Callback should then return Status::kOkPartial if the full frame hasn't been seen yet
or Status::kOkCompleted if it has. kWouldBlock indicates that we do not have information to
read. kOkPartial and kWouldBlock indicates that libwebm should
retry later to complete the current frame. All other codes indicate an error.
- createSampleBuffer() would use the entire m_packetsData to create a CMSampleBuffer, even if partial
data was read but not yet complete. Only use the fully parsed data to create the CMSampleBuffer.
When the fully parsed packets are removed from packetsData; adjust the offset of the start of the
current partial data (this was the primary cause for bug 227499 that caused the first backout)
- consumeFrameData() would only increase the size of m_packetsData when m_currentPacketSize was
unset, which would leave the buffer zeroed when partial sample data was present. Always grow
m_packetsData to be large enough to receive the read data.
- The Read() method would not return the correct number of bytes read (0) when a null destination
buffer was passed in.
- Bug 227382 - SourceBufferParserWebM::StreamingVectorReader Read() returns an incorrect value
for numActuallyRead when moving to the next segment.

Test: media/media-source/media-vorbis-partial.html
      media/media-source/media-opus-partial.html

* platform/graphics/cocoa/SourceBufferParserWebM.cpp:
(WebCore::SourceBufferParserWebM::appendData):
(WebCore::SourceBufferParserWebM::VideoTrackData::consumeFrameData):
(WebCore::SourceBufferParserWebM::VideoTrackData::createSampleBuffer):
(WebCore::SourceBufferParserWebM::AudioTrackData::consumeFrameData):
(WebCore::SourceBufferParserWebM::AudioTrackData::createSampleBuffer):
* platform/graphics/cocoa/SourceBufferParserWebM.h: Rename some members to better indicate what
they contain. Move some members to the base class as they are always used by Video and Audio.

LayoutTests:

* platform/mac/TestExpectations:
* media/media-source/content/test-vorbis-manifest.json: Added.
* media/media-source/content/test-vorbis.webm: Added.
* media/media-source/content/test-opus-manifest.json: Added.
* media/media-source/content/test-opus.webm: Added.
* media/media-source/media-vorbis-partial-expected.txt: Added.
* media/media-source/media-vorbis-partial.html: Added.
* media/media-source/media-opus-partial-expected.txt: Added.
* media/media-source/media-opus-partial.html: Added.

LayoutTests:

Reviewed by Jer Noble.

* media/media-source/content/test-vorbis-manifest.json: Added.
* media/media-source/media-vorbis-partial-expected.txt: Added.
* media/media-source/content/test-vorbis.webm: Added.
* media/media-source/content/test-opus-manifest.json: Added.
* media/media-source/media-opus-partial-expected.txt: Added.
* media/media-source/media-opus-partial.html: Added.
* media/media-source/content/test-opus.webm: Added.
* media/media-source/media-vorbis-partial.html: Added.


Canonical link: https://commits.webkit.org/239344@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@279492 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-07-02 01:08:44 +00:00
Eric Carlson 8cee0ef0ba WebAudio auto-play policy should come from top document
https://bugs.webkit.org/show_bug.cgi?id=227593
rdar://76920375

Reviewed by Chris Dumez.

Source/WebCore:

Tests: media/auto-play-video-in-about-blank-iframe.html
       media/auto-play-web-audio-in-about-blank-iframe.html

* Modules/webaudio/AudioContext.cpp:
(WebCore::AudioContext::constructCommon): Get auto-play policy from document()->topDocument().

* testing/Internals.cpp:
(WebCore::Internals::setDocumentAutoplayPolicy): New method to test auto-play policy.
* testing/Internals.h:
* testing/Internals.idl:

LayoutTests:

* media/auto-play-video-in-about-blank-iframe-expected.txt: Added.
* media/auto-play-video-in-about-blank-iframe.html: Added.
* media/auto-play-web-audio-in-about-blank-iframe-expected.txt: Added.
* media/auto-play-web-audio-in-about-blank-iframe.html: Added.

* media/video-test.js:
(waitForEventWithTimeout): Return event.


Canonical link: https://commits.webkit.org/239339@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@279487 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-07-02 00:08:31 +00:00
Ryosuke Niwa 6ba30d40a8 RemotePlayback must keep its media element alive when there is a pending activity
https://bugs.webkit.org/show_bug.cgi?id=227471
<rdar://79694015>

Reviewed by Geoffrey Garen.

Source/WebCore:

Fixed the bug that the media element's JS wrapper can be collected while there is still
a pending activity for RemotePlayback. In fact, the newly added test demonstrates that
the media element can be deleted without this patch.

This patch also introduces new extended IDL interface attribute GenerateAddOpaqueRoot
to make adding an opaque root as a part of visitChildren easy in the DOM code.

Test: media/remoteplayback-watch-availability-gc.html

* Modules/remoteplayback/RemotePlayback.cpp:
(WebCore::RemotePlayback::ownerNode const):
* Modules/remoteplayback/RemotePlayback.h:
* Modules/remoteplayback/RemotePlayback.idl:
* bindings/scripts/CodeGeneratorJS.pm:
(InstanceNeedsVisitChildren):
(GenerateImplementation):
* bindings/scripts/IDLAttributes.json:
* bindings/scripts/test/BindingTestGlobalConstructors.idl:
* bindings/scripts/test/JS/JSTestGenerateAddOpaqueRoot.cpp: Added.
(WebCore::JSTestGenerateAddOpaqueRootDOMConstructor::prototypeForStructure):
(WebCore::JSTestGenerateAddOpaqueRootDOMConstructor::initializeProperties):
(WebCore::JSTestGenerateAddOpaqueRootPrototype::finishCreation):
(WebCore::JSTestGenerateAddOpaqueRoot::JSTestGenerateAddOpaqueRoot):
(WebCore::JSTestGenerateAddOpaqueRoot::finishCreation):
(WebCore::JSTestGenerateAddOpaqueRoot::createPrototype):
(WebCore::JSTestGenerateAddOpaqueRoot::prototype):
(WebCore::JSTestGenerateAddOpaqueRoot::getConstructor):
(WebCore::JSTestGenerateAddOpaqueRoot::destroy):
(WebCore::JSC_DEFINE_CUSTOM_GETTER):
(WebCore::jsTestGenerateAddOpaqueRoot_someAttributeGetter):
(WebCore::JSTestGenerateAddOpaqueRoot::subspaceForImpl):
(WebCore::JSTestGenerateAddOpaqueRoot::visitChildrenImpl):
(WebCore::JSTestGenerateAddOpaqueRoot::analyzeHeap):
(WebCore::JSTestGenerateAddOpaqueRootOwner::isReachableFromOpaqueRoots):
(WebCore::JSTestGenerateAddOpaqueRootOwner::finalize):
(WebCore::toJSNewlyCreated):
(WebCore::toJS):
(WebCore::JSTestGenerateAddOpaqueRoot::toWrapped):
* bindings/scripts/test/JS/JSTestGenerateAddOpaqueRoot.h: Added.
(WebCore::JSTestGenerateAddOpaqueRoot::create):
(WebCore::JSTestGenerateAddOpaqueRoot::createStructure):
(WebCore::JSTestGenerateAddOpaqueRoot::subspaceFor):
(WebCore::wrapperOwner):
(WebCore::wrapperKey):
(WebCore::toJS):
(WebCore::toJSNewlyCreated):
* bindings/scripts/test/JS/JSTestGlobalObject.cpp:
(WebCore::jsTestGlobalObject_TestGenerateAddOpaqueRootConstructorGetter):
(WebCore::JSC_DEFINE_CUSTOM_GETTER):
* bindings/scripts/test/SupplementalDependencies.dep:
* bindings/scripts/test/TestGenerateAddOpaqueRoot.idl: Added.
* testing/Internals.cpp:
(WebCore::Internals::isElementAlive const):
(WebCore::Internals::mediaElementCount):
* testing/Internals.h:
* testing/Internals.idl:

LayoutTests:

Added a GC test.

* media/remoteplayback-watch-availability-gc-expected.txt: Added.
* media/remoteplayback-watch-availability-gc.html: Added.


Canonical link: https://commits.webkit.org/239299@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@279443 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-30 23:53:16 +00:00
Philippe Normand fb0a9eeb02 [GStreamer] SleepDisabler not destroyed when video playback stops
https://bugs.webkit.org/show_bug.cgi?id=219353

Patch by Philippe Normand <pnormand@igalia.com> on 2021-06-27
Reviewed by Eric Carlson.

Source/WebCore:

In GStreamer ports the SleepDisabler remained active after EOS because
HTMLMediaElement::updateSleepDisabling() was not being triggered. An explicit clean-up upon
the ended event in the media element is better than any other implicit action.

Test: media/video-ended-does-not-hold-sleep-assertion.html

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::dispatchEvent):

LayoutTests:

* media/video-ended-does-not-hold-sleep-assertion-expected.txt: Added.
* media/video-ended-does-not-hold-sleep-assertion.html: Added.

Canonical link: https://commits.webkit.org/239189@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@279313 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-27 09:32:37 +00:00
Sam Weinig 9db9341a7d [Modern Media Controls] Modern media controls should not need to know about specific platforms in shared code
https://bugs.webkit.org/show_bug.cgi?id=227423

Reviewed by Eric Carlson.

Source/WebCore:

Rather than requiring the shared media control classes to know specifics about
the various platforms via the LayoutTraits flags, we now abstract those decisions
via a new polymorphic LayoutTraits class, which each platform subclasses and
implements.

This will gives better separation and will allow easier experimentation with new
control patterns.

* DerivedSources-input.xcfilelist:
* DerivedSources.make:
* PlatformMac.cmake:
* WebCore.xcodeproj/project.pbxproj:
* Modules/modern-media-controls/js-files:
Adds new files for layout traits and its subclasses.

* Modules/mediacontrols/MediaControlsHost.cpp:
(WebCore::MediaControlsHost::layoutTraitsClassName const):
(WebCore::MediaControlsHost::platform const): Deleted.
* Modules/mediacontrols/MediaControlsHost.h:
* Modules/mediacontrols/MediaControlsHost.idl:
Replace platform accessor with a new layoutTraitsClassName, which allows
the platform to spcecify which of the trait subclasses to use.

* Modules/modern-media-controls/controls/layout-traits.js: Added.
* Modules/modern-media-controls/controls/ios-layout-traits.js: Added.
* Modules/modern-media-controls/controls/macos-layout-traits.js: Added.
* Modules/modern-media-controls/controls/watchos-layout-traits.js: Added.
Add new layout trait files.

* Modules/modern-media-controls/controls/fullscreen-button.js:
* Modules/modern-media-controls/controls/icon-service.js:
* Modules/modern-media-controls/controls/ios-inline-media-controls.js:
* Modules/modern-media-controls/controls/layout-item.js:
* Modules/modern-media-controls/controls/macos-fullscreen-media-controls.js:
* Modules/modern-media-controls/controls/macos-inline-media-controls.js:
* Modules/modern-media-controls/controls/media-controls.js:
* Modules/modern-media-controls/controls/play-pause-button.js:
* Modules/modern-media-controls/controls/time-control.js:
* Modules/modern-media-controls/controls/watchos-media-controls.js:
* Modules/modern-media-controls/media/media-controller.js:
* Modules/modern-media-controls/media/tracks-support.js:
Replace explicit checks for platform with queries to the layout traits interface.

LayoutTests:

Update tests and results to use LayoutTraits class.

* media/modern-media-controls/airplay-button/airplay-button-on.html:
* media/modern-media-controls/airplay-button/airplay-button.html:
* media/modern-media-controls/airplay-placard/airplay-placard.html:
* media/modern-media-controls/button/button-active-state.html:
* media/modern-media-controls/button/button-click-on-edges.html:
* media/modern-media-controls/button/button-focus-state.html:
* media/modern-media-controls/button/button-icon-name-expected.txt:
* media/modern-media-controls/button/button-icon-name.html:
* media/modern-media-controls/button/button-on.html:
* media/modern-media-controls/forward-button/forward-button.html:
* media/modern-media-controls/fullscreen-button/fullscreen-button.html:
* media/modern-media-controls/icon-service/icon-service-expected.txt:
* media/modern-media-controls/icon-service/icon-service.html:
* media/modern-media-controls/invalid-placard/invalid-placard-constrained-metrics-expected.txt:
* media/modern-media-controls/invalid-placard/invalid-placard-constrained-metrics.html:
* media/modern-media-controls/invalid-placard/invalid-placard.html:
* media/modern-media-controls/ios-inline-media-controls/ios-inline-media-controls-constructor.html:
* media/modern-media-controls/layout-item/layout-item-expected.txt:
* media/modern-media-controls/layout-item/layout-item.html:
* media/modern-media-controls/macos-fullscreen-media-controls/macos-fullscreen-media-controls-constructor-expected.txt:
* media/modern-media-controls/macos-fullscreen-media-controls/macos-fullscreen-media-controls-constructor.html:
* media/modern-media-controls/macos-inline-media-controls/macos-inline-media-controls-constructor-expected.txt:
* media/modern-media-controls/macos-inline-media-controls/macos-inline-media-controls-constructor.html:
* media/modern-media-controls/media-controller/media-controller-fullscreen-change.html:
* media/modern-media-controls/media-controls/media-controls-appear-when-focus.html:
* media/modern-media-controls/media-controls/media-controls-constructor-expected.txt:
* media/modern-media-controls/media-controls/media-controls-constructor.html:
* media/modern-media-controls/media-controls/media-controls-placard-compressed-metrics-expected.txt:
* media/modern-media-controls/media-controls/media-controls-placard-compressed-metrics.html:
* media/modern-media-controls/mute-button/mute-button.html:
* media/modern-media-controls/overflow-button/overflow-button.html:
* media/modern-media-controls/pip-button/pip-button.html:
* media/modern-media-controls/pip-placard/pip-placard.html:
* media/modern-media-controls/placard/placard-expected.txt:
* media/modern-media-controls/placard/placard.html:
* media/modern-media-controls/play-pause-button/play-pause-button.html:
* media/modern-media-controls/rewind-button/rewind-button.html:
* media/modern-media-controls/skip-back-button/skip-back-button.html:
* media/modern-media-controls/skip-forward-button/skip-forward-button.html:
* media/modern-media-controls/time-control/time-control-expected.txt:
* media/modern-media-controls/time-control/time-control.html:
* media/modern-media-controls/tracks-button/tracks-button.html:
* media/modern-media-controls/watchos-media-controls/watchos-media-controls-constructor-expected.txt:
* media/modern-media-controls/watchos-media-controls/watchos-media-controls-constructor.html:


Canonical link: https://commits.webkit.org/239185@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@279309 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-27 01:07:51 +00:00
eocanha@igalia.com 1e51fcaac6 [GTK] media/muted-video-is-playing-audio.html is timing out
https://bugs.webkit.org/show_bug.cgi?id=208321

Reviewed by Xabier Rodriguez-Calvar.

Source/WebCore:

Added setPageMediaVolume() API to set the Page mediaVolume. This was 0
by default and a way to set it to a non-zero value was needed in order
to prevent a zero effectiveVolume in HTMLMediaElement.

* testing/Internals.cpp:
(WebCore::Internals::setPageMediaVolume): Set the Page mediaVolume.
* testing/Internals.h: Added setPageMediaVolume().
* testing/Internals.idl: Ditto.

Tools:

Set the WebKitTestRunnerWPE application name on user-agent to ease the
detection of the WPE port from the layout tests using the isWPE()
function in platform-helper.js.

* WebKitTestRunner/wpe/TestControllerWPE.cpp:
(WTR::TestController::platformConfigureViewForTest): Set WebKitTestRunnerWPE application name on user-agent.

LayoutTests:

Changed the test to set a non-zero mediaVolume, because a zero one
(default value set by TestController::resetStateToConsistentValues())
would multiply any other volume in HTMLMediaElement::effectiveVolume(),
cause a zero effectiveVolume (being considered in practice as "no audio" by
HTMLMediaElement::mediaState()) and prevent the IsPlayingAudio MediaState
being set.

Also, adapted the test to still expect IsPlayingAudio after mute on the
glib ports (GTK & WPE), since on those ports a muted video is expected to
report IsPlayingAudio, as per the HTMLMediaElement::mediaState() source
code comments.

* media/muted-video-is-playing-audio.html: Test changed as described above.
* platform/glib/media/muted-video-is-playing-audio-expected.txt: Added expectation for glib port.
* resources/platform-helper.js:
(isGtk): Clarified where the GTK user-agent string comes from.
(isWPE): New function to check if a WPE port is being used.


Canonical link: https://commits.webkit.org/239103@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@279217 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-24 09:31:16 +00:00
Toshio Ogasawara c9f32535ff [MSE] Crash when getting audioTracks, videoTracks, textTracks of sourceBuffer after executing MediaSource::removeSourceBuffer()
https://bugs.webkit.org/show_bug.cgi?id=227018

Patch by Toshio Ogasawara <toshio.ogasawara@access-company.com> on 2021-06-16
Reviewed by Eric Carlson.

Source/WebCore:

Fixed not to refer to m_source when isRemoved() is true in SourceBuffer::videoTracks(),
SourceBuffer::audioTracks(), SourceBuffer::textTracks().

Test: media/media-source/media-source-get-tracks-crash.html

* Modules/mediasource/SourceBuffer.cpp:
(WebCore::SourceBuffer::videoTracks):
(WebCore::SourceBuffer::audioTracks):
(WebCore::SourceBuffer::textTracks):

LayoutTests:

* media/media-source/media-source-get-tracks-crash-expected.txt: Added.
* media/media-source/media-source-get-tracks-crash.html: Added.

Canonical link: https://commits.webkit.org/238863@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278932 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-16 14:27:47 +00:00
Jean-Yves Avenard 17759a5dff REGRESSION: MSE: Netflix playback sometimes fails when going to "next episode" in series
https://bugs.webkit.org/show_bug.cgi?id=226952
rdar://77583769

Reviewed by Eric Carlson.

Source/WebKit:

Following bug #225396, the remote/proxy MediaPlayer readyState became decoupled
from the currentTime. In the scenario where a time update was pushed from the
GPU to the WebContent process, followed by a change of readyState status; should
the HTMLMediaElement query the MediaPlayer's time in-between those two IPC calls,
it would be possible for the time to be incorrectly estimated as it assumed it
had progressed since it received the update.
Additionally, it was assumed that the only case where the time won't progress
was if the media element was explicitly paused. This was incorrect it could
have stalled due to the lack of data such as commonly happen with MSE.
We add in the time update IPC message a boolean indicating if the GPU's
MediaPlayer is either stalled or paused and that the time shouldn't advance.
While this new boolean appears redundant with the values of the cached
readyState/paused it differs in that timeIsProgressing is accurate at the
moment the time update is sent and received.

Test: media/media-source/media-source-seek-unbuffered.html

* GPUProcess/media/RemoteMediaPlayerProxy.cpp:
(WebKit::RemoteMediaPlayerProxy::mediaPlayerPausedOrStalled const): Add utility method.
(WebKit::RemoteMediaPlayerProxy::currentTimeChanged):
* GPUProcess/media/RemoteMediaPlayerProxy.h:
* WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp:
(WebKit::MediaPlayerPrivateRemote::currentMediaTime const):
(WebKit::MediaPlayerPrivateRemote::seek): Set the cached media time to the seek
value so that reading it back the time will provide accurate data.
(WebKit::MediaPlayerPrivateRemote::seekWithTolerance): same as with seek method.
(WebKit::MediaPlayerPrivateRemote::currentTimeChanged): Check if timeIsProgressing
is true and only estimate the time if we are certain playback has continued.
* WebProcess/GPU/media/MediaPlayerPrivateRemote.h:
* WebProcess/GPU/media/MediaPlayerPrivateRemote.messages.in: add timeIsProgressing
to method.

LayoutTests:

* media/media-source/media-source-seek-unbuffered-expected.txt: Added.
* media/media-source/media-source-seek-unbuffered.html: Added.


Canonical link: https://commits.webkit.org/238848@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278917 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-16 01:01:52 +00:00
eocanha@igalia.com 3849c8a651 [GStreamer] media/video-seek-after-end.html is no longer flakey
https://bugs.webkit.org/show_bug.cgi?id=203079
<rdar://problem/56366173>

Reviewed by Philippe Normand.

Increased test timeout to something higher than 1300ms to prevent the test failure.

* media/video-seek-after-end.html: Increased timeout.
* platform/glib/TestExpectations: Unskipped the test.


Canonical link: https://commits.webkit.org/238810@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278866 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-15 09:58:17 +00:00
Diego Pino Garcia 97910b5b93 [GStreamer] media/track/audio/audio-track-mkv-vorbis-language.html and media/track/video/video-track-mkv-theora-language.html are failing
https://bugs.webkit.org/show_bug.cgi?id=226864

Reviewed by Eric Carlson.

These tests were failing due to an apparently incorrect order of
languages in audio and video tracks.

Examining the video container with tools like mediasource or VLC shows
that the order expected by GStreamer ports is correct. To make these
tests pass I changed the tests to make them language order independent
by fetching audio or video tracks by id.

* media/in-band-tracks.js:
(canplaythrough):
(testAttribute): values' can be also an Object. In that case, fetch tracks by 'id'.
* media/track/audio/audio-track-mkv-vorbis-language-expected.txt: Updated.
* media/track/audio/audio-track-mkv-vorbis-language.html: Pass language expected results as a map indexed by track id.
* media/track/video/video-track-mkv-theora-language-expected.txt: Updated.
* media/track/video/video-track-mkv-theora-language.html: Pass language expected results as a map indexed by track id.


Canonical link: https://commits.webkit.org/238804@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278860 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-15 05:26:56 +00:00
Devin Rousso 348c0e4e6c (r278618) media/modern-media-controls/overflow-support/chapters.html is timing out since introduction
https://bugs.webkit.org/show_bug.cgi?id=226828
<rdar://problem/79084756>

Unreviewed followup for flaky test.


* media/modern-media-controls/overflow-support/chapters.html:
* media/modern-media-controls/overflow-support/chapters-expected.txt:
It may take a moment for the `currentTime` to updating after selecting a chapter.


Canonical link: https://commits.webkit.org/238767@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278814 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-12 20:16:58 +00:00
Robert Jenner a6efba9dfc N[LayoutTests] Delete unused LayoutTests/media resources
https://bugs.webkit.org/show_bug.cgi?id=226836

Reviewed by Jonathan Bedard.

* media/track/opera/resources/media/sunflower.mp4: Removed.
* media/track/opera/resources/media/sunflower.webm: Removed.


Canonical link: https://commits.webkit.org/238749@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278792 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-11 23:35:33 +00:00
Devin Rousso b5cd101546 (r278618) media/modern-media-controls/overflow-support/chapters.html is timing out since introduction
https://bugs.webkit.org/show_bug.cgi?id=226828
<rdar://problem/79084756>

Unreviewed followup for flaky test.


* media/modern-media-controls/overflow-support/chapters.html:
Add manual timeouts for each `await` to see where exactly the test fails.


Canonical link: https://commits.webkit.org/238701@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278739 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-10 23:32:08 +00:00
Toshio Ogasawara 22d590fc1d [MSE] When currentTime is a large value, it takes time to process SourceBufferPrivate::evictCodedFrames().
https://bugs.webkit.org/show_bug.cgi?id=226867

Patch by Toshio Ogasawara <toshio.ogasawara@access-company.com> on 2021-06-10
Reviewed by Eric Carlson.

Source/WebCore:

SourceBufferPrivate::evictCodedFrames() now starts with the earliest PTS value
in trackBuffer instead of MediaTime::zeroTime() to avoid unnecessary loops.

Test: media/media-source/media-source-evict-codedframe-large-currenttime.html

* platform/graphics/SourceBufferPrivate.cpp:
(WebCore::SourceBufferPrivate::evictCodedFrames):

LayoutTests:

* media/media-source/media-source-evict-codedframe-large-currenttime-expected.txt: Added.
* media/media-source/media-source-evict-codedframe-large-currenttime.html: Added.

Canonical link: https://commits.webkit.org/238691@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278728 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-10 20:50:40 +00:00
Devin Rousso 19a1174af6 (r278618) media/modern-media-controls/overflow-support/chapters.html is timing out since introduction
https://bugs.webkit.org/show_bug.cgi?id=226828
<rdar://problem/79084756>

Unreviewed text fix.


* media/modern-media-controls/overflow-support/chapters.html:
* media/modern-media-controls/overflow-support/chapters-expected.txt:
Wait for the `<track kind="chapters">` to load before clicking on the overflow button as
otherwise there won't be any chapter cues to display in the contextmenu, meaning that the
contextmenu would be empty and therefore not be shown.

* http/tests/resources/js-test-pre.js:
(shouldBecomeEqual):
(shouldBecomeDifferent):
* resources/js-test-pre.js:
(shouldBecomeEqual):
(shouldBecomeDifferent):
* resources/js-test.js:
(shouldBecomeEqual):
(shouldBecomeDifferent):
Allow for `completionHandler` to not be provided, which will cause the function to return a `Promise`.


Canonical link: https://commits.webkit.org/238657@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278678 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-09 22:42:51 +00:00
Jean-Yves Avenard fbcd7fc467 [MSE] Assertion if attempting to perform eviction before playback starts.
https://bugs.webkit.org/show_bug.cgi?id=226720
<rdar://problem/78943223>

Reviewed by Eric Carlson.

Source/WebCore:

Handle the case where the buffered range doesn't yet exist as we haven't parsed
an init segment yet.
Test: media/media-source/media-source-append-buffer-full-quota-exceeded-error-onstart.html

* platform/graphics/SourceBufferPrivate.cpp:
(WebCore::SourceBufferPrivate::evictCodedFrames): Exit early if the buffered range is empty
and handle the case where a buffered range index wasn't found.

LayoutTests:

* media/media-source/media-source-append-buffer-full-quota-exceeded-error-onstart-expected.txt: Added.
* media/media-source/media-source-append-buffer-full-quota-exceeded-error-onstart.html: Added.


Canonical link: https://commits.webkit.org/238618@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278635 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-09 01:02:55 +00:00
Devin Rousso 066c80da98 [Modern Media Controls] upstream new features
https://bugs.webkit.org/show_bug.cgi?id=226736
<rdar://problem/78957464>

Reviewed by Eric Carlson.

Source/WebCore:

 - bring the "Audio"/"Languages" tracks menu to iOS
 - add a new "Playback Speed" menu in the overflow menu on iOS and macOS
 - add support for showing the most relevant `<track kind="chapters">` in the overflow menu on iOS and macOS

Tests: media/modern-media-controls/overflow-button/overflow-button.html
       media/modern-media-controls/overflow-support/chapters.html
       media/modern-media-controls/overflow-support/playback-speed.html

* Modules/mediacontrols/MediaControlsHost.cpp:
(WebCore::MediaControlsHost::showMediaControlsContextMenu):
* Modules/modern-media-controls/media/overflow-support.js:
(OverflowSupport.prototype.get mediaEvents):
(OverflowSupport.prototype.get tracksToMonitor):
(OverflowSupport.prototype.syncControl):
* en.lproj/Localizable.strings:

* rendering/RenderTheme.h:
(WebCore::RenderTheme::mediaControlsScripts):
* rendering/RenderThemeAdwaita.cpp:
(WebCore::RenderThemeAdwaita::mediaControlsScripts):
* rendering/RenderThemeAdwaita.h:
* rendering/RenderThemeCocoa.h:
* rendering/RenderThemeCocoa.mm:
(WebCore::RenderThemeCocoa::purgeCaches):
(WebCore::RenderThemeCocoa::mediaControlsScripts):
* rendering/RenderThemeWin.h:
* rendering/RenderThemeWin.cpp:
(WebCore::RenderThemeWin::mediaControlsScripts):
Drop the "additional script" and lower the inline capacity of the `Vector`.

* testing/Internals.idl:
* testing/Internals.h:
* testing/Internals.cpp:
(WebCore::Internals::setMediaControlsHidePlaybackRates): Added.
* html/HTMLMediaElement.h:
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::setMediaControlsHidePlaybackRates): Added.
Since Playback Rates is always shown, provide a way for tests to turn it off.

Source/WTF:

 - bring the "Audio"/"Languages" tracks menu to iOS
 - add a new "Playback Speed" menu on iOS and macOS in the overflow menu
 - add support for showing the most relevant `<track kind="chapters">` in the overflow menu

* wtf/PlatformEnableCocoa.h:

LayoutTests:

* media/modern-media-controls/overflow-button/overflow-button.html: Added.
* media/modern-media-controls/overflow-button/overflow-button-expected.txt: Added.
* media/modern-media-controls/overflow-support/chapters.html: Added.
* media/modern-media-controls/overflow-support/chapters-expected.txt: Added.
* media/modern-media-controls/overflow-support/playback-speed.html: Added.
* media/modern-media-controls/overflow-support/playback-speed-expected.txt: Added.

* TestExpectations:
* platform/mac-wk2/TestExpectations:


Canonical link: https://commits.webkit.org/238603@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278618 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-08 17:27:33 +00:00
Jean-Yves Avenard 574893f0f6 LayoutTests/imported/w3c:
MediaSession.coordinator should not be optional, relying on coordinator state change instead
https://bugs.webkit.org/show_bug.cgi?id=226328
rdar://77461335

Reviewed by Eric Carlson.

* web-platform-tests/mediasession/idlharness.window-expected.txt:

Source/WebCore:
MediaSession.coordinator should not be optional, relying on coordinator state change instead
https://bugs.webkit.org/show_bug.cgi?id=226328
rdar://77461335

Reviewed by Eric Carlson.

The coordinator was a read-only optional attribute of the MediaSession element.
Testing if the attribute was to be used to determine if a MediaSessionCoordinator
was now available and for the MediaSession to join it. This made the use of an external
polyfill difficult and enforcing the validity of an user created custom
MediaSessionCoordinator due to IDL semantics limitations hard.
We instead always create a MediaSessionCoordinator which in its default state is Closed.
Once this state is changed to Waiting and an event is fire the MediaSession can now
join it.

* Modules/mediasession/MediaSession.cpp:
(WebCore::MediaSession::MediaSession): MediaSession no longer needs to fire event.
Remove no longer necessary inheritance and async event queue.
(WebCore::MediaSession::create): Drive-by fix, don't call suspendIfNeeded() in the constructor.
(WebCore::MediaSession::createCoordinator): Make method private.
* Modules/mediasession/MediaSession.h:
(WebCore::MediaSession::coordinator const): MediaSessionCoordinator always exists. Return reference instead.
* Modules/mediasession/MediaSession.idl: Amend definition, remove EventHandler
* Modules/mediasession/MediaSessionCoordinator.cpp:
(WebCore::MediaSessionCoordinator::create):
(WebCore::MediaSessionCoordinator::MediaSessionCoordinator):
(WebCore::MediaSessionCoordinator::setMediaSessionCoordinatorPrivate):
(WebCore::MediaSessionCoordinator::virtualHasPendingActivity const):
(WebCore::MediaSessionCoordinator::join):
(WebCore::MediaSessionCoordinator::close):
(WebCore::MediaSessionCoordinator::coordinatorStateChanged):
* Modules/mediasession/MediaSessionCoordinator.h:
* Modules/mediasession/MediaSessionCoordinator.idl: Added new EventHandler attribute.
* Modules/mediasession/MediaSessionCoordinatorMixin.idl: Update for new API definition.
* dom/EventNames.h:
* dom/EventTargetFactory.in:
* page/Page.cpp:
(WebCore::Page::setMediaSessionCoordinator):
(WebCore::Page::invalidateMediaSessionCoordinator):
* testing/Internals.cpp:
(WebCore::Internals::registerMockMediaSessionCoordinator):

Tools:
MediaSession.coordinator should not be optional, relying on coordinator readyState change instead
https://bugs.webkit.org/show_bug.cgi?id=226328
rdar://77461335

Reviewed by Eric Carlson.

* TestWebKitAPI/Tests/WebKit/MediaSessionCoordinatorTest.mm:
(TestWebKitAPI::MediaSessionCoordinatorTest::createCoordinator): Change test to match new API,
using coordinatorstatechange event instead.
* TestWebKitAPI/Tests/WebKitCocoa/media-remote.html:

LayoutTests:
MediaSession.coordinator should not be optional, relying on coordinator readyState change instead
https://bugs.webkit.org/show_bug.cgi?id=226328
rdar://77461335

Reviewed by Eric Carlson.

* media/media-session/mock-coordinator-expected.txt:
* media/media-session/mock-coordinator.html: Change test to match new API.


Canonical link: https://commits.webkit.org/238369@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278336 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-02 01:20:38 +00:00
Miguel Gomez 75dc0ad3ad [GStreamer] Incorrect rendering of VP9 with transparency
https://bugs.webkit.org/show_bug.cgi?id=225961

Reviewed by Žan Doberšek.

Source/WebCore:

Fix the rendering of videos with transparency. This is done both AC and non AC modes and
with and without GSTREAMER_GL enabled.

On AC mode and using GSTREAMER_GL, a new option is added to TextureMapperGL and TextureMapperShaderProgram
to support premultiplying the components of a pixel. This is required because GStreamer uses straight alpha,
and we need it premultiplied in order to perform the correct blending blending of the video frames. Then we
use that new option to render video frames. This new option is also used when copying the video frame into
an external texture if premultiplyAlpha is requested.

On non AC mode, or when GStreamer-gl is disabled, add support to ImageGStreamerCairo to premultiply the alpha
of the video frame before creating the cairo surface to paint, and pass the appropriate composite operator when
drawing with alpha.

Test: media/video-with-alpha.html

* platform/graphics/gstreamer/GStreamerVideoFrameHolder.cpp:
(WebCore::GstVideoFrameHolder::GstVideoFrameHolder):
* platform/graphics/gstreamer/ImageGStreamerCairo.cpp:
(WebCore::ImageGStreamer::ImageGStreamer):
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
(WebCore::MediaPlayerPrivateGStreamer::pushTextureToCompositor):
(WebCore::MediaPlayerPrivateGStreamer::paint): update the caps of the conversion to make them match the format
expected by cairo, so we can avoid a component swap.
(WebCore::MediaPlayerPrivateGStreamer::copyVideoTextureToPlatformTexture):
* platform/graphics/gstreamer/VideoTextureCopierGStreamer.cpp:
(WebCore::VideoTextureCopierGStreamer::copyVideoTextureToPlatformTexture):
* platform/graphics/gstreamer/VideoTextureCopierGStreamer.h:
* platform/graphics/texmap/TextureMapperGL.cpp:
(WebCore::TextureMapperGL::drawTexture):
* platform/graphics/texmap/TextureMapperGL.h:
* platform/graphics/texmap/TextureMapperShaderProgram.cpp:
(WebCore::TextureMapperShaderProgram::create):
* platform/graphics/texmap/TextureMapperShaderProgram.h:

LayoutTests:

Add a test for the playback of transparent videos. This is initially skipped because it's not supported
on Apple ports and won't be working on GTK and WPE until GStreamer is bumped to 1.20.

* TestExpectations:
* media/content/video-with-alpha.webm: Added.
* media/video-with-alpha-expected.html: Added.
* media/video-with-alpha.html: Added.


Canonical link: https://commits.webkit.org/238313@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278276 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-31 13:33:16 +00:00
Jean-Yves Avenard 3a02218c2d Add MediaSession.callActionHandler
https://bugs.webkit.org/show_bug.cgi?id=226077
rdar://77463304

Reviewed by Eric Carlson.

Source/WebCore:

Make it possible for JavaScript to be able to trigger a MediaSession action
handler so a MediaSession.coordinator polyfill such as one provided by an
external JS library will work.
Test: media/media-session/callActionHandler.html

* Modules/mediasession/MediaSession.cpp:
(WebCore::MediaSession::callActionHandler):
* Modules/mediasession/MediaSession.h:
* Modules/mediasession/MediaSession.idl: Add method definition.

LayoutTests:

* media/media-session/callActionHandler-expected.txt: Added.
* media/media-session/callActionHandler.html: Added.


Canonical link: https://commits.webkit.org/238260@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278222 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 20:08:08 +00:00
Devin Rousso 2e3e2c1746 [Modern Media Controls] put the localized information for tracks first if the track is not in the user's preferred language
https://bugs.webkit.org/show_bug.cgi?id=226361
<rdar://problem/78497853>

Reviewed by Eric Carlson.

Source/WebCore:

Test: media/modern-media-controls/tracks-support/sorted-by-user-preferred-languages.html

This makes it clearer/easier for the user to understand what's going on when the track label
is not in the user's preferred language. For example, if a `<video>` has an "English" audio
track, it's not very helpful to show "English (英语)" for Chinese users instead of something
like "英语 (English)".

If the track has a `label` and either matches the user's preferred language or its `label`
already contains the localized language name, combine the track's `label` with a localized
description of the track if that description isn't already in the `label`. Otherwise, add
the localized language name first, then the description of the track, and finally the `label`.

Here are some examples if the user's preferred language is English:
 - `<track kind="subtitles" srclang="en">`                  would show "English"
 - `<track kind="subtitles" srclang="en" label="Foo">`      would show "Foo"
 - `<track kind="captions"  srclang="en">`                  would show "English Captions"
 - `<track kind="captions"  srclang="en" label="Foo">`      would show "Foo Captions"
 - `<track kind="captions"  srclang="en" label="Captions">` would show "Captions"
 - `<track kind="subtitles" srclang="fr">`                  would show "French"
 - `<track kind="subtitles" srclang="fr" label="Foo">`      would show "French (Foo)"
 - `<track kind="captions"  srclang="fr">`                  would show "French Captions"
 - `<track kind="captions"  srclang="fr" label="Foo">`      would show "French Captions (Foo)"
 - `<track kind="captions"  srclang="fr" label="Captions">` would show "French Captions"

* page/CaptionUserPreferences.cpp:
(WebCore::trackDisplayName):
* page/CaptionUserPreferencesMediaAF.cpp:
(WebCore::addTextTrackKindDisplayNameIfNeeded): Added.
(WebCore::addAudioTrackKindDisplayNameIfNeeded): Added.
(WebCore::addTrackKindDisplayNameIfNeeded): Added.
(WebCore::trackDisplayName):
(WebCore::CaptionUserPreferencesMediaAF::displayNameForTrack const):
(WebCore::textTrackCompare):
(WebCore::CaptionUserPreferencesMediaAF::sortedTrackListForMenu):
(WebCore::buildDisplayStringForTrackBase): Deleted.

* platform/LocalizedStrings.h:
* platform/LocalizedStrings.cpp:
(WebCore::trackNoLabelText): Added.
(WebCore::textTrackOffMenuItemText): Added.
(WebCore::textTrackAutomaticMenuItemText): Added.
(WebCore::addTrackLabelAsSuffix): Added.
(WebCore::textTrackKindClosedCaptionsDisplayName): Added.
(WebCore::addTextTrackKindClosedCaptionsSuffix): Added.
(WebCore::textTrackKindCaptionsDisplayName): Added.
(WebCore::addTextTrackKindCaptionsSuffix): Added.
(WebCore::textTrackKindDescriptionsDisplayName): Added.
(WebCore::addTextTrackKindDescriptionsSuffix): Added.
(WebCore::textTrackKindChaptersDisplayName): Added.
(WebCore::addTextTrackKindChaptersSuffix): Added.
(WebCore::textTrackKindMetadataDisplayName): Added.
(WebCore::addTextTrackKindMetadataSuffix): Added.
(WebCore::textTrackKindSDHDisplayName): Added.
(WebCore::addTextTrackKindSDHSuffix): Added.
(WebCore::textTrackKindEasyReaderDisplayName): Added.
(WebCore::addTextTrackKindEasyReaderSuffix): Added.
(WebCore::textTrackKindForcedDisplayName): Added.
(WebCore::addTextTrackKindForcedSuffix): Added.
(WebCore::audioTrackKindDescriptionsDisplayName): Added.
(WebCore::addAudioTrackKindDescriptionsSuffix): Added.
(WebCore::audioTrackKindCommentaryDisplayName): Added.
(WebCore::addAudioTrackKindCommentarySuffix): Added.
(WebCore::textTrackNoLabelText): Deleted.
(WebCore::audioTrackNoLabelText): Deleted.
(WebCore::captionsTextTrackKindDisplayName): Deleted.
(WebCore::captionsTextTrackWithoutLabelMenuItemText): Deleted.
(WebCore::descriptionsTextTrackKindDisplayName): Deleted.
(WebCore::descriptionsTextTrackWithoutLabelMenuItemText): Deleted.
(WebCore::chaptersTextTrackKindDisplayName): Deleted.
(WebCore::chaptersTextTrackWithoutLabelMenuItemText): Deleted.
(WebCore::metadataTextTrackKindDisplayName): Deleted.
(WebCore::metadataTextTrackWithoutLabelMenuItemText): Deleted.
(WebCore::textTrackCountryAndLanguageMenuItemText): Deleted.
(WebCore::textTrackLanguageMenuItemText): Deleted.
(WebCore::closedCaptionKindTrackDisplayName): Deleted.
(WebCore::closedCaptionTrackMenuItemText): Deleted.
(WebCore::sdhTrackKindDisplayName): Deleted.
(WebCore::sdhTrackMenuItemText): Deleted.
(WebCore::easyReaderKindDisplayName): Deleted.
(WebCore::easyReaderTrackMenuItemText): Deleted.
(WebCore::forcedTrackKindDisplayName): Deleted.
(WebCore::forcedTrackMenuItemText): Deleted.
(WebCore::audioDescriptionTrackSuffixText): Deleted.
* en.lproj/Localizable.strings:
Clean up localized string functions related to media controls.

LayoutTests:

* media/modern-media-controls/tracks-support/sorted-by-user-preferred-languages-expected.txt:


Canonical link: https://commits.webkit.org/238245@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278202 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 16:39:42 +00:00
Devin Rousso 78477f51cd Use `NSLocale` SPI for comparing language identifiers instead of string comparison
https://bugs.webkit.org/show_bug.cgi?id=226252

Reviewed by Wenson Hsieh.

Source/WTF:

The existing `indexOfBestMatchingLanguageInList` logic uses (sub)string comparison of BCP47
language tags (e.g. looking for a `'-'` and comparing the substring before and after in the
input language and each item in the language list). While this does work for some languages,
it's really not the correct way to compare BCP47 language tags. Additionally, it basically
ignores the text after the first `'-'`, unless there's an exact match with the input
language. This leads to `"zh-CN"` and `"zh-HK"` being considered a (not exact) match, which
isn't ideal.

* wtf/Language.cpp:
* wtf/cocoa/LanguageCocoa.mm:
(WTF::indexOfBestMatchingLanguageInList): Added.
* wtf/spi/cocoa/NSLocaleSPI.h:

LayoutTests:

* media/modern-media-controls/tracks-support/sorted-by-user-preferred-languages.html:
* media/modern-media-controls/tracks-support/sorted-by-user-preferred-languages-expected.txt:


Canonical link: https://commits.webkit.org/238212@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278168 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-27 17:54:13 +00:00
Toshio Ogasawara 550a21bb95 [MSE] MediaSample that need to be removed with SourceBufferPrivate::evictCodedFrames() may not be removed.
https://bugs.webkit.org/show_bug.cgi?id=225800
<rdar://problem/78296352>

Patch by Toshio Ogasawara <toshio.ogasawara@access-company.com> on 2021-05-26
Reviewed by Jer Noble.

Source/WebCore:

Fixed evictCodedFrames to remove MediaSample that can be removed after the minimumRangeStart.

Test: media/media-source/media-source-evict-codedframe-after-seek.html

* platform/graphics/SourceBufferPrivate.cpp:
(WebCore::SourceBufferPrivate::evictCodedFrames):

LayoutTests:

* media/media-source/media-source-evict-codedframe-after-seek-expected.txt: Added.
* media/media-source/media-source-evict-codedframe-after-seek.html: Added.

Canonical link: https://commits.webkit.org/238191@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278147 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-27 04:35:17 +00:00
Jean-Yves Avenard 3af6e7c869 Make MediaSession readystate enums all lowercase
https://bugs.webkit.org/show_bug.cgi?id=226213
<rdar://problem/78437011>

Reviewed by Eric Carlson.

Source/WebCore:

Use the current MediaSession definition pattern which makes all enum names
lower case.

* Modules/mediasession/MediaSession.h:
* Modules/mediasession/MediaSessionReadyState.h:
* Modules/mediasession/MediaSessionReadyState.idl:

Source/WebKit:

* UIProcess/API/Cocoa/WKWebViewTesting.mm:
(-[WKWebView _createMediaSessionCoordinatorForTesting:completionHandler:]):

Tools:

* TestWebKitAPI/Tests/WebKit/MediaSessionCoordinatorTest.mm:
(TestWebKitAPI::TEST_F):

LayoutTests:

Use the current MediaSession definition pattern which makes all enum names
lower case.

* media/media-session/mock-coordinator-expected.txt:
* media/media-session/mock-coordinator.html:


Canonical link: https://commits.webkit.org/238187@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278143 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-27 01:33:00 +00:00
Devin Rousso 985831945d [Modern Media Controls] REGRESSION(r254389) media controls needs the full list of language preferences for ordering tracks
https://bugs.webkit.org/show_bug.cgi?id=226038

Reviewed by Myles C. Maxfield and Eric Carlson.

Source/JavaScriptCore:

Media controls need access to the full list of language preferences in order to properly
sort/order the list of tracks in the controls UI. For example, if a `<video>` has subtitles
for English, Spanish, and French, and the user has English (default) and French (alternate)
configured in the Language & Region view of System Preferences on macOS, WebKit should order
the subtitles list English, French, and then Spanish.

* shell/playstation/TestShell.cpp:
(preTest):
Instead of propagating the override, just clear it out.

Source/WebCore:

Media controls need access to the full list of language preferences in order to properly
sort/order the list of tracks in the controls UI. For example, if a `<video>` has subtitles
for English, Spanish, and French, and the user has English (default) and French (alternate)
configured in the Language & Region view of System Preferences on macOS, WebKit should order
the subtitles list English, French, and then Spanish.

Test: media/modern-media-controls/tracks-support/sorted-by-user-preferred-languages.html

* page/CaptionUserPreferences.cpp:
(WebCore::CaptionUserPreferences::preferredLanguages const):
(WebCore::CaptionUserPreferences::textTrackSelectionScore const):
(WebCore::CaptionUserPreferences::primaryAudioTrackLanguageOverride const):
* page/CaptionUserPreferencesMediaAF.cpp:
(WebCore::CaptionUserPreferencesMediaAF::preferredLanguages const):
(WebCore::buildDisplayStringForTrackBase):
(WebCore::trackDisplayName):
(WebCore::textTrackCompare):
* platform/graphics/avfoundation/MediaSelectionGroupAVFObjC.mm:
(WebCore::MediaSelectionGroupAVFObjC::updateOptions):

* bindings/js/JSDOMWindowBase.cpp:
* bindings/js/JSWorkerGlobalScopeBase.cpp:
* bindings/js/JSWorkletGlobalScopeBase.cpp:
Wrap `defaultLanguage` in a lambda since it now has a parameter.

* platform/LocalizedStrings.h:
* platform/LocalizedStrings.cpp:
(WebCore::captionsTextTrackKindDisplayName): Added.
(WebCore::descriptionsTextTrackKindDisplayName): Added.
(WebCore::chaptersTextTrackKindDisplayName): Added.
(WebCore::metadataTextTrackKindDisplayName): Added.
(WebCore::closedCaptionKindTrackDisplayName): Added.
(WebCore::sdhTrackKindDisplayName): Added.
(WebCore::easyReaderKindDisplayName): Added.
(WebCore::forcedTrackKindDisplayName): Added.
Move the logic added in r277797 from `buildDisplayStringForTrackBase` to `trackDisplayName`
and only perform it if the text track display name doesn't already contain the display name
for the text track kind (e.g. if the `label` is "English Captions" don't add "Captions", but
do if the `label` is only "English").

Source/WTF:

Media controls need access to the full list of language preferences in order to properly
sort/order the list of tracks in the controls UI. For example, if a `<video>` has subtitles
for English, Spanish, and French, and the user has English (default) and French (alternate)
configured in the Language & Region view of System Preferences on macOS, WebKit should order
the subtitles list English, French, and then Spanish.

* wtf/Language.h:
* wtf/Language.cpp:
(WTF::cachedFullPlatformPreferredLanguages): Added.
(WTF::cachedMinimizedPlatformPreferredLanguages): Added.
(WTF::languageDidChange):
(WTF::defaultLanguage):
(WTF::userPreferredLanguages):
(WTF::platformLanguageDidChange): Deleted.
Move the caching in `wtf/cf/LanguageCF.cpp` to `wtf/Language.cpp` so that all platforms can
benefit from caching the result of `platformUserPreferredLanguages`.

* wtf/cf/LanguageCF.cpp:
(WTF::platformUserPreferredLanguages):
(WTF::platformLanguageDidChange): Deleted.
* wtf/playstation/LanguagePlayStation.cpp:
(WTF::platformUserPreferredLanguages):
* wtf/spi/cocoa/NSLocaleSPI.h:
* wtf/unix/LanguageUnix.cpp:
(WTF::platformUserPreferredLanguages):
* wtf/win/LanguageWin.cpp:
(WTF::platformUserPreferredLanguages):
Add `WTF::ShouldMinimizeLanguages` that controls whether `WTF::minimizedPreferredLanguages`
is called. Since the result is cached, create separate `Vector<String>` for each enum value.

LayoutTests:

* media/modern-media-controls/tracks-support/sorted-by-user-preferred-languages.html: Added.
* media/modern-media-controls/tracks-support/sorted-by-user-preferred-languages-expected.txt: Added.

* media/content/lorem-ipsum.vtt: Added.


Canonical link: https://commits.webkit.org/238145@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278064 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-26 00:15:02 +00:00
Jer Noble 4c7f38aeea [Mac] MSE-based video pauses when put in background; PiP context menu disabled
https://bugs.webkit.org/show_bug.cgi?id=225958
<rdar://78130303>

Reviewed by Eric Carlson.

Source/WebCore:

Test: media/media-source/media-source-has-audio-video.html

In r277116, in order to reduce the CPU usage incurred when pushing state changes from
the GPU process to the WebContent process, state changes to `hasAudio` and `hasVideo`
were now only updated when the MediaPlayer indicated that its `characteristicsChanged()`.
However, in SourceBufferPrivateAVFObjC, this call was performed too early, before the
SourceBuffer in the WebContent process had informed SourceBufferPrivate of newly added
audio and video tracks. Thus the cached values of `hasAudio` and `hasVideo` inside the
WebContent process were never updated.

Call `characteristicsChanged()` from the callback handler of `didReceiveInitializationSegment()`,
which will be called only after the WebContent process completes its handling of the
new initialization segment, which includes telling the SourceBufferPrivate in the GPU
process about newly added audio and video tracks.

* platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:
(WebCore::SourceBufferPrivateAVFObjC::didParseInitializationData):

LayoutTests:

* media/media-source/media-source-has-audio-video-expected.txt: Added.
* media/media-source/media-source-has-audio-video.html: Added.


Canonical link: https://commits.webkit.org/237903@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@277726 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-19 16:43:28 +00:00
Devin Rousso af75d6bcbd [Modern Media Controls] promote submenus items if there is only one
https://bugs.webkit.org/show_bug.cgi?id=225883

Reviewed by Eric Carlson.

Source/WebCore:

As an example, if a `<video>` only has subtitles and not any other languages, the "Subtitles"
submenu should really be top-level (i.e. have "Subtitles" be the title of the entire
contextmenu instead of being a submenu of a title-less contextmenu) in the contextmenu shown
when tapping the tracks button.

Tests: media/modern-media-controls/tracks-support/auto-text-track.html
       media/modern-media-controls/tracks-support/click-track-in-contextmenu.html
       media/modern-media-controls/tracks-support/hidden-tracks.html
       media/modern-media-controls/tracks-support/off-text-track.html
       media/modern-media-controls/tracks-support/text-track-selected-via-media-api.html

* Modules/mediacontrols/MediaControlsHost.cpp:
(WebCore::MediaControlsHost::showMediaControlsContextMenu):

Source/WebKit:

As an example, if a `<video>` only has subtitles and not any other languages, the "Subtitles"
submenu should really be top-level (i.e. have "Subtitles" be the title of the entire
contextmenu instead of being a submenu of a title-less contextmenu) in the contextmenu shown
when tapping the tracks button.

* UIProcess/ios/WKActionSheetAssistant.mm:
(-[WKActionSheetAssistant showMediaControlsContextMenu:items:completionHandler:]):

LayoutTests:

* media/modern-media-controls/tracks-support/auto-text-track.html:
* media/modern-media-controls/tracks-support/click-track-in-contextmenu.html:
* media/modern-media-controls/tracks-support/hidden-tracks.html:
* media/modern-media-controls/tracks-support/off-text-track.html:
* media/modern-media-controls/tracks-support/text-track-selected-via-media-api.html:


Canonical link: https://commits.webkit.org/237831@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@277616 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-18 00:09:17 +00:00
Jer Noble baf5934699 MediaSession action handlers aren't treated as having a user gesture
https://bugs.webkit.org/show_bug.cgi?id=225875

Reviewed by Eric Carlson.

Source/WebCore:

Test: media/media-session/user-gesture-action-handlers.html

We treat remote control commands as having a user gesture, but not when firing
a MediaSession action handler; we should treat them the same.

* Modules/mediasession/MediaSession.cpp:
(WebCore::MediaSession::callActionHandler):

LayoutTests:

* media/media-session/user-gesture-action-handlers-expected.txt: Added.
* media/media-session/user-gesture-action-handlers.html: Added.


Canonical link: https://commits.webkit.org/237813@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@277588 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-17 18:12:36 +00:00
Eric Carlson 3c4a76b9fa [GPUP] a media element with a data url and "crossorigin='anonymous'" doesn't load
https://bugs.webkit.org/show_bug.cgi?id=225786
<rdar://77625185>

Reviewed by Jer Noble.

Source/WebCore:

Test: media/data-url-cross-origin.html

* loader/MediaResourceLoader.cpp:
(WebCore::MediaResourceLoader::requestResource): Set loader options `sameOriginDataURLFlag`
to `SameOriginDataURLFlag::Set` so data: urls are treated as same origin.

LayoutTests:

* media/data-url-cross-origin-expected.txt: Added.
* media/data-url-cross-origin.html: Added.
* media/media-file.js:
(findDataURL):
* media/sources-fallback-codecs.html:


Canonical link: https://commits.webkit.org/237749@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@277520 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-15 00:00:25 +00:00
Toshio Ogasawara ad98036337 [MSE] QuotaExceededError Exception not thrown even if the sum of totalTrackBufferSize and appendBuffer size exceeds maximumBufferSize.
https://bugs.webkit.org/show_bug.cgi?id=225630

Patch by Toshio Ogasawara <toshio.ogasawara@access-company.com> on 2021-05-11
Reviewed by Eric Carlson.

Source/WebCore:

Test: media/media-source/media-source-append-buffer-full-quota-exceeded-error.html

* Modules/mediasource/SourceBuffer.cpp:
(WebCore::SourceBuffer::appendBufferInternal):
* platform/graphics/SourceBufferPrivate.cpp:
(WebCore::SourceBufferPrivate::evictCodedFrames):
* platform/graphics/SourceBufferPrivate.h:

LayoutTests:

* media/media-source/media-source-append-buffer-full-quota-exceeded-error-expected.txt: Added.
* media/media-source/media-source-append-buffer-full-quota-exceeded-error.html: Added.

Canonical link: https://commits.webkit.org/237603@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@277345 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-12 00:46:17 +00:00
Chris Gambrell 61d2fb8ef6 [LayoutTests] Decouple http/tests/media/resources/create-id3-db.php from webserver
https://bugs.webkit.org/show_bug.cgi?id=224561
<rdar://problem/76653054>

Reviewed by Jonathan Bedard.

Replacing the creation of metadata.db with JSON into a new file named metadata.json. This standalone script remains in PHP to be able to still use getid3.

* http/tests/media/resources/create-id3-db.php: Removed.
* http/tests/resources/dir-helpers.php: Removed.
* http/tests/resources/portabilityLayer.php: Removed.
* media/content/create-id3-db: Copied from LayoutTests/http/tests/media/resources/create-id3-db.php.


Canonical link: https://commits.webkit.org/237571@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@277311 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-11 00:41:50 +00:00
eocanha@igalia.com 4abfd4b229 [GStreamer] Layout test media/video-playsinline.html is flaky
https://bugs.webkit.org/show_bug.cgi?id=186664

Reviewed by Philippe Normand.

The change to fullscreen takes a while on WebKitGTK and WPE platforms and can't be checked immediately.

* media/video-playsinline.html: Added a setTimeout to the test in order to defer the check to the next main loop iteration.


Canonical link: https://commits.webkit.org/237450@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@277164 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-07 08:46:34 +00:00
Darin Adler d7549ecd93 Streamline codec parsing, replacing uses of HashMap with SortedArrayMap
https://bugs.webkit.org/show_bug.cgi?id=225368

Reviewed by Sam Weinig.

Source/WebCore:

* platform/ContentType.cpp:
(WebCore::ContentType::parameter const): Use early return instead of nesting.
Strip HTML spaces, not all whitespace, and do it only once rather than twice.
Fixed a small bug where we search for the second quotation mark in a way that
could find the same quotation mark twice if there is a space before the first
one. Added FIXME comments about a few obvious problems in the parsing algorithm.
Improved efficiency by using StringView, saving the allocation of one temporary
StringImpl in the case where we have some HTML spaces to strip.
(WebCore::ContentType::containerType const): Simplified the implemementation
by taking advantage of the fact that our notFound value is designed to be used
as an argument to functions like String::left, telling them to return the
entire string. Strip HTML spaces, not all whitespace.

* platform/graphics/HEVCUtilities.cpp:
(WebCore::parseHEVCCodecParameters): Take a StringView instead of a String
for greater flexibility and efficiency. Don't store codecName, which is
never used after verifying that it is a legal value here. Don't store the
generalTierFlag, which is never used after verifying that it is a legal
value here. Don't store the constraint flags, which are never used after
verifying that they are legal values here.
(WebCore::makeOptionalFromPointer): Added to make code below cleaner.
(WebCore::parseDoViCodecType): Renamed from codecStringForDoViCodecType
since it now returns an enumeration value instead of a string. Also
take a StringView instead of a String for greater flexibility and efficiency.
Also use a SortedArrayMap instead of a MemoryCompactLookupOnlyRobinHoodHashMap.
(WebCore::profileIDForAlphabeticDoViProfile): Take a StringView instead of
a String for greater flexibility and efficiency. Use a SortedArrayMap instead
of a MemoryCompactLookupOnlyRobinHoodHashMap.
(WebCore::isValidProfileIDForCodec): Take a codec enumeration value parameter
instead of a string.
(WebCore::parseDoViCodecParameters): Take a StringView instead of a String
for greater flexibility and efficiency. Store the codec as an enumeration
instead of a String. Don't create a temporary String just so we can call the
profileIDForAlphabeticDoViProfile function.

* platform/graphics/HEVCUtilities.h: Renamed HEVCParameterSet and
DoViParameterSet to HEVCParameters and DoViParameters. The word "set" is not
helpful in these names. Removed codecName, generalTierFlag, and constraintFlags
from HEVCParameterSet. Changed the parse functions to take StringView instead
of String. Replaced the string codecName in DoViParameterSet with an enumeration
since there are only a few valid values.

* platform/graphics/cocoa/HEVCUtilitiesCocoa.h: Use Optional return value
instead of a bool and an out argument.

* platform/graphics/cocoa/HEVCUtilitiesCocoa.mm:
(WebCore::validateHEVCParameters): Updated to return Optional.
(WebCore::codecType): Updated to take an enumeration value and no longer
need to return an optional. Also renamed from codecTypeForDoViCodecString
since the type now makes this clear without a long function name.
(WebCore::parseStringArrayFromDictionaryToUInt16Vector): Renamed from
CFStringArrayToNumberVector, and moved the dictionary lookup in here.
The old name was a little vague; "NumberVector" doesn't say 16-bit unsigned.
Simplified code by using an Objective-C for loop instead of a block and
enumeration. This cut the size of the function down quite a bit.
(WebCore::validateDoViParameters): Updated to return Optional. Also
refactored to use the imrpoved helper functions above.

* platform/graphics/cocoa/MediaEngineConfigurationFactoryCocoa.cpp:
(WebCore::videoCodecTypeFromRFC4281Type): Take a StringView instead of a String
for greater flexibility and efficiency.
(WebCore::computeMediaCapabilitiesInfo): Factored out this helper function
so we don't have such complicated callback logic. Refactored to use the new
versions of validateHEVCParameters, validateDoViParameters, and
validateVPParameters.
(WebCore::createMediaPlayerDecodingConfigurationCocoa): Moved most of the
code into computeMediaCapabilitiesInfo; this mostly deals with the callback.

* platform/graphics/cocoa/VP9UtilitiesCocoa.h: Removed extraneous use of extern.
Added const for input-only reference arguments. Changed validateVPParameters to
return Optional instead of a bool with an out argument.

* platform/graphics/cocoa/VP9UtilitiesCocoa.mm:
(WebCore::isVP9CodecConfigurationRecordSupported): Added const.
(WebCore::isVP8CodecConfigurationRecordSupported): Ditto.
(WebCore::isVPCodecConfigurationRecordSupported): Ditto.
(WebCore::validateVPParameters): Refactored to return Optional.

* platform/network/HTTPHeaderMap.h: Removed unneeded includes.

* platform/text/LocaleToScriptMapping.cpp: Moved PackedASCIILowerCodes from
here into the SortedArrayMap.h header.

* testing/Internals.cpp:
(WebCore::Internals::parseHEVCCodecParameters): Tweaked since HEVCParameterSet
is now only the correct name here in the Internals class.
(WebCore::Internals::parseDoViCodecParameters): Ditto. Also added code to
expose the codec enumeration as a string. This is now a testing-only thing.
(WebCore::Internals::parseVPCodecParameters): Ditto.

* testing/Internals.h: Tweaked the ParameterSet types since they now don't
exactly match the structures used in the real code.

* testing/Internals.idl: Removed codecName, generalTierFlag, and
constraintFlags from HEVCParameterSet. Neither codecName nor constraintFlags
was used in any test. And the generalTierFlag test was something we can
do without; the parsed value isn't actually used in any WebKit code.

Source/WebKit:

* Shared/RemoteLayerTree/RemoteScrollingCoordinatorTransaction.cpp:
Removed unneeded include.
* Shared/WebsiteData/WebsiteData.h: Ditto.

Source/WTF:

* wtf/SortedArrayMap.h: Moved PackedASCIILowerCodes here for reuse.
Slightly tweaked ComparableASCIISubsetLiteral to match better.

LayoutTests:

* media/hevc-codec-parameters-expected.txt: Remove testing of generalTierFlag, which is ignored
by our actual media code after parsing.
* media/hevc-codec-parameters.html: Ditto.


Canonical link: https://commits.webkit.org/237395@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@277093 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-06 16:08:17 +00:00
Philippe Normand e42db87895 REGRESSION(r271341): media/media-fullscreen-inline.html times out on GTK
https://bugs.webkit.org/show_bug.cgi?id=220540

Reviewed by Xabier Rodriguez-Calvar.

Source/WebCore:

When the GStreamer player client is an <audio> tag it won't render any video, but setting no
explicit video sink on playbin will not prevent video rendering per-se. In that situation
playbin will use autovideosink which will end-up creating a standalone window through
glimagesink or whatever has the highest rank. For now with playbin2 we can use fakevideosink
for such situation. For the playbin3 case we might be able to entirely deactivate video
rendering through stream selection.

Internals::isChangingPresentationMode was enabled for ports not implementing
VIDEO_PRESENTATION_MODE yet, because this test makes use of it.

* platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
(WebCore::MediaPlayerPrivateGStreamer::createGSTPlayBin):
(WebCore::MediaPlayerPrivateGStreamer::createVideoSink):
* testing/Internals.cpp:
(WebCore::Internals::isChangingPresentationMode const):
* testing/Internals.h:
* testing/Internals.idl:

LayoutTests:

Call webkitExitFullScreen() asynchronously to give time to the WebCore FullscreenManager to
notify the video element that it entered full-screen, and thus allowing the exitFullScreen()
call to go through.

* media/media-fullscreen.js:
(fullscreenchange):
(async beginfullscreen):
* platform/glib/TestExpectations:
* platform/glib/media/media-fullscreen-inline-expected.txt:

Canonical link: https://commits.webkit.org/237383@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@277080 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-06 11:11:39 +00:00