OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserv
ed. | 2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserv
ed. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 map.add(document, set); | 175 map.add(document, set); |
176 } | 176 } |
177 | 177 |
178 HTMLMediaElement::HTMLMediaElement(const QualifiedName& tagName, Document* docum
ent, bool createdByParser) | 178 HTMLMediaElement::HTMLMediaElement(const QualifiedName& tagName, Document* docum
ent, bool createdByParser) |
179 : HTMLElement(tagName, document) | 179 : HTMLElement(tagName, document) |
180 , ActiveDOMObject(document, this) | 180 , ActiveDOMObject(document, this) |
181 , m_loadTimer(this, &HTMLMediaElement::loadTimerFired) | 181 , m_loadTimer(this, &HTMLMediaElement::loadTimerFired) |
182 , m_progressEventTimer(this, &HTMLMediaElement::progressEventTimerFired) | 182 , m_progressEventTimer(this, &HTMLMediaElement::progressEventTimerFired) |
183 , m_playbackProgressTimer(this, &HTMLMediaElement::playbackProgressTimerFire
d) | 183 , m_playbackProgressTimer(this, &HTMLMediaElement::playbackProgressTimerFire
d) |
184 , m_playedTimeRanges() | 184 , m_playedTimeRanges() |
| 185 , m_asyncEventQueue(GenericEventQueue::create(this)) |
185 , m_playbackRate(1.0f) | 186 , m_playbackRate(1.0f) |
186 , m_defaultPlaybackRate(1.0f) | 187 , m_defaultPlaybackRate(1.0f) |
187 , m_webkitPreservesPitch(true) | 188 , m_webkitPreservesPitch(true) |
188 , m_networkState(NETWORK_EMPTY) | 189 , m_networkState(NETWORK_EMPTY) |
189 , m_readyState(HAVE_NOTHING) | 190 , m_readyState(HAVE_NOTHING) |
190 , m_readyStateMaximum(HAVE_NOTHING) | 191 , m_readyStateMaximum(HAVE_NOTHING) |
191 , m_volume(1.0f) | 192 , m_volume(1.0f) |
192 , m_lastSeekTime(0) | 193 , m_lastSeekTime(0) |
193 , m_previousProgress(0) | 194 , m_previousProgress(0) |
194 , m_previousProgressTime(numeric_limits<double>::max()) | 195 , m_previousProgressTime(numeric_limits<double>::max()) |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
543 } | 544 } |
544 | 545 |
545 void HTMLMediaElement::scheduleEvent(const AtomicString& eventName) | 546 void HTMLMediaElement::scheduleEvent(const AtomicString& eventName) |
546 { | 547 { |
547 #if LOG_MEDIA_EVENTS | 548 #if LOG_MEDIA_EVENTS |
548 LOG(Media, "HTMLMediaElement::scheduleEvent - scheduling '%s'", eventName.st
ring().ascii().data()); | 549 LOG(Media, "HTMLMediaElement::scheduleEvent - scheduling '%s'", eventName.st
ring().ascii().data()); |
549 #endif | 550 #endif |
550 RefPtr<Event> event = Event::create(eventName, false, true); | 551 RefPtr<Event> event = Event::create(eventName, false, true); |
551 event->setTarget(this); | 552 event->setTarget(this); |
552 | 553 |
553 m_asyncEventQueue.enqueueEvent(event.release()); | 554 m_asyncEventQueue->enqueueEvent(event.release()); |
554 } | 555 } |
555 | 556 |
556 void HTMLMediaElement::loadTimerFired(Timer<HTMLMediaElement>*) | 557 void HTMLMediaElement::loadTimerFired(Timer<HTMLMediaElement>*) |
557 { | 558 { |
558 RefPtr<HTMLMediaElement> protect(this); // loadNextSourceChild may fire 'bef
oreload', which can make arbitrary DOM mutations. | 559 RefPtr<HTMLMediaElement> protect(this); // loadNextSourceChild may fire 'bef
oreload', which can make arbitrary DOM mutations. |
559 | 560 |
560 #if ENABLE(VIDEO_TRACK) | 561 #if ENABLE(VIDEO_TRACK) |
561 if (m_pendingLoadFlags & TextTrackResource) | 562 if (m_pendingLoadFlags & TextTrackResource) |
562 configureNewTextTracks(); | 563 configureNewTextTracks(); |
563 #endif | 564 #endif |
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1142 // Each event in eventTasks may be either an enterEvent or an exitEvent, | 1143 // Each event in eventTasks may be either an enterEvent or an exitEvent, |
1143 // depending on the time that is associated with the event. This | 1144 // depending on the time that is associated with the event. This |
1144 // correctly identifies the type of the event, since the startTime is | 1145 // correctly identifies the type of the event, since the startTime is |
1145 // always less than the endTime. | 1146 // always less than the endTime. |
1146 if (eventTasks[i].first == eventTasks[i].second->startTime()) | 1147 if (eventTasks[i].first == eventTasks[i].second->startTime()) |
1147 event = Event::create(eventNames().enterEvent, false, false); | 1148 event = Event::create(eventNames().enterEvent, false, false); |
1148 else | 1149 else |
1149 event = Event::create(eventNames().exitEvent, false, false); | 1150 event = Event::create(eventNames().exitEvent, false, false); |
1150 | 1151 |
1151 event->setTarget(eventTasks[i].second); | 1152 event->setTarget(eventTasks[i].second); |
1152 m_asyncEventQueue.enqueueEvent(event.release()); | 1153 m_asyncEventQueue->enqueueEvent(event.release()); |
1153 } | 1154 } |
1154 | 1155 |
1155 // 14 - Sort affected tracks in the same order as the text tracks appear in | 1156 // 14 - Sort affected tracks in the same order as the text tracks appear in |
1156 // the media element's list of text tracks, and remove duplicates. | 1157 // the media element's list of text tracks, and remove duplicates. |
1157 nonCopyingSort(affectedTracks.begin(), affectedTracks.end(), trackIndexCompa
re); | 1158 nonCopyingSort(affectedTracks.begin(), affectedTracks.end(), trackIndexCompa
re); |
1158 | 1159 |
1159 // 15 - For each text track in affected tracks, in the list order, queue a | 1160 // 15 - For each text track in affected tracks, in the list order, queue a |
1160 // task to fire a simple event named cuechange at the TextTrack object, and, | 1161 // task to fire a simple event named cuechange at the TextTrack object, and, |
1161 // if the text track has a corresponding track element, to then fire a | 1162 // if the text track has a corresponding track element, to then fire a |
1162 // simple event named cuechange at the track element as well. | 1163 // simple event named cuechange at the track element as well. |
1163 for (size_t i = 0; i < affectedTracks.size(); ++i) { | 1164 for (size_t i = 0; i < affectedTracks.size(); ++i) { |
1164 RefPtr<Event> event = Event::create(eventNames().cuechangeEvent, false,
false); | 1165 RefPtr<Event> event = Event::create(eventNames().cuechangeEvent, false,
false); |
1165 event->setTarget(affectedTracks[i]); | 1166 event->setTarget(affectedTracks[i]); |
1166 | 1167 |
1167 m_asyncEventQueue.enqueueEvent(event.release()); | 1168 m_asyncEventQueue->enqueueEvent(event.release()); |
1168 | 1169 |
1169 // Fire syncronous cue change event for track elements. | 1170 // Fire syncronous cue change event for track elements. |
1170 if (affectedTracks[i]->trackType() == TextTrack::TrackElement) | 1171 if (affectedTracks[i]->trackType() == TextTrack::TrackElement) |
1171 affectedTracks[i]->fireCueChangeEvent(); | 1172 affectedTracks[i]->fireCueChangeEvent(); |
1172 } | 1173 } |
1173 | 1174 |
1174 // 16 - Set the text track cue active flag of all the cues in the current | 1175 // 16 - Set the text track cue active flag of all the cues in the current |
1175 // cues, and unset the text track cue active flag of all the cues in the | 1176 // cues, and unset the text track cue active flag of all the cues in the |
1176 // other cues. | 1177 // other cues. |
1177 for (size_t i = 0; i < currentCuesSize; ++i) | 1178 for (size_t i = 0; i < currentCuesSize; ++i) |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1392 // 5 - Set the element's delaying-the-load-event flag to false. This stops d
elaying the load event. | 1393 // 5 - Set the element's delaying-the-load-event flag to false. This stops d
elaying the load event. |
1393 setShouldDelayLoadEvent(false); | 1394 setShouldDelayLoadEvent(false); |
1394 | 1395 |
1395 // 6 - Abort the overall resource selection algorithm. | 1396 // 6 - Abort the overall resource selection algorithm. |
1396 m_currentSourceNode = 0; | 1397 m_currentSourceNode = 0; |
1397 } | 1398 } |
1398 | 1399 |
1399 void HTMLMediaElement::cancelPendingEventsAndCallbacks() | 1400 void HTMLMediaElement::cancelPendingEventsAndCallbacks() |
1400 { | 1401 { |
1401 LOG(Media, "HTMLMediaElement::cancelPendingEventsAndCallbacks"); | 1402 LOG(Media, "HTMLMediaElement::cancelPendingEventsAndCallbacks"); |
1402 m_asyncEventQueue.cancelAllEvents(); | 1403 m_asyncEventQueue->cancelAllEvents(); |
1403 | 1404 |
1404 for (Node* node = firstChild(); node; node = node->nextSibling()) { | 1405 for (Node* node = firstChild(); node; node = node->nextSibling()) { |
1405 if (node->hasTagName(sourceTag)) | 1406 if (node->hasTagName(sourceTag)) |
1406 static_cast<HTMLSourceElement*>(node)->cancelPendingErrorEvent(); | 1407 static_cast<HTMLSourceElement*>(node)->cancelPendingErrorEvent(); |
1407 } | 1408 } |
1408 } | 1409 } |
1409 | 1410 |
1410 Document* HTMLMediaElement::mediaPlayerOwningDocument() | 1411 Document* HTMLMediaElement::mediaPlayerOwningDocument() |
1411 { | 1412 { |
1412 Document* d = document(); | 1413 Document* d = document(); |
(...skipping 2046 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3459 ExceptionCode ec; | 3460 ExceptionCode ec; |
3460 load(ec); | 3461 load(ec); |
3461 } | 3462 } |
3462 | 3463 |
3463 if (renderer()) | 3464 if (renderer()) |
3464 renderer()->updateFromElement(); | 3465 renderer()->updateFromElement(); |
3465 } | 3466 } |
3466 | 3467 |
3467 bool HTMLMediaElement::hasPendingActivity() const | 3468 bool HTMLMediaElement::hasPendingActivity() const |
3468 { | 3469 { |
3469 return m_asyncEventQueue.hasPendingEvents(); | 3470 return m_asyncEventQueue->hasPendingEvents(); |
3470 } | 3471 } |
3471 | 3472 |
3472 void HTMLMediaElement::mediaVolumeDidChange() | 3473 void HTMLMediaElement::mediaVolumeDidChange() |
3473 { | 3474 { |
3474 LOG(Media, "HTMLMediaElement::mediaVolumeDidChange"); | 3475 LOG(Media, "HTMLMediaElement::mediaVolumeDidChange"); |
3475 updateVolume(); | 3476 updateVolume(); |
3476 } | 3477 } |
3477 | 3478 |
3478 void HTMLMediaElement::defaultEventHandler(Event* event) | 3479 void HTMLMediaElement::defaultEventHandler(Event* event) |
3479 { | 3480 { |
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4096 | 4097 |
4097 } | 4098 } |
4098 | 4099 |
4099 void HTMLMediaElement::removeBehaviorsRestrictionsAfterFirstUserGesture() | 4100 void HTMLMediaElement::removeBehaviorsRestrictionsAfterFirstUserGesture() |
4100 { | 4101 { |
4101 m_restrictions = NoRestrictions; | 4102 m_restrictions = NoRestrictions; |
4102 } | 4103 } |
4103 | 4104 |
4104 } | 4105 } |
4105 #endif | 4106 #endif |
OLD | NEW |