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