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 14 matching lines...) Expand all Loading... |
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 #include "core/html/track/TextTrack.h" | 33 #include "core/html/track/TextTrack.h" |
34 | 34 |
| 35 #include "RuntimeEnabledFeatures.h" |
35 #include "bindings/v8/ExceptionStatePlaceholder.h" | 36 #include "bindings/v8/ExceptionStatePlaceholder.h" |
36 #include "core/dom/ExceptionCode.h" | 37 #include "core/dom/ExceptionCode.h" |
37 #include "core/html/HTMLMediaElement.h" | 38 #include "core/html/HTMLMediaElement.h" |
38 #include "core/html/track/TextTrackCueList.h" | 39 #include "core/html/track/TextTrackCueList.h" |
39 #include "core/html/track/TextTrackList.h" | 40 #include "core/html/track/TextTrackList.h" |
40 #include "core/html/track/TextTrackRegion.h" | 41 #include "core/html/track/TextTrackRegion.h" |
41 #include "core/html/track/TextTrackRegionList.h" | 42 #include "core/html/track/TextTrackRegionList.h" |
42 | 43 |
43 namespace WebCore { | 44 namespace WebCore { |
44 | 45 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 | 89 |
89 const AtomicString& TextTrack::showingKeyword() | 90 const AtomicString& TextTrack::showingKeyword() |
90 { | 91 { |
91 DEFINE_STATIC_LOCAL(const AtomicString, ended, ("showing", AtomicString::Con
structFromLiteral)); | 92 DEFINE_STATIC_LOCAL(const AtomicString, ended, ("showing", AtomicString::Con
structFromLiteral)); |
92 return ended; | 93 return ended; |
93 } | 94 } |
94 | 95 |
95 TextTrack::TextTrack(ExecutionContext* context, TextTrackClient* client, const A
tomicString& kind, const AtomicString& label, const AtomicString& language, Text
TrackType type) | 96 TextTrack::TextTrack(ExecutionContext* context, TextTrackClient* client, const A
tomicString& kind, const AtomicString& label, const AtomicString& language, Text
TrackType type) |
96 : TrackBase(context, TrackBase::TextTrack) | 97 : TrackBase(context, TrackBase::TextTrack) |
97 , m_cues(0) | 98 , m_cues(0) |
98 #if ENABLE(WEBVTT_REGIONS) | |
99 , m_regions(0) | 99 , m_regions(0) |
100 #endif | |
101 , m_mediaElement(0) | 100 , m_mediaElement(0) |
102 , m_label(label) | 101 , m_label(label) |
103 , m_language(language) | 102 , m_language(language) |
104 , m_mode(disabledKeyword().string()) | 103 , m_mode(disabledKeyword().string()) |
105 , m_client(client) | 104 , m_client(client) |
106 , m_trackType(type) | 105 , m_trackType(type) |
107 , m_readinessState(NotLoaded) | 106 , m_readinessState(NotLoaded) |
108 , m_trackIndex(invalidTrackIndex) | 107 , m_trackIndex(invalidTrackIndex) |
109 , m_renderedTrackIndex(invalidTrackIndex) | 108 , m_renderedTrackIndex(invalidTrackIndex) |
110 , m_hasBeenConfigured(false) | 109 , m_hasBeenConfigured(false) |
111 { | 110 { |
112 ScriptWrappable::init(this); | 111 ScriptWrappable::init(this); |
113 setKind(kind); | 112 setKind(kind); |
114 } | 113 } |
115 | 114 |
116 TextTrack::~TextTrack() | 115 TextTrack::~TextTrack() |
117 { | 116 { |
118 if (m_cues) { | 117 if (m_cues) { |
119 if (m_client) | 118 if (m_client) |
120 m_client->textTrackRemoveCues(this, m_cues.get()); | 119 m_client->textTrackRemoveCues(this, m_cues.get()); |
121 | 120 |
122 for (size_t i = 0; i < m_cues->length(); ++i) | 121 for (size_t i = 0; i < m_cues->length(); ++i) |
123 m_cues->item(i)->setTrack(0); | 122 m_cues->item(i)->setTrack(0); |
124 } | 123 } |
125 | 124 |
126 #if ENABLE(WEBVTT_REGIONS) | |
127 if (m_regions) { | 125 if (m_regions) { |
128 for (size_t i = 0; i < m_regions->length(); ++i) | 126 for (size_t i = 0; i < m_regions->length(); ++i) |
129 m_regions->item(i)->setTrack(0); | 127 m_regions->item(i)->setTrack(0); |
130 } | 128 } |
131 #endif | |
132 clearClient(); | 129 clearClient(); |
133 } | 130 } |
134 | 131 |
135 bool TextTrack::isValidKindKeyword(const AtomicString& value) | 132 bool TextTrack::isValidKindKeyword(const AtomicString& value) |
136 { | 133 { |
137 if (value == subtitlesKeyword()) | 134 if (value == subtitlesKeyword()) |
138 return true; | 135 return true; |
139 if (value == captionsKeyword()) | 136 if (value == captionsKeyword()) |
140 return true; | 137 return true; |
141 if (value == descriptionsKeyword()) | 138 if (value == descriptionsKeyword()) |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 if (!m_cues || !m_cues->remove(cue)) { | 271 if (!m_cues || !m_cues->remove(cue)) { |
275 es.throwUninformativeAndGenericDOMException(InvalidStateError); | 272 es.throwUninformativeAndGenericDOMException(InvalidStateError); |
276 return; | 273 return; |
277 } | 274 } |
278 | 275 |
279 cue->setTrack(0); | 276 cue->setTrack(0); |
280 if (m_client) | 277 if (m_client) |
281 m_client->textTrackRemoveCue(this, cue); | 278 m_client->textTrackRemoveCue(this, cue); |
282 } | 279 } |
283 | 280 |
284 #if ENABLE(WEBVTT_REGIONS) | |
285 TextTrackRegionList* TextTrack::regionList() | |
286 { | |
287 return ensureTextTrackRegionList(); | |
288 } | |
289 | |
290 TextTrackRegionList* TextTrack::ensureTextTrackRegionList() | 281 TextTrackRegionList* TextTrack::ensureTextTrackRegionList() |
291 { | 282 { |
292 if (!m_regions) | 283 if (!m_regions) |
293 m_regions = TextTrackRegionList::create(); | 284 m_regions = TextTrackRegionList::create(); |
294 | 285 |
295 return m_regions.get(); | 286 return m_regions.get(); |
296 } | 287 } |
297 | 288 |
298 TextTrackRegionList* TextTrack::regions() | 289 TextTrackRegionList* TextTrack::regions() |
299 { | 290 { |
300 // If the text track mode of the text track that the TextTrack object | 291 // If the text track mode of the text track that the TextTrack object |
301 // represents is not the text track disabled mode, then the regions | 292 // represents is not the text track disabled mode, then the regions |
302 // attribute must return a live TextTrackRegionList object that represents | 293 // attribute must return a live TextTrackRegionList object that represents |
303 // the text track list of regions of the text track. Otherwise, it must | 294 // the text track list of regions of the text track. Otherwise, it must |
304 // return null. When an object is returned, the same object must be returned | 295 // return null. When an object is returned, the same object must be returned |
305 // each time. | 296 // each time. |
306 if (m_mode != disabledKeyword()) | 297 if (RuntimeEnabledFeatures::webVTTRegionsEnabled() && m_mode != disabledKeyw
ord()) |
307 return ensureTextTrackRegionList(); | 298 return ensureTextTrackRegionList(); |
308 | |
309 return 0; | 299 return 0; |
310 } | 300 } |
311 | 301 |
312 void TextTrack::addRegion(PassRefPtr<TextTrackRegion> prpRegion) | 302 void TextTrack::addRegion(PassRefPtr<TextTrackRegion> prpRegion) |
313 { | 303 { |
314 if (!prpRegion) | 304 if (!prpRegion) |
315 return; | 305 return; |
316 | 306 |
317 RefPtr<TextTrackRegion> region = prpRegion; | 307 RefPtr<TextTrackRegion> region = prpRegion; |
318 TextTrackRegionList* regionList = ensureTextTrackRegionList(); | 308 TextTrackRegionList* regionList = ensureTextTrackRegionList(); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 return; | 341 return; |
352 } | 342 } |
353 | 343 |
354 if (!m_regions || !m_regions->remove(region)) { | 344 if (!m_regions || !m_regions->remove(region)) { |
355 es.throwUninformativeAndGenericDOMException(InvalidStateError); | 345 es.throwUninformativeAndGenericDOMException(InvalidStateError); |
356 return; | 346 return; |
357 } | 347 } |
358 | 348 |
359 region->setTrack(0); | 349 region->setTrack(0); |
360 } | 350 } |
361 #endif | |
362 | 351 |
363 void TextTrack::cueWillChange(TextTrackCue* cue) | 352 void TextTrack::cueWillChange(TextTrackCue* cue) |
364 { | 353 { |
365 if (!m_client) | 354 if (!m_client) |
366 return; | 355 return; |
367 | 356 |
368 // The cue may need to be repositioned in the media element's interval tree,
may need to | 357 // The cue may need to be repositioned in the media element's interval tree,
may need to |
369 // be re-rendered, etc, so remove it before the modification... | 358 // be re-rendered, etc, so remove it before the modification... |
370 m_client->textTrackRemoveCue(this, cue); | 359 m_client->textTrackRemoveCue(this, cue); |
371 } | 360 } |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 { | 478 { |
490 // "Main program" content is intrinsic to the presentation of the media file
, regardless of locale. Content such as | 479 // "Main program" content is intrinsic to the presentation of the media file
, regardless of locale. Content such as |
491 // directors commentary is not "main program" because it is not essential fo
r the presentation. HTML5 doesn't have | 480 // directors commentary is not "main program" because it is not essential fo
r the presentation. HTML5 doesn't have |
492 // a way to express this in a machine-reable form, it is typically done with
the track label, so we assume that caption | 481 // a way to express this in a machine-reable form, it is typically done with
the track label, so we assume that caption |
493 // tracks are main content and all other track types are not. | 482 // tracks are main content and all other track types are not. |
494 return m_kind == captionsKeyword(); | 483 return m_kind == captionsKeyword(); |
495 } | 484 } |
496 | 485 |
497 } // namespace WebCore | 486 } // namespace WebCore |
498 | 487 |
OLD | NEW |