Chromium Code Reviews| 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); |
| } |