| 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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 | 131 |
| 132 void TextTrack::setTrackList(TextTrackList* trackList) | 132 void TextTrack::setTrackList(TextTrackList* trackList) |
| 133 { | 133 { |
| 134 if (!trackList && cueTimeline() && m_cues) | 134 if (!trackList && cueTimeline() && m_cues) |
| 135 cueTimeline()->removeCues(this, m_cues.get()); | 135 cueTimeline()->removeCues(this, m_cues.get()); |
| 136 | 136 |
| 137 m_trackList = trackList; | 137 m_trackList = trackList; |
| 138 invalidateTrackIndex(); | 138 invalidateTrackIndex(); |
| 139 } | 139 } |
| 140 | 140 |
| 141 bool TextTrack::isVisualKind() const |
| 142 { |
| 143 return kind() == subtitlesKeyword() || kind() == captionsKeyword(); |
| 144 } |
| 145 |
| 141 void TextTrack::setKind(const AtomicString& newKind) | 146 void TextTrack::setKind(const AtomicString& newKind) |
| 142 { | 147 { |
| 143 AtomicString oldKind = kind(); | 148 AtomicString oldKind = kind(); |
| 144 TrackBase::setKind(newKind); | 149 TrackBase::setKind(newKind); |
| 145 | 150 |
| 146 // If kind changes from visual to non-visual and mode is 'showing', then for
ce mode to 'hidden'. | 151 // If kind changes from visual to non-visual and mode is 'showing', then for
ce mode to 'hidden'. |
| 147 // FIXME: This is not per spec. crbug.com/460923 | 152 // FIXME: This is not per spec. crbug.com/460923 |
| 148 if (oldKind != kind() && mode() == showingKeyword()) { | 153 if (oldKind != kind() && mode() == showingKeyword() && !isVisualKind()) |
| 149 if (kind() != captionsKeyword() && kind() != subtitlesKeyword()) | 154 setMode(hiddenKeyword()); |
| 150 setMode(hiddenKeyword()); | |
| 151 } | |
| 152 } | 155 } |
| 153 | 156 |
| 154 void TextTrack::setMode(const AtomicString& mode) | 157 void TextTrack::setMode(const AtomicString& mode) |
| 155 { | 158 { |
| 156 ASSERT(mode == disabledKeyword() || mode == hiddenKeyword() || mode == showi
ngKeyword()); | 159 ASSERT(mode == disabledKeyword() || mode == hiddenKeyword() || mode == showi
ngKeyword()); |
| 157 | 160 |
| 158 // On setting, if the new value isn't equal to what the attribute would curr
ently | 161 // On setting, if the new value isn't equal to what the attribute would curr
ently |
| 159 // return, the new value must be processed as follows ... | 162 // return, the new value must be processed as follows ... |
| 160 if (m_mode == mode) | 163 if (m_mode == mode) |
| 161 return; | 164 return; |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 } | 412 } |
| 410 | 413 |
| 411 void TextTrack::invalidateTrackIndex() | 414 void TextTrack::invalidateTrackIndex() |
| 412 { | 415 { |
| 413 m_trackIndex = invalidTrackIndex; | 416 m_trackIndex = invalidTrackIndex; |
| 414 m_renderedTrackIndex = invalidTrackIndex; | 417 m_renderedTrackIndex = invalidTrackIndex; |
| 415 } | 418 } |
| 416 | 419 |
| 417 bool TextTrack::isRendered() const | 420 bool TextTrack::isRendered() const |
| 418 { | 421 { |
| 419 if (kind() != captionsKeyword() && kind() != subtitlesKeyword()) | 422 return m_mode == showingKeyword() && isVisualKind(); |
| 420 return false; | |
| 421 | |
| 422 if (m_mode != showingKeyword()) | |
| 423 return false; | |
| 424 | |
| 425 return true; | |
| 426 } | 423 } |
| 427 | 424 |
| 428 bool TextTrack::canBeRendered() const | 425 bool TextTrack::canBeRendered() const |
| 429 { | 426 { |
| 430 // A track can be displayed when it's of kind captions or subtitles and hasn
't failed to load. | 427 // A track can be displayed when it's of kind captions or subtitles and hasn
't failed to load. |
| 431 if (kind() != captionsKeyword() && kind() != subtitlesKeyword()) | 428 return getReadinessState() != FailedToLoad && isVisualKind(); |
| 432 return false; | |
| 433 | |
| 434 if (getReadinessState() == FailedToLoad) | |
| 435 return false; | |
| 436 | |
| 437 return true; | |
| 438 } | 429 } |
| 439 | 430 |
| 440 TextTrackCueList* TextTrack::ensureTextTrackCueList() | 431 TextTrackCueList* TextTrack::ensureTextTrackCueList() |
| 441 { | 432 { |
| 442 if (!m_cues) | 433 if (!m_cues) |
| 443 m_cues = TextTrackCueList::create(); | 434 m_cues = TextTrackCueList::create(); |
| 444 | 435 |
| 445 return m_cues.get(); | 436 return m_cues.get(); |
| 446 } | 437 } |
| 447 | 438 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 visitor->trace(m_trackList); | 480 visitor->trace(m_trackList); |
| 490 TrackBase::trace(visitor); | 481 TrackBase::trace(visitor); |
| 491 EventTargetWithInlineData::trace(visitor); | 482 EventTargetWithInlineData::trace(visitor); |
| 492 } | 483 } |
| 493 | 484 |
| 494 DEFINE_TRACE_WRAPPERS(TextTrack) | 485 DEFINE_TRACE_WRAPPERS(TextTrack) |
| 495 { | 486 { |
| 496 visitor->traceWrappers(m_cues); | 487 visitor->traceWrappers(m_cues); |
| 497 } | 488 } |
| 498 } // namespace blink | 489 } // namespace blink |
| OLD | NEW |