| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2013, Opera Software ASA. All rights reserved. | 2 * Copyright (c) 2013, Opera Software ASA. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 519 { | 519 { |
| 520 TextRun run(value); | 520 TextRun run(value); |
| 521 BidiResolver<VTTTextRunIterator, BidiCharacterRun> bidiResolver; | 521 BidiResolver<VTTTextRunIterator, BidiCharacterRun> bidiResolver; |
| 522 bidiResolver.setStatus(BidiStatus(LTR, false)); | 522 bidiResolver.setStatus(BidiStatus(LTR, false)); |
| 523 bidiResolver.setPositionIgnoringNestedIsolates(VTTTextRunIterator(&run, 0)); | 523 bidiResolver.setPositionIgnoringNestedIsolates(VTTTextRunIterator(&run, 0)); |
| 524 return bidiResolver.determineParagraphDirectionality(&hasStrongDirectionalit
y); | 524 return bidiResolver.determineParagraphDirectionality(&hasStrongDirectionalit
y); |
| 525 } | 525 } |
| 526 | 526 |
| 527 static CSSValueID determineTextDirection(DocumentFragment* vttRoot) | 527 static CSSValueID determineTextDirection(DocumentFragment* vttRoot) |
| 528 { | 528 { |
| 529 DEFINE_STATIC_LOCAL(const String, rtTag, ("rt")); | |
| 530 ASSERT(vttRoot); | 529 ASSERT(vttRoot); |
| 531 | 530 |
| 532 // Apply the Unicode Bidirectional Algorithm's Paragraph Level steps to the | 531 // Apply the Unicode Bidirectional Algorithm's Paragraph Level steps to the |
| 533 // concatenation of the values of each WebVTT Text Object in nodes, in a | 532 // concatenation of the values of each WebVTT Text Object in nodes, in a |
| 534 // pre-order, depth-first traversal, excluding WebVTT Ruby Text Objects and | 533 // pre-order, depth-first traversal, excluding WebVTT Ruby Text Objects and |
| 535 // their descendants. | 534 // their descendants. |
| 536 TextDirection textDirection = LTR; | 535 TextDirection textDirection = LTR; |
| 537 for (Node& node : NodeTraversal::descendantsOf(*vttRoot)) { | 536 Node* node = NodeTraversal::next(*vttRoot); |
| 538 if (!node.isTextNode() || node.localName() == rtTag) | 537 while (node) { |
| 539 continue; | 538 ASSERT(node->isDescendantOf(vttRoot)); |
| 540 | 539 |
| 541 bool hasStrongDirectionality; | 540 if (node->isTextNode()) { |
| 542 textDirection = determineDirectionality(node.nodeValue(), hasStrongDirec
tionality); | 541 bool hasStrongDirectionality; |
| 543 if (hasStrongDirectionality) | 542 textDirection = determineDirectionality(node->nodeValue(), hasStrong
Directionality); |
| 544 break; | 543 if (hasStrongDirectionality) |
| 544 break; |
| 545 } else if (node->isVTTElement()) { |
| 546 if (toVTTElement(node)->webVTTNodeType() == VTTNodeTypeRubyText) { |
| 547 node = NodeTraversal::nextSkippingChildren(*node); |
| 548 continue; |
| 549 } |
| 550 } |
| 551 |
| 552 node = NodeTraversal::next(*node); |
| 545 } | 553 } |
| 546 return isLeftToRightDirection(textDirection) ? CSSValueLtr : CSSValueRtl; | 554 return isLeftToRightDirection(textDirection) ? CSSValueLtr : CSSValueRtl; |
| 547 } | 555 } |
| 548 | 556 |
| 549 void VTTCue::calculateDisplayParameters() | 557 void VTTCue::calculateDisplayParameters() |
| 550 { | 558 { |
| 551 createVTTNodeTree(); | 559 createVTTNodeTree(); |
| 552 | 560 |
| 553 // Steps 10.2, 10.3 | 561 // Steps 10.2, 10.3 |
| 554 m_displayDirection = determineTextDirection(m_vttNodeTree.get()); | 562 m_displayDirection = determineTextDirection(m_vttNodeTree.get()); |
| (...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1097 | 1105 |
| 1098 void VTTCue::trace(Visitor* visitor) | 1106 void VTTCue::trace(Visitor* visitor) |
| 1099 { | 1107 { |
| 1100 visitor->trace(m_vttNodeTree); | 1108 visitor->trace(m_vttNodeTree); |
| 1101 visitor->trace(m_cueBackgroundBox); | 1109 visitor->trace(m_cueBackgroundBox); |
| 1102 visitor->trace(m_displayTree); | 1110 visitor->trace(m_displayTree); |
| 1103 TextTrackCue::trace(visitor); | 1111 TextTrackCue::trace(visitor); |
| 1104 } | 1112 } |
| 1105 | 1113 |
| 1106 } // namespace blink | 1114 } // namespace blink |
| OLD | NEW |