| 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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 | 147 |
| 148 // the 'unicode-bidi' property must be set to 'plaintext' | 148 // the 'unicode-bidi' property must be set to 'plaintext' |
| 149 setInlineStyleProperty(CSSPropertyUnicodeBidi, CSSValueWebkitPlaintext); | 149 setInlineStyleProperty(CSSPropertyUnicodeBidi, CSSValueWebkitPlaintext); |
| 150 | 150 |
| 151 // the 'direction' property must be set to direction | 151 // the 'direction' property must be set to direction |
| 152 setInlineStyleProperty(CSSPropertyDirection, m_cue->getCSSWritingDirection()
); | 152 setInlineStyleProperty(CSSPropertyDirection, m_cue->getCSSWritingDirection()
); |
| 153 | 153 |
| 154 // the 'writing-mode' property must be set to writing-mode | 154 // the 'writing-mode' property must be set to writing-mode |
| 155 setInlineStyleProperty(CSSPropertyWebkitWritingMode, m_cue->getCSSWritingMod
e()); | 155 setInlineStyleProperty(CSSPropertyWebkitWritingMode, m_cue->getCSSWritingMod
e()); |
| 156 | 156 |
| 157 std::pair<float, float> position = m_cue->getCSSPosition(); | 157 FloatPoint position = m_cue->getCSSPosition(); |
| 158 | 158 |
| 159 // the 'top' property must be set to top, | 159 // the 'top' property must be set to top, |
| 160 setInlineStyleProperty(CSSPropertyTop, position.second, CSSPrimitiveValue::C
SS_PERCENTAGE); | 160 setInlineStyleProperty(CSSPropertyTop, position.y(), CSSPrimitiveValue::CSS_
PERCENTAGE); |
| 161 | 161 |
| 162 // the 'left' property must be set to left | 162 // the 'left' property must be set to left |
| 163 setInlineStyleProperty(CSSPropertyLeft, position.first, CSSPrimitiveValue::C
SS_PERCENTAGE); | 163 setInlineStyleProperty(CSSPropertyLeft, position.x(), CSSPrimitiveValue::CSS
_PERCENTAGE); |
| 164 | 164 |
| 165 // the 'width' property must be set to width, and the 'height' property mus
t be set to height | 165 // the 'width' property must be set to width, and the 'height' property mus
t be set to height |
| 166 if (m_cue->vertical() == horizontalKeyword()) { | 166 if (m_cue->vertical() == horizontalKeyword()) { |
| 167 setInlineStyleProperty(CSSPropertyWidth, static_cast<double>(m_cue->getC
SSSize()), CSSPrimitiveValue::CSS_PERCENTAGE); | 167 setInlineStyleProperty(CSSPropertyWidth, static_cast<double>(m_cue->getC
SSSize()), CSSPrimitiveValue::CSS_PERCENTAGE); |
| 168 setInlineStyleProperty(CSSPropertyHeight, CSSValueAuto); | 168 setInlineStyleProperty(CSSPropertyHeight, CSSValueAuto); |
| 169 } else { | 169 } else { |
| 170 setInlineStyleProperty(CSSPropertyWidth, CSSValueAuto); | 170 setInlineStyleProperty(CSSPropertyWidth, CSSValueAuto); |
| 171 setInlineStyleProperty(CSSPropertyHeight, static_cast<double>(m_cue->get
CSSSize()), CSSPrimitiveValue::CSS_PERCENTAGE); | 171 setInlineStyleProperty(CSSPropertyHeight, static_cast<double>(m_cue->get
CSSSize()), CSSPrimitiveValue::CSS_PERCENTAGE); |
| 172 } | 172 } |
| 173 | 173 |
| 174 // The 'text-align' property on the (root) List of WebVTT Node Objects must | 174 // The 'text-align' property on the (root) List of WebVTT Node Objects must |
| 175 // be set to the value in the second cell of the row of the table below | 175 // be set to the value in the second cell of the row of the table below |
| 176 // whose first cell is the value of the corresponding cue's text track cue | 176 // whose first cell is the value of the corresponding cue's text track cue |
| 177 // alignment: | 177 // alignment: |
| 178 setInlineStyleProperty(CSSPropertyTextAlign, m_cue->getCSSAlignment()); | 178 setInlineStyleProperty(CSSPropertyTextAlign, m_cue->getCSSAlignment()); |
| 179 | 179 |
| 180 if (!m_cue->snapToLines()) { | 180 if (!m_cue->snapToLines()) { |
| 181 // 10.13.1 Set up x and y: | 181 // 10.13.1 Set up x and y: |
| 182 // Note: x and y are set through the CSS left and top above. | 182 // Note: x and y are set through the CSS left and top above. |
| 183 | 183 |
| 184 // 10.13.2 Position the boxes in boxes such that the point x% along the | 184 // 10.13.2 Position the boxes in boxes such that the point x% along the |
| 185 // width of the bounding box of the boxes in boxes is x% of the way | 185 // width of the bounding box of the boxes in boxes is x% of the way |
| 186 // across the width of the video's rendering area, and the point y% | 186 // across the width of the video's rendering area, and the point y% |
| 187 // along the height of the bounding box of the boxes in boxes is y% | 187 // along the height of the bounding box of the boxes in boxes is y% |
| 188 // of the way across the height of the video's rendering area, while | 188 // of the way across the height of the video's rendering area, while |
| 189 // maintaining the relative positions of the boxes in boxes to each | 189 // maintaining the relative positions of the boxes in boxes to each |
| 190 // other. | 190 // other. |
| 191 setInlineStyleProperty(CSSPropertyWebkitTransform, | 191 setInlineStyleProperty(CSSPropertyWebkitTransform, |
| 192 String::format("translate(-%.2f%%, -%.2f%%)", position.first, positi
on.second)); | 192 String::format("translate(-%.2f%%, -%.2f%%)", position.x(), position
.y())); |
| 193 | 193 |
| 194 setInlineStyleProperty(CSSPropertyWhiteSpace, CSSValuePre); | 194 setInlineStyleProperty(CSSPropertyWhiteSpace, CSSValuePre); |
| 195 } | 195 } |
| 196 } | 196 } |
| 197 | 197 |
| 198 RenderObject* VTTCueBox::createRenderer(RenderStyle*) | 198 RenderObject* VTTCueBox::createRenderer(RenderStyle*) |
| 199 { | 199 { |
| 200 return new RenderVTTCue(this); | 200 return new RenderVTTCue(this); |
| 201 } | 201 } |
| 202 | 202 |
| (...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 614 // FIXME: Understand why step 10.7 is missing (just a copy/paste error?) | 614 // FIXME: Understand why step 10.7 is missing (just a copy/paste error?) |
| 615 // Could be done within a spec implementation check - http://crbug.com/30158
0 | 615 // Could be done within a spec implementation check - http://crbug.com/30158
0 |
| 616 | 616 |
| 617 // 10.8 Determine the value of x-position or y-position for cue as per the | 617 // 10.8 Determine the value of x-position or y-position for cue as per the |
| 618 // appropriate rules from the following list: | 618 // appropriate rules from the following list: |
| 619 if (m_writingDirection == Horizontal) { | 619 if (m_writingDirection == Horizontal) { |
| 620 int visualTextPosition = m_displayDirection == CSSValueLtr ? m_textPosit
ion : 100 - m_textPosition; | 620 int visualTextPosition = m_displayDirection == CSSValueLtr ? m_textPosit
ion : 100 - m_textPosition; |
| 621 | 621 |
| 622 switch (resolveCueAlignment(m_cueAlignment, m_displayDirection)) { | 622 switch (resolveCueAlignment(m_cueAlignment, m_displayDirection)) { |
| 623 case Left: | 623 case Left: |
| 624 m_displayPosition.first = visualTextPosition; | 624 m_displayPosition.setX(visualTextPosition); |
| 625 break; | 625 break; |
| 626 case Right: | 626 case Right: |
| 627 m_displayPosition.first = visualTextPosition - m_displaySize; | 627 m_displayPosition.setX(visualTextPosition - m_displaySize); |
| 628 break; | 628 break; |
| 629 case Middle: | 629 case Middle: |
| 630 m_displayPosition.first = visualTextPosition - m_displaySize / 2; | 630 m_displayPosition.setX(visualTextPosition - m_displaySize / 2); |
| 631 break; | 631 break; |
| 632 default: | 632 default: |
| 633 ASSERT_NOT_REACHED(); | 633 ASSERT_NOT_REACHED(); |
| 634 } | 634 } |
| 635 } else { | 635 } else { |
| 636 // Cases for m_writingDirection being VerticalGrowing{Left|Right} | 636 // Cases for m_writingDirection being VerticalGrowing{Left|Right} |
| 637 switch (m_cueAlignment) { | 637 switch (m_cueAlignment) { |
| 638 case Start: | 638 case Start: |
| 639 case Left: | 639 case Left: |
| 640 m_displayPosition.second = m_textPosition; | 640 m_displayPosition.setY(m_textPosition); |
| 641 break; | 641 break; |
| 642 case End: | 642 case End: |
| 643 case Right: | 643 case Right: |
| 644 m_displayPosition.second = m_textPosition - m_displaySize; | 644 m_displayPosition.setY(m_textPosition - m_displaySize); |
| 645 break; | 645 break; |
| 646 case Middle: | 646 case Middle: |
| 647 m_displayPosition.second = m_textPosition - m_displaySize / 2; | 647 m_displayPosition.setY(m_textPosition - m_displaySize / 2); |
| 648 break; | 648 break; |
| 649 default: | 649 default: |
| 650 ASSERT_NOT_REACHED(); | 650 ASSERT_NOT_REACHED(); |
| 651 } | 651 } |
| 652 } | 652 } |
| 653 | 653 |
| 654 // A text track cue has a text track cue computed line position whose value | 654 // A text track cue has a text track cue computed line position whose value |
| 655 // is defined in terms of the other aspects of the cue. | 655 // is defined in terms of the other aspects of the cue. |
| 656 m_computedLinePosition = calculateComputedLinePosition(); | 656 m_computedLinePosition = calculateComputedLinePosition(); |
| 657 | 657 |
| 658 // 10.9 Determine the value of whichever of x-position or y-position is not | 658 // 10.9 Determine the value of whichever of x-position or y-position is not |
| 659 // yet calculated for cue as per the appropriate rules from the following | 659 // yet calculated for cue as per the appropriate rules from the following |
| 660 // list: | 660 // list: |
| 661 if (m_snapToLines && m_writingDirection == Horizontal) | 661 if (m_snapToLines && m_writingDirection == Horizontal) |
| 662 m_displayPosition.second = 0; | 662 m_displayPosition.setY(0); |
| 663 | 663 |
| 664 if (!m_snapToLines && m_writingDirection == Horizontal) | 664 if (!m_snapToLines && m_writingDirection == Horizontal) |
| 665 m_displayPosition.second = m_computedLinePosition; | 665 m_displayPosition.setY(m_computedLinePosition); |
| 666 | 666 |
| 667 if (m_snapToLines && (m_writingDirection == VerticalGrowingLeft || m_writing
Direction == VerticalGrowingRight)) | 667 if (m_snapToLines && (m_writingDirection == VerticalGrowingLeft || m_writing
Direction == VerticalGrowingRight)) |
| 668 m_displayPosition.first = 0; | 668 m_displayPosition.setX(0); |
| 669 | 669 |
| 670 if (!m_snapToLines && (m_writingDirection == VerticalGrowingLeft || m_writin
gDirection == VerticalGrowingRight)) | 670 if (!m_snapToLines && (m_writingDirection == VerticalGrowingLeft || m_writin
gDirection == VerticalGrowingRight)) |
| 671 m_displayPosition.first = m_computedLinePosition; | 671 m_displayPosition.setX(m_computedLinePosition); |
| 672 } | 672 } |
| 673 | 673 |
| 674 void VTTCue::markFutureAndPastNodes(ContainerNode* root, double previousTimestam
p, double movieTime) | 674 void VTTCue::markFutureAndPastNodes(ContainerNode* root, double previousTimestam
p, double movieTime) |
| 675 { | 675 { |
| 676 DEFINE_STATIC_LOCAL(const String, timestampTag, ("timestamp")); | 676 DEFINE_STATIC_LOCAL(const String, timestampTag, ("timestamp")); |
| 677 | 677 |
| 678 bool isPastNode = true; | 678 bool isPastNode = true; |
| 679 double currentTimestamp = previousTimestamp; | 679 double currentTimestamp = previousTimestamp; |
| 680 if (currentTimestamp > movieTime) | 680 if (currentTimestamp > movieTime) |
| 681 isPastNode = false; | 681 isPastNode = false; |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 814 RefPtrWillBeRawPtr<HTMLDivElement> regionNode = region->getDisplayTree(d
ocument()); | 814 RefPtrWillBeRawPtr<HTMLDivElement> regionNode = region->getDisplayTree(d
ocument()); |
| 815 | 815 |
| 816 // Append the region to the viewport, if it was not already. | 816 // Append the region to the viewport, if it was not already. |
| 817 if (!container.contains(regionNode.get())) | 817 if (!container.contains(regionNode.get())) |
| 818 container.appendChild(regionNode); | 818 container.appendChild(regionNode); |
| 819 | 819 |
| 820 region->appendVTTCueBox(displayBox); | 820 region->appendVTTCueBox(displayBox); |
| 821 } | 821 } |
| 822 } | 822 } |
| 823 | 823 |
| 824 std::pair<double, double> VTTCue::getPositionCoordinates() const | 824 FloatPoint VTTCue::getPositionCoordinates() const |
| 825 { | 825 { |
| 826 // This method is used for setting x and y when snap to lines is not set. | 826 // This method is used for setting x and y when snap to lines is not set. |
| 827 std::pair<double, double> coordinates; | |
| 828 | 827 |
| 829 if (m_writingDirection == Horizontal && m_displayDirection == CSSValueLtr) { | 828 if (m_writingDirection == Horizontal && m_displayDirection == CSSValueLtr) |
| 830 coordinates.first = m_textPosition; | 829 return FloatPoint(m_textPosition, m_computedLinePosition); |
| 831 coordinates.second = m_computedLinePosition; | |
| 832 | 830 |
| 833 return coordinates; | 831 if (m_writingDirection == Horizontal && m_displayDirection == CSSValueRtl) |
| 834 } | 832 return FloatPoint(100 - m_textPosition, m_computedLinePosition); |
| 835 | 833 |
| 836 if (m_writingDirection == Horizontal && m_displayDirection == CSSValueRtl) { | 834 if (m_writingDirection == VerticalGrowingLeft) |
| 837 coordinates.first = 100 - m_textPosition; | 835 return FloatPoint(100 - m_computedLinePosition, m_textPosition); |
| 838 coordinates.second = m_computedLinePosition; | |
| 839 | 836 |
| 840 return coordinates; | 837 if (m_writingDirection == VerticalGrowingRight) |
| 841 } | 838 return FloatPoint(m_computedLinePosition, m_textPosition); |
| 842 | |
| 843 if (m_writingDirection == VerticalGrowingLeft) { | |
| 844 coordinates.first = 100 - m_computedLinePosition; | |
| 845 coordinates.second = m_textPosition; | |
| 846 | |
| 847 return coordinates; | |
| 848 } | |
| 849 | |
| 850 if (m_writingDirection == VerticalGrowingRight) { | |
| 851 coordinates.first = m_computedLinePosition; | |
| 852 coordinates.second = m_textPosition; | |
| 853 | |
| 854 return coordinates; | |
| 855 } | |
| 856 | 839 |
| 857 ASSERT_NOT_REACHED(); | 840 ASSERT_NOT_REACHED(); |
| 858 | 841 return FloatPoint(); |
| 859 return coordinates; | |
| 860 } | 842 } |
| 861 | 843 |
| 862 VTTCue::CueSetting VTTCue::settingName(VTTScanner& input) | 844 VTTCue::CueSetting VTTCue::settingName(VTTScanner& input) |
| 863 { | 845 { |
| 864 CueSetting parsedSetting = None; | 846 CueSetting parsedSetting = None; |
| 865 if (input.scan("vertical")) | 847 if (input.scan("vertical")) |
| 866 parsedSetting = Vertical; | 848 parsedSetting = Vertical; |
| 867 else if (input.scan("line")) | 849 else if (input.scan("line")) |
| 868 parsedSetting = Line; | 850 parsedSetting = Line; |
| 869 else if (input.scan("position")) | 851 else if (input.scan("position")) |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1069 { | 1051 { |
| 1070 return displayWritingModeMap[m_writingDirection]; | 1052 return displayWritingModeMap[m_writingDirection]; |
| 1071 } | 1053 } |
| 1072 | 1054 |
| 1073 int VTTCue::getCSSSize() const | 1055 int VTTCue::getCSSSize() const |
| 1074 { | 1056 { |
| 1075 ASSERT(m_displaySize != undefinedSize); | 1057 ASSERT(m_displaySize != undefinedSize); |
| 1076 return m_displaySize; | 1058 return m_displaySize; |
| 1077 } | 1059 } |
| 1078 | 1060 |
| 1079 std::pair<double, double> VTTCue::getCSSPosition() const | 1061 FloatPoint VTTCue::getCSSPosition() const |
| 1080 { | 1062 { |
| 1081 if (!m_snapToLines) | 1063 if (!m_snapToLines) |
| 1082 return getPositionCoordinates(); | 1064 return getPositionCoordinates(); |
| 1083 | 1065 |
| 1084 return m_displayPosition; | 1066 return m_displayPosition; |
| 1085 } | 1067 } |
| 1086 | 1068 |
| 1087 ExecutionContext* VTTCue::executionContext() const | 1069 ExecutionContext* VTTCue::executionContext() const |
| 1088 { | 1070 { |
| 1089 ASSERT(m_cueBackgroundBox); | 1071 ASSERT(m_cueBackgroundBox); |
| 1090 return m_cueBackgroundBox->executionContext(); | 1072 return m_cueBackgroundBox->executionContext(); |
| 1091 } | 1073 } |
| 1092 | 1074 |
| 1093 Document& VTTCue::document() const | 1075 Document& VTTCue::document() const |
| 1094 { | 1076 { |
| 1095 ASSERT(m_cueBackgroundBox); | 1077 ASSERT(m_cueBackgroundBox); |
| 1096 return m_cueBackgroundBox->document(); | 1078 return m_cueBackgroundBox->document(); |
| 1097 } | 1079 } |
| 1098 | 1080 |
| 1099 void VTTCue::trace(Visitor* visitor) | 1081 void VTTCue::trace(Visitor* visitor) |
| 1100 { | 1082 { |
| 1101 visitor->trace(m_vttNodeTree); | 1083 visitor->trace(m_vttNodeTree); |
| 1102 visitor->trace(m_cueBackgroundBox); | 1084 visitor->trace(m_cueBackgroundBox); |
| 1103 visitor->trace(m_displayTree); | 1085 visitor->trace(m_displayTree); |
| 1104 TextTrackCue::trace(visitor); | 1086 TextTrackCue::trace(visitor); |
| 1105 } | 1087 } |
| 1106 | 1088 |
| 1107 } // namespace blink | 1089 } // namespace blink |
| OLD | NEW |