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

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

Issue 96933004: Fix tag closing issues in the WebVTT tree builder (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 1 month 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/opera/track/webvtt/parsing-cue-data/tests/tree-building-expected.txt ('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 eeb0c9f0cfa7c74a2df86191e076d01773de0d30..b89b1df64430f13019ed41db6f8b07940f52de30 100644
--- a/Source/core/html/track/vtt/VTTParser.cpp
+++ b/Source/core/html/track/vtt/VTTParser.cpp
@@ -565,12 +565,29 @@ void VTTTreeBuilder::constructTreeFromToken(Document& document)
}
case VTTTokenTypes::EndTag: {
VTTNodeType nodeType = tokenToNodeType(m_token);
- if (nodeType != VTTNodeTypeNone) {
- if (nodeType == VTTNodeTypeLanguage && m_currentNode->isVTTElement() && toVTTElement(m_currentNode.get())->webVTTNodeType() == VTTNodeTypeLanguage)
- m_languageStack.removeLast();
- if (m_currentNode->parentNode())
- m_currentNode = m_currentNode->parentNode();
+ if (nodeType == VTTNodeTypeNone)
+ break;
+
+ // The only non-VTTElement would be the DocumentFragment root. (Text
+ // nodes and PIs will never appear as m_currentNode.)
+ if (!m_currentNode->isVTTElement())
+ break;
+
+ VTTNodeType currentType = toVTTElement(m_currentNode.get())->webVTTNodeType();
+ bool matchesCurrent = nodeType == currentType;
+ if (!matchesCurrent) {
+ // </ruby> auto-closes <rt>.
+ if (currentType == VTTNodeTypeRubyText && nodeType == VTTNodeTypeRuby) {
+ if (m_currentNode->parentNode())
+ m_currentNode = m_currentNode->parentNode();
+ } else {
+ break;
+ }
}
+ if (nodeType == VTTNodeTypeLanguage)
+ m_languageStack.removeLast();
+ if (m_currentNode->parentNode())
+ m_currentNode = m_currentNode->parentNode();
break;
}
case VTTTokenTypes::TimestampTag: {
« no previous file with comments | « LayoutTests/media/track/opera/track/webvtt/parsing-cue-data/tests/tree-building-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698