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

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 and move reloadPage() call so the test is more deterministic. Created 7 years, 2 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 | « LayoutTests/http/tests/media/video-in-iframe-crash-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/HTMLMediaElement.cpp
diff --git a/Source/core/html/HTMLMediaElement.cpp b/Source/core/html/HTMLMediaElement.cpp
index 82794ff304815ec6a0fe94f87be969867e44ee7b..5d5aad872c97875d0c8ce7eef0e27681c2057f38 100644
--- a/Source/core/html/HTMLMediaElement.cpp
+++ b/Source/core/html/HTMLMediaElement.cpp
@@ -369,9 +369,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)
@@ -386,6 +391,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.
+ if (oldDocument)
+ oldDocument->decrementLoadEventDelayCount();
+
HTMLElement::didMoveToNewDocument(oldDocument);
}
« no previous file with comments | « LayoutTests/http/tests/media/video-in-iframe-crash-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698