| Index: Source/core/html/track/vtt/VTTParser.cpp
|
| diff --git a/Source/core/html/track/vtt/VTTParser.cpp b/Source/core/html/track/vtt/VTTParser.cpp
|
| index b89b1df64430f13019ed41db6f8b07940f52de30..08a1b974d6882cdcb1573a96de5666c282f6c16d 100644
|
| --- a/Source/core/html/track/vtt/VTTParser.cpp
|
| +++ b/Source/core/html/track/vtt/VTTParser.cpp
|
| @@ -542,25 +542,29 @@ void VTTTreeBuilder::constructTreeFromToken(Document& document)
|
| break;
|
| }
|
| case VTTTokenTypes::StartTag: {
|
| - RefPtr<VTTElement> child;
|
| VTTNodeType nodeType = tokenToNodeType(m_token);
|
| - if (nodeType != VTTNodeTypeNone)
|
| - child = VTTElement::create(nodeType, &document);
|
| - if (child) {
|
| - if (!m_token.classes().isEmpty())
|
| - child->setAttribute(classAttr, m_token.classes());
|
| -
|
| - if (child->webVTTNodeType() == VTTNodeTypeVoice) {
|
| - child->setAttribute(VTTElement::voiceAttributeName(), m_token.annotation());
|
| - } else if (child->webVTTNodeType() == VTTNodeTypeLanguage) {
|
| - m_languageStack.append(m_token.annotation());
|
| - child->setAttribute(VTTElement::langAttributeName(), m_languageStack.last());
|
| - }
|
| - if (!m_languageStack.isEmpty())
|
| - child->setLanguage(m_languageStack.last());
|
| - m_currentNode->parserAppendChild(child);
|
| - m_currentNode = child;
|
| + if (nodeType == VTTNodeTypeNone)
|
| + break;
|
| +
|
| + VTTNodeType currentType = m_currentNode->isVTTElement() ? toVTTElement(m_currentNode.get())->webVTTNodeType() : VTTNodeTypeNone;
|
| + // <rt> is only allowed if the current node is <ruby>.
|
| + if (nodeType == VTTNodeTypeRubyText && currentType != VTTNodeTypeRuby)
|
| + break;
|
| +
|
| + RefPtr<VTTElement> child = VTTElement::create(nodeType, &document);
|
| + if (!m_token.classes().isEmpty())
|
| + child->setAttribute(classAttr, m_token.classes());
|
| +
|
| + if (nodeType == VTTNodeTypeVoice) {
|
| + child->setAttribute(VTTElement::voiceAttributeName(), m_token.annotation());
|
| + } else if (nodeType == VTTNodeTypeLanguage) {
|
| + m_languageStack.append(m_token.annotation());
|
| + child->setAttribute(VTTElement::langAttributeName(), m_languageStack.last());
|
| }
|
| + if (!m_languageStack.isEmpty())
|
| + child->setLanguage(m_languageStack.last());
|
| + m_currentNode->parserAppendChild(child);
|
| + m_currentNode = child;
|
| break;
|
| }
|
| case VTTTokenTypes::EndTag: {
|
|
|