Improve behavior of media elements in page cache.
<https://webkit.org/b/147020>
<rdar://problem/21712311>
Reviewed by Chris Dumez.
Source/WebCore:
Make improvements for media elements when transitioning in/out of page cache:
- Events that were scheduled when going into cache will now be delivered
when the page is restored from cache.
- Data buffering is turned off while in the cache. This reduces the memory
cost of cached pages with media elements on iOS (where mediaserverd would
keep upcoming video frames in memory for cached pages.)
Test: media/restore-from-page-cache.html (amended)
* dom/GenericEventQueue.h:
* dom/GenericEventQueue.cpp:
(WebCore::GenericEventQueue::enqueueEvent):
(WebCore::GenericEventQueue::suspend):
(WebCore::GenericEventQueue::resume):
Add a simple suspend/resume mechanism to GenericEventQueue that can
be used to support page caching.
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::stop):
(WebCore::HTMLMediaElement::suspend):
(WebCore::HTMLMediaElement::resume):
(WebCore::HTMLMediaElement::stopWithoutDestroyingMediaPlayer):
Adapt to event queueing changes and add calls to setShouldBufferData().
* html/HTMLSourceElement.h:
* html/HTMLSourceElement.cpp:
(WebCore::HTMLSourceElement::HTMLSourceElement):
(WebCore::HTMLSourceElement::create):
(WebCore::HTMLSourceElement::activeDOMObjectName):
(WebCore::HTMLSourceElement::canSuspendForPageCache):
(WebCore::HTMLSourceElement::suspend):
(WebCore::HTMLSourceElement::resume):
(WebCore::HTMLSourceElement::stop):
Turn HTMLSourceElement into an ActiveDOMObject so it gets all the
appropriate page cache notifications directly. Suspend the delayed
error event delivery timer when cached.
LayoutTests:
Add some coverage for suspend/resume of queued events on cached media elements.
* media/restore-from-page-cache-expected.txt:
* media/restore-from-page-cache.html:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@187031 268f45cc-cd09-0410-ab3c-d52691b4dbfc
9 files changed