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

Side by Side Diff: third_party/WebKit/Source/core/html/shadow/MediaControls.cpp

Issue 2725873002: Media: fix memory leak because of the document holding on an EventListener. (Closed)
Patch Set: event-based Created 3 years, 9 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
OLDNEW
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 670 matching lines...) Expand 10 before | Expand all | Expand 10 after
681 681
682 bool MediaControls::containsRelatedTarget(Event* event) { 682 bool MediaControls::containsRelatedTarget(Event* event) {
683 if (!event->isMouseEvent()) 683 if (!event->isMouseEvent())
684 return false; 684 return false;
685 EventTarget* relatedTarget = toMouseEvent(event)->relatedTarget(); 685 EventTarget* relatedTarget = toMouseEvent(event)->relatedTarget();
686 if (!relatedTarget) 686 if (!relatedTarget)
687 return false; 687 return false;
688 return contains(relatedTarget->toNode()); 688 return contains(relatedTarget->toNode());
689 } 689 }
690 690
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
691 void MediaControls::onVolumeChange() { 712 void MediaControls::onVolumeChange() {
692 m_muteButton->updateDisplayType(); 713 m_muteButton->updateDisplayType();
693 m_volumeSlider->setVolume(mediaElement().muted() ? 0 714 m_volumeSlider->setVolume(mediaElement().muted() ? 0
694 : mediaElement().volume()); 715 : mediaElement().volume());
695 716
696 // Update visibility of volume controls. 717 // Update visibility of volume controls.
697 // TODO(mlamouri): it should not be part of the volumechange handling because 718 // TODO(mlamouri): it should not be part of the volumechange handling because
698 // it is using audio availability as input. 719 // it is using audio availability as input.
699 BatchedControlUpdate batch(this); 720 BatchedControlUpdate batch(this);
700 m_volumeSlider->setIsWanted(mediaElement().hasAudio() && 721 m_volumeSlider->setIsWanted(mediaElement().hasAudio() &&
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
976 visitor->trace(m_overflowList); 997 visitor->trace(m_overflowList);
977 visitor->trace(m_castButton); 998 visitor->trace(m_castButton);
978 visitor->trace(m_overlayCastButton); 999 visitor->trace(m_overlayCastButton);
979 visitor->trace(m_mediaEventListener); 1000 visitor->trace(m_mediaEventListener);
980 visitor->trace(m_windowEventListener); 1001 visitor->trace(m_windowEventListener);
981 visitor->trace(m_orientationLockDelegate); 1002 visitor->trace(m_orientationLockDelegate);
982 HTMLDivElement::trace(visitor); 1003 HTMLDivElement::trace(visitor);
983 } 1004 }
984 1005
985 } // namespace blink 1006 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698