| OLD | NEW |
| 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 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 { | 478 { |
| 479 ASSERT(element); | 479 ASSERT(element); |
| 480 ASSERT(m_mediaElements.contains(element)); | 480 ASSERT(m_mediaElements.contains(element)); |
| 481 | 481 |
| 482 // When the user agent is to bring a media element up to speed with its new
media controller, | 482 // When the user agent is to bring a media element up to speed with its new
media controller, |
| 483 // it must seek that media element to the MediaController's media controller
position relative | 483 // it must seek that media element to the MediaController's media controller
position relative |
| 484 // to the media element's timeline. | 484 // to the media element's timeline. |
| 485 element->seek(currentTime(), IGNORE_EXCEPTION); | 485 element->seek(currentTime(), IGNORE_EXCEPTION); |
| 486 } | 486 } |
| 487 | 487 |
| 488 bool MediaController::isRestrained() const |
| 489 { |
| 490 ASSERT(!m_mediaElements.isEmpty()); |
| 491 |
| 492 // A MediaController is a restrained media controller if the MediaController
is a playing media |
| 493 // controller, |
| 494 if (m_paused) |
| 495 return false; |
| 496 |
| 497 bool anyAutoplayingAndPaused = false; |
| 498 bool allPaused = true; |
| 499 for (size_t index = 0; index < m_mediaElements.size(); ++index) { |
| 500 HTMLMediaElement* element = m_mediaElements[index]; |
| 501 |
| 502 // and none of its slaved media elements are blocked media elements, |
| 503 if (element->isBlocked()) |
| 504 return false; |
| 505 |
| 506 if (element->isAutoplaying() && element->paused()) |
| 507 anyAutoplayingAndPaused = true; |
| 508 |
| 509 if (!element->paused()) |
| 510 allPaused = false; |
| 511 } |
| 512 |
| 513 // but either at least one of its slaved media elements whose autoplaying fl
ag is true still has |
| 514 // its paused attribute set to true, or, all of its slaved media elements ha
ve their paused |
| 515 // attribute set to true. |
| 516 return anyAutoplayingAndPaused || allPaused; |
| 517 } |
| 518 |
| 488 bool MediaController::isBlocked() const | 519 bool MediaController::isBlocked() const |
| 489 { | 520 { |
| 521 ASSERT(!m_mediaElements.isEmpty()); |
| 522 |
| 490 // A MediaController is a blocked media controller if the MediaController is
a paused media | 523 // A MediaController is a blocked media controller if the MediaController is
a paused media |
| 491 // controller, | 524 // controller, |
| 492 if (m_paused) | 525 if (m_paused) |
| 493 return true; | 526 return true; |
| 494 | 527 |
| 495 if (m_mediaElements.isEmpty()) | |
| 496 return false; | |
| 497 | |
| 498 bool allPaused = true; | 528 bool allPaused = true; |
| 499 for (size_t index = 0; index < m_mediaElements.size(); ++index) { | 529 for (size_t index = 0; index < m_mediaElements.size(); ++index) { |
| 500 HTMLMediaElement* element = m_mediaElements[index]; | 530 HTMLMediaElement* element = m_mediaElements[index]; |
| 501 // or if any of its slaved media elements are blocked media elements, | 531 |
| 532 // or if any of its slaved media elements are blocked media elements, |
| 502 if (element->isBlocked()) | 533 if (element->isBlocked()) |
| 503 return true; | 534 return true; |
| 504 | 535 |
| 505 // or if any of its slaved media elements whose autoplaying flag is true
still have their | 536 // or if any of its slaved media elements whose autoplaying flag is true
still have their |
| 506 // paused attribute set to true, | 537 // paused attribute set to true, |
| 507 if (element->isAutoplaying() && element->paused()) | 538 if (element->isAutoplaying() && element->paused()) |
| 508 return true; | 539 return true; |
| 509 | 540 |
| 510 if (!element->paused()) | 541 if (!element->paused()) |
| 511 allPaused = false; | 542 allPaused = false; |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 619 { | 650 { |
| 620 double now = WTF::currentTime(); | 651 double now = WTF::currentTime(); |
| 621 double timedelta = now - m_previousTimeupdateTime; | 652 double timedelta = now - m_previousTimeupdateTime; |
| 622 | 653 |
| 623 if (timedelta < maxTimeupdateEventFrequency) | 654 if (timedelta < maxTimeupdateEventFrequency) |
| 624 return; | 655 return; |
| 625 | 656 |
| 626 scheduleEvent(EventTypeNames::timeupdate); | 657 scheduleEvent(EventTypeNames::timeupdate); |
| 627 m_previousTimeupdateTime = now; | 658 m_previousTimeupdateTime = now; |
| 628 } | 659 } |
| OLD | NEW |