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

Unified Diff: third_party/WebKit/Source/core/html/HTMLSourceElement.cpp

Issue 2256533002: Remove MediaQueryList listener from removed HTMLSourceElement. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: typo Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLSourceElement.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/html/HTMLSourceElement.cpp
diff --git a/third_party/WebKit/Source/core/html/HTMLSourceElement.cpp b/third_party/WebKit/Source/core/html/HTMLSourceElement.cpp
index 705ba44582dfe288415cdc8c53dd5445e6b61a15..f65e834ef53fbc00b5fdca11d4ed3da34a3eb7a1 100644
--- a/third_party/WebKit/Source/core/html/HTMLSourceElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLSourceElement.cpp
@@ -84,11 +84,10 @@ void HTMLSourceElement::createMediaQueryList(const AtomicString& media)
if (media.isEmpty())
return;
- if (m_mediaQueryList)
- m_mediaQueryList->removeListener(m_listener);
+ removeMediaQueryListListener();
MediaQuerySet* set = MediaQuerySet::create(media);
m_mediaQueryList = MediaQueryList::create(&document(), &document().mediaQueryMatcher(), set);
- m_mediaQueryList->addListener(m_listener);
+ addMediaQueryListListener();
}
void HTMLSourceElement::didMoveToNewDocument(Document& oldDocument)
@@ -115,11 +114,25 @@ void HTMLSourceElement::removedFrom(ContainerNode* removalRoot)
parent = toElement(removalRoot);
if (isHTMLMediaElement(parent))
toHTMLMediaElement(parent)->sourceWasRemoved(this);
- if (isHTMLPictureElement(parent))
+ if (isHTMLPictureElement(parent)) {
+ removeMediaQueryListListener();
toHTMLPictureElement(parent)->sourceOrMediaChanged();
+ }
HTMLElement::removedFrom(removalRoot);
}
+void HTMLSourceElement::removeMediaQueryListListener()
+{
+ if (m_mediaQueryList)
+ m_mediaQueryList->removeListener(m_listener);
+}
+
+void HTMLSourceElement::addMediaQueryListListener()
+{
+ if (m_mediaQueryList)
+ m_mediaQueryList->addListener(m_listener);
+}
+
void HTMLSourceElement::setSrc(const String& url)
{
setAttribute(srcAttr, AtomicString(url));
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLSourceElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698