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

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

Issue 747363003: Ignore <rt> children when determining WebVTT text direction (LTR/RTL) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 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/track-cue-rendering-rtl-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/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;
}
« no previous file with comments | « LayoutTests/media/track/track-cue-rendering-rtl-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698