Commit 767c7ab1 by aquilescanta Committed by Oliver Woodman

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
parent def59ebb
...@@ -10,14 +10,14 @@ STYLE ...@@ -10,14 +10,14 @@ STYLE
NOTE comment blocks can be used between style blocks. NOTE comment blocks can be used between style blocks.
STYLE STYLE
::cue(2) { ::cue(#id2) {
color: peachpuff; color: peachpuff;
} }
1 id1
00:00.000 --> 00:01.234 00:00.000 --> 00:01.234
This is the first subtitle. This is the first subtitle.
2 id2
00:02.345 --> 00:03.456 00:02.345 --> 00:03.456
This is the second subtitle. This is the second subtitle.
...@@ -41,6 +41,7 @@ import java.util.Map; ...@@ -41,6 +41,7 @@ import java.util.Map;
/* package */ final class WebvttCue extends Cue { /* package */ final class WebvttCue extends Cue {
public static final String UNIVERSAL_CUE_ID = ""; public static final String UNIVERSAL_CUE_ID = "";
public static final String CUE_ID_PREFIX = "#";
public final String id; public final String id;
public final long startTime; public final long startTime;
...@@ -122,7 +123,7 @@ import java.util.Map; ...@@ -122,7 +123,7 @@ import java.util.Map;
public WebvttCue build(Map<String, WebvttCssStyle> styleMap) { public WebvttCue build(Map<String, WebvttCssStyle> styleMap) {
// TODO: Add support for inner spans. // TODO: Add support for inner spans.
maybeApplyStyleToText(styleMap.get(UNIVERSAL_CUE_ID), 0, text.length()); 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) { if (position != Cue.DIMEN_UNSET && positionAnchor == Cue.TYPE_UNSET) {
derivePositionAnchorFromAlignment(); derivePositionAnchorFromAlignment();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment