| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011, 2012 Apple Inc. All rights reserved. | 2 * Copyright (C) 2011, 2012 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. | 3 * Copyright (C) 2011, 2012 Google 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 | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 *this, MediaControlDownloadButtonElement::create(*this))); | 331 *this, MediaControlDownloadButtonElement::create(*this))); |
| 332 m_overflowList->appendChild(m_muteButton->createOverflowElement( | 332 m_overflowList->appendChild(m_muteButton->createOverflowElement( |
| 333 *this, MediaControlMuteButtonElement::create(*this))); | 333 *this, MediaControlMuteButtonElement::create(*this))); |
| 334 m_overflowList->appendChild(m_castButton->createOverflowElement( | 334 m_overflowList->appendChild(m_castButton->createOverflowElement( |
| 335 *this, MediaControlCastButtonElement::create(*this, false))); | 335 *this, MediaControlCastButtonElement::create(*this, false))); |
| 336 m_overflowList->appendChild( | 336 m_overflowList->appendChild( |
| 337 m_toggleClosedCaptionsButton->createOverflowElement( | 337 m_toggleClosedCaptionsButton->createOverflowElement( |
| 338 *this, MediaControlToggleClosedCaptionsButtonElement::create(*this))); | 338 *this, MediaControlToggleClosedCaptionsButtonElement::create(*this))); |
| 339 } | 339 } |
| 340 | 340 |
| 341 Node::InsertionNotificationRequest MediaControls::insertedInto( |
| 342 ContainerNode* root) { |
| 343 if (!mediaElement().isConnected()) |
| 344 return HTMLDivElement::insertedInto(root); |
| 345 |
| 346 // TODO(mlamouri): we should show the controls instead of having |
| 347 // HTMLMediaElement do it. |
| 348 |
| 349 // m_windowEventListener doesn't need to be re-attached as it's only needed |
| 350 // when a menu is visible. |
| 351 m_mediaEventListener->attach(); |
| 352 if (m_orientationLockDelegate) |
| 353 m_orientationLockDelegate->attach(); |
| 354 |
| 355 return HTMLDivElement::insertedInto(root); |
| 356 } |
| 357 |
| 358 void MediaControls::removedFrom(ContainerNode*) { |
| 359 DCHECK(!mediaElement().isConnected()); |
| 360 |
| 361 // TODO(mlamouri): we hide show the controls instead of having |
| 362 // HTMLMediaElement do it. |
| 363 |
| 364 m_windowEventListener->stop(); |
| 365 m_mediaEventListener->detach(); |
| 366 if (m_orientationLockDelegate) |
| 367 m_orientationLockDelegate->detach(); |
| 368 } |
| 369 |
| 341 void MediaControls::reset() { | 370 void MediaControls::reset() { |
| 342 EventDispatchForbiddenScope::AllowUserAgentEvents allowEventsInShadow; | 371 EventDispatchForbiddenScope::AllowUserAgentEvents allowEventsInShadow; |
| 343 BatchedControlUpdate batch(this); | 372 BatchedControlUpdate batch(this); |
| 344 | 373 |
| 345 const double duration = mediaElement().duration(); | 374 const double duration = mediaElement().duration(); |
| 346 m_durationDisplay->setTextContent( | 375 m_durationDisplay->setTextContent( |
| 347 LayoutTheme::theme().formatMediaControlsTime(duration)); | 376 LayoutTheme::theme().formatMediaControlsTime(duration)); |
| 348 m_durationDisplay->setCurrentValue(duration); | 377 m_durationDisplay->setCurrentValue(duration); |
| 349 | 378 |
| 350 // Show everything that we might hide. | 379 // Show everything that we might hide. |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 681 | 710 |
| 682 bool MediaControls::containsRelatedTarget(Event* event) { | 711 bool MediaControls::containsRelatedTarget(Event* event) { |
| 683 if (!event->isMouseEvent()) | 712 if (!event->isMouseEvent()) |
| 684 return false; | 713 return false; |
| 685 EventTarget* relatedTarget = toMouseEvent(event)->relatedTarget(); | 714 EventTarget* relatedTarget = toMouseEvent(event)->relatedTarget(); |
| 686 if (!relatedTarget) | 715 if (!relatedTarget) |
| 687 return false; | 716 return false; |
| 688 return contains(relatedTarget->toNode()); | 717 return contains(relatedTarget->toNode()); |
| 689 } | 718 } |
| 690 | 719 |
| 691 void MediaControls::onInsertedIntoDocument() { | |
| 692 // TODO(mlamouri): we should show the controls instead of having | |
| 693 // HTMLMediaElement do it. | |
| 694 | |
| 695 // m_windowEventListener doesn't need to be re-attached as it's only needed | |
| 696 // when a menu is visible. | |
| 697 m_mediaEventListener->attach(); | |
| 698 if (m_orientationLockDelegate) | |
| 699 m_orientationLockDelegate->attach(); | |
| 700 } | |
| 701 | |
| 702 void MediaControls::onRemovedFromDocument() { | |
| 703 // TODO(mlamouri): we hide show the controls instead of having | |
| 704 // HTMLMediaElement do it. | |
| 705 | |
| 706 m_windowEventListener->stop(); | |
| 707 m_mediaEventListener->detach(); | |
| 708 if (m_orientationLockDelegate) | |
| 709 m_orientationLockDelegate->detach(); | |
| 710 } | |
| 711 | |
| 712 void MediaControls::onVolumeChange() { | 720 void MediaControls::onVolumeChange() { |
| 713 m_muteButton->updateDisplayType(); | 721 m_muteButton->updateDisplayType(); |
| 714 m_volumeSlider->setVolume(mediaElement().muted() ? 0 | 722 m_volumeSlider->setVolume(mediaElement().muted() ? 0 |
| 715 : mediaElement().volume()); | 723 : mediaElement().volume()); |
| 716 | 724 |
| 717 // Update visibility of volume controls. | 725 // Update visibility of volume controls. |
| 718 // TODO(mlamouri): it should not be part of the volumechange handling because | 726 // TODO(mlamouri): it should not be part of the volumechange handling because |
| 719 // it is using audio availability as input. | 727 // it is using audio availability as input. |
| 720 BatchedControlUpdate batch(this); | 728 BatchedControlUpdate batch(this); |
| 721 m_volumeSlider->setIsWanted(mediaElement().hasAudio() && | 729 m_volumeSlider->setIsWanted(mediaElement().hasAudio() && |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 997 visitor->trace(m_overflowList); | 1005 visitor->trace(m_overflowList); |
| 998 visitor->trace(m_castButton); | 1006 visitor->trace(m_castButton); |
| 999 visitor->trace(m_overlayCastButton); | 1007 visitor->trace(m_overlayCastButton); |
| 1000 visitor->trace(m_mediaEventListener); | 1008 visitor->trace(m_mediaEventListener); |
| 1001 visitor->trace(m_windowEventListener); | 1009 visitor->trace(m_windowEventListener); |
| 1002 visitor->trace(m_orientationLockDelegate); | 1010 visitor->trace(m_orientationLockDelegate); |
| 1003 HTMLDivElement::trace(visitor); | 1011 HTMLDivElement::trace(visitor); |
| 1004 } | 1012 } |
| 1005 | 1013 |
| 1006 } // namespace blink | 1014 } // namespace blink |
| OLD | NEW |