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 12 matching lines...) Expand all Loading... | |
23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
30 */ | 30 */ |
31 | 31 |
32 #include "config.h" | 32 #include "config.h" |
33 | |
34 #include "core/html/track/TextTrackCue.h" | 33 #include "core/html/track/TextTrackCue.h" |
35 | 34 |
36 #include "CSSPropertyNames.h" | 35 #include "CSSPropertyNames.h" |
37 #include "CSSValueKeywords.h" | 36 #include "CSSValueKeywords.h" |
37 #include "RuntimeEnabledFeatures.h" | |
38 #include "bindings/v8/ExceptionStatePlaceholder.h" | 38 #include "bindings/v8/ExceptionStatePlaceholder.h" |
39 #include "core/dom/DocumentFragment.h" | 39 #include "core/dom/DocumentFragment.h" |
40 #include "core/events/Event.h" | 40 #include "core/events/Event.h" |
41 #include "core/dom/NodeTraversal.h" | 41 #include "core/dom/NodeTraversal.h" |
42 #include "core/html/HTMLDivElement.h" | 42 #include "core/html/HTMLDivElement.h" |
43 #include "core/html/track/TextTrack.h" | 43 #include "core/html/track/TextTrack.h" |
44 #include "core/html/track/TextTrackCueList.h" | 44 #include "core/html/track/TextTrackCueList.h" |
45 #include "core/html/track/TextTrackRegionList.h" | 45 #include "core/html/track/TextTrackRegionList.h" |
46 #include "core/html/track/WebVTTElement.h" | 46 #include "core/html/track/WebVTTElement.h" |
47 #include "core/html/track/WebVTTParser.h" | 47 #include "core/html/track/WebVTTParser.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
100 } | 100 } |
101 | 101 |
102 TextTrackCue* TextTrackCueBox::getCue() const | 102 TextTrackCue* TextTrackCueBox::getCue() const |
103 { | 103 { |
104 return m_cue; | 104 return m_cue; |
105 } | 105 } |
106 | 106 |
107 void TextTrackCueBox::applyCSSProperties(const IntSize&) | 107 void TextTrackCueBox::applyCSSProperties(const IntSize&) |
108 { | 108 { |
109 // FIXME: Apply all the initial CSS positioning properties. http://wkb.ug/79 916 | 109 // FIXME: Apply all the initial CSS positioning properties. http://wkb.ug/79 916 |
110 #if ENABLE(WEBVTT_REGIONS) | 110 if (RuntimeEnabledFeatures::webVTTRegionsEnabled() && !m_cue->regionId().isE mpty()) { |
acolwell GONE FROM CHROMIUM
2013/10/04 19:48:20
nit: Can the regionId be non-empty if this flag is
vcarbune.chromium
2013/10/08 18:07:38
Done.
| |
111 if (!m_cue->regionId().isEmpty()) { | |
112 setInlineStyleProperty(CSSPropertyPosition, CSSValueRelative); | 111 setInlineStyleProperty(CSSPropertyPosition, CSSValueRelative); |
113 return; | 112 return; |
114 } | 113 } |
115 #endif | |
116 | 114 |
117 // 3.5.1 On the (root) List of WebVTT Node Objects: | 115 // 3.5.1 On the (root) List of WebVTT Node Objects: |
118 | 116 |
119 // the 'position' property must be set to 'absolute' | 117 // the 'position' property must be set to 'absolute' |
120 setInlineStyleProperty(CSSPropertyPosition, CSSValueAbsolute); | 118 setInlineStyleProperty(CSSPropertyPosition, CSSValueAbsolute); |
121 | 119 |
122 // the 'unicode-bidi' property must be set to 'plaintext' | 120 // the 'unicode-bidi' property must be set to 'plaintext' |
123 setInlineStyleProperty(CSSPropertyUnicodeBidi, CSSValueWebkitPlaintext); | 121 setInlineStyleProperty(CSSPropertyUnicodeBidi, CSSValueWebkitPlaintext); |
124 | 122 |
125 // the 'direction' property must be set to direction | 123 // the 'direction' property must be set to direction |
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
532 | 530 |
533 bool TextTrackCue::dispatchEvent(PassRefPtr<Event> event) | 531 bool TextTrackCue::dispatchEvent(PassRefPtr<Event> event) |
534 { | 532 { |
535 // When a TextTrack's mode is disabled: no cues are active, no events fired. | 533 // When a TextTrack's mode is disabled: no cues are active, no events fired. |
536 if (!track() || track()->mode() == TextTrack::disabledKeyword()) | 534 if (!track() || track()->mode() == TextTrack::disabledKeyword()) |
537 return false; | 535 return false; |
538 | 536 |
539 return EventTarget::dispatchEvent(event); | 537 return EventTarget::dispatchEvent(event); |
540 } | 538 } |
541 | 539 |
542 #if ENABLE(WEBVTT_REGIONS) | |
543 void TextTrackCue::setRegionId(const String& regionId) | 540 void TextTrackCue::setRegionId(const String& regionId) |
544 { | 541 { |
545 if (m_regionId == regionId) | 542 if (m_regionId == regionId) |
546 return; | 543 return; |
547 | 544 |
548 cueWillChange(); | 545 cueWillChange(); |
549 m_regionId = regionId; | 546 m_regionId = regionId; |
550 cueDidChange(); | 547 cueDidChange(); |
551 } | 548 } |
552 #endif | 549 |
550 void TextTrackCue::notifyRegionWhenRemovingDisplayTree(bool notifyRegion) | |
551 { | |
552 m_notifyRegion = notifyRegion; | |
553 } | |
553 | 554 |
554 bool TextTrackCue::isActive() | 555 bool TextTrackCue::isActive() |
555 { | 556 { |
556 return m_isActive && track() && track()->mode() != TextTrack::disabledKeywor d(); | 557 return m_isActive && track() && track()->mode() != TextTrack::disabledKeywor d(); |
557 } | 558 } |
558 | 559 |
559 void TextTrackCue::setIsActive(bool active) | 560 void TextTrackCue::setIsActive(bool active) |
560 { | 561 { |
561 m_isActive = active; | 562 m_isActive = active; |
562 | 563 |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
823 | 824 |
824 m_displayTreeShouldChange = false; | 825 m_displayTreeShouldChange = false; |
825 | 826 |
826 // 10.15. Let cue's text track cue display state have the CSS boxes in | 827 // 10.15. Let cue's text track cue display state have the CSS boxes in |
827 // boxes. | 828 // boxes. |
828 return displayTree; | 829 return displayTree; |
829 } | 830 } |
830 | 831 |
831 void TextTrackCue::removeDisplayTree() | 832 void TextTrackCue::removeDisplayTree() |
832 { | 833 { |
833 #if ENABLE(WEBVTT_REGIONS) | 834 if (RuntimeEnabledFeatures::webVTTRegionsEnabled() && m_notifyRegion) { |
acolwell GONE FROM CHROMIUM
2013/10/04 19:48:20
nit: Do you really need the flag check here? What
vcarbune.chromium
2013/10/08 18:07:38
Removed, added the proper check that track->region
| |
834 // The region needs to be informed about the cue removal. | 835 // The region needs to be informed about the cue removal. |
835 TextTrackRegion* region = m_track->regions()->getRegionById(m_regionId); | 836 TextTrackRegion* region = m_track->regions()->getRegionById(m_regionId); |
836 if (region) | 837 if (region) |
837 region->willRemoveTextTrackCueBox(m_displayTree.get()); | 838 region->willRemoveTextTrackCueBox(m_displayTree.get()); |
838 #endif | 839 } |
839 | 840 |
840 displayTreeInternal()->remove(ASSERT_NO_EXCEPTION); | 841 displayTreeInternal()->remove(ASSERT_NO_EXCEPTION); |
841 } | 842 } |
842 | 843 |
843 std::pair<double, double> TextTrackCue::getPositionCoordinates() const | 844 std::pair<double, double> TextTrackCue::getPositionCoordinates() const |
844 { | 845 { |
845 // This method is used for setting x and y when snap to lines is not set. | 846 // This method is used for setting x and y when snap to lines is not set. |
846 std::pair<double, double> coordinates; | 847 std::pair<double, double> coordinates; |
847 | 848 |
848 if (m_writingDirection == Horizontal && m_displayDirection == CSSValueLtr) { | 849 if (m_writingDirection == Horizontal && m_displayDirection == CSSValueLtr) { |
(...skipping 29 matching lines...) Expand all Loading... | |
878 return coordinates; | 879 return coordinates; |
879 } | 880 } |
880 | 881 |
881 TextTrackCue::CueSetting TextTrackCue::settingName(const String& name) | 882 TextTrackCue::CueSetting TextTrackCue::settingName(const String& name) |
882 { | 883 { |
883 DEFINE_STATIC_LOCAL(const String, verticalKeyword, ("vertical")); | 884 DEFINE_STATIC_LOCAL(const String, verticalKeyword, ("vertical")); |
884 DEFINE_STATIC_LOCAL(const String, lineKeyword, ("line")); | 885 DEFINE_STATIC_LOCAL(const String, lineKeyword, ("line")); |
885 DEFINE_STATIC_LOCAL(const String, positionKeyword, ("position")); | 886 DEFINE_STATIC_LOCAL(const String, positionKeyword, ("position")); |
886 DEFINE_STATIC_LOCAL(const String, sizeKeyword, ("size")); | 887 DEFINE_STATIC_LOCAL(const String, sizeKeyword, ("size")); |
887 DEFINE_STATIC_LOCAL(const String, alignKeyword, ("align")); | 888 DEFINE_STATIC_LOCAL(const String, alignKeyword, ("align")); |
888 #if ENABLE(WEBVTT_REGIONS) | |
889 DEFINE_STATIC_LOCAL(const String, regionIdKeyword, ("region")); | 889 DEFINE_STATIC_LOCAL(const String, regionIdKeyword, ("region")); |
890 #endif | |
891 | 890 |
892 if (name == verticalKeyword) | 891 if (name == verticalKeyword) |
893 return Vertical; | 892 return Vertical; |
894 else if (name == lineKeyword) | 893 else if (name == lineKeyword) |
895 return Line; | 894 return Line; |
896 else if (name == positionKeyword) | 895 else if (name == positionKeyword) |
897 return Position; | 896 return Position; |
898 else if (name == sizeKeyword) | 897 else if (name == sizeKeyword) |
899 return Size; | 898 return Size; |
900 else if (name == alignKeyword) | 899 else if (name == alignKeyword) |
901 return Align; | 900 return Align; |
902 #if ENABLE(WEBVTT_REGIONS) | 901 else if (RuntimeEnabledFeatures::webVTTRegionsEnabled() && name == regionIdK eyword) |
903 else if (name == regionIdKeyword) | |
904 return RegionId; | 902 return RegionId; |
905 #endif | |
906 | 903 |
907 return None; | 904 return None; |
908 } | 905 } |
909 | 906 |
910 void TextTrackCue::setCueSettings(const String& input) | 907 void TextTrackCue::setCueSettings(const String& input) |
911 { | 908 { |
912 m_settings = input; | 909 m_settings = input; |
913 unsigned position = 0; | 910 unsigned position = 0; |
914 | 911 |
915 while (position < input.length()) { | 912 while (position < input.length()) { |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1089 | 1086 |
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. | 1087 // 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()) | 1088 else if (cueAlignment == middleKeyword()) |
1092 m_cueAlignment = Middle; | 1089 m_cueAlignment = Middle; |
1093 | 1090 |
1094 // 3. If value is a case-sensitive match for the string "end", then let cue's text track cue alignment be end alignment. | 1091 // 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()) | 1092 else if (cueAlignment == endKeyword()) |
1096 m_cueAlignment = End; | 1093 m_cueAlignment = End; |
1097 } | 1094 } |
1098 break; | 1095 break; |
1099 #if ENABLE(WEBVTT_REGIONS) | |
1100 case RegionId: | 1096 case RegionId: |
1101 m_regionId = WebVTTParser::collectWord(input, &position); | 1097 if (RuntimeEnabledFeatures::webVTTRegionsEnabled()) { |
acolwell GONE FROM CHROMIUM
2013/10/04 19:48:20
nit: The check in settingName() should make this c
vcarbune.chromium
2013/10/08 18:07:38
Done.
| |
1102 break; | 1098 m_regionId = WebVTTParser::collectWord(input, &position); |
1103 #endif | 1099 break; |
1100 } | |
1104 case None: | 1101 case None: |
1105 break; | 1102 break; |
1106 } | 1103 } |
1107 | 1104 |
1108 NextSetting: | 1105 NextSetting: |
1109 position = endOfSetting; | 1106 position = endOfSetting; |
1110 } | 1107 } |
1111 #if ENABLE(WEBVTT_REGIONS) | |
1112 // 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 | |
1114 // the empty string, let cue's region identifier be the empty string. | |
1115 if (m_regionId.isEmpty()) | |
1116 return; | |
1117 | 1108 |
1118 if (m_linePosition != undefinedPosition || m_cueSize != 100 || m_writingDire ction != Horizontal) | 1109 if (RuntimeEnabledFeatures::webVTTRegionsEnabled()) { |
acolwell GONE FROM CHROMIUM
2013/10/04 19:48:20
nit: ditto. If m_regionId can only become non-empt
vcarbune.chromium
2013/10/08 18:07:38
Done.
| |
1119 m_regionId = emptyString(); | 1110 // If cue's line position is not auto or cue's size is not 100 or cue's |
1120 #endif | 1111 // writing direction is not horizontal, but cue's region identifier is n ot |
1112 // the empty string, let cue's region identifier be the empty string. | |
1113 if (m_regionId.isEmpty()) | |
1114 return; | |
1115 | |
1116 if (m_linePosition != undefinedPosition || m_cueSize != 100 || m_writing Direction != Horizontal) | |
1117 m_regionId = emptyString(); | |
1118 } | |
1121 } | 1119 } |
1122 | 1120 |
1123 CSSValueID TextTrackCue::getCSSWritingDirection() const | 1121 CSSValueID TextTrackCue::getCSSWritingDirection() const |
1124 { | 1122 { |
1125 return m_displayDirection; | 1123 return m_displayDirection; |
1126 } | 1124 } |
1127 | 1125 |
1128 CSSValueID TextTrackCue::getCSSWritingMode() const | 1126 CSSValueID TextTrackCue::getCSSWritingMode() const |
1129 { | 1127 { |
1130 return m_displayWritingMode; | 1128 return m_displayWritingMode; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1184 return false; | 1182 return false; |
1185 if (m_cueSize != cue.size()) | 1183 if (m_cueSize != cue.size()) |
1186 return false; | 1184 return false; |
1187 if (align() != cue.align()) | 1185 if (align() != cue.align()) |
1188 return false; | 1186 return false; |
1189 | 1187 |
1190 return true; | 1188 return true; |
1191 } | 1189 } |
1192 | 1190 |
1193 } // namespace WebCore | 1191 } // namespace WebCore |
OLD | NEW |