## Background:
The native DOM Parser can perform poorly on some older devices, this
approach is faster on newer devices but is considerably better on older
devices.
This PR replaces the usage of the DOM Parser for DASH, MSS, VTT and
TTML.
The draw back of this approach that it does not include any validation
at the cost of better performance.
Harden the XmlUtils.parseXmlString function against XML documents that embed elements from the HTML or SVG namespaces, which could trigger script execution and cause XSS vulnerabilities.
Also migrate direct users of the DOMParser.parseFromString function to XmlUtils, and add appropriate unit tests.
When running in sequence mode, we ignore the normal timestamps
of video and audio segments. This lead to problems in some Apple-
encoded webvtt content, which used the X-TIMESTAMP-MAP tag to account
for the timestamp offsets in their video. Thus, those subtitles would
end up 10 seconds offset.
This changes the webvtt parser to ignore the X-TIMESTAMP-MAP when in
sequence mode.
Issue #2337
The recent changes to TTML parsing, to not inherit regions,
inadvertently ended up breaking text alignment in situations
where a region with alignment was on the p or div above a span.
Previously, we only inherited the text and display alignment
from a region on leaf nodes... which was a problem, since we
also didn't apply any styles to text nodes.
Change-Id: I62ac155bc4310a5f7da52c10ca2dd434f8015c97
This changes the TTML parser to not allow cue regions to be inherited
to the children of the element the region was originally assigned on,
except for the purposes of styles (colors, etc).
To allow regions on elements "above" the cues in TTML, such as the
<body> or <div> elements, this also changes the TTML parser to render
the full structure of the TTML file as a tree of cues. The end result
will be a single cue representing the <body>, with children
representing the <div> elements inside it, and those <divs> will have
children that represent the actual cues. Now that our text displayer
can intelligently update child cues as they enter or leave the display
window, this approach should be possible.
Closes#3850Closes#3741
Change-Id: Ia8d750daa06920610c04e9b26e29d2d304eaf8a9
When trying to detect if it is appropriate to ignore a non-break
element, the ttml parser would base the decision on the presence
of timing info in the cue itself, and on the presence of
textContent within the node. If neither is present, the element
might be ignored.
This works in most cases of nested cues, as the presence of text
within a child node will show up in the textContent of the parent
node. However, not all valid ttml cues have textContent; image
cues, for example, have their contents defined as a DOM attribute.
This changes the ttml parser to not ignore any cue that has child
cues. It also changes the ttml parser to cause cues with no defined
timing to base their timing on their child cues, if present.
This also changes our UI text displayer to respect the timing info
of child cues.
Closes#3643
Change-Id: I9a017f53398bbed8dbeeeebca2cff76dd3666c64
Unfortunately, modern browsers do not support any CSS property that
directly maps to tts:textOutline. However, the non-standard (but still
commonly implemented) -webkit-text-stroke-width and
-webkit-text-stroke-color properties, when used together, can
replicate the functionality of tts:textOutline, with the exception of
the optional blur radius.
Closes#3612
Change-Id: I863d09fc447765646bd405c59b0b20960362a594
TTML allows "smpte:backgroundImage" on both the div level and p level. Adding parsing the background images into cues on the div level.
Closes: #3097Closes#3248
Ever since background image support was introduced in PR #1859, and
since the feature was first released in v2.5.0, we were checking for
"imagetype" (lowercase) instead of the spec-compliant "imageType"
(camelCase).
This fixes the parser to accept both, and updates our unit tests with
spec-compliant content.
Fixes#3196
Change-Id: Ife13ca92220e4bfde150f9f0b1d9a3de3a954821
1. Add support for multiple layers of nested cues.
2. Add support for anonymous span.
Closes#2623Closes#2761
Change-Id: I10a253b1a965606fc2db49c3168e92bcf4a95fa1
Styles in TTML can refer to other styles for inheritance. This fixes
the implementation of inheritance in the TTML parser so that it
recurses up the chain of styles that refer to other styles. This is
done both for elements and regions.
Fixes: 159050711
Change-Id: I59a8f9df73d98710832b329f59ce64ba28c9f573
This fixes all the license headers in the main library, which corrects
the appearance of the main license in the compiled output.
It seems that the `!` in the header forces the compiler to keep it in
the output. I believe older compiler releases did this purely based
on `@license`.
Issue #2638
Change-Id: I7f0e918caad10c9af689c9d07672b7fe9be7b2f3
Various issues with the nullability of string types led to various
fixes, including:
- adding an assertion or runtime check that something is not null
- moving an existing null check to before a calculation
- converting a test expectation into an assertion that the compiler
understands (which will still fail the test if the assertion
fails)
These issues were caught by a compiler upgrade.
Issue #2528
Change-Id: I11da091c9e7974c8bea84b3b584cbd29d1e320e2
A regex in the TTML parser was looking for "word" characters (\w),
which is short-hand for non-whitespace ASCII characters, and excludes
Unicode characters and symbols from non-English languages.
There is a better option in Regex in some browsers, which is /\p{L}/u.
This is not supported universally yet, and defining an equivalent
regex constant using character codes is over 4kB of extra code.
It seems that the original author of that code meant "word" (\w) in
the sense of "non-whitespace" (\S), so we can just use \S instead.
This change also adds a regression test that doesn't depend on the
specifics of the regular expression used.
Closes#2478
Change-Id: I794258a797ba5d26a7bd8fc0a5244adc70c8a1ef
querySelector isn't available in Shaka Player Embedded. Since we only
use it to find nodes with a specific tag name, we can usually use
getElementsByTagName.
Issue google/shaka-player-embedded#113
Change-Id: Ia225e5d1f7598b13bd05db868fe2ea566dca4493
Instead of having the "factories" use "new" to construct them, now they
will be plain functions.
Closes#1521
Change-Id: Ia6151ad679a78a5c6db128d43094c82add0af348