OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "core/html/track/CueTimeline.h" | 5 #include "core/html/track/CueTimeline.h" |
6 | 6 |
7 #include "core/events/Event.h" | 7 #include "core/events/Event.h" |
8 #include "core/html/HTMLMediaElement.h" | 8 #include "core/html/HTMLMediaElement.h" |
9 #include "core/html/HTMLTrackElement.h" | 9 #include "core/html/HTMLTrackElement.h" |
10 #include "core/html/track/LoadableTextTrack.h" | 10 #include "core/html/track/LoadableTextTrack.h" |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 // https://html.spec.whatwg.org/#time-marches-on | 129 // https://html.spec.whatwg.org/#time-marches-on |
130 | 130 |
131 // 1 - Let current cues be a list of cues, initialized to contain all the | 131 // 1 - Let current cues be a list of cues, initialized to contain all the |
132 // cues of all the hidden, showing, or showing by default text tracks of the | 132 // cues of all the hidden, showing, or showing by default text tracks of the |
133 // media element (not the disabled ones) whose start times are less than or | 133 // media element (not the disabled ones) whose start times are less than or |
134 // equal to the current playback position and whose end times are greater | 134 // equal to the current playback position and whose end times are greater |
135 // than the current playback position. | 135 // than the current playback position. |
136 CueList currentCues; | 136 CueList currentCues; |
137 | 137 |
138 // The user agent must synchronously unset [the text track cue active] flag | 138 // The user agent must synchronously unset [the text track cue active] flag |
139 // whenever ... the media element's readyState is changed back to kHaveNothing
. | 139 // whenever ... the media element's readyState is changed back to |
| 140 // kHaveNothing. |
140 if (mediaElement.getReadyState() != HTMLMediaElement::kHaveNothing && | 141 if (mediaElement.getReadyState() != HTMLMediaElement::kHaveNothing && |
141 mediaElement.webMediaPlayer()) | 142 mediaElement.webMediaPlayer()) |
142 currentCues = | 143 currentCues = |
143 m_cueTree.allOverlaps(m_cueTree.createInterval(movieTime, movieTime)); | 144 m_cueTree.allOverlaps(m_cueTree.createInterval(movieTime, movieTime)); |
144 | 145 |
145 CueList previousCues; | 146 CueList previousCues; |
146 CueList missedCues; | 147 CueList missedCues; |
147 | 148 |
148 // 2 - Let other cues be a list of cues, initialized to contain all the cues | 149 // 2 - Let other cues be a list of cues, initialized to contain all the cues |
149 // of hidden, showing, and showing by default text tracks of the media | 150 // of hidden, showing, and showing by default text tracks of the media |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 createEventWithTarget(eventName, eventTasks[i].second.get())); | 309 createEventWithTarget(eventName, eventTasks[i].second.get())); |
309 } | 310 } |
310 } | 311 } |
311 | 312 |
312 // 14 - Sort affected tracks in the same order as the text tracks appear in | 313 // 14 - Sort affected tracks in the same order as the text tracks appear in |
313 // the media element's list of text tracks, and remove duplicates. | 314 // the media element's list of text tracks, and remove duplicates. |
314 nonCopyingSort(affectedTracks.begin(), affectedTracks.end(), | 315 nonCopyingSort(affectedTracks.begin(), affectedTracks.end(), |
315 trackIndexCompare); | 316 trackIndexCompare); |
316 | 317 |
317 // 15 - For each text track in affected tracks, in the list order, queue a | 318 // 15 - For each text track in affected tracks, in the list order, queue a |
318 // task to fire a simple event named cuechange at the TextTrack object, and, .
.. | 319 // task to fire a simple event named cuechange at the TextTrack object, and, |
| 320 // ... |
319 for (size_t i = 0; i < affectedTracks.size(); ++i) { | 321 for (size_t i = 0; i < affectedTracks.size(); ++i) { |
320 mediaElement.scheduleEvent(createEventWithTarget(EventTypeNames::cuechange, | 322 mediaElement.scheduleEvent(createEventWithTarget(EventTypeNames::cuechange, |
321 affectedTracks[i].get())); | 323 affectedTracks[i].get())); |
322 | 324 |
323 // ... if the text track has a corresponding track element, to then fire a | 325 // ... if the text track has a corresponding track element, to then fire a |
324 // simple event named cuechange at the track element as well. | 326 // simple event named cuechange at the track element as well. |
325 if (affectedTracks[i]->trackType() == TextTrack::TrackElement) { | 327 if (affectedTracks[i]->trackType() == TextTrack::TrackElement) { |
326 HTMLTrackElement* trackElement = | 328 HTMLTrackElement* trackElement = |
327 static_cast<LoadableTextTrack*>(affectedTracks[i].get()) | 329 static_cast<LoadableTextTrack*>(affectedTracks[i].get()) |
328 ->trackElement(); | 330 ->trackElement(); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 --m_ignoreUpdate; | 362 --m_ignoreUpdate; |
361 if (!m_ignoreUpdate) | 363 if (!m_ignoreUpdate) |
362 updateActiveCues(mediaElement().currentTime()); | 364 updateActiveCues(mediaElement().currentTime()); |
363 } | 365 } |
364 | 366 |
365 DEFINE_TRACE(CueTimeline) { | 367 DEFINE_TRACE(CueTimeline) { |
366 visitor->trace(m_mediaElement); | 368 visitor->trace(m_mediaElement); |
367 } | 369 } |
368 | 370 |
369 } // namespace blink | 371 } // namespace blink |
OLD | NEW |