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

WebVTT should expose an inline-block backdrop element for cues #516

Open
jernoble opened this issue Jun 28, 2023 · 11 comments
Open

WebVTT should expose an inline-block backdrop element for cues #516

jernoble opened this issue Jun 28, 2023 · 11 comments

Comments

@jernoble
Copy link

Safari and WebKit on macOS and iOS have a long-standing default treatment of text track cues that incorporates an inline-block wrapper around the cues, so as to provide the same rendering of cues as is available to native applications using system media frameworks. The styles for this inline-block wrapper are configurable through system defaults, allowing the user to choose between an inline-block style highlight, and a inline highlight. (See attached images for examples.)

Because this block is not exposed through WebVTT, it is very difficult (if not impossible) for inline- or page-provided styles to override this rendering.

inline-block inline
@jernoble
Copy link
Author

Strawman solution 1: Add an additional wrapper anonymous block with a display: inline-block style, and add a specific selector for ::cue(selector) that applies to the block.

Strawman solution 2: Allow the display: property to apply to the ::cue and ::cue(selector) pseudo element, with the allowed values of inline and inline-block.

@jernoble
Copy link
Author

jernoble commented Jun 28, 2023

The macOS System Preferences allow users to specify cue treatments that have separate properties for the cue "window" (i.e., the inline-block wrapper) and the cue "background" (i.e., the "WebVTT background box"). See the settings for "background color / opacity" and "window color / opacity" below:

image
image
image

This may mean that "straw man solution 2" is untenable on macOS and iOS, since they allow the user to override styles of the inline-box and inline wrappers separately.

@jernoble
Copy link
Author

jernoble commented Jul 6, 2023

As an internal implementation detail, WebKit uses the pseudo-element ::-webkit-media-text-track-display-backdrop to refer to the inline-block element which wraps each ::cue. While that's an unreasonably verbose pesudo name, something like ::cue-backdrop would be sufficiently succinct. The ::cue-backdrop pseudo-element could be restricted to a short list of CSS properties; such as background, border-radius, and padding.

@nigelmegitt
Copy link
Contributor

How does this map semantically to e.g. region, div or p in TTML? Is it definitely equivalent to an HTML div or could it be equivalent to a p being a different block element?

I ask because if there is an opportunity to close the semantic gap, we should probably take it. It's unclear how the FCC "window" concept maps too, in the sense that there is more than one possible option for mapping, and I suspect (only by reading between the lines) that FCC does not consider it appropriate for them to go into this level of format-dependent detail.

@jernoble
Copy link
Author

jernoble commented Jul 6, 2023

No idea how this maps to TTML. For HTML, it's definitely equivalent to a div insofar as a p is just a div with style.

@jernoble
Copy link
Author

Pinging this thread. Strawman proposal would be that the "window" of a WebVTT cue should be selectable by a ::cue-window selector.

@nigelmegitt
Copy link
Contributor

@jernoble can you define "window"?

@jernoble
Copy link
Author

What definition are you looking for? CEA-708 already defines "caption windows", as well as defines display properties of those windows, including background color, border effects, and transparency. But in the context of WebVTT, I would define a "cue window" as an "inline-block element wrapping the WebVTT Internal Objects generated by the cue".

@jernoble
Copy link
Author

Ping on this issue. The ability for web pages to override system-provided styling of "caption windows" is critical for interoperability and use of WebVTT in web pages generally.

@silviapfeiffer
Copy link
Member

I like the idea of ::cue-window for dealing with the background. Can I suggest preparing a pull request? That makes the life of the current maintainer a bit easier...

@gkatsev
Copy link
Collaborator

gkatsev commented Sep 24, 2024

I would be in support of exposing ::cue-window. It would basically be an alias for the existing ::-webkit-media-text-track-display-backdrop element in safari?

It would be nice to figure out the TTML mapping, but that can be done separately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants