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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 { | 117 { |
118 if (TextTrackCue::isInfiniteOrNonNumber(value, method, exceptionState)) | 118 if (TextTrackCue::isInfiniteOrNonNumber(value, method, exceptionState)) |
119 return true; | 119 return true; |
120 if (value < 0 || value > 100) { | 120 if (value < 0 || value > 100) { |
121 exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::fail
edToSet(method, "TextTrackCue", "The value provided (" + String::number(value) +
") is not between 0 and 100.")); | 121 exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::fail
edToSet(method, "TextTrackCue", "The value provided (" + String::number(value) +
") is not between 0 and 100.")); |
122 return true; | 122 return true; |
123 } | 123 } |
124 return false; | 124 return false; |
125 } | 125 } |
126 | 126 |
127 // ---------------------------- | |
128 | |
129 VTTCueBox::VTTCueBox(Document& document, VTTCue* cue) | 127 VTTCueBox::VTTCueBox(Document& document, VTTCue* cue) |
130 : TextTrackCueBox(document) | 128 : HTMLDivElement(document) |
131 , m_cue(cue) | 129 , m_cue(cue) |
132 { | 130 { |
133 setPseudo(textTrackCueBoxShadowPseudoId()); | 131 setPseudo(AtomicString("-webkit-media-text-track-display", AtomicString::Con
structFromLiteral)); |
134 } | 132 } |
135 | 133 |
136 void VTTCueBox::applyCSSProperties(const IntSize&) | 134 void VTTCueBox::applyCSSProperties(const IntSize&) |
137 { | 135 { |
138 // FIXME: Apply all the initial CSS positioning properties. http://wkb.ug/79
916 | 136 // FIXME: Apply all the initial CSS positioning properties. http://wkb.ug/79
916 |
139 if (!m_cue->regionId().isEmpty()) { | 137 if (!m_cue->regionId().isEmpty()) { |
140 setInlineStyleProperty(CSSPropertyPosition, CSSValueRelative); | 138 setInlineStyleProperty(CSSPropertyPosition, CSSValueRelative); |
141 return; | 139 return; |
142 } | 140 } |
143 | 141 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 | 192 |
195 setInlineStyleProperty(CSSPropertyWhiteSpace, CSSValuePre); | 193 setInlineStyleProperty(CSSPropertyWhiteSpace, CSSValuePre); |
196 } | 194 } |
197 } | 195 } |
198 | 196 |
199 RenderObject* VTTCueBox::createRenderer(RenderStyle*) | 197 RenderObject* VTTCueBox::createRenderer(RenderStyle*) |
200 { | 198 { |
201 return new RenderVTTCue(this); | 199 return new RenderVTTCue(this); |
202 } | 200 } |
203 | 201 |
204 // ---------------------------- | |
205 | |
206 VTTCue::VTTCue(Document& document, double startTime, double endTime, const Strin
g& text) | 202 VTTCue::VTTCue(Document& document, double startTime, double endTime, const Strin
g& text) |
207 : TextTrackCue(startTime, endTime) | 203 : TextTrackCue(startTime, endTime) |
208 , m_text(text) | 204 , m_text(text) |
209 , m_linePosition(undefinedPosition) | 205 , m_linePosition(undefinedPosition) |
210 , m_computedLinePosition(undefinedPosition) | 206 , m_computedLinePosition(undefinedPosition) |
211 , m_textPosition(50) | 207 , m_textPosition(50) |
212 , m_cueSize(100) | 208 , m_cueSize(100) |
213 , m_writingDirection(Horizontal) | 209 , m_writingDirection(Horizontal) |
214 , m_cueAlignment(Middle) | 210 , m_cueAlignment(Middle) |
215 , m_vttNodeTree(0) | 211 , m_vttNodeTree(0) |
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
705 | 701 |
706 // Clear the contents of the set. | 702 // Clear the contents of the set. |
707 m_cueBackgroundBox->removeChildren(); | 703 m_cueBackgroundBox->removeChildren(); |
708 | 704 |
709 // Update the two sets containing past and future WebVTT objects. | 705 // Update the two sets containing past and future WebVTT objects. |
710 RefPtr<DocumentFragment> referenceTree = createCueRenderingTree(); | 706 RefPtr<DocumentFragment> referenceTree = createCueRenderingTree(); |
711 markFutureAndPastNodes(referenceTree.get(), startTime(), movieTime); | 707 markFutureAndPastNodes(referenceTree.get(), startTime(), movieTime); |
712 m_cueBackgroundBox->appendChild(referenceTree, ASSERT_NO_EXCEPTION); | 708 m_cueBackgroundBox->appendChild(referenceTree, ASSERT_NO_EXCEPTION); |
713 } | 709 } |
714 | 710 |
715 PassRefPtr<TextTrackCueBox> VTTCue::getDisplayTree(const IntSize& videoSize) | 711 PassRefPtr<VTTCueBox> VTTCue::getDisplayTree(const IntSize& videoSize) |
716 { | 712 { |
717 RefPtr<VTTCueBox> displayTree = displayTreeInternal(); | 713 RefPtr<VTTCueBox> displayTree = displayTreeInternal(); |
718 if (!m_displayTreeShouldChange || !track()->isRendered()) | 714 if (!m_displayTreeShouldChange || !track()->isRendered()) |
719 return displayTree; | 715 return displayTree; |
720 | 716 |
721 // 10.1 - 10.10 | 717 // 10.1 - 10.10 |
722 calculateDisplayParameters(); | 718 calculateDisplayParameters(); |
723 | 719 |
724 // 10.11. Apply the terms of the CSS specifications to nodes within the | 720 // 10.11. Apply the terms of the CSS specifications to nodes within the |
725 // following constraints, thus obtaining a set of CSS boxes positioned | 721 // following constraints, thus obtaining a set of CSS boxes positioned |
(...skipping 29 matching lines...) Expand all Loading... |
755 // boxes. | 751 // boxes. |
756 return displayTree; | 752 return displayTree; |
757 } | 753 } |
758 | 754 |
759 void VTTCue::removeDisplayTree() | 755 void VTTCue::removeDisplayTree() |
760 { | 756 { |
761 if (m_notifyRegion && track()->regions()) { | 757 if (m_notifyRegion && track()->regions()) { |
762 // The region needs to be informed about the cue removal. | 758 // The region needs to be informed about the cue removal. |
763 VTTRegion* region = track()->regions()->getRegionById(m_regionId); | 759 VTTRegion* region = track()->regions()->getRegionById(m_regionId); |
764 if (region) | 760 if (region) |
765 region->willRemoveTextTrackCueBox(m_displayTree.get()); | 761 region->willRemoveVTTCueBox(m_displayTree.get()); |
766 } | 762 } |
767 | 763 |
768 displayTreeInternal()->remove(ASSERT_NO_EXCEPTION); | 764 displayTreeInternal()->remove(ASSERT_NO_EXCEPTION); |
769 } | 765 } |
770 | 766 |
771 void VTTCue::updateDisplay(const IntSize& videoSize, HTMLDivElement& container) | 767 void VTTCue::updateDisplay(const IntSize& videoSize, HTMLDivElement& container) |
772 { | 768 { |
773 RefPtr<TextTrackCueBox> displayBox = getDisplayTree(videoSize); | 769 RefPtr<VTTCueBox> displayBox = getDisplayTree(videoSize); |
774 VTTRegion* region = 0; | 770 VTTRegion* region = 0; |
775 if (track()->regions()) | 771 if (track()->regions()) |
776 region = track()->regions()->getRegionById(regionId()); | 772 region = track()->regions()->getRegionById(regionId()); |
777 | 773 |
778 if (!region) { | 774 if (!region) { |
779 // If cue has an empty text track cue region identifier or there is no | 775 // If cue has an empty text track cue region identifier or there is no |
780 // WebVTT region whose region identifier is identical to cue's text | 776 // WebVTT region whose region identifier is identical to cue's text |
781 // track cue region identifier, run the following substeps: | 777 // track cue region identifier, run the following substeps: |
782 if (displayBox->hasChildNodes() && !container.contains(displayBox.get())
) { | 778 if (displayBox->hasChildNodes() && !container.contains(displayBox.get())
) { |
783 // Note: the display tree of a cue is removed when the active flag o
f the cue is unset. | 779 // Note: the display tree of a cue is removed when the active flag o
f the cue is unset. |
784 container.appendChild(displayBox); | 780 container.appendChild(displayBox); |
785 } | 781 } |
786 } else { | 782 } else { |
787 // Let region be the WebVTT region whose region identifier | 783 // Let region be the WebVTT region whose region identifier |
788 // matches the text track cue region identifier of cue. | 784 // matches the text track cue region identifier of cue. |
789 RefPtr<HTMLDivElement> regionNode = region->getDisplayTree(document()); | 785 RefPtr<HTMLDivElement> regionNode = region->getDisplayTree(document()); |
790 | 786 |
791 // Append the region to the viewport, if it was not already. | 787 // Append the region to the viewport, if it was not already. |
792 if (!container.contains(regionNode.get())) | 788 if (!container.contains(regionNode.get())) |
793 container.appendChild(regionNode); | 789 container.appendChild(regionNode); |
794 | 790 |
795 region->appendTextTrackCueBox(displayBox); | 791 region->appendVTTCueBox(displayBox); |
796 } | 792 } |
797 } | 793 } |
798 | 794 |
799 std::pair<double, double> VTTCue::getPositionCoordinates() const | 795 std::pair<double, double> VTTCue::getPositionCoordinates() const |
800 { | 796 { |
801 // This method is used for setting x and y when snap to lines is not set. | 797 // This method is used for setting x and y when snap to lines is not set. |
802 std::pair<double, double> coordinates; | 798 std::pair<double, double> coordinates; |
803 | 799 |
804 if (m_writingDirection == Horizontal && m_displayDirection == CSSValueLtr) { | 800 if (m_writingDirection == Horizontal && m_displayDirection == CSSValueLtr) { |
805 coordinates.first = m_textPosition; | 801 coordinates.first = m_textPosition; |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1110 return m_cueBackgroundBox->executionContext(); | 1106 return m_cueBackgroundBox->executionContext(); |
1111 } | 1107 } |
1112 | 1108 |
1113 Document& VTTCue::document() const | 1109 Document& VTTCue::document() const |
1114 { | 1110 { |
1115 ASSERT(m_cueBackgroundBox); | 1111 ASSERT(m_cueBackgroundBox); |
1116 return m_cueBackgroundBox->document(); | 1112 return m_cueBackgroundBox->document(); |
1117 } | 1113 } |
1118 | 1114 |
1119 } // namespace WebCore | 1115 } // namespace WebCore |
OLD | NEW |