Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(888)

Unified Diff: Source/core/html/track/vtt/VTTParser.cpp

Issue 98783005: WebVTT only allows <rt> if the currently innermost node is <ruby> (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « LayoutTests/media/track/track-webvtt-tc023-markup.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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: {
« no previous file with comments | « LayoutTests/media/track/track-webvtt-tc023-markup.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698