Open Bug 865401 Opened 13 years ago Updated 1 month ago

Implement :past and :future pseudo-classes

Categories

(Core :: Audio/Video: Playback, enhancement)

enhancement

Tracking

()

REOPENED

People

(Reporter: reyre, Assigned: alwu)

References

(Depends on 3 open bugs, Blocks 2 open bugs, )

Details

(4 keywords, Whiteboard: [webcompat:risk-low])

User Story

web-feature: time-relative-selectors
User Agent: Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.64 Safari/537.31 Steps to reproduce: The :future and :past pseudo-elements need to be implemented so that anonymous content created by the WEBVTT parser, relating to captions that are in the immediate past or future of the current caption displaying, can be accessed through it. See: http://dev.w3.org/html5/webvtt/#the-past-and-future-pseudo-classes
OS: Windows 8 → All
Hardware: x86_64 → All
Blocks: old-webvtt
Summary: Implement :past and :future pseudo-element → Implement :past and :future pseudo-classes
Pseudo-classes are pretty easy to implement (unlike pseudo-elements; the distinction is important).
Though it's not clear to me whether these WebVTT nodes are DOM nodes... perhaps whether they are or not is an implementation detail, in which case we can just make them so and then I agree: pseudo-classes are easy.
Status: UNCONFIRMED → RESOLVED
Closed: 13 years ago
Resolution: --- → WONTFIX
Status: RESOLVED → REOPENED
Ever confirmed: true
Resolution: WONTFIX → ---
Component: Audio/Video → Audio/Video: Playback
This should be related to layout.
Component: Audio/Video: Playback → Layout
From email by :heycam : To support these I think we just need to: (a) add two #defines NS_EVENT_STATE_* entries in dom/events/EventStates.h for past and future (b) add entries in nsCSSPseudoClassList.h using CSS_STATE_PSEUDO_CLASS that references these two NS_EVENT_STATE_* values (c) when you need to update which nodes in your DOM tree match these pseudo-classes, you need to call the C++ functions Element::AddStates(NS_EVENT_STATE_*) and Element::RemoveStates(NS_EVENT_STATE_*) to set and clear these state bits, but since you're in JS you might want to add a function to nsIDOMWindowUtils that calls into Element::AddStates/RemoveStates
Assignee: nobody → bechen
AddStates/RemoveStates are for use from the ESM only. That's why they're protected and have assertions about the set of states passed to them. That said, we could do some renaming (e.g. ESM_MANAGED_STATES to EXTERNALLY_MANAGED_STATES) and allow whatever API we're talking about here to call Add/RemoveStates. If we do that, you will be taking over management of these states completely, including for cases like node removal from the document, adoption into another document, etc (assuming that can happen for the relevant nodes). That all said, depending on how many of these nodes you have and whether the perf/memory overhead is acceptable, you may be able to use inIDOMUtils.addPseudoClassLock to do this.
(In reply to Boris Zbarsky [:bz] (still a bit busy) from comment #6) > AddStates/RemoveStates are for use from the ESM only. That's why they're > protected and have assertions about the set of states passed to them. > > That said, we could do some renaming (e.g. ESM_MANAGED_STATES to > EXTERNALLY_MANAGED_STATES) and allow whatever API we're talking about here > to call Add/RemoveStates. Ah, indeed, I missed that we'd need to add them to ESM_MANAGED_STATES. > If we do that, you will be taking over management of these states > completely, including for cases like node removal from the document, > adoption into another document, etc (assuming that can happen for the > relevant nodes). These are NAC nodes that will be controlled entirely from within webvtt.jsm, so I don't think we need to handle such cases. > That all said, depending on how many of these nodes you have and whether the > perf/memory overhead is acceptable, you may be able to use > inIDOMUtils.addPseudoClassLock to do this. Hmm, my initial thought was to suggest this, but then I realised that this would preclude devtools locking these state bits. (Which may or not be something they'd want to do.)
Ah, good point. If devtools can examine these nodes (can they?) then I agree we shouldn't stomp on their API.
I don't know the answer to that, but it seems plausible that it would be useful for developers producing WebVTT files to be able to inspect the stylable captions that we show.
Depends on: 1341230
Depends on: 1344609
Depends on: 1346700
Assignee: bechen → nobody
FYI, Chrome supports :past and :future, here is the test case, https://people-mozilla.org/~alwu/WebVTT/vttTest.html
Severity: normal → S3
Depends on: 1852406
Type: defect → enhancement
User Story: (updated)
Keywords: web-feature
Whiteboard: [webcompat:risk-low]

Moving to the media component. The complexity is there, the CSS bits are trivial. Alastor, do you have a sense of how easy / hard would it be to plumb these? Do we even support WebVTT inline stylesheets? I think we don't?

Component: Layout → Audio/Video: Playback
Flags: needinfo?(alwu)

I might be able to find sometime this year to work on this, assign to myself to do a quick investigation for the current status/plan later. Keep my NI.

Assignee: nobody → alwu

(In reply to Emilio Cobos Álvarez [:emilio] from comment #11)

Do we even support WebVTT inline stylesheets?

Supported today:

  • bare ::cue from a document stylesheet, for the WebVTT-allowed properties: color, background, font, text-shadow...e.t.c.

Not supported:

  • functional ::cue(<selector>)
  • in-file STYLE blocks
  • ::cue-region
  • :past / :future

So basically only the bare ::cue-from-document case works. This matches the status I noted in bug 865395 comment 21. Nothing has changed since.


Do you have a sense of how easy / hard would it be to plumb these?

The CSS keyword bits are trivial as you say, but there's a prerequisite and then the WebVTT work.

1. Selector support

:past/:future are always authored as ::cue(:past) (they're general time-dimensional pseudo-classes, Selectors L5, but cue words are anonymous content, so ::cue() is the only way author CSS can reach them; a bare :past {} is meaningless for captions).

We don't parse the functional ::cue(<selector>) form at all today, so we first need at least a minimal ::cue() parser that accepts a pseudo-class argument. We can keep it minimal because the property set inside ::cue(:past) is the same as plain ::cue, so we skip the selector-dependent property-restriction machinery (the hard/weird part of full ::cue(<selector>)).

2. WebVTT Plumbing

In the WebVTT side, the direction is: make the inline timestamps stylable and flip a past/future state on the surrounding text as playback crosses each timestamp. WebKit does essentially this (markFutureAndPastNodes()/updateDisplayTree()).

3. Testing.

The WPT already exist, so this part is easy.

Conclusion

I'd put :past/:future (minimal ::cue() prerequisite + the WebVTT work) at roughly 1-2 months.

However, filling the whole gap is a lot bigger: full functional ::cue(<selector>) with its per-selector property restrictions, STYLE-block styling, and ::cue-region. That is what bug 865395 is tracking.

Flags: needinfo?(alwu)
You need to log in before you can comment on or make changes to this bug.