Index: Source/core/html/track/vtt/VTTCue.cpp |
diff --git a/Source/core/html/track/vtt/VTTCue.cpp b/Source/core/html/track/vtt/VTTCue.cpp |
index 6752297ead9ae74350d49724ca733063e39b006a..5fd28fac9fbd72a97bcd3c87c213859f3769f9ae 100644 |
--- a/Source/core/html/track/vtt/VTTCue.cpp |
+++ b/Source/core/html/track/vtt/VTTCue.cpp |
@@ -526,7 +526,6 @@ static TextDirection determineDirectionality(const String& value, bool& hasStron |
static CSSValueID determineTextDirection(DocumentFragment* vttRoot) |
{ |
- DEFINE_STATIC_LOCAL(const String, rtTag, ("rt")); |
ASSERT(vttRoot); |
// Apply the Unicode Bidirectional Algorithm's Paragraph Level steps to the |
@@ -534,14 +533,23 @@ static CSSValueID determineTextDirection(DocumentFragment* vttRoot) |
// pre-order, depth-first traversal, excluding WebVTT Ruby Text Objects and |
// their descendants. |
TextDirection textDirection = LTR; |
- for (Node& node : NodeTraversal::descendantsOf(*vttRoot)) { |
- if (!node.isTextNode() || node.localName() == rtTag) |
- continue; |
+ Node* node = NodeTraversal::next(*vttRoot); |
+ while (node) { |
+ ASSERT(node->isDescendantOf(vttRoot)); |
+ |
+ if (node->isTextNode()) { |
+ bool hasStrongDirectionality; |
+ textDirection = determineDirectionality(node->nodeValue(), hasStrongDirectionality); |
+ if (hasStrongDirectionality) |
+ break; |
+ } else if (node->isVTTElement()) { |
+ if (toVTTElement(node)->webVTTNodeType() == VTTNodeTypeRubyText) { |
+ node = NodeTraversal::nextSkippingChildren(*node); |
+ continue; |
+ } |
+ } |
- bool hasStrongDirectionality; |
- textDirection = determineDirectionality(node.nodeValue(), hasStrongDirectionality); |
- if (hasStrongDirectionality) |
- break; |
+ node = NodeTraversal::next(*node); |
} |
return isLeftToRightDirection(textDirection) ? CSSValueLtr : CSSValueRtl; |
} |