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

Side by Side Diff: Source/core/html/track/TextTrackCue.cpp

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

Powered by Google App Engine
This is Rietveld 408576698