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

Side by Side Diff: Source/core/html/MediaController.cpp

Issue 314113008: Oilpan: have MediaController weakly refer to its media elements. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add FIXME (crbug.com/383072) Created 6 years, 6 months 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
« no previous file with comments | « Source/core/html/MediaController.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2011 Apple Inc. All rights reserved.
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 20 matching lines...) Expand all
31 #include "bindings/v8/ExceptionStatePlaceholder.h" 31 #include "bindings/v8/ExceptionStatePlaceholder.h"
32 #include "core/dom/ExceptionCode.h" 32 #include "core/dom/ExceptionCode.h"
33 #include "core/events/GenericEventQueue.h" 33 #include "core/events/GenericEventQueue.h"
34 #include "core/html/HTMLMediaElement.h" 34 #include "core/html/HTMLMediaElement.h"
35 #include "core/html/TimeRanges.h" 35 #include "core/html/TimeRanges.h"
36 #include "platform/Clock.h" 36 #include "platform/Clock.h"
37 #include "wtf/CurrentTime.h" 37 #include "wtf/CurrentTime.h"
38 #include "wtf/StdLibExtras.h" 38 #include "wtf/StdLibExtras.h"
39 #include "wtf/text/AtomicString.h" 39 #include "wtf/text/AtomicString.h"
40 40
41 using namespace WebCore;
42 using namespace std; 41 using namespace std;
43 42
43 namespace WebCore {
44
44 PassRefPtrWillBeRawPtr<MediaController> MediaController::create(ExecutionContext * context) 45 PassRefPtrWillBeRawPtr<MediaController> MediaController::create(ExecutionContext * context)
45 { 46 {
46 return adoptRefWillBeRefCountedGarbageCollected(new MediaController(context) ); 47 return adoptRefWillBeRefCountedGarbageCollected(new MediaController(context) );
47 } 48 }
48 49
49 MediaController::MediaController(ExecutionContext* context) 50 MediaController::MediaController(ExecutionContext* context)
50 : m_paused(false) 51 : m_paused(false)
51 , m_defaultPlaybackRate(1) 52 , m_defaultPlaybackRate(1)
52 , m_volume(1) 53 , m_volume(1)
53 , m_position(MediaPlayer::invalidTime()) 54 , m_position(MediaPlayer::invalidTime())
(...skipping 12 matching lines...) Expand all
66 67
67 MediaController::~MediaController() 68 MediaController::~MediaController()
68 { 69 {
69 } 70 }
70 71
71 void MediaController::addMediaElement(HTMLMediaElement* element) 72 void MediaController::addMediaElement(HTMLMediaElement* element)
72 { 73 {
73 ASSERT(element); 74 ASSERT(element);
74 ASSERT(!m_mediaElements.contains(element)); 75 ASSERT(!m_mediaElements.contains(element));
75 76
76 m_mediaElements.append(element); 77 m_mediaElements.add(element);
77 bringElementUpToSpeed(element); 78 bringElementUpToSpeed(element);
78 } 79 }
79 80
80 void MediaController::removeMediaElement(HTMLMediaElement* element) 81 void MediaController::removeMediaElement(HTMLMediaElement* element)
81 { 82 {
82 ASSERT(element); 83 ASSERT(element);
83 ASSERT(m_mediaElements.contains(element)); 84 ASSERT(m_mediaElements.contains(element));
84 m_mediaElements.remove(m_mediaElements.find(element)); 85 m_mediaElements.remove(m_mediaElements.find(element));
85 } 86 }
86 87
87 PassRefPtr<TimeRanges> MediaController::buffered() const 88 PassRefPtr<TimeRanges> MediaController::buffered() const
88 { 89 {
89 if (m_mediaElements.isEmpty()) 90 if (m_mediaElements.isEmpty())
90 return TimeRanges::create(); 91 return TimeRanges::create();
91 92
92 // The buffered attribute must return a new static normalized TimeRanges obj ect that represents 93 // The buffered attribute must return a new static normalized TimeRanges obj ect that represents
93 // the intersection of the ranges of the media resources of the slaved media elements that the 94 // the intersection of the ranges of the media resources of the slaved media elements that the
94 // user agent has buffered, at the time the attribute is evaluated. 95 // user agent has buffered, at the time the attribute is evaluated.
95 RefPtr<TimeRanges> bufferedRanges = m_mediaElements.first()->buffered(); 96 MediaElementSequence::const_iterator it = m_mediaElements.begin();
96 for (size_t index = 1; index < m_mediaElements.size(); ++index) 97 RefPtr<TimeRanges> bufferedRanges = (*it)->buffered();
97 bufferedRanges->intersectWith(m_mediaElements[index]->buffered().get()); 98 for (++it; it != m_mediaElements.end(); ++it)
99 bufferedRanges->intersectWith((*it)->buffered().get());
98 return bufferedRanges; 100 return bufferedRanges;
99 } 101 }
100 102
101 PassRefPtr<TimeRanges> MediaController::seekable() const 103 PassRefPtr<TimeRanges> MediaController::seekable() const
102 { 104 {
103 if (m_mediaElements.isEmpty()) 105 if (m_mediaElements.isEmpty())
104 return TimeRanges::create(); 106 return TimeRanges::create();
105 107
106 // The seekable attribute must return a new static normalized TimeRanges obj ect that represents 108 // The seekable attribute must return a new static normalized TimeRanges obj ect that represents
107 // the intersection of the ranges of the media resources of the slaved media elements that the 109 // the intersection of the ranges of the media resources of the slaved media elements that the
108 // user agent is able to seek to, at the time the attribute is evaluated. 110 // user agent is able to seek to, at the time the attribute is evaluated.
109 RefPtr<TimeRanges> seekableRanges = m_mediaElements.first()->seekable(); 111 MediaElementSequence::const_iterator it = m_mediaElements.begin();
110 for (size_t index = 1; index < m_mediaElements.size(); ++index) 112 RefPtr<TimeRanges> seekableRanges = (*it)->seekable();
111 seekableRanges->intersectWith(m_mediaElements[index]->seekable().get()); 113 for (++it; it != m_mediaElements.end(); ++it)
114 seekableRanges->intersectWith((*it)->seekable().get());
112 return seekableRanges; 115 return seekableRanges;
113 } 116 }
114 117
115 PassRefPtr<TimeRanges> MediaController::played() 118 PassRefPtr<TimeRanges> MediaController::played()
116 { 119 {
117 if (m_mediaElements.isEmpty()) 120 if (m_mediaElements.isEmpty())
118 return TimeRanges::create(); 121 return TimeRanges::create();
119 122
120 // The played attribute must return a new static normalized TimeRanges objec t that represents 123 // The played attribute must return a new static normalized TimeRanges objec t that represents
121 // the union of the ranges of the media resources of the slaved media elemen ts that the 124 // the union of the ranges of the media resources of the slaved media elemen ts that the
122 // user agent has so far rendered, at the time the attribute is evaluated. 125 // user agent has so far rendered, at the time the attribute is evaluated.
123 RefPtr<TimeRanges> playedRanges = m_mediaElements.first()->played(); 126 MediaElementSequence::const_iterator it = m_mediaElements.begin();
124 for (size_t index = 1; index < m_mediaElements.size(); ++index) 127 RefPtr<TimeRanges> playedRanges = (*it)->played();
125 playedRanges->unionWith(m_mediaElements[index]->played().get()); 128 for (++it; it != m_mediaElements.end(); ++it)
129 playedRanges->unionWith((*it)->played().get());
126 return playedRanges; 130 return playedRanges;
127 } 131 }
128 132
129 double MediaController::duration() const 133 double MediaController::duration() const
130 { 134 {
131 // FIXME: Investigate caching the maximum duration and only updating the cac hed value 135 // FIXME: Investigate caching the maximum duration and only updating the cac hed value
132 // when the slaved media elements' durations change. 136 // when the slaved media elements' durations change.
133 double maxDuration = 0; 137 double maxDuration = 0;
134 for (size_t index = 0; index < m_mediaElements.size(); ++index) { 138 for (MediaElementSequence::const_iterator it = m_mediaElements.begin(); it ! = m_mediaElements.end(); ++it) {
135 double duration = m_mediaElements[index]->duration(); 139 double duration = (*it)->duration();
136 if (std::isnan(duration)) 140 if (std::isnan(duration))
137 continue; 141 continue;
138 maxDuration = max(maxDuration, duration); 142 maxDuration = max(maxDuration, duration);
139 } 143 }
140 return maxDuration; 144 return maxDuration;
141 } 145 }
142 146
143 double MediaController::currentTime() const 147 double MediaController::currentTime() const
144 { 148 {
145 if (m_mediaElements.isEmpty()) 149 if (m_mediaElements.isEmpty())
(...skipping 17 matching lines...) Expand all
163 167
164 // If the new playback position is greater than the media controller duratio n, then set it 168 // If the new playback position is greater than the media controller duratio n, then set it
165 // to the media controller duration. 169 // to the media controller duration.
166 time = min(time, duration()); 170 time = min(time, duration());
167 171
168 // Set the media controller position to the new playback position. 172 // Set the media controller position to the new playback position.
169 m_position = time; 173 m_position = time;
170 m_clock->setCurrentTime(time); 174 m_clock->setCurrentTime(time);
171 175
172 // Seek each slaved media element to the new playback position relative to t he media element timeline. 176 // Seek each slaved media element to the new playback position relative to t he media element timeline.
173 for (size_t index = 0; index < m_mediaElements.size(); ++index) 177 for (MediaElementSequence::const_iterator it = m_mediaElements.begin(); it ! = m_mediaElements.end(); ++it)
174 m_mediaElements[index]->seek(time, exceptionState); 178 (*it)->seek(time, exceptionState);
175 179
176 scheduleTimeupdateEvent(); 180 scheduleTimeupdateEvent();
177 } 181 }
178 182
179 void MediaController::unpause() 183 void MediaController::unpause()
180 { 184 {
181 // When the unpause() method is invoked, if the MediaController is a paused media controller, 185 // When the unpause() method is invoked, if the MediaController is a paused media controller,
182 if (!m_paused) 186 if (!m_paused)
183 return; 187 return;
184 188
185 // the user agent must change the MediaController into a playing media contr oller, 189 // the user agent must change the MediaController into a playing media contr oller,
186 m_paused = false; 190 m_paused = false;
187 // queue a task to fire a simple event named play at the MediaController, 191 // queue a task to fire a simple event named play at the MediaController,
188 scheduleEvent(EventTypeNames::play); 192 scheduleEvent(EventTypeNames::play);
189 // and then report the controller state of the MediaController. 193 // and then report the controller state of the MediaController.
190 reportControllerState(); 194 reportControllerState();
191 } 195 }
192 196
193 void MediaController::play() 197 void MediaController::play()
194 { 198 {
195 // When the play() method is invoked, the user agent must invoke the play me thod of each 199 // When the play() method is invoked, the user agent must invoke the play me thod of each
196 // slaved media element in turn, 200 // slaved media element in turn,
197 for (size_t index = 0; index < m_mediaElements.size(); ++index) 201 for (MediaElementSequence::const_iterator it = m_mediaElements.begin(); it ! = m_mediaElements.end(); ++it)
198 m_mediaElements[index]->play(); 202 (*it)->play();
199 203
200 // and then invoke the unpause method of the MediaController. 204 // and then invoke the unpause method of the MediaController.
201 unpause(); 205 unpause();
202 } 206 }
203 207
204 void MediaController::pause() 208 void MediaController::pause()
205 { 209 {
206 // When the pause() method is invoked, if the MediaController is a playing m edia controller, 210 // When the pause() method is invoked, if the MediaController is a playing m edia controller,
207 if (m_paused) 211 if (m_paused)
208 return; 212 return;
(...skipping 26 matching lines...) Expand all
235 239
236 void MediaController::setPlaybackRate(double rate) 240 void MediaController::setPlaybackRate(double rate)
237 { 241 {
238 if (m_clock->playRate() == rate) 242 if (m_clock->playRate() == rate)
239 return; 243 return;
240 244
241 // The playbackRate attribute, on setting, must set the MediaController's me dia controller 245 // The playbackRate attribute, on setting, must set the MediaController's me dia controller
242 // playback rate to the new value, 246 // playback rate to the new value,
243 m_clock->setPlayRate(rate); 247 m_clock->setPlayRate(rate);
244 248
245 for (size_t index = 0; index < m_mediaElements.size(); ++index) 249 for (MediaElementSequence::const_iterator it = m_mediaElements.begin(); it ! = m_mediaElements.end(); ++it)
246 m_mediaElements[index]->updatePlaybackRate(); 250 (*it)->updatePlaybackRate();
247 251
248 // then queue a task to fire a simple event named ratechange at the MediaCon troller. 252 // then queue a task to fire a simple event named ratechange at the MediaCon troller.
249 scheduleEvent(EventTypeNames::ratechange); 253 scheduleEvent(EventTypeNames::ratechange);
250 } 254 }
251 255
252 void MediaController::setVolume(double level, ExceptionState& exceptionState) 256 void MediaController::setVolume(double level, ExceptionState& exceptionState)
253 { 257 {
254 if (m_volume == level) 258 if (m_volume == level)
255 return; 259 return;
256 260
257 // If the new value is outside the range 0.0 to 1.0 inclusive, then, on sett ing, an 261 // If the new value is outside the range 0.0 to 1.0 inclusive, then, on sett ing, an
258 // IndexSizeError exception must be raised instead. 262 // IndexSizeError exception must be raised instead.
259 if (level < 0 || level > 1) { 263 if (level < 0 || level > 1) {
260 exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::inde xOutsideRange("volume", level, 0.0, ExceptionMessages::InclusiveBound, 1.0, Exce ptionMessages::InclusiveBound)); 264 exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::inde xOutsideRange("volume", level, 0.0, ExceptionMessages::InclusiveBound, 1.0, Exce ptionMessages::InclusiveBound));
261 return; 265 return;
262 } 266 }
263 267
264 // The volume attribute, on setting, if the new value is in the range 0.0 to 1.0 inclusive, 268 // The volume attribute, on setting, if the new value is in the range 0.0 to 1.0 inclusive,
265 // must set the MediaController's media controller volume multiplier to the new value 269 // must set the MediaController's media controller volume multiplier to the new value
266 m_volume = level; 270 m_volume = level;
267 271
268 // and queue a task to fire a simple event named volumechange at the MediaCo ntroller. 272 // and queue a task to fire a simple event named volumechange at the MediaCo ntroller.
269 scheduleEvent(EventTypeNames::volumechange); 273 scheduleEvent(EventTypeNames::volumechange);
270 274
271 for (size_t index = 0; index < m_mediaElements.size(); ++index) 275 for (MediaElementSequence::const_iterator it = m_mediaElements.begin(); it ! = m_mediaElements.end(); ++it)
272 m_mediaElements[index]->updateVolume(); 276 (*it)->updateVolume();
273 } 277 }
274 278
275 void MediaController::setMuted(bool flag) 279 void MediaController::setMuted(bool flag)
276 { 280 {
277 if (m_muted == flag) 281 if (m_muted == flag)
278 return; 282 return;
279 283
280 // The muted attribute, on setting, must set the MediaController's media con troller mute override 284 // The muted attribute, on setting, must set the MediaController's media con troller mute override
281 // to the new value 285 // to the new value
282 m_muted = flag; 286 m_muted = flag;
283 287
284 // and queue a task to fire a simple event named volumechange at the MediaCo ntroller. 288 // and queue a task to fire a simple event named volumechange at the MediaCo ntroller.
285 scheduleEvent(EventTypeNames::volumechange); 289 scheduleEvent(EventTypeNames::volumechange);
286 290
287 for (size_t index = 0; index < m_mediaElements.size(); ++index) 291 for (MediaElementSequence::const_iterator it = m_mediaElements.begin(); it ! = m_mediaElements.end(); ++it)
288 m_mediaElements[index]->updateVolume(); 292 (*it)->updateVolume();
289 } 293 }
290 294
291 static const AtomicString& playbackStateWaiting() 295 static const AtomicString& playbackStateWaiting()
292 { 296 {
293 DEFINE_STATIC_LOCAL(AtomicString, waiting, ("waiting", AtomicString::Constru ctFromLiteral)); 297 DEFINE_STATIC_LOCAL(AtomicString, waiting, ("waiting", AtomicString::Constru ctFromLiteral));
294 return waiting; 298 return waiting;
295 } 299 }
296 300
297 static const AtomicString& playbackStatePlaying() 301 static const AtomicString& playbackStatePlaying()
298 { 302 {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 { 354 {
351 ReadyState oldReadyState = m_readyState; 355 ReadyState oldReadyState = m_readyState;
352 ReadyState newReadyState; 356 ReadyState newReadyState;
353 357
354 if (m_mediaElements.isEmpty()) { 358 if (m_mediaElements.isEmpty()) {
355 // If the MediaController has no slaved media elements, let new readines s state be 0. 359 // If the MediaController has no slaved media elements, let new readines s state be 0.
356 newReadyState = HTMLMediaElement::HAVE_NOTHING; 360 newReadyState = HTMLMediaElement::HAVE_NOTHING;
357 } else { 361 } else {
358 // Otherwise, let it have the lowest value of the readyState IDL attribu tes of all of its 362 // Otherwise, let it have the lowest value of the readyState IDL attribu tes of all of its
359 // slaved media elements. 363 // slaved media elements.
360 newReadyState = m_mediaElements.first()->readyState(); 364 MediaElementSequence::const_iterator it = m_mediaElements.begin();
361 for (size_t index = 1; index < m_mediaElements.size(); ++index) 365 newReadyState = (*it)->readyState();
362 newReadyState = min(newReadyState, m_mediaElements[index]->readyStat e()); 366 for (++it; it != m_mediaElements.end(); ++it)
367 newReadyState = min(newReadyState, (*it)->readyState());
363 } 368 }
364 369
365 if (newReadyState == oldReadyState) 370 if (newReadyState == oldReadyState)
366 return; 371 return;
367 372
368 // If the MediaController's most recently reported readiness state is greate r than new readiness 373 // If the MediaController's most recently reported readiness state is greate r than new readiness
369 // state then queue a task to fire a simple event at the MediaController obj ect, whose name is the 374 // state then queue a task to fire a simple event at the MediaController obj ect, whose name is the
370 // event name corresponding to the value of new readiness state given in the table below. [omitted] 375 // event name corresponding to the value of new readiness state given in the table below. [omitted]
371 if (oldReadyState > newReadyState) { 376 if (oldReadyState > newReadyState) {
372 scheduleEvent(eventNameForReadyState(newReadyState)); 377 scheduleEvent(eventNameForReadyState(newReadyState));
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 scheduleEvent(eventName); 465 scheduleEvent(eventName);
461 466
462 // Let the MediaController's most recently reported playback state be new pl ayback state. 467 // Let the MediaController's most recently reported playback state be new pl ayback state.
463 m_playbackState = newPlaybackState; 468 m_playbackState = newPlaybackState;
464 469
465 updateMediaElements(); 470 updateMediaElements();
466 } 471 }
467 472
468 void MediaController::updateMediaElements() 473 void MediaController::updateMediaElements()
469 { 474 {
470 for (size_t index = 0; index < m_mediaElements.size(); ++index) 475 for (MediaElementSequence::const_iterator it = m_mediaElements.begin(); it ! = m_mediaElements.end(); ++it)
471 m_mediaElements[index]->updatePlayState(); 476 (*it)->updatePlayState();
472 } 477 }
473 478
474 void MediaController::bringElementUpToSpeed(HTMLMediaElement* element) 479 void MediaController::bringElementUpToSpeed(HTMLMediaElement* element)
475 { 480 {
476 ASSERT(element); 481 ASSERT(element);
477 ASSERT(m_mediaElements.contains(element)); 482 ASSERT(m_mediaElements.contains(element));
478 483
479 // When the user agent is to bring a media element up to speed with its new media controller, 484 // When the user agent is to bring a media element up to speed with its new media controller,
480 // it must seek that media element to the MediaController's media controller position relative 485 // it must seek that media element to the MediaController's media controller position relative
481 // to the media element's timeline. 486 // to the media element's timeline.
482 element->seek(currentTime(), IGNORE_EXCEPTION); 487 element->seek(currentTime(), IGNORE_EXCEPTION);
483 } 488 }
484 489
485 bool MediaController::isRestrained() const 490 bool MediaController::isRestrained() const
486 { 491 {
487 ASSERT(!m_mediaElements.isEmpty()); 492 ASSERT(!m_mediaElements.isEmpty());
488 493
489 // A MediaController is a restrained media controller if the MediaController is a playing media 494 // A MediaController is a restrained media controller if the MediaController is a playing media
490 // controller, 495 // controller,
491 if (m_paused) 496 if (m_paused)
492 return false; 497 return false;
493 498
494 bool anyAutoplayingAndPaused = false; 499 bool anyAutoplayingAndPaused = false;
495 bool allPaused = true; 500 bool allPaused = true;
496 for (size_t index = 0; index < m_mediaElements.size(); ++index) { 501 for (MediaElementSequence::const_iterator it = m_mediaElements.begin(); it ! = m_mediaElements.end(); ++it) {
497 HTMLMediaElement* element = m_mediaElements[index]; 502 HTMLMediaElement* element = *it;
498 503
499 // and none of its slaved media elements are blocked media elements, 504 // and none of its slaved media elements are blocked media elements,
500 if (element->isBlocked()) 505 if (element->isBlocked())
501 return false; 506 return false;
502 507
503 if (element->isAutoplaying() && element->paused()) 508 if (element->isAutoplaying() && element->paused())
504 anyAutoplayingAndPaused = true; 509 anyAutoplayingAndPaused = true;
505 510
506 if (!element->paused()) 511 if (!element->paused())
507 allPaused = false; 512 allPaused = false;
508 } 513 }
509 514
510 // but either at least one of its slaved media elements whose autoplaying fl ag is true still has 515 // but either at least one of its slaved media elements whose autoplaying fl ag is true still has
511 // its paused attribute set to true, or, all of its slaved media elements ha ve their paused 516 // its paused attribute set to true, or, all of its slaved media elements ha ve their paused
512 // attribute set to true. 517 // attribute set to true.
513 return anyAutoplayingAndPaused || allPaused; 518 return anyAutoplayingAndPaused || allPaused;
514 } 519 }
515 520
516 bool MediaController::isBlocked() const 521 bool MediaController::isBlocked() const
517 { 522 {
518 ASSERT(!m_mediaElements.isEmpty()); 523 ASSERT(!m_mediaElements.isEmpty());
519 524
520 // A MediaController is a blocked media controller if the MediaController is a paused media 525 // A MediaController is a blocked media controller if the MediaController is a paused media
521 // controller, 526 // controller,
522 if (m_paused) 527 if (m_paused)
523 return true; 528 return true;
524 529
525 bool allPaused = true; 530 bool allPaused = true;
526 for (size_t index = 0; index < m_mediaElements.size(); ++index) { 531 for (MediaElementSequence::const_iterator it = m_mediaElements.begin(); it ! = m_mediaElements.end(); ++it) {
527 HTMLMediaElement* element = m_mediaElements[index]; 532 HTMLMediaElement* element = *it;
528 533
529 // or if any of its slaved media elements are blocked media elements, 534 // or if any of its slaved media elements are blocked media elements,
530 if (element->isBlocked()) 535 if (element->isBlocked())
531 return true; 536 return true;
532 537
533 // or if any of its slaved media elements whose autoplaying flag is true still have their 538 // or if any of its slaved media elements whose autoplaying flag is true still have their
534 // paused attribute set to true, 539 // paused attribute set to true,
535 if (element->isAutoplaying() && element->paused()) 540 if (element->isAutoplaying() && element->paused())
536 return true; 541 return true;
537 542
(...skipping 10 matching lines...) Expand all
548 // If the ... media controller playback rate is positive or zero 553 // If the ... media controller playback rate is positive or zero
549 if (m_clock->playRate() < 0) 554 if (m_clock->playRate() < 0)
550 return false; 555 return false;
551 556
552 // [and] all of the MediaController's slaved media elements have ended playb ack ... let new 557 // [and] all of the MediaController's slaved media elements have ended playb ack ... let new
553 // playback state be ended. 558 // playback state be ended.
554 if (m_mediaElements.isEmpty()) 559 if (m_mediaElements.isEmpty())
555 return false; 560 return false;
556 561
557 bool allHaveEnded = true; 562 bool allHaveEnded = true;
558 for (size_t index = 0; index < m_mediaElements.size(); ++index) { 563 for (MediaElementSequence::const_iterator it = m_mediaElements.begin(); it ! = m_mediaElements.end(); ++it) {
559 if (!m_mediaElements[index]->ended()) 564 if (!(*it)->ended())
560 allHaveEnded = false; 565 allHaveEnded = false;
561 } 566 }
562 return allHaveEnded; 567 return allHaveEnded;
563 } 568 }
564 569
565 void MediaController::scheduleEvent(const AtomicString& eventName) 570 void MediaController::scheduleEvent(const AtomicString& eventName)
566 { 571 {
567 m_pendingEventsQueue->enqueueEvent(Event::createCancelable(eventName)); 572 m_pendingEventsQueue->enqueueEvent(Event::createCancelable(eventName));
568 } 573 }
569 574
(...skipping 28 matching lines...) Expand all
598 { 603 {
599 double now = WTF::currentTime(); 604 double now = WTF::currentTime();
600 double timedelta = now - m_previousTimeupdateTime; 605 double timedelta = now - m_previousTimeupdateTime;
601 606
602 if (timedelta < maxTimeupdateEventFrequency) 607 if (timedelta < maxTimeupdateEventFrequency)
603 return; 608 return;
604 609
605 scheduleEvent(EventTypeNames::timeupdate); 610 scheduleEvent(EventTypeNames::timeupdate);
606 m_previousTimeupdateTime = now; 611 m_previousTimeupdateTime = now;
607 } 612 }
613
614 void MediaController::trace(Visitor* visitor)
615 {
616 visitor->trace(m_mediaElements);
617 EventTargetWithInlineData::trace(visitor);
618 }
619
620 }
OLDNEW
« no previous file with comments | « Source/core/html/MediaController.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698