Changeset 55699 in webkit
- Timestamp:
- Mar 8, 2010 5:06:58 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r55693 r55699 1 2010-03-08 Darin Adler <darin@apple.com> 2 3 Reviewed by Jon Honeycutt. 4 5 Don't auto-play <audio> and <video> elements loaded in background tabs 6 https://bugs.webkit.org/show_bug.cgi?id=35886 7 rdar://problem/7117745 8 9 * manual-tests/video-in-non-frontmost-tab.html: Added. 10 * manual-tests/resources/video-tab.html: Added. 11 12 * html/HTMLMediaElement.h: Added MediaCanStartListener as a base class, and 13 added the mediaCanStart function as well as a boolean, 14 m_isWaitingUntilMediaCanStart. 15 16 * html/HTMLMediaElement.cpp: 17 (WebCore::HTMLMediaElement::HTMLMediaElement): Initialize 18 m_isWaitingUntilMediaCanStart. 19 (WebCore::HTMLMediaElement::~HTMLMediaElement): Call 20 removeMediaCanStartListener if m_isWaitingUntilMediaCanStart is true. 21 (WebCore::HTMLMediaElement::loadInternal): Set m_isWaitingUntilMediaCanStart 22 and call addMediaCanStartListener if canStartMedia is false. 23 (WebCore::HTMLMediaElement::mediaCanStart): Clear m_isWaitingUntilMediaCanStart 24 and call loadInternal. 25 1 26 2010-03-08 Csaba Osztrogonác <ossy@webkit.org> 2 27 -
trunk/WebCore/html/HTMLMediaElement.cpp
r55682 r55699 106 106 , m_playing(false) 107 107 , m_processingMediaPlayerCallback(0) 108 , m_isWaitingUntilMediaCanStart(false) 108 109 , m_processingLoad(false) 109 110 , m_delayingTheLoadEvent(false) … … 130 131 HTMLMediaElement::~HTMLMediaElement() 131 132 { 133 if (m_isWaitingUntilMediaCanStart) { 134 if (Page* page = document()->page()) 135 page->removeMediaCanStartListener(this); 136 } 137 132 138 document()->unregisterForDocumentActivationCallbacks(this); 133 139 document()->unregisterForMediaVolumeCallbacks(this); … … 465 471 void HTMLMediaElement::loadInternal() 466 472 { 473 // If we can't start a load right away, start it later. 474 Page* page = document()->page(); 475 if (page && !page->canStartMedia()) { 476 if (m_isWaitingUntilMediaCanStart) 477 return; 478 page->addMediaCanStartListener(this); 479 m_isWaitingUntilMediaCanStart = true; 480 return; 481 } 482 467 483 // If the load() method for this element is already being invoked, then abort these steps. 468 484 if (m_processingLoad) … … 1961 1977 } 1962 1978 1979 void HTMLMediaElement::mediaCanStart() 1980 { 1981 ASSERT(m_isWaitingUntilMediaCanStart); 1982 m_isWaitingUntilMediaCanStart = false; 1983 loadInternal(); 1984 } 1985 1963 1986 } 1964 1987 -
trunk/WebCore/html/HTMLMediaElement.h
r55682 r55699 30 30 31 31 #include "HTMLElement.h" 32 #include "MediaCanStartListener.h" 32 33 #include "MediaPlayer.h" 33 34 … … 44 45 // no longer depends on typecasting a MediaPlayerClient to an HTMLMediaElement. 45 46 46 class HTMLMediaElement : public HTMLElement, public MediaPlayerClient {47 class HTMLMediaElement : public HTMLElement, public MediaPlayerClient, private MediaCanStartListener { 47 48 public: 48 49 MediaPlayer* player() const { return m_player.get(); } … … 263 264 void setPausedInternal(bool); 264 265 266 virtual void mediaCanStart(); 267 265 268 // Restrictions to change default behaviors. This is effectively a compile time choice at the moment 266 269 // because there are no accessor functions. … … 315 318 // calling the media engine recursively. 316 319 int m_processingMediaPlayerCallback; 320 321 bool m_isWaitingUntilMediaCanStart; 317 322 318 323 bool m_processingLoad : 1; -
trunk/WebKit/mac/WebView/WebView.mm
r55697 r55699 976 976 #endif 977 977 978 _private->closed = YES;979 980 978 [[NSDistributedNotificationCenter defaultCenter] removeObserver:self]; 981 979 [[NSNotificationCenter defaultCenter] removeObserver:self]; … … 1010 1008 return; 1011 1009 1010 _private->closed = YES; 1011 1012 1012 [self _closingEventHandling]; 1013 1013 … … 1042 1042 1043 1043 [_private->inspector webViewClosed]; 1044 1045 // setHostWindow:nil must be called before this value is set (see 5408186)1046 _private->closed = YES;1047 1044 1048 1045 // To avoid leaks, call removeDragCaret in case it wasn't called after moveDragCaretToPoint. … … 3340 3337 - (void)setHostWindow:(NSWindow *)hostWindow 3341 3338 { 3342 if (_private->closed )3339 if (_private->closed && hostWindow) 3343 3340 return; 3344 3341 if (hostWindow == _private->hostWindow)
Note: See TracChangeset
for help on using the changeset viewer.