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

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

Issue 92783002: Move code that applies to audio and video tracks into TrackBase. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@tmp
Patch Set: Created 7 years 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
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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 return closed; 90 return closed;
91 } 91 }
92 92
93 const AtomicString& TextTrack::showingKeyword() 93 const AtomicString& TextTrack::showingKeyword()
94 { 94 {
95 DEFINE_STATIC_LOCAL(const AtomicString, ended, ("showing", AtomicString::Con structFromLiteral)); 95 DEFINE_STATIC_LOCAL(const AtomicString, ended, ("showing", AtomicString::Con structFromLiteral));
96 return ended; 96 return ended;
97 } 97 }
98 98
99 TextTrack::TextTrack(Document& document, TextTrackClient* client, const AtomicSt ring& kind, const AtomicString& label, const AtomicString& language, const Atomi cString& id, TextTrackType type) 99 TextTrack::TextTrack(Document& document, TextTrackClient* client, const AtomicSt ring& kind, const AtomicString& label, const AtomicString& language, const Atomi cString& id, TextTrackType type)
100 : TrackBase(TrackBase::TextTrack) 100 : TrackBase(TrackBase::TextTrack, label, language, id)
101 , m_cues(0) 101 , m_cues(0)
102 , m_regions(0) 102 , m_regions(0)
103 , m_document(&document) 103 , m_document(&document)
104 , m_mediaElement(0)
105 , m_label(label)
106 , m_language(language)
107 , m_id(id)
108 , m_mode(disabledKeyword()) 104 , m_mode(disabledKeyword())
109 , m_client(client) 105 , m_client(client)
110 , m_trackType(type) 106 , m_trackType(type)
111 , m_readinessState(NotLoaded) 107 , m_readinessState(NotLoaded)
112 , m_trackIndex(invalidTrackIndex) 108 , m_trackIndex(invalidTrackIndex)
113 , m_renderedTrackIndex(invalidTrackIndex) 109 , m_renderedTrackIndex(invalidTrackIndex)
114 , m_hasBeenConfigured(false) 110 , m_hasBeenConfigured(false)
115 { 111 {
116 ScriptWrappable::init(this); 112 ScriptWrappable::init(this);
117 setKind(kind); 113 setKind(kind);
(...skipping 25 matching lines...) Expand all
143 if (value == descriptionsKeyword()) 139 if (value == descriptionsKeyword())
144 return true; 140 return true;
145 if (value == chaptersKeyword()) 141 if (value == chaptersKeyword())
146 return true; 142 return true;
147 if (value == metadataKeyword()) 143 if (value == metadataKeyword())
148 return true; 144 return true;
149 145
150 return false; 146 return false;
151 } 147 }
152 148
153 void TextTrack::setKind(const AtomicString& kind) 149 void TextTrack::setKind(const AtomicString& newKind)
154 { 150 {
155 String oldKind = m_kind; 151 String oldKind = kind();
acolwell GONE FROM CHROMIUM 2013/11/28 03:02:17 nit: s/String/AtomicString?
152 TrackBase::setKind(newKind);
156 153
157 if (isValidKindKeyword(kind)) 154 if (m_client && oldKind != kind())
158 m_kind = kind;
159 else
160 m_kind = subtitlesKeyword();
161
162 if (m_client && oldKind != m_kind)
163 m_client->textTrackKindChanged(this); 155 m_client->textTrackKindChanged(this);
164 } 156 }
165 157
166 void TextTrack::setMode(const AtomicString& mode) 158 void TextTrack::setMode(const AtomicString& mode)
167 { 159 {
168 ASSERT(mode == disabledKeyword() || mode == hiddenKeyword() || mode == showi ngKeyword()); 160 ASSERT(mode == disabledKeyword() || mode == hiddenKeyword() || mode == showi ngKeyword());
169 161
170 // On setting, if the new value isn't equal to what the attribute would curr ently 162 // On setting, if the new value isn't equal to what the attribute would curr ently
171 // return, the new value must be processed as follows ... 163 // return, the new value must be processed as follows ...
172 if (m_mode == mode) 164 if (m_mode == mode)
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 362
371 // Make sure the TextTrackCueList order is up-to-date. 363 // Make sure the TextTrackCueList order is up-to-date.
372 ensureTextTrackCueList()->updateCueIndex(cue); 364 ensureTextTrackCueList()->updateCueIndex(cue);
373 365
374 // ... and add it back again. 366 // ... and add it back again.
375 m_client->textTrackAddCue(this, cue); 367 m_client->textTrackAddCue(this, cue);
376 } 368 }
377 369
378 int TextTrack::trackIndex() 370 int TextTrack::trackIndex()
379 { 371 {
380 ASSERT(m_mediaElement); 372 ASSERT(mediaElement());
381 373
382 if (m_trackIndex == invalidTrackIndex) 374 if (m_trackIndex == invalidTrackIndex)
383 m_trackIndex = m_mediaElement->textTracks()->getTrackIndex(this); 375 m_trackIndex = mediaElement()->textTracks()->getTrackIndex(this);
384 376
385 return m_trackIndex; 377 return m_trackIndex;
386 } 378 }
387 379
388 void TextTrack::invalidateTrackIndex() 380 void TextTrack::invalidateTrackIndex()
389 { 381 {
390 m_trackIndex = invalidTrackIndex; 382 m_trackIndex = invalidTrackIndex;
391 m_renderedTrackIndex = invalidTrackIndex; 383 m_renderedTrackIndex = invalidTrackIndex;
392 } 384 }
393 385
394 bool TextTrack::isRendered() 386 bool TextTrack::isRendered()
395 { 387 {
396 if (m_kind != captionsKeyword() && m_kind != subtitlesKeyword()) 388 if (kind() != captionsKeyword() && kind() != subtitlesKeyword())
397 return false; 389 return false;
398 390
399 if (m_mode != showingKeyword()) 391 if (kind() != showingKeyword())
400 return false; 392 return false;
401 393
402 return true; 394 return true;
403 } 395 }
404 396
405 TextTrackCueList* TextTrack::ensureTextTrackCueList() 397 TextTrackCueList* TextTrack::ensureTextTrackCueList()
406 { 398 {
407 if (!m_cues) 399 if (!m_cues)
408 m_cues = TextTrackCueList::create(); 400 m_cues = TextTrackCueList::create();
409 401
410 return m_cues.get(); 402 return m_cues.get();
411 } 403 }
412 404
413 int TextTrack::trackIndexRelativeToRenderedTracks() 405 int TextTrack::trackIndexRelativeToRenderedTracks()
414 { 406 {
415 ASSERT(m_mediaElement); 407 ASSERT(mediaElement());
416 408
417 if (m_renderedTrackIndex == invalidTrackIndex) 409 if (m_renderedTrackIndex == invalidTrackIndex)
418 m_renderedTrackIndex = m_mediaElement->textTracks()->getTrackIndexRelati veToRenderedTracks(this); 410 m_renderedTrackIndex = mediaElement()->textTracks()->getTrackIndexRelati veToRenderedTracks(this);
419 411
420 return m_renderedTrackIndex; 412 return m_renderedTrackIndex;
421 } 413 }
422 414
423 const AtomicString& TextTrack::interfaceName() const 415 const AtomicString& TextTrack::interfaceName() const
424 { 416 {
425 return EventTargetNames::TextTrack; 417 return EventTargetNames::TextTrack;
426 } 418 }
427 419
428 ExecutionContext* TextTrack::executionContext() const 420 ExecutionContext* TextTrack::executionContext() const
429 { 421 {
430 return m_document; 422 return m_document;
431 } 423 }
432 424
433 } // namespace WebCore 425 } // namespace WebCore
434 426
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698