Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(799)

Side by Side Diff: Source/core/html/track/TextTrack.cpp

Issue 25798003: Enable WebVTT regions for runtime testing, updated tests and minor fixes (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Revert Logging Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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(ScriptExecutionContext* context, TextTrackClient* client, c onst AtomicString& kind, const AtomicString& label, const AtomicString& language , TextTrackType type) 96 TextTrack::TextTrack(ScriptExecutionContext* context, TextTrackClient* client, c onst AtomicString& kind, const AtomicString& label, const AtomicString& language , TextTrackType 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) 125 if (RuntimeEnabledFeatures::webVTTRegionsEnabled() && m_regions) {
acolwell GONE FROM CHROMIUM 2013/10/04 19:48:20 nit: Why is this covered by the feature guard. Wil
vcarbune.chromium 2013/10/08 18:07:38 Removed the runtime flag check. It should be zero
127 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
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() 281 TextTrackRegionList* TextTrack::regionList()
286 { 282 {
287 return ensureTextTrackRegionList(); 283 return ensureTextTrackRegionList();
288 } 284 }
289 285
290 TextTrackRegionList* TextTrack::ensureTextTrackRegionList() 286 TextTrackRegionList* TextTrack::ensureTextTrackRegionList()
291 { 287 {
292 if (!m_regions) 288 if (!m_regions)
293 m_regions = TextTrackRegionList::create(); 289 m_regions = TextTrackRegionList::create();
294 290
295 return m_regions.get(); 291 return m_regions.get();
296 } 292 }
297 293
298 TextTrackRegionList* TextTrack::regions() 294 TextTrackRegionList* TextTrack::regions()
299 { 295 {
300 // If the text track mode of the text track that the TextTrack object 296 // 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 297 // represents is not the text track disabled mode, then the regions
302 // attribute must return a live TextTrackRegionList object that represents 298 // attribute must return a live TextTrackRegionList object that represents
303 // the text track list of regions of the text track. Otherwise, it must 299 // 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 300 // return null. When an object is returned, the same object must be returned
305 // each time. 301 // each time.
306 if (m_mode != disabledKeyword()) 302 if (m_mode != disabledKeyword())
307 return ensureTextTrackRegionList(); 303 return ensureTextTrackRegionList();
308
309 return 0; 304 return 0;
310 } 305 }
311 306
312 void TextTrack::addRegion(PassRefPtr<TextTrackRegion> prpRegion) 307 void TextTrack::addRegion(PassRefPtr<TextTrackRegion> prpRegion)
313 { 308 {
314 if (!prpRegion) 309 if (!prpRegion)
315 return; 310 return;
316 311
317 RefPtr<TextTrackRegion> region = prpRegion; 312 RefPtr<TextTrackRegion> region = prpRegion;
318 TextTrackRegionList* regionList = ensureTextTrackRegionList(); 313 TextTrackRegionList* regionList = ensureTextTrackRegionList();
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 return; 346 return;
352 } 347 }
353 348
354 if (!m_regions || !m_regions->remove(region)) { 349 if (!m_regions || !m_regions->remove(region)) {
355 es.throwUninformativeAndGenericDOMException(InvalidStateError); 350 es.throwUninformativeAndGenericDOMException(InvalidStateError);
356 return; 351 return;
357 } 352 }
358 353
359 region->setTrack(0); 354 region->setTrack(0);
360 } 355 }
361 #endif
362 356
363 void TextTrack::cueWillChange(TextTrackCue* cue) 357 void TextTrack::cueWillChange(TextTrackCue* cue)
364 { 358 {
365 if (!m_client) 359 if (!m_client)
366 return; 360 return;
367 361
368 // The cue may need to be repositioned in the media element's interval tree, may need to 362 // 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... 363 // be re-rendered, etc, so remove it before the modification...
370 m_client->textTrackRemoveCue(this, cue); 364 m_client->textTrackRemoveCue(this, cue);
371 } 365 }
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 { 483 {
490 // "Main program" content is intrinsic to the presentation of the media file , regardless of locale. Content such as 484 // "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 485 // 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 486 // 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. 487 // tracks are main content and all other track types are not.
494 return m_kind == captionsKeyword(); 488 return m_kind == captionsKeyword();
495 } 489 }
496 490
497 } // namespace WebCore 491 } // namespace WebCore
498 492
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698