Bug 105478 - Implemet :lang() pseudo class support for the WebVTT ::cue pseudo element
Summary: Implemet :lang() pseudo class support for the WebVTT ::cue pseudo element
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Media (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks: 43668
  Show dependency treegraph
 
Reported: 2012-12-19 16:44 PST by Dima Gorbik
Modified: 2013-02-04 13:37 PST (History)
12 users (show)

See Also:


Attachments
Proposed fix 0.1 (4.67 KB, patch)
2013-02-01 20:46 PST, Dima Gorbik
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dima Gorbik 2012-12-19 16:44:19 PST
"For the purposes of the :lang() pseudo-class, WebVTT Internal Node Objects have the language described as the WebVTT Node Object's applicable language."
http://dev.w3.org/html5/webvtt/#the-'::cue'-pseudo-element
Comment 1 Radar WebKit Bug Importer 2012-12-19 16:47:43 PST
<rdar://problem/12914550>
Comment 2 Dima Gorbik 2013-02-01 20:46:41 PST
Created attachment 186209 [details]
Proposed fix 0.1
Comment 3 Silvia Pfeiffer 2013-02-01 22:18:07 PST
You're mistaken. <lang> is an actual element in WebVTT and not a pseudo-element. It's similar to <b>, <c>, <u> etc in that way. See http://dev.w3.org/html5/webvtt/#webvtt-cue-language-span .

Your example should not be:

 ::cue(:lang(ru)) { color: lime; }
::cue(:lang(en)) { color: purple; }

But rather:

 ::cue(lang[lang="ru"]) { color: lime; }
::cue(lang[lang="en"]) { color: purple; }
Comment 4 Silvia Pfeiffer 2013-02-01 22:20:11 PST
Ha, I totally missed that there is also a :lang() pseudo-class - apologies! That's great!
Comment 5 Silvia Pfeiffer 2013-02-01 22:28:47 PST
However, I now wonder what the other part of that example means:

::cue(c[lang="ru"]) { color: red; }
::cue(c[lang="en"]) { color: green; }

As I understand it, the <c> tag in WebVTT does not have a lang attribute. The lang attribute is only defined on the <lang> element.

I believe it might be caused by a typo in the table in http://dev.w3.org/html5/webvtt/#webvtt-cue-language-span . I've just registered https://www.w3.org/Bugs/Public/show_bug.cgi?id=20852 .
Comment 6 Dima Gorbik 2013-02-01 22:52:42 PST
(In reply to comment #5)
> However, I now wonder what the other part of that example means:
> 
> ::cue(c[lang="ru"]) { color: red; }
> ::cue(c[lang="en"]) { color: green; }
> 
> As I understand it, the <c> tag in WebVTT does not have a lang attribute. The lang attribute is only defined on the <lang> element.
> 
> I believe it might be caused by a typo in the table in http://dev.w3.org/html5/webvtt/#webvtt-cue-language-span . I've just registered https://www.w3.org/Bugs/Public/show_bug.cgi?id=20852 .

Hm, interesting. It really looks like only webvtt lang objects have the 'lang' attribute. And I should store the language for those elements internally so that it's only accessible by using this :lang pseudo-class. But why can't we have a lang attribute for all elements? Is this something we should discuss?
Comment 7 Dima Gorbik 2013-02-01 22:55:11 PST
(In reply to comment #5)
> I believe it might be caused by a typo in the table in http://dev.w3.org/html5/webvtt/#webvtt-cue-language-span . I've just registered https://www.w3.org/Bugs/Public/show_bug.cgi?id=20852 .

Yes, you are right! This part was confusing as well. :)
Comment 8 Silvia Pfeiffer 2013-02-01 23:06:06 PST
(In reply to comment #6)
>But why can't we have a lang attribute for all elements? Is this something we should discuss?

It's not like in HTML where all elements have a @lang attribute. The intention is that a section (span? ;-) of text in a cue can be given in a different language to the default language of the file (which is somewhat specified in the @srclang attribute of <track>). It doesn't really make sense to have a bold section in a different language, or a class section - language is not bound to another element.

More at https://www.w3.org/Bugs/Public/show_bug.cgi?id=15922 which led to the introduction of <lang>

That reminds me to register a bug to actually have a default language for the file...
Comment 9 Silvia Pfeiffer 2013-02-01 23:14:14 PST
I've registered https://www.w3.org/Bugs/Public/show_bug.cgi?id=20853 . I'll leave the lang([lang="xx"]) bug on WebKit to you. Thanks for all this great work on getting CSS styling for WebVTT!
Comment 10 Dima Gorbik 2013-02-01 23:40:49 PST
(In reply to comment #9)
> I've registered https://www.w3.org/Bugs/Public/show_bug.cgi?id=20853 . I'll leave the lang([lang="xx"]) bug on WebKit to you. Thanks for all this great work on getting CSS styling for WebVTT!

Yeah, I will have to fix this separately, because it was introduced before in https://bugs.webkit.org/show_bug.cgi?id=107907.
Thanks for the feedback, it's really helpful!
Comment 11 WebKit Review Bot 2013-02-04 13:02:02 PST
Comment on attachment 186209 [details]
Proposed fix 0.1

Clearing flags on attachment: 186209

Committed r141795: <http://trac.webkit.org/changeset/141795>
Comment 12 WebKit Review Bot 2013-02-04 13:02:08 PST
All reviewed patches have been landed.  Closing bug.
Comment 13 Darin Adler 2013-02-04 13:15:08 PST
Comment on attachment 186209 [details]
Proposed fix 0.1

View in context: https://bugs.webkit.org/attachment.cgi?id=186209&action=review

> Source/WebCore/css/SelectorChecker.cpp:825
> +                    value = element->getAttribute(langAttr);

Should probably be fastGetAttribute.

Are we guaranteed that there is always a lang attribute in WebVTT? Would we ever want to compute the inherited language instead?

Is there a way to factor this so we don’t have to put this code into CSS? Maybe a virtual function?
Comment 14 Dima Gorbik 2013-02-04 13:37:21 PST
(In reply to comment #13)
> (From update of attachment 186209 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=186209&action=review
> 
> > Source/WebCore/css/SelectorChecker.cpp:825
> > +                    value = element->getAttribute(langAttr);
> 
> Should probably be fastGetAttribute.
> 
> Are we guaranteed that there is always a lang attribute in WebVTT? Would we ever want to compute the inherited language instead?
> 
> Is there a way to factor this so we don’t have to put this code into CSS? Maybe a virtual function?

According to specs lang attribute should only exist for lang webvtt objects. We should store the language internally to all other nodes, so we will not get this attribute. This is something I have to modify soon. Specs also require to precalculate on the parsing stage so we probably will never do it the same way as we do for html elements. 
Renaming computeInheritedLanguage() function and making it virtual is a good idea, I will do that.