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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 #include "core/rendering/RenderTextTrackCue.h" | 48 #include "core/rendering/RenderTextTrackCue.h" |
49 #include "wtf/MathExtras.h" | 49 #include "wtf/MathExtras.h" |
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 CSSValueID displayWritingModeMap[] = { |
| 59 CSSValueHorizontalTb, CSSValueVerticalRl, CSSValueVerticalLr |
| 60 }; |
| 61 COMPILE_ASSERT(WTF_ARRAY_LENGTH(displayWritingModeMap) == TextTrackCue::NumberOf
WritingDirections, |
| 62 displayWritingModeMap_has_wrong_size); |
| 63 |
| 64 static const CSSValueID displayAlignmentMap[] = { |
| 65 CSSValueStart, CSSValueCenter, CSSValueEnd, CSSValueLeft, CSSValueRight |
| 66 }; |
| 67 COMPILE_ASSERT(WTF_ARRAY_LENGTH(displayAlignmentMap) == TextTrackCue::NumberOfAl
ignments, |
| 68 displayAlignmentMap_has_wrong_size); |
| 69 |
58 static const String& startKeyword() | 70 static const String& startKeyword() |
59 { | 71 { |
60 DEFINE_STATIC_LOCAL(const String, start, ("start")); | 72 DEFINE_STATIC_LOCAL(const String, start, ("start")); |
61 return start; | 73 return start; |
62 } | 74 } |
63 | 75 |
64 static const String& middleKeyword() | 76 static const String& middleKeyword() |
65 { | 77 { |
66 DEFINE_STATIC_LOCAL(const String, middle, ("middle")); | 78 DEFINE_STATIC_LOCAL(const String, middle, ("middle")); |
67 return middle; | 79 return middle; |
68 } | 80 } |
69 | 81 |
70 static const String& endKeyword() | 82 static const String& endKeyword() |
71 { | 83 { |
72 DEFINE_STATIC_LOCAL(const String, end, ("end")); | 84 DEFINE_STATIC_LOCAL(const String, end, ("end")); |
73 return end; | 85 return end; |
74 } | 86 } |
75 | 87 |
| 88 static const String& leftKeyword() |
| 89 { |
| 90 DEFINE_STATIC_LOCAL(const String, left, ("left")); |
| 91 return left; |
| 92 } |
| 93 |
| 94 static const String& rightKeyword() |
| 95 { |
| 96 DEFINE_STATIC_LOCAL(const String, right, ("right")); |
| 97 return right; |
| 98 } |
| 99 |
76 static const String& horizontalKeyword() | 100 static const String& horizontalKeyword() |
77 { | 101 { |
78 return emptyString(); | 102 return emptyString(); |
79 } | 103 } |
80 | 104 |
81 static const String& verticalGrowingLeftKeyword() | 105 static const String& verticalGrowingLeftKeyword() |
82 { | 106 { |
83 DEFINE_STATIC_LOCAL(const String, verticalrl, ("rl")); | 107 DEFINE_STATIC_LOCAL(const String, verticalrl, ("rl")); |
84 return verticalrl; | 108 return verticalrl; |
85 } | 109 } |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 setInlineStyleProperty(CSSPropertyHeight, CSSValueAuto); | 166 setInlineStyleProperty(CSSPropertyHeight, CSSValueAuto); |
143 } else { | 167 } else { |
144 setInlineStyleProperty(CSSPropertyWidth, CSSValueAuto); | 168 setInlineStyleProperty(CSSPropertyWidth, CSSValueAuto); |
145 setInlineStyleProperty(CSSPropertyHeight, static_cast<double>(m_cue->get
CSSSize()), CSSPrimitiveValue::CSS_PERCENTAGE); | 169 setInlineStyleProperty(CSSPropertyHeight, static_cast<double>(m_cue->get
CSSSize()), CSSPrimitiveValue::CSS_PERCENTAGE); |
146 } | 170 } |
147 | 171 |
148 // The 'text-align' property on the (root) List of WebVTT Node Objects must | 172 // The 'text-align' property on the (root) List of WebVTT Node Objects must |
149 // be set to the value in the second cell of the row of the table below | 173 // be set to the value in the second cell of the row of the table below |
150 // whose first cell is the value of the corresponding cue's text track cue | 174 // whose first cell is the value of the corresponding cue's text track cue |
151 // alignment: | 175 // alignment: |
152 if (m_cue->align() == startKeyword()) | 176 setInlineStyleProperty(CSSPropertyTextAlign, m_cue->getCSSAlignment()); |
153 setInlineStyleProperty(CSSPropertyTextAlign, CSSValueStart); | |
154 else if (m_cue->align() == endKeyword()) | |
155 setInlineStyleProperty(CSSPropertyTextAlign, CSSValueEnd); | |
156 else | |
157 setInlineStyleProperty(CSSPropertyTextAlign, CSSValueCenter); | |
158 | 177 |
159 if (!m_cue->snapToLines()) { | 178 if (!m_cue->snapToLines()) { |
160 // 10.13.1 Set up x and y: | 179 // 10.13.1 Set up x and y: |
161 // Note: x and y are set through the CSS left and top above. | 180 // Note: x and y are set through the CSS left and top above. |
162 | 181 |
163 // 10.13.2 Position the boxes in boxes such that the point x% along the | 182 // 10.13.2 Position the boxes in boxes such that the point x% along the |
164 // width of the bounding box of the boxes in boxes is x% of the way | 183 // width of the bounding box of the boxes in boxes is x% of the way |
165 // across the width of the video's rendering area, and the point y% | 184 // across the width of the video's rendering area, and the point y% |
166 // along the height of the bounding box of the boxes in boxes is y% | 185 // along the height of the bounding box of the boxes in boxes is y% |
167 // of the way across the height of the video's rendering area, while | 186 // of the way across the height of the video's rendering area, while |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 , m_scriptExecutionContext(context) | 222 , m_scriptExecutionContext(context) |
204 , m_isActive(false) | 223 , m_isActive(false) |
205 , m_pauseOnExit(false) | 224 , m_pauseOnExit(false) |
206 , m_snapToLines(true) | 225 , m_snapToLines(true) |
207 , m_cueBackgroundBox(HTMLDivElement::create(*toDocument(context))) | 226 , m_cueBackgroundBox(HTMLDivElement::create(*toDocument(context))) |
208 , m_displayTreeShouldChange(true) | 227 , m_displayTreeShouldChange(true) |
209 , m_displayDirection(CSSValueLtr) | 228 , m_displayDirection(CSSValueLtr) |
210 { | 229 { |
211 ASSERT(m_scriptExecutionContext->isDocument()); | 230 ASSERT(m_scriptExecutionContext->isDocument()); |
212 ScriptWrappable::init(this); | 231 ScriptWrappable::init(this); |
213 | |
214 // 4. If the text track cue writing direction is horizontal, then let | |
215 // writing-mode be 'horizontal-tb'. Otherwise, if the text track cue writing | |
216 // direction is vertical growing left, then let writing-mode be | |
217 // 'vertical-rl'. Otherwise, the text track cue writing direction is | |
218 // vertical growing right; let writing-mode be 'vertical-lr'. | |
219 m_displayWritingModeMap[Horizontal] = CSSValueHorizontalTb; | |
220 m_displayWritingModeMap[VerticalGrowingLeft] = CSSValueVerticalRl; | |
221 m_displayWritingModeMap[VerticalGrowingRight] = CSSValueVerticalLr; | |
222 } | 232 } |
223 | 233 |
224 TextTrackCue::~TextTrackCue() | 234 TextTrackCue::~TextTrackCue() |
225 { | 235 { |
226 displayTreeInternal()->remove(ASSERT_NO_EXCEPTION); | 236 displayTreeInternal()->remove(ASSERT_NO_EXCEPTION); |
227 } | 237 } |
228 | 238 |
229 PassRefPtr<TextTrackCueBox> TextTrackCue::createDisplayTree() | 239 PassRefPtr<TextTrackCueBox> TextTrackCue::createDisplayTree() |
230 { | 240 { |
231 ASSERT(ownerDocument()); | 241 ASSERT(ownerDocument()); |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 | 438 |
429 const String& TextTrackCue::align() const | 439 const String& TextTrackCue::align() const |
430 { | 440 { |
431 switch (m_cueAlignment) { | 441 switch (m_cueAlignment) { |
432 case Start: | 442 case Start: |
433 return startKeyword(); | 443 return startKeyword(); |
434 case Middle: | 444 case Middle: |
435 return middleKeyword(); | 445 return middleKeyword(); |
436 case End: | 446 case End: |
437 return endKeyword(); | 447 return endKeyword(); |
| 448 case Left: |
| 449 return leftKeyword(); |
| 450 case Right: |
| 451 return rightKeyword(); |
438 default: | 452 default: |
439 ASSERT_NOT_REACHED(); | 453 ASSERT_NOT_REACHED(); |
440 return emptyString(); | 454 return emptyString(); |
441 } | 455 } |
442 } | 456 } |
443 | 457 |
444 void TextTrackCue::setAlign(const String& value, ExceptionState& es) | 458 void TextTrackCue::setAlign(const String& value, ExceptionState& es) |
445 { | 459 { |
446 // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-ele
ment.html#dom-texttrackcue-align | 460 // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-ele
ment.html#dom-texttrackcue-align |
447 // On setting, the text track cue alignment must be set to the value given i
n the | 461 // On setting, the text track cue alignment must be set to the value given i
n the |
448 // first cell of the row in the table above whose second cell is a case-sens
itive | 462 // first cell of the row in the table above whose second cell is a case-sens
itive |
449 // match for the new value, if any. If none of the values match, then the us
er | 463 // match for the new value, if any. If none of the values match, then the us
er |
450 // agent must instead throw a SyntaxError exception. | 464 // agent must instead throw a SyntaxError exception. |
451 | 465 |
452 CueAlignment alignment = m_cueAlignment; | 466 CueAlignment alignment = m_cueAlignment; |
453 if (value == startKeyword()) | 467 if (value == startKeyword()) |
454 alignment = Start; | 468 alignment = Start; |
455 else if (value == middleKeyword()) | 469 else if (value == middleKeyword()) |
456 alignment = Middle; | 470 alignment = Middle; |
457 else if (value == endKeyword()) | 471 else if (value == endKeyword()) |
458 alignment = End; | 472 alignment = End; |
| 473 else if (value == leftKeyword()) |
| 474 alignment = Left; |
| 475 else if (value == rightKeyword()) |
| 476 alignment = Right; |
459 else | 477 else |
460 es.throwUninformativeAndGenericDOMException(SyntaxError); | 478 es.throwUninformativeAndGenericDOMException(SyntaxError); |
461 | 479 |
462 if (alignment == m_cueAlignment) | 480 if (alignment == m_cueAlignment) |
463 return; | 481 return; |
464 | 482 |
465 cueWillChange(); | 483 cueWillChange(); |
466 m_cueAlignment = alignment; | 484 m_cueAlignment = alignment; |
467 cueDidChange(); | 485 cueDidChange(); |
468 } | 486 } |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
651 void TextTrackCue::calculateDisplayParameters() | 669 void TextTrackCue::calculateDisplayParameters() |
652 { | 670 { |
653 // Steps 10.2, 10.3 | 671 // Steps 10.2, 10.3 |
654 determineTextDirection(); | 672 determineTextDirection(); |
655 | 673 |
656 // 10.4 If the text track cue writing direction is horizontal, then let | 674 // 10.4 If the text track cue writing direction is horizontal, then let |
657 // block-flow be 'tb'. Otherwise, if the text track cue writing direction is | 675 // block-flow be 'tb'. Otherwise, if the text track cue writing direction is |
658 // vertical growing left, then let block-flow be 'lr'. Otherwise, the text | 676 // vertical growing left, then let block-flow be 'lr'. Otherwise, the text |
659 // track cue writing direction is vertical growing right; let block-flow be | 677 // track cue writing direction is vertical growing right; let block-flow be |
660 // 'rl'. | 678 // 'rl'. |
661 m_displayWritingMode = m_displayWritingModeMap[m_writingDirection]; | 679 |
| 680 // The above step is done through the writing direction static map. |
662 | 681 |
663 // 10.5 Determine the value of maximum size for cue as per the appropriate | 682 // 10.5 Determine the value of maximum size for cue as per the appropriate |
664 // rules from the following list: | 683 // rules from the following list: |
665 int maximumSize = m_textPosition; | 684 int maximumSize = m_textPosition; |
666 if ((m_writingDirection == Horizontal && m_cueAlignment == Start && m_displa
yDirection == CSSValueLtr) | 685 if ((m_writingDirection == Horizontal && m_cueAlignment == Start && m_displa
yDirection == CSSValueLtr) |
667 || (m_writingDirection == Horizontal && m_cueAlignment == End && m_d
isplayDirection == CSSValueRtl) | 686 || (m_writingDirection == Horizontal && m_cueAlignment == End && m_d
isplayDirection == CSSValueRtl) |
668 || (m_writingDirection == VerticalGrowingLeft && m_cueAlignment == S
tart) | 687 || (m_writingDirection == Horizontal && m_cueAlignment == Left) |
669 || (m_writingDirection == VerticalGrowingRight && m_cueAlignment ==
Start)) { | 688 || (m_writingDirection == VerticalGrowingLeft && (m_cueAlignment ==
Start || m_cueAlignment == Left)) |
| 689 || (m_writingDirection == VerticalGrowingRight && (m_cueAlignment ==
Start || m_cueAlignment == Left))) { |
670 maximumSize = 100 - m_textPosition; | 690 maximumSize = 100 - m_textPosition; |
671 } else if ((m_writingDirection == Horizontal && m_cueAlignment == End && m_d
isplayDirection == CSSValueLtr) | 691 } else if ((m_writingDirection == Horizontal && m_cueAlignment == End && m_d
isplayDirection == CSSValueLtr) |
672 || (m_writingDirection == Horizontal && m_cueAlignment == Start && m
_displayDirection == CSSValueRtl) | 692 || (m_writingDirection == Horizontal && m_cueAlignment == Start && m
_displayDirection == CSSValueRtl) |
673 || (m_writingDirection == VerticalGrowingLeft && m_cueAlignment == E
nd) | 693 || (m_writingDirection == Horizontal && m_cueAlignment == Right) |
674 || (m_writingDirection == VerticalGrowingRight && m_cueAlignment ==
End)) { | 694 || (m_writingDirection == VerticalGrowingLeft && (m_cueAlignment ==
End || m_cueAlignment == Right)) |
| 695 || (m_writingDirection == VerticalGrowingRight && (m_cueAlignment ==
End || m_cueAlignment == Right))) { |
675 maximumSize = m_textPosition; | 696 maximumSize = m_textPosition; |
676 } else if (m_cueAlignment == Middle) { | 697 } else if (m_cueAlignment == Middle) { |
677 maximumSize = m_textPosition <= 50 ? m_textPosition : (100 - m_textPosit
ion); | 698 maximumSize = m_textPosition <= 50 ? m_textPosition : (100 - m_textPosit
ion); |
678 maximumSize = maximumSize * 2; | 699 maximumSize = maximumSize * 2; |
| 700 } else { |
| 701 ASSERT_NOT_REACHED(); |
679 } | 702 } |
680 | 703 |
681 // 10.6 If the text track cue size is less than maximum size, then let size | 704 // 10.6 If the text track cue size is less than maximum size, then let size |
682 // be text track cue size. Otherwise, let size be maximum size. | 705 // be text track cue size. Otherwise, let size be maximum size. |
683 m_displaySize = std::min(m_cueSize, maximumSize); | 706 m_displaySize = std::min(m_cueSize, maximumSize); |
684 | 707 |
| 708 // FIXME: Understand why step 10.7 is missing (just a copy/paste error?) |
| 709 // Could be done within a spec implementation check - http://crbug.com/30158
0 |
| 710 |
685 // 10.8 Determine the value of x-position or y-position for cue as per the | 711 // 10.8 Determine the value of x-position or y-position for cue as per the |
686 // appropriate rules from the following list: | 712 // appropriate rules from the following list: |
687 if (m_writingDirection == Horizontal) { | 713 if (m_writingDirection == Horizontal) { |
688 if (m_cueAlignment == Start) { | 714 switch (m_cueAlignment) { |
| 715 case Start: |
689 if (m_displayDirection == CSSValueLtr) | 716 if (m_displayDirection == CSSValueLtr) |
690 m_displayPosition.first = m_textPosition; | 717 m_displayPosition.first = m_textPosition; |
691 else | 718 else |
692 m_displayPosition.first = 100 - m_textPosition - m_displaySize; | 719 m_displayPosition.first = 100 - m_textPosition - m_displaySize; |
693 } else if (m_cueAlignment == End) { | 720 break; |
| 721 case End: |
694 if (m_displayDirection == CSSValueRtl) | 722 if (m_displayDirection == CSSValueRtl) |
695 m_displayPosition.first = 100 - m_textPosition; | 723 m_displayPosition.first = 100 - m_textPosition; |
696 else | 724 else |
697 m_displayPosition.first = m_textPosition - m_displaySize; | 725 m_displayPosition.first = m_textPosition - m_displaySize; |
| 726 break; |
| 727 case Left: |
| 728 if (m_displayDirection == CSSValueLtr) |
| 729 m_displayPosition.first = m_textPosition; |
| 730 else |
| 731 m_displayPosition.first = 100 - m_textPosition; |
| 732 break; |
| 733 case Right: |
| 734 if (m_displayDirection == CSSValueLtr) |
| 735 m_displayPosition.first = m_textPosition - m_displaySize; |
| 736 else |
| 737 m_displayPosition.first = 100 - m_textPosition - m_displaySize; |
| 738 break; |
| 739 case Middle: |
| 740 if (m_displayDirection == CSSValueLtr) |
| 741 m_displayPosition.first = m_textPosition - m_displaySize / 2; |
| 742 else |
| 743 m_displayPosition.first = 100 - m_textPosition - m_displaySize /
2; |
| 744 break; |
| 745 case NumberOfAlignments: |
| 746 ASSERT_NOT_REACHED(); |
| 747 } |
| 748 } else { |
| 749 // Cases for m_writingDirection being VerticalGrowing{Left|Right} |
| 750 switch (m_cueAlignment) { |
| 751 case Start: |
| 752 case Left: |
| 753 m_displayPosition.second = m_textPosition; |
| 754 break; |
| 755 case End: |
| 756 case Right: |
| 757 m_displayPosition.second = m_textPosition - m_displaySize; |
| 758 break; |
| 759 case Middle: |
| 760 m_displayPosition.second = m_textPosition - m_displaySize / 2; |
| 761 break; |
| 762 case NumberOfAlignments: |
| 763 ASSERT_NOT_REACHED(); |
698 } | 764 } |
699 } | 765 } |
700 | 766 |
701 if ((m_writingDirection == VerticalGrowingLeft && m_cueAlignment == Start) | 767 // A text track cue has a text track cue computed line position whose value |
702 || (m_writingDirection == VerticalGrowingRight && m_cueAlignment ==
Start)) { | 768 // is defined in terms of the other aspects of the cue. |
703 m_displayPosition.second = m_textPosition; | 769 m_computedLinePosition = calculateComputedLinePosition(); |
704 } else if ((m_writingDirection == VerticalGrowingLeft && m_cueAlignment == E
nd) | |
705 || (m_writingDirection == VerticalGrowingRight && m_cueAlignment ==
End)) { | |
706 m_displayPosition.second = 100 - m_textPosition; | |
707 } | |
708 | |
709 if (m_writingDirection == Horizontal && m_cueAlignment == Middle) { | |
710 if (m_displayDirection == CSSValueLtr) | |
711 m_displayPosition.first = m_textPosition - m_displaySize / 2; | |
712 else | |
713 m_displayPosition.first = 100 - m_textPosition - m_displaySize / 2; | |
714 } | |
715 | |
716 if ((m_writingDirection == VerticalGrowingLeft && m_cueAlignment == Middle) | |
717 || (m_writingDirection == VerticalGrowingRight && m_cueAlignment == Midd
le)) | |
718 m_displayPosition.second = m_textPosition - m_displaySize / 2; | |
719 | 770 |
720 // 10.9 Determine the value of whichever of x-position or y-position is not | 771 // 10.9 Determine the value of whichever of x-position or y-position is not |
721 // yet calculated for cue as per the appropriate rules from the following | 772 // yet calculated for cue as per the appropriate rules from the following |
722 // list: | 773 // list: |
723 if (m_snapToLines && m_displayPosition.second == undefinedPosition && m_writ
ingDirection == Horizontal) | 774 if (m_snapToLines && m_displayPosition.second == undefinedPosition && m_writ
ingDirection == Horizontal) |
724 m_displayPosition.second = 0; | 775 m_displayPosition.second = 0; |
725 | 776 |
726 if (!m_snapToLines && m_displayPosition.second == undefinedPosition && m_wri
tingDirection == Horizontal) | 777 if (!m_snapToLines && m_displayPosition.second == undefinedPosition && m_wri
tingDirection == Horizontal) |
727 m_displayPosition.second = m_computedLinePosition; | 778 m_displayPosition.second = m_computedLinePosition; |
728 | 779 |
729 if (m_snapToLines && m_displayPosition.first == undefinedPosition | 780 if (m_snapToLines && m_displayPosition.first == undefinedPosition |
730 && (m_writingDirection == VerticalGrowingLeft || m_writingDirection
== VerticalGrowingRight)) | 781 && (m_writingDirection == VerticalGrowingLeft || m_writingDirection
== VerticalGrowingRight)) |
731 m_displayPosition.first = 0; | 782 m_displayPosition.first = 0; |
732 | 783 |
733 if (!m_snapToLines && (m_writingDirection == VerticalGrowingLeft || m_writin
gDirection == VerticalGrowingRight)) | 784 if (!m_snapToLines && (m_writingDirection == VerticalGrowingLeft || m_writin
gDirection == VerticalGrowingRight)) |
734 m_displayPosition.first = m_computedLinePosition; | 785 m_displayPosition.first = m_computedLinePosition; |
735 | |
736 // A text track cue has a text track cue computed line position whose value | |
737 // is defined in terms of the other aspects of the cue. | |
738 m_computedLinePosition = calculateComputedLinePosition(); | |
739 } | 786 } |
740 | 787 |
741 void TextTrackCue::markFutureAndPastNodes(ContainerNode* root, double previousTi
mestamp, double movieTime) | 788 void TextTrackCue::markFutureAndPastNodes(ContainerNode* root, double previousTi
mestamp, double movieTime) |
742 { | 789 { |
743 DEFINE_STATIC_LOCAL(const String, timestampTag, ("timestamp")); | 790 DEFINE_STATIC_LOCAL(const String, timestampTag, ("timestamp")); |
744 | 791 |
745 bool isPastNode = true; | 792 bool isPastNode = true; |
746 double currentTimestamp = previousTimestamp; | 793 double currentTimestamp = previousTimestamp; |
747 if (currentTimestamp > movieTime) | 794 if (currentTimestamp > movieTime) |
748 isPastNode = false; | 795 isPastNode = false; |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1087 if (cueAlignment == startKeyword()) | 1134 if (cueAlignment == startKeyword()) |
1088 m_cueAlignment = Start; | 1135 m_cueAlignment = Start; |
1089 | 1136 |
1090 // 2. If value is a case-sensitive match for the string "middle", th
en let cue's text track cue alignment be middle alignment. | 1137 // 2. If value is a case-sensitive match for the string "middle", th
en let cue's text track cue alignment be middle alignment. |
1091 else if (cueAlignment == middleKeyword()) | 1138 else if (cueAlignment == middleKeyword()) |
1092 m_cueAlignment = Middle; | 1139 m_cueAlignment = Middle; |
1093 | 1140 |
1094 // 3. If value is a case-sensitive match for the string "end", then
let cue's text track cue alignment be end alignment. | 1141 // 3. If value is a case-sensitive match for the string "end", then
let cue's text track cue alignment be end alignment. |
1095 else if (cueAlignment == endKeyword()) | 1142 else if (cueAlignment == endKeyword()) |
1096 m_cueAlignment = End; | 1143 m_cueAlignment = End; |
| 1144 |
| 1145 // 4. If value is a case-sensitive match for the string "left", then
let cue's text track cue alignment be left alignment. |
| 1146 else if (cueAlignment == leftKeyword()) |
| 1147 m_cueAlignment = Left; |
| 1148 |
| 1149 // 5. If value is a case-sensitive match for the string "right", the
n let cue's text track cue alignment be right alignment. |
| 1150 else if (cueAlignment == rightKeyword()) |
| 1151 m_cueAlignment = Right; |
1097 } | 1152 } |
1098 break; | 1153 break; |
1099 #if ENABLE(WEBVTT_REGIONS) | 1154 #if ENABLE(WEBVTT_REGIONS) |
1100 case RegionId: | 1155 case RegionId: |
1101 m_regionId = WebVTTParser::collectWord(input, &position); | 1156 m_regionId = WebVTTParser::collectWord(input, &position); |
1102 break; | 1157 break; |
1103 #endif | 1158 #endif |
1104 case None: | 1159 case None: |
1105 break; | 1160 break; |
1106 } | 1161 } |
1107 | 1162 |
1108 NextSetting: | 1163 NextSetting: |
1109 position = endOfSetting; | 1164 position = endOfSetting; |
1110 } | 1165 } |
1111 #if ENABLE(WEBVTT_REGIONS) | 1166 #if ENABLE(WEBVTT_REGIONS) |
1112 // If cue's line position is not auto or cue's size is not 100 or cue's | 1167 // If cue's line position is not auto or cue's size is not 100 or cue's |
1113 // writing direction is not horizontal, but cue's region identifier is not | 1168 // writing direction is not horizontal, but cue's region identifier is not |
1114 // the empty string, let cue's region identifier be the empty string. | 1169 // the empty string, let cue's region identifier be the empty string. |
1115 if (m_regionId.isEmpty()) | 1170 if (m_regionId.isEmpty()) |
1116 return; | 1171 return; |
1117 | 1172 |
1118 if (m_linePosition != undefinedPosition || m_cueSize != 100 || m_writingDire
ction != Horizontal) | 1173 if (m_linePosition != undefinedPosition || m_cueSize != 100 || m_writingDire
ction != Horizontal) |
1119 m_regionId = emptyString(); | 1174 m_regionId = emptyString(); |
1120 #endif | 1175 #endif |
1121 } | 1176 } |
1122 | 1177 |
| 1178 CSSValueID TextTrackCue::getCSSAlignment() const |
| 1179 { |
| 1180 return displayAlignmentMap[m_cueAlignment]; |
| 1181 } |
| 1182 |
1123 CSSValueID TextTrackCue::getCSSWritingDirection() const | 1183 CSSValueID TextTrackCue::getCSSWritingDirection() const |
1124 { | 1184 { |
1125 return m_displayDirection; | 1185 return m_displayDirection; |
1126 } | 1186 } |
1127 | 1187 |
1128 CSSValueID TextTrackCue::getCSSWritingMode() const | 1188 CSSValueID TextTrackCue::getCSSWritingMode() const |
1129 { | 1189 { |
1130 return m_displayWritingMode; | 1190 return displayWritingModeMap[m_writingDirection]; |
1131 } | 1191 } |
1132 | 1192 |
1133 int TextTrackCue::getCSSSize() const | 1193 int TextTrackCue::getCSSSize() const |
1134 { | 1194 { |
1135 return m_displaySize; | 1195 return m_displaySize; |
1136 } | 1196 } |
1137 | 1197 |
1138 std::pair<double, double> TextTrackCue::getCSSPosition() const | 1198 std::pair<double, double> TextTrackCue::getCSSPosition() const |
1139 { | 1199 { |
1140 if (!m_snapToLines) | 1200 if (!m_snapToLines) |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1184 return false; | 1244 return false; |
1185 if (m_cueSize != cue.size()) | 1245 if (m_cueSize != cue.size()) |
1186 return false; | 1246 return false; |
1187 if (align() != cue.align()) | 1247 if (align() != cue.align()) |
1188 return false; | 1248 return false; |
1189 | 1249 |
1190 return true; | 1250 return true; |
1191 } | 1251 } |
1192 | 1252 |
1193 } // namespace WebCore | 1253 } // namespace WebCore |
OLD | NEW |