"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
<rdar://problem/12914550>
Created attachment 186209 [details] Proposed fix 0.1
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; }
Ha, I totally missed that there is also a :lang() pseudo-class - apologies! That's great!
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 .
(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?
(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. :)
(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...
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!
(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 on attachment 186209 [details] Proposed fix 0.1 Clearing flags on attachment: 186209 Committed r141795: <http://trac.webkit.org/changeset/141795>
All reviewed patches have been landed. Closing bug.
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?
(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.