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

Unified Diff: Source/core/html/HTMLMediaElement.cpp

Issue 25362002: Block load event dispatching on old document when an HTMLMediaElement is moved between documents. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 7 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
Index: Source/core/html/HTMLMediaElement.cpp
diff --git a/Source/core/html/HTMLMediaElement.cpp b/Source/core/html/HTMLMediaElement.cpp
index cfe442397c75afbbe97d8d06a79fd678961a8dea..6469002ecc62074f6b06aef0666d012e4ef4f7b1 100644
--- a/Source/core/html/HTMLMediaElement.cpp
+++ b/Source/core/html/HTMLMediaElement.cpp
@@ -370,9 +370,14 @@ void HTMLMediaElement::didMoveToNewDocument(Document* oldDocument)
LOG(Media, "HTMLMediaElement::didMoveToNewDocument");
if (m_shouldDelayLoadEvent) {
- if (oldDocument)
- oldDocument->decrementLoadEventDelayCount();
document().incrementLoadEventDelayCount();
+ // Note: Keeping the load event delay count increment on oldDocument that was added
+ // when m_shouldDelayLoadEvent was set so that destruction of m_player can not
+ // cause load event dispatching in oldDocument.
+ } else if (oldDocument) {
+ // Incrementing the load event delay count so that destruction of m_player can not
+ // cause load event dispatching in oldDocument.
+ oldDocument->incrementLoadEventDelayCount();
}
if (oldDocument)
@@ -387,6 +392,11 @@ void HTMLMediaElement::didMoveToNewDocument(Document* oldDocument)
// document changes so that playback can be resumed properly.
userCancelledLoad();
+ // Decrement the load event delay count on oldDocument now that m_player has been destroyed
+ // and there is no risk of dispatching a load event from within the destructor.
abarth-chromium 2013/10/01 19:49:19 This code looks very fragile. Is there a better d
acolwell GONE FROM CHROMIUM 2013/10/01 22:02:04 This increment/decrementLoadEventDelayCount() does
+ if (oldDocument)
+ oldDocument->decrementLoadEventDelayCount();
+
HTMLElement::didMoveToNewDocument(oldDocument);
}

Powered by Google App Engine
This is Rietveld 408576698