Fixed id referencing in WebVTT CSS styling

In CSS, ids are references using #. The absence of # references elements.

NOTE: If the id of a cue was "1", we support its reference with ::cue(#1).
In CSS, however, this is not valid, and the number should be escaped with
\3 as in ::cue(\31). We still do not use number escaping (and I doubt
whether we should at some point).
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=119634708
This commit is contained in:
aquilescanta 2016-04-12 07:02:45 -07:00 committed by Oliver Woodman
parent def59ebb26
commit 767c7ab169
2 changed files with 6 additions and 5 deletions

View File

@ -10,14 +10,14 @@ STYLE
NOTE comment blocks can be used between style blocks.
STYLE
::cue(2) {
::cue(#id2) {
color: peachpuff;
}
1
id1
00:00.000 --> 00:01.234
This is the first subtitle.
2
id2
00:02.345 --> 00:03.456
This is the second subtitle.

View File

@ -41,6 +41,7 @@ import java.util.Map;
/* package */ final class WebvttCue extends Cue {
public static final String UNIVERSAL_CUE_ID = "";
public static final String CUE_ID_PREFIX = "#";
public final String id;
public final long startTime;
@ -122,7 +123,7 @@ import java.util.Map;
public WebvttCue build(Map<String, WebvttCssStyle> styleMap) {
// TODO: Add support for inner spans.
maybeApplyStyleToText(styleMap.get(UNIVERSAL_CUE_ID), 0, text.length());
maybeApplyStyleToText(styleMap.get(id), 0, text.length());
maybeApplyStyleToText(styleMap.get(CUE_ID_PREFIX + id), 0, text.length());
if (position != Cue.DIMEN_UNSET && positionAnchor == Cue.TYPE_UNSET) {
derivePositionAnchorFromAlignment();
}