Closed Bug 1707584 Opened 4 years ago Closed 1 month ago

Implement new pseudo-classes for media element states `:playing`, `:paused`, `:seeking`, `:buffering`, `:stalled`, `:muted` and `:volume-locked`

Categories

(Core :: CSS Parsing and Computation, enhancement)

enhancement

Tracking

()

RESOLVED FIXED
149 Branch
Size Estimate M
Tracking Status
firefox149 --- fixed

People

(Reporter: padenot, Assigned: alwu)

References

(Blocks 4 open bugs)

Details

(Keywords: dev-doc-complete, Whiteboard: [platform-feature][webcompat:risk-moderate], [wptsync upstream])

Attachments

(6 files)

This has been merged recently: https://github.com/w3c/csswg-drafts/pull/6219

This adds new pseudo-classes for HTMLMediaElement: :playing, :paused, and :seeking, :buffering and :stalled. Considering the amount of time I see this not being implemented very well on the web, it's quite a nice addition.

There also is :muted, which also sounds really useful (although harder to get wrong), and :volume-locked, that is useful to implement Safari's behaviour on iOS devices (where you can't change the volume of an HTMLMediaElement, only the global volume of the device), but is unnecessary for Gecko, regardless of the platform (it will never match, I don't know if this means we need to do anything about it?).

(In reply to Paul Adenot (:padenot) from comment #0)

There also is :muted, which also sounds really useful (although harder to get wrong), and :volume-locked, that is useful to implement Safari's behaviour on iOS devices (where you can't change the volume of an HTMLMediaElement, only the global volume of the device), but is unnecessary for Gecko, regardless of the platform (it will never match, I don't know if this means we need to do anything about it?).

We should probably parse it even if it doesn't match.

This should be straight-forward to implement, do you plan to take it? If so I can mentor, it's basically a matter of adding entries here, add a relevant flag here, that matches a flag here.

Then depending on how do you want to manage that flag, you need to either add it to MANUALLY_MANAGED_STATES (and AddState / RemoveState appropriately in HTMLMediaElement) or return it from HTMLMediaElement::IntrinsicState() and call UpdateState(true) in the relevant places. Either way seems sensible.

Adding DDN here, in case we feel the need to move on these docs early.

Keywords: dev-doc-needed

(In reply to Emilio Cobos Álvarez (:emilio) from comment #1)

This should be straight-forward to implement, do you plan to take it? If so I can mentor, it's basically a matter of adding entries here, add a relevant flag here, that matches a flag here.

I'd love to, it's been a while I haven't been doing style things (and it must be even cooler in rust!), but I can't prioritize this above what I'm doing now and for the forseable future. Let's leave this available. I can also mentor for the media bits, but they are really straightforward.

User Story: (updated)
Whiteboard: [platform-feature][webcompat:risk-moderate]
Size Estimate: --- → M
Assignee: nobody → alwu
Duplicate of this bug: 1565572

I think the definition of :stalled might be incorrect. From this test, it appears that this selector is intended to correspond to the media element’s stalled event. However, its definition conflicts with how the stalled event is defined in the HTML spec.

Let me explain it below. First, let see the selector definition.

:buffering
The :buffering pseudo-class must match all media elements whose paused attribute is false, networkState attribute is NETWORK_LOADING, and ready state is HAVE_CURRENT_DATA or less.

:stalled
The :stalled pseudo-class must match all media elements that match the :buffering pseudo-class and whose is currently stalled is true.

So the :stalled selector is required to match :buffering, which means the readyState must be HAVE_CURRENT_DATA or less. However, in the HTML spec, the stalled event is related to downloading.

A media element could already have enough data buffered and then encountering not able to download more data, which would trigger stalled. That does not necessarily mean the readyState must be equal to or below HAVE_CURRENT_DATA.

Because of this, I think it is incorrect for :stalled to require matching :buffering. Instead, it should likely only check networkState and paused, but not readyState.

Paul, could you help double-check whether my understanding is correct? If so, I can file an issue on the spec. Thanks!

Flags: needinfo?(padenot)

I will implement :playing, :paused, :seeking, :buffering, :stalled (I still have some questions about its definition though) and :muted. I will file another new bug for :volume-locked because it's still unclear what we can do for that.

Blocks: 2013367
Summary: Implement new pseudo-classes for media element states → Implement new pseudo-classes for media element states `:playing`, `:paused`, `:seeking`, `:buffering`, `:stalled` and `:muted`.

I will still implement :volume-locked in this bug, but will separate the implementation for matching element into bug 2013371.

Summary: Implement new pseudo-classes for media element states `:playing`, `:paused`, `:seeking`, `:buffering`, `:stalled` and `:muted`. → Implement new pseudo-classes for media element states `:playing`, `:paused`, `:seeking`, `:buffering`, `:stalled`, `:muted` and `:volume-locked`
Blocks: 2013371
Duplicate of this bug: 2000526
Attachment #9541015 - Attachment description: WIP: Bug 1707584 - part1 : implement :playing and :paused pseudo classes. → Bug 1707584 - part1 : implement :playing and :paused pseudo classes.
Attachment #9541016 - Attachment description: WIP: Bug 1707584 - part2 : implement :seeking pseudo class. → Bug 1707584 - part2 : implement :seeking pseudo class.
Attachment #9541017 - Attachment description: WIP: Bug 1707584 - part3 : implement :buffering and :stalled pseudo classes. → Bug 1707584 - part3 : implement :buffering and :stalled pseudo classes.
Attachment #9541018 - Attachment description: WIP: Bug 1707584 - part4 : implement :muted pseudo classes. → Bug 1707584 - part4 : implement :muted pseudo classes.

This patch only implements the :volume-locked [1] but doesn't implement
the matching process for media element, which should be done in bug 2013371.

[1] https://html.spec.whatwg.org/multipage/semantics-other.html#selector-volume-locked

Attachment #9541018 - Attachment description: Bug 1707584 - part4 : implement :muted pseudo classes. → Bug 1707584 - part4 : implement :muted pseudo class.

Yes, I think your reading of the spec is correct and this warrants an issue.

Flags: needinfo?(padenot)
Blocks: 2014512
Pushed by alwu@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/4c7319eb8292 https://hg.mozilla.org/integration/autoland/rev/4769fac12cfe part1 : implement :playing and :paused pseudo classes. r=media-playback-reviewers,firefox-style-system-reviewers,emilio,chunmin https://github.com/mozilla-firefox/firefox/commit/adc25451597d https://hg.mozilla.org/integration/autoland/rev/4cc103a7f0ee part2 : implement :seeking pseudo class. r=media-playback-reviewers,firefox-style-system-reviewers,emilio,chunmin https://github.com/mozilla-firefox/firefox/commit/606b5bcb40aa https://hg.mozilla.org/integration/autoland/rev/a241d7fe65ed part3 : implement :buffering and :stalled pseudo classes. r=media-playback-reviewers,firefox-style-system-reviewers,emilio,chunmin https://github.com/mozilla-firefox/firefox/commit/cc9c51c3dd5c https://hg.mozilla.org/integration/autoland/rev/ac9c93a4ea92 part4 : implement :muted pseudo class. r=media-playback-reviewers,firefox-style-system-reviewers,emilio,chunmin https://github.com/mozilla-firefox/firefox/commit/911b73e9ff35 https://hg.mozilla.org/integration/autoland/rev/7d6c34023428 part5 : implement :volume-locked pseudo class. r=firefox-style-system-reviewers,emilio https://github.com/mozilla-firefox/firefox/commit/9cd813feb917 https://hg.mozilla.org/integration/autoland/rev/19f33556bfc6 apply code formatting via Lando
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/57593 for changes under testing/web-platform/tests
Whiteboard: [platform-feature][webcompat:risk-moderate] → [platform-feature][webcompat:risk-moderate], [wptsync upstream]
Pushed by chorotan@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/2f14f7a2e1b8 https://hg.mozilla.org/integration/autoland/rev/2ec1f6de1e0e Revert "Bug 1707584: apply code formatting via Lando" for causing Crashtest failures on Assertions.h
Upstream PR merged by moz-wptsync-bot
Attachment #9543032 - Attachment description: Bug 1707584 - part6 : defer states change if in the proces of style update. → Bug 1707584 - part6 : defer pausing video element during the style refresh.
Blocks: 2015167
Flags: needinfo?(alwu)
Pushed by alwu@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/7edf28d1aba2 https://hg.mozilla.org/integration/autoland/rev/686e360ad67e part1 : implement :playing and :paused pseudo classes. r=media-playback-reviewers,firefox-style-system-reviewers,emilio,chunmin https://github.com/mozilla-firefox/firefox/commit/90eb82c617c1 https://hg.mozilla.org/integration/autoland/rev/967e757e6850 part2 : implement :seeking pseudo class. r=media-playback-reviewers,firefox-style-system-reviewers,emilio,chunmin https://github.com/mozilla-firefox/firefox/commit/b25ca8c165a0 https://hg.mozilla.org/integration/autoland/rev/845ed049fa40 part3 : implement :buffering and :stalled pseudo classes. r=media-playback-reviewers,firefox-style-system-reviewers,emilio,chunmin https://github.com/mozilla-firefox/firefox/commit/4c0c504a8868 https://hg.mozilla.org/integration/autoland/rev/fd9b3f83d1b4 part4 : implement :muted pseudo class. r=media-playback-reviewers,firefox-style-system-reviewers,emilio,chunmin https://github.com/mozilla-firefox/firefox/commit/b6a6bba800ff https://hg.mozilla.org/integration/autoland/rev/d8c8118af08f part5 : implement :volume-locked pseudo class. r=firefox-style-system-reviewers,emilio https://github.com/mozilla-firefox/firefox/commit/b418243a4446 https://hg.mozilla.org/integration/autoland/rev/d1a65d9be4dd part6 : defer pausing video element during the style refresh. r=emilio
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/57633 for changes under testing/web-platform/tests
No longer blocks: 1707597
See Also: → 1707597

Alastor, is that something we should mention in our 149 release notes? Thanks

https://wiki.mozilla.org/Release_Management/Release_Notes_Nomination

Flags: needinfo?(alwu)

This is still pref-off by default, and there is a follow-up (bug 2015556) that needs to be completed before we turn it on. I’ll likely consider enabling it in Fx150 and will add a release note flag at that time.

Flags: needinfo?(alwu)
User Story: (updated)

Related issues and pull requests

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: