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 // ---------------------------- | 127 static const AtomicString& textTrackCueBoxShadowPseudoId() |
128 { | |
129 DEFINE_STATIC_LOCAL(const AtomicString, trackDisplayBoxShadowPseudoId, ("-we bkit-media-text-track-display", AtomicString::ConstructFromLiteral)); | |
acolwell GONE FROM CHROMIUM
2013/12/03 20:51:31
nit: Any reason not to just move this into the con
philipj_slow
2013/12/03 21:16:23
I imagined it might be some deliberate style. I've
| |
130 return trackDisplayBoxShadowPseudoId; | |
131 } | |
128 | 132 |
129 VTTCueBox::VTTCueBox(Document& document, VTTCue* cue) | 133 VTTCueBox::VTTCueBox(Document& document, VTTCue* cue) |
130 : TextTrackCueBox(document) | 134 : HTMLDivElement(document) |
131 , m_cue(cue) | 135 , m_cue(cue) |
132 { | 136 { |
133 setPseudo(textTrackCueBoxShadowPseudoId()); | 137 setPseudo(textTrackCueBoxShadowPseudoId()); |
134 } | 138 } |
135 | 139 |
136 void VTTCueBox::applyCSSProperties(const IntSize&) | 140 void VTTCueBox::applyCSSProperties(const IntSize&) |
137 { | 141 { |
138 // FIXME: Apply all the initial CSS positioning properties. http://wkb.ug/79 916 | 142 // FIXME: Apply all the initial CSS positioning properties. http://wkb.ug/79 916 |
139 if (!m_cue->regionId().isEmpty()) { | 143 if (!m_cue->regionId().isEmpty()) { |
140 setInlineStyleProperty(CSSPropertyPosition, CSSValueRelative); | 144 setInlineStyleProperty(CSSPropertyPosition, CSSValueRelative); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
194 | 198 |
195 setInlineStyleProperty(CSSPropertyWhiteSpace, CSSValuePre); | 199 setInlineStyleProperty(CSSPropertyWhiteSpace, CSSValuePre); |
196 } | 200 } |
197 } | 201 } |
198 | 202 |
199 RenderObject* VTTCueBox::createRenderer(RenderStyle*) | 203 RenderObject* VTTCueBox::createRenderer(RenderStyle*) |
200 { | 204 { |
201 return new RenderVTTCue(this); | 205 return new RenderVTTCue(this); |
202 } | 206 } |
203 | 207 |
204 // ---------------------------- | |
205 | |
206 VTTCue::VTTCue(Document& document, double startTime, double endTime, const Strin g& text) | 208 VTTCue::VTTCue(Document& document, double startTime, double endTime, const Strin g& text) |
207 : TextTrackCue(startTime, endTime) | 209 : TextTrackCue(startTime, endTime) |
208 , m_text(text) | 210 , m_text(text) |
209 , m_linePosition(undefinedPosition) | 211 , m_linePosition(undefinedPosition) |
210 , m_computedLinePosition(undefinedPosition) | 212 , m_computedLinePosition(undefinedPosition) |
211 , m_textPosition(50) | 213 , m_textPosition(50) |
212 , m_cueSize(100) | 214 , m_cueSize(100) |
213 , m_writingDirection(Horizontal) | 215 , m_writingDirection(Horizontal) |
214 , m_cueAlignment(Middle) | 216 , m_cueAlignment(Middle) |
215 , m_vttNodeTree(0) | 217 , m_vttNodeTree(0) |
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
705 | 707 |
706 // Clear the contents of the set. | 708 // Clear the contents of the set. |
707 m_cueBackgroundBox->removeChildren(); | 709 m_cueBackgroundBox->removeChildren(); |
708 | 710 |
709 // Update the two sets containing past and future WebVTT objects. | 711 // Update the two sets containing past and future WebVTT objects. |
710 RefPtr<DocumentFragment> referenceTree = createCueRenderingTree(); | 712 RefPtr<DocumentFragment> referenceTree = createCueRenderingTree(); |
711 markFutureAndPastNodes(referenceTree.get(), startTime(), movieTime); | 713 markFutureAndPastNodes(referenceTree.get(), startTime(), movieTime); |
712 m_cueBackgroundBox->appendChild(referenceTree, ASSERT_NO_EXCEPTION); | 714 m_cueBackgroundBox->appendChild(referenceTree, ASSERT_NO_EXCEPTION); |
713 } | 715 } |
714 | 716 |
715 PassRefPtr<TextTrackCueBox> VTTCue::getDisplayTree(const IntSize& videoSize) | 717 PassRefPtr<VTTCueBox> VTTCue::getDisplayTree(const IntSize& videoSize) |
716 { | 718 { |
717 RefPtr<VTTCueBox> displayTree = displayTreeInternal(); | 719 RefPtr<VTTCueBox> displayTree = displayTreeInternal(); |
718 if (!m_displayTreeShouldChange || !track()->isRendered()) | 720 if (!m_displayTreeShouldChange || !track()->isRendered()) |
719 return displayTree; | 721 return displayTree; |
720 | 722 |
721 // 10.1 - 10.10 | 723 // 10.1 - 10.10 |
722 calculateDisplayParameters(); | 724 calculateDisplayParameters(); |
723 | 725 |
724 // 10.11. Apply the terms of the CSS specifications to nodes within the | 726 // 10.11. Apply the terms of the CSS specifications to nodes within the |
725 // following constraints, thus obtaining a set of CSS boxes positioned | 727 // following constraints, thus obtaining a set of CSS boxes positioned |
(...skipping 29 matching lines...) Expand all Loading... | |
755 // boxes. | 757 // boxes. |
756 return displayTree; | 758 return displayTree; |
757 } | 759 } |
758 | 760 |
759 void VTTCue::removeDisplayTree() | 761 void VTTCue::removeDisplayTree() |
760 { | 762 { |
761 if (m_notifyRegion && track()->regions()) { | 763 if (m_notifyRegion && track()->regions()) { |
762 // The region needs to be informed about the cue removal. | 764 // The region needs to be informed about the cue removal. |
763 VTTRegion* region = track()->regions()->getRegionById(m_regionId); | 765 VTTRegion* region = track()->regions()->getRegionById(m_regionId); |
764 if (region) | 766 if (region) |
765 region->willRemoveTextTrackCueBox(m_displayTree.get()); | 767 region->willRemoveVTTCueBox(m_displayTree.get()); |
766 } | 768 } |
767 | 769 |
768 displayTreeInternal()->remove(ASSERT_NO_EXCEPTION); | 770 displayTreeInternal()->remove(ASSERT_NO_EXCEPTION); |
769 } | 771 } |
770 | 772 |
771 void VTTCue::updateDisplay(const IntSize& videoSize, HTMLDivElement& container) | 773 void VTTCue::updateDisplay(const IntSize& videoSize, HTMLDivElement& container) |
772 { | 774 { |
773 RefPtr<TextTrackCueBox> displayBox = getDisplayTree(videoSize); | 775 RefPtr<VTTCueBox> displayBox = getDisplayTree(videoSize); |
774 VTTRegion* region = 0; | 776 VTTRegion* region = 0; |
775 if (track()->regions()) | 777 if (track()->regions()) |
776 region = track()->regions()->getRegionById(regionId()); | 778 region = track()->regions()->getRegionById(regionId()); |
777 | 779 |
778 if (!region) { | 780 if (!region) { |
779 // If cue has an empty text track cue region identifier or there is no | 781 // 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 | 782 // WebVTT region whose region identifier is identical to cue's text |
781 // track cue region identifier, run the following substeps: | 783 // track cue region identifier, run the following substeps: |
782 if (displayBox->hasChildNodes() && !container.contains(displayBox.get()) ) { | 784 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. | 785 // Note: the display tree of a cue is removed when the active flag o f the cue is unset. |
784 container.appendChild(displayBox); | 786 container.appendChild(displayBox); |
785 } | 787 } |
786 } else { | 788 } else { |
787 // Let region be the WebVTT region whose region identifier | 789 // Let region be the WebVTT region whose region identifier |
788 // matches the text track cue region identifier of cue. | 790 // matches the text track cue region identifier of cue. |
789 RefPtr<HTMLDivElement> regionNode = region->getDisplayTree(document()); | 791 RefPtr<HTMLDivElement> regionNode = region->getDisplayTree(document()); |
790 | 792 |
791 // Append the region to the viewport, if it was not already. | 793 // Append the region to the viewport, if it was not already. |
792 if (!container.contains(regionNode.get())) | 794 if (!container.contains(regionNode.get())) |
793 container.appendChild(regionNode); | 795 container.appendChild(regionNode); |
794 | 796 |
795 region->appendTextTrackCueBox(displayBox); | 797 region->appendVTTCueBox(displayBox); |
796 } | 798 } |
797 } | 799 } |
798 | 800 |
799 std::pair<double, double> VTTCue::getPositionCoordinates() const | 801 std::pair<double, double> VTTCue::getPositionCoordinates() const |
800 { | 802 { |
801 // This method is used for setting x and y when snap to lines is not set. | 803 // This method is used for setting x and y when snap to lines is not set. |
802 std::pair<double, double> coordinates; | 804 std::pair<double, double> coordinates; |
803 | 805 |
804 if (m_writingDirection == Horizontal && m_displayDirection == CSSValueLtr) { | 806 if (m_writingDirection == Horizontal && m_displayDirection == CSSValueLtr) { |
805 coordinates.first = m_textPosition; | 807 coordinates.first = m_textPosition; |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1110 return m_cueBackgroundBox->executionContext(); | 1112 return m_cueBackgroundBox->executionContext(); |
1111 } | 1113 } |
1112 | 1114 |
1113 Document& VTTCue::document() const | 1115 Document& VTTCue::document() const |
1114 { | 1116 { |
1115 ASSERT(m_cueBackgroundBox); | 1117 ASSERT(m_cueBackgroundBox); |
1116 return m_cueBackgroundBox->document(); | 1118 return m_cueBackgroundBox->document(); |
1117 } | 1119 } |
1118 | 1120 |
1119 } // namespace WebCore | 1121 } // namespace WebCore |
OLD | NEW |