OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
3 * Copyright (C) 2011, 2012, 2013 Apple Inc. All rights reserved. | 3 * Copyright (C) 2011, 2012, 2013 Apple Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
7 * met: | 7 * met: |
8 * | 8 * |
9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 #include "wtf/text/StringBuilder.h" | 50 #include "wtf/text/StringBuilder.h" |
51 | 51 |
52 namespace WebCore { | 52 namespace WebCore { |
53 | 53 |
54 static const int invalidCueIndex = -1; | 54 static const int invalidCueIndex = -1; |
55 static const int undefinedPosition = -1; | 55 static const int undefinedPosition = -1; |
56 static const int autoSize = 0; | 56 static const int autoSize = 0; |
57 | 57 |
58 static const String& startKeyword() | 58 static const String& startKeyword() |
59 { | 59 { |
60 DEFINE_STATIC_LOCAL(const String, start, (ASCIILiteral("start"))); | 60 DEFINE_STATIC_LOCAL(const String, start, ("start")); |
61 return start; | 61 return start; |
62 } | 62 } |
63 | 63 |
64 static const String& middleKeyword() | 64 static const String& middleKeyword() |
65 { | 65 { |
66 DEFINE_STATIC_LOCAL(const String, middle, (ASCIILiteral("middle"))); | 66 DEFINE_STATIC_LOCAL(const String, middle, ("middle")); |
67 return middle; | 67 return middle; |
68 } | 68 } |
69 | 69 |
70 static const String& endKeyword() | 70 static const String& endKeyword() |
71 { | 71 { |
72 DEFINE_STATIC_LOCAL(const String, end, (ASCIILiteral("end"))); | 72 DEFINE_STATIC_LOCAL(const String, end, ("end")); |
73 return end; | 73 return end; |
74 } | 74 } |
75 | 75 |
76 static const String& horizontalKeyword() | 76 static const String& horizontalKeyword() |
77 { | 77 { |
78 return emptyString(); | 78 return emptyString(); |
79 } | 79 } |
80 | 80 |
81 static const String& verticalGrowingLeftKeyword() | 81 static const String& verticalGrowingLeftKeyword() |
82 { | 82 { |
83 DEFINE_STATIC_LOCAL(const String, verticalrl, (ASCIILiteral("rl"))); | 83 DEFINE_STATIC_LOCAL(const String, verticalrl, ("rl")); |
84 return verticalrl; | 84 return verticalrl; |
85 } | 85 } |
86 | 86 |
87 static const String& verticalGrowingRightKeyword() | 87 static const String& verticalGrowingRightKeyword() |
88 { | 88 { |
89 DEFINE_STATIC_LOCAL(const String, verticallr, (ASCIILiteral("lr"))); | 89 DEFINE_STATIC_LOCAL(const String, verticallr, ("lr")); |
90 return verticallr; | 90 return verticallr; |
91 } | 91 } |
92 | 92 |
93 // ---------------------------- | 93 // ---------------------------- |
94 | 94 |
95 TextTrackCueBox::TextTrackCueBox(Document* document, TextTrackCue* cue) | 95 TextTrackCueBox::TextTrackCueBox(Document* document, TextTrackCue* cue) |
96 : HTMLDivElement(divTag, document) | 96 : HTMLDivElement(divTag, document) |
97 , m_cue(cue) | 97 , m_cue(cue) |
98 { | 98 { |
99 setPart(textTrackCueBoxShadowPseudoId()); | 99 setPart(textTrackCueBoxShadowPseudoId()); |
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
601 | 601 |
602 static bool isCueParagraphSeparator(UChar character) | 602 static bool isCueParagraphSeparator(UChar character) |
603 { | 603 { |
604 // Within a cue, paragraph boundaries are only denoted by Type B characters, | 604 // Within a cue, paragraph boundaries are only denoted by Type B characters, |
605 // such as U+000A LINE FEED (LF), U+0085 NEXT LINE (NEL), and U+2029 PARAGRA
PH SEPARATOR. | 605 // such as U+000A LINE FEED (LF), U+0085 NEXT LINE (NEL), and U+2029 PARAGRA
PH SEPARATOR. |
606 return WTF::Unicode::category(character) & WTF::Unicode::Separator_Paragraph
; | 606 return WTF::Unicode::category(character) & WTF::Unicode::Separator_Paragraph
; |
607 } | 607 } |
608 | 608 |
609 void TextTrackCue::determineTextDirection() | 609 void TextTrackCue::determineTextDirection() |
610 { | 610 { |
611 DEFINE_STATIC_LOCAL(const String, rtTag, (ASCIILiteral("rt"))); | 611 DEFINE_STATIC_LOCAL(const String, rtTag, ("rt")); |
612 createWebVTTNodeTree(); | 612 createWebVTTNodeTree(); |
613 | 613 |
614 // Apply the Unicode Bidirectional Algorithm's Paragraph Level steps to the | 614 // Apply the Unicode Bidirectional Algorithm's Paragraph Level steps to the |
615 // concatenation of the values of each WebVTT Text Object in nodes, in a | 615 // concatenation of the values of each WebVTT Text Object in nodes, in a |
616 // pre-order, depth-first traversal, excluding WebVTT Ruby Text Objects and | 616 // pre-order, depth-first traversal, excluding WebVTT Ruby Text Objects and |
617 // their descendants. | 617 // their descendants. |
618 StringBuilder paragraphBuilder; | 618 StringBuilder paragraphBuilder; |
619 for (Node* node = m_webVTTNodeTree->firstChild(); node; node = NodeTraversal
::next(node, m_webVTTNodeTree.get())) { | 619 for (Node* node = m_webVTTNodeTree->firstChild(); node; node = NodeTraversal
::next(node, m_webVTTNodeTree.get())) { |
620 if (!node->isTextNode() || node->localName() == rtTag) | 620 if (!node->isTextNode() || node->localName() == rtTag) |
621 continue; | 621 continue; |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
732 if (!m_snapToLines && (m_writingDirection == VerticalGrowingLeft || m_writin
gDirection == VerticalGrowingRight)) | 732 if (!m_snapToLines && (m_writingDirection == VerticalGrowingLeft || m_writin
gDirection == VerticalGrowingRight)) |
733 m_displayPosition.first = m_computedLinePosition; | 733 m_displayPosition.first = m_computedLinePosition; |
734 | 734 |
735 // A text track cue has a text track cue computed line position whose value | 735 // A text track cue has a text track cue computed line position whose value |
736 // is defined in terms of the other aspects of the cue. | 736 // is defined in terms of the other aspects of the cue. |
737 m_computedLinePosition = calculateComputedLinePosition(); | 737 m_computedLinePosition = calculateComputedLinePosition(); |
738 } | 738 } |
739 | 739 |
740 void TextTrackCue::markFutureAndPastNodes(ContainerNode* root, double previousTi
mestamp, double movieTime) | 740 void TextTrackCue::markFutureAndPastNodes(ContainerNode* root, double previousTi
mestamp, double movieTime) |
741 { | 741 { |
742 DEFINE_STATIC_LOCAL(const String, timestampTag, (ASCIILiteral("timestamp")))
; | 742 DEFINE_STATIC_LOCAL(const String, timestampTag, ("timestamp")); |
743 | 743 |
744 bool isPastNode = true; | 744 bool isPastNode = true; |
745 double currentTimestamp = previousTimestamp; | 745 double currentTimestamp = previousTimestamp; |
746 if (currentTimestamp > movieTime) | 746 if (currentTimestamp > movieTime) |
747 isPastNode = false; | 747 isPastNode = false; |
748 | 748 |
749 for (Node* child = root->firstChild(); child; child = NodeTraversal::next(ch
ild, root)) { | 749 for (Node* child = root->firstChild(); child; child = NodeTraversal::next(ch
ild, root)) { |
750 if (child->nodeName() == timestampTag) { | 750 if (child->nodeName() == timestampTag) { |
751 unsigned position = 0; | 751 unsigned position = 0; |
752 String timestamp = child->nodeValue(); | 752 String timestamp = child->nodeValue(); |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
872 return coordinates; | 872 return coordinates; |
873 } | 873 } |
874 | 874 |
875 ASSERT_NOT_REACHED(); | 875 ASSERT_NOT_REACHED(); |
876 | 876 |
877 return coordinates; | 877 return coordinates; |
878 } | 878 } |
879 | 879 |
880 TextTrackCue::CueSetting TextTrackCue::settingName(const String& name) | 880 TextTrackCue::CueSetting TextTrackCue::settingName(const String& name) |
881 { | 881 { |
882 DEFINE_STATIC_LOCAL(const String, verticalKeyword, (ASCIILiteral("vertical")
)); | 882 DEFINE_STATIC_LOCAL(const String, verticalKeyword, ("vertical")); |
883 DEFINE_STATIC_LOCAL(const String, lineKeyword, (ASCIILiteral("line"))); | 883 DEFINE_STATIC_LOCAL(const String, lineKeyword, ("line")); |
884 DEFINE_STATIC_LOCAL(const String, positionKeyword, (ASCIILiteral("position")
)); | 884 DEFINE_STATIC_LOCAL(const String, positionKeyword, ("position")); |
885 DEFINE_STATIC_LOCAL(const String, sizeKeyword, (ASCIILiteral("size"))); | 885 DEFINE_STATIC_LOCAL(const String, sizeKeyword, ("size")); |
886 DEFINE_STATIC_LOCAL(const String, alignKeyword, (ASCIILiteral("align"))); | 886 DEFINE_STATIC_LOCAL(const String, alignKeyword, ("align")); |
887 #if ENABLE(WEBVTT_REGIONS) | 887 #if ENABLE(WEBVTT_REGIONS) |
888 DEFINE_STATIC_LOCAL(const String, regionIdKeyword, (ASCIILiteral("region")))
; | 888 DEFINE_STATIC_LOCAL(const String, regionIdKeyword, ("region")); |
889 #endif | 889 #endif |
890 | 890 |
891 if (name == verticalKeyword) | 891 if (name == verticalKeyword) |
892 return Vertical; | 892 return Vertical; |
893 else if (name == lineKeyword) | 893 else if (name == lineKeyword) |
894 return Line; | 894 return Line; |
895 else if (name == positionKeyword) | 895 else if (name == positionKeyword) |
896 return Position; | 896 return Position; |
897 else if (name == sizeKeyword) | 897 else if (name == sizeKeyword) |
898 return Size; | 898 return Size; |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1183 return false; | 1183 return false; |
1184 if (m_cueSize != cue.size()) | 1184 if (m_cueSize != cue.size()) |
1185 return false; | 1185 return false; |
1186 if (align() != cue.align()) | 1186 if (align() != cue.align()) |
1187 return false; | 1187 return false; |
1188 | 1188 |
1189 return true; | 1189 return true; |
1190 } | 1190 } |
1191 | 1191 |
1192 } // namespace WebCore | 1192 } // namespace WebCore |
OLD | NEW |