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

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

Issue 2736853003: Media: fix memory leak because of the document holding on an EventListener. (Closed)
Patch Set: 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 663 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 674
675 bool MediaControls::containsRelatedTarget(Event* event) { 675 bool MediaControls::containsRelatedTarget(Event* event) {
676 if (!event->isMouseEvent()) 676 if (!event->isMouseEvent())
677 return false; 677 return false;
678 EventTarget* relatedTarget = toMouseEvent(event)->relatedTarget(); 678 EventTarget* relatedTarget = toMouseEvent(event)->relatedTarget();
679 if (!relatedTarget) 679 if (!relatedTarget)
680 return false; 680 return false;
681 return contains(relatedTarget->toNode()); 681 return contains(relatedTarget->toNode());
682 } 682 }
683 683
684 void MediaControls::onInsertedIntoDocument() {
685 // TODO(mlamouri): we should show the controls instead of having
686 // HTMLMediaElement do it.
687
688 // m_windowEventListener doesn't need to be re-attached as it's only needed
689 // when a menu is visible.
690 m_mediaEventListener->attach();
691 if (m_orientationLockDelegate)
692 m_orientationLockDelegate->attach();
693 }
694
695 void MediaControls::onRemovedFromDocument() {
696 // TODO(mlamouri): we hide show the controls instead of having
697 // HTMLMediaElement do it.
698
699 m_windowEventListener->stop();
700 m_mediaEventListener->detach();
701 if (m_orientationLockDelegate)
702 m_orientationLockDelegate->detach();
703 }
704
684 void MediaControls::onVolumeChange() { 705 void MediaControls::onVolumeChange() {
685 m_muteButton->updateDisplayType(); 706 m_muteButton->updateDisplayType();
686 m_volumeSlider->setVolume(mediaElement().muted() ? 0 707 m_volumeSlider->setVolume(mediaElement().muted() ? 0
687 : mediaElement().volume()); 708 : mediaElement().volume());
688 709
689 // Update visibility of volume controls. 710 // Update visibility of volume controls.
690 // TODO(mlamouri): it should not be part of the volumechange handling because 711 // TODO(mlamouri): it should not be part of the volumechange handling because
691 // it is using audio availability as input. 712 // it is using audio availability as input.
692 BatchedControlUpdate batch(this); 713 BatchedControlUpdate batch(this);
693 m_volumeSlider->setIsWanted(mediaElement().hasAudio() && 714 m_volumeSlider->setIsWanted(mediaElement().hasAudio() &&
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
969 visitor->trace(m_overflowList); 990 visitor->trace(m_overflowList);
970 visitor->trace(m_castButton); 991 visitor->trace(m_castButton);
971 visitor->trace(m_overlayCastButton); 992 visitor->trace(m_overlayCastButton);
972 visitor->trace(m_mediaEventListener); 993 visitor->trace(m_mediaEventListener);
973 visitor->trace(m_windowEventListener); 994 visitor->trace(m_windowEventListener);
974 visitor->trace(m_orientationLockDelegate); 995 visitor->trace(m_orientationLockDelegate);
975 HTMLDivElement::trace(visitor); 996 HTMLDivElement::trace(visitor);
976 } 997 }
977 998
978 } // namespace blink 999 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698