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

Side by Side 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, 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 audioSourceProvider()->setClient(0); 363 audioSourceProvider()->setClient(0);
364 #endif 364 #endif
365 document().decrementLoadEventDelayCount(); 365 document().decrementLoadEventDelayCount();
366 } 366 }
367 367
368 void HTMLMediaElement::didMoveToNewDocument(Document* oldDocument) 368 void HTMLMediaElement::didMoveToNewDocument(Document* oldDocument)
369 { 369 {
370 LOG(Media, "HTMLMediaElement::didMoveToNewDocument"); 370 LOG(Media, "HTMLMediaElement::didMoveToNewDocument");
371 371
372 if (m_shouldDelayLoadEvent) { 372 if (m_shouldDelayLoadEvent) {
373 if (oldDocument)
374 oldDocument->decrementLoadEventDelayCount();
375 document().incrementLoadEventDelayCount(); 373 document().incrementLoadEventDelayCount();
374 // Note: Keeping the load event delay count increment on oldDocument tha t was added
375 // when m_shouldDelayLoadEvent was set so that destruction of m_player c an not
376 // cause load event dispatching in oldDocument.
377 } else if (oldDocument) {
378 // Incrementing the load event delay count so that destruction of m_play er can not
379 // cause load event dispatching in oldDocument.
380 oldDocument->incrementLoadEventDelayCount();
376 } 381 }
377 382
378 if (oldDocument) 383 if (oldDocument)
379 removeElementFromDocumentMap(this, oldDocument); 384 removeElementFromDocumentMap(this, oldDocument);
380 385
381 addElementToDocumentMap(this, &document()); 386 addElementToDocumentMap(this, &document());
382 387
383 // FIXME: This is a temporary fix to prevent this object from causing the 388 // FIXME: This is a temporary fix to prevent this object from causing the
384 // MediaPlayer to dereference Frame and FrameLoader pointers from the 389 // MediaPlayer to dereference Frame and FrameLoader pointers from the
385 // previous document. A proper fix would provide a mechanism to allow this 390 // previous document. A proper fix would provide a mechanism to allow this
386 // object to refresh the MediaPlayer's Frame and FrameLoader references on 391 // object to refresh the MediaPlayer's Frame and FrameLoader references on
387 // document changes so that playback can be resumed properly. 392 // document changes so that playback can be resumed properly.
388 userCancelledLoad(); 393 userCancelledLoad();
389 394
395 // Decrement the load event delay count on oldDocument now that m_player has been destroyed
396 // and there is no risk of dispatching a load event from within the destruct or.
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
397 if (oldDocument)
398 oldDocument->decrementLoadEventDelayCount();
399
390 HTMLElement::didMoveToNewDocument(oldDocument); 400 HTMLElement::didMoveToNewDocument(oldDocument);
391 } 401 }
392 402
393 bool HTMLMediaElement::hasCustomFocusLogic() const 403 bool HTMLMediaElement::hasCustomFocusLogic() const
394 { 404 {
395 return true; 405 return true;
396 } 406 }
397 407
398 bool HTMLMediaElement::supportsFocus() const 408 bool HTMLMediaElement::supportsFocus() const
399 { 409 {
(...skipping 3597 matching lines...) Expand 10 before | Expand all | Expand 10 after
3997 { 4007 {
3998 m_restrictions = NoRestrictions; 4008 m_restrictions = NoRestrictions;
3999 } 4009 }
4000 4010
4001 void HTMLMediaElement::mediaPlayerScheduleLayerUpdate() 4011 void HTMLMediaElement::mediaPlayerScheduleLayerUpdate()
4002 { 4012 {
4003 scheduleLayerUpdate(); 4013 scheduleLayerUpdate();
4004 } 4014 }
4005 4015
4006 } 4016 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698