Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Media element never populates its UA shadow if it was initially created in a document without browsing context #2955

Merged
merged 1 commit into from Aug 8, 2022

Conversation

dcrousso
Copy link
Member

@dcrousso dcrousso commented Aug 2, 2022

f331cc9

Media element never populates its UA shadow if it was initially created in a document without browsing context
https://bugs.webkit.org/show_bug.cgi?id=222657
<rdar://problem/75266631>

Reviewed by Eric Carlson.

Previously, `HTMLMediaElement` relied on `didAddUserAgentShadowRoot` to call the JS `createControls`
that actually populates the UA shadow root. This did not work with `adoptNode` because in that case
the UA shadow root already existed and was already attached to the `<video>`, so it was not called.

Rather than rely on this single path to set up everything, instead have a `ControlsState` enum that
`HTMLMediaElement` can internally reason about to decide whether or not it needs to inject the JS
that creates `createControls` and then call it. This also has the added benefit of having those two
steps now be in the same place, whereas before they were split across two unrelated functions.

* Source/WebCore/html/HTMLMediaElement.h:
* Source/WebCore/html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::HTMLMediaElement):
(WebCore::HTMLMediaElement::updateCaptionContainer):
(WebCore::HTMLMediaElement::virtualHasPendingActivity const):
(WebCore::HTMLMediaElement::configureTextTrackDisplay):
(WebCore::HTMLMediaElement::updateTextTrackDisplay):
(WebCore::HTMLMediaElement::updateTextTrackRepresentationImageIfNeeded):
(WebCore::HTMLMediaElement::configureMediaControls):
(WebCore::HTMLMediaElement::ensureMediaControls): Added.
(WebCore::HTMLMediaElement::getCurrentMediaControlsStatus):
(WebCore::HTMLMediaElement::ensureMediaControlsShadowRoot): Deleted.
(WebCore::HTMLMediaElement::ensureMediaControlsInjectedScript): Deleted.
(WebCore::HTMLMediaElement::didAddUserAgentShadowRoot): Deleted.

* LayoutTests/media/audio-controls-adoptNode.html: Added.
* LayoutTests/media/audio-controls-adoptNode-expected.txt: Added.
* LayoutTests/media/video-controls-adoptNode.html: Added.
* LayoutTests/media/video-controls-adoptNode-expected.txt: Added.

Canonical link: https://commits.webkit.org/253225@main

@dcrousso dcrousso requested a review from cdumez as a code owner August 2, 2022 18:16
@dcrousso dcrousso self-assigned this Aug 2, 2022
@dcrousso dcrousso added Media Bugs related to the HTML 5 Media elements. Safari 14 labels Aug 2, 2022
@@ -1153,6 +1150,9 @@ class HTMLMediaElement
bool m_shouldVideoPlaybackRequireUserGesture : 1;
bool m_volumeLocked : 1;

enum class ControlsState { None, Initializing, Ready };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Specify the width of uint8_t?

@webkit-early-warning-system webkit-early-warning-system added the merging-blocked Applied to prevent a change from being merged label Aug 3, 2022
@dcrousso dcrousso removed the merging-blocked Applied to prevent a change from being merged label Aug 3, 2022
Copy link
Contributor

@eric-carlson eric-carlson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r=me

@dcrousso dcrousso added the merge-queue Applied to send a pull request to merge-queue label Aug 8, 2022
…ed in a document without browsing context

https://bugs.webkit.org/show_bug.cgi?id=222657
<rdar://problem/75266631>

Reviewed by Eric Carlson.

Previously, `HTMLMediaElement` relied on `didAddUserAgentShadowRoot` to call the JS `createControls`
that actually populates the UA shadow root. This did not work with `adoptNode` because in that case
the UA shadow root already existed and was already attached to the `<video>`, so it was not called.

Rather than rely on this single path to set up everything, instead have a `ControlsState` enum that
`HTMLMediaElement` can internally reason about to decide whether or not it needs to inject the JS
that creates `createControls` and then call it. This also has the added benefit of having those two
steps now be in the same place, whereas before they were split across two unrelated functions.

* Source/WebCore/html/HTMLMediaElement.h:
* Source/WebCore/html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::HTMLMediaElement):
(WebCore::HTMLMediaElement::updateCaptionContainer):
(WebCore::HTMLMediaElement::virtualHasPendingActivity const):
(WebCore::HTMLMediaElement::configureTextTrackDisplay):
(WebCore::HTMLMediaElement::updateTextTrackDisplay):
(WebCore::HTMLMediaElement::updateTextTrackRepresentationImageIfNeeded):
(WebCore::HTMLMediaElement::configureMediaControls):
(WebCore::HTMLMediaElement::ensureMediaControls): Added.
(WebCore::HTMLMediaElement::getCurrentMediaControlsStatus):
(WebCore::HTMLMediaElement::ensureMediaControlsShadowRoot): Deleted.
(WebCore::HTMLMediaElement::ensureMediaControlsInjectedScript): Deleted.
(WebCore::HTMLMediaElement::didAddUserAgentShadowRoot): Deleted.

* LayoutTests/media/audio-controls-adoptNode.html: Added.
* LayoutTests/media/audio-controls-adoptNode-expected.txt: Added.
* LayoutTests/media/video-controls-adoptNode.html: Added.
* LayoutTests/media/video-controls-adoptNode-expected.txt: Added.

Canonical link: https://commits.webkit.org/253225@main
@webkit-commit-queue
Copy link
Collaborator

Committed 253225@main (f331cc9): https://commits.webkit.org/253225@main

Reviewed commits have been landed. Closing PR #2955 and removing active labels.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Media Bugs related to the HTML 5 Media elements.
Projects
None yet
5 participants