<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[187081] branches/safari-601.1-branch</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/187081">187081</a></dd>
<dt>Author</dt> <dd>matthew_hanson@apple.com</dd>
<dt>Date</dt> <dd>2015-07-20 21:38:02 -0700 (Mon, 20 Jul 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Merge <a href="http://trac.webkit.org/projects/webkit/changeset/187031">r187031</a>. rdar://problem/21712311</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#branchessafari6011branchLayoutTestsChangeLog">branches/safari-601.1-branch/LayoutTests/ChangeLog</a></li>
<li><a href="#branchessafari6011branchLayoutTestsmediarestorefrompagecacheexpectedtxt">branches/safari-601.1-branch/LayoutTests/media/restore-from-page-cache-expected.txt</a></li>
<li><a href="#branchessafari6011branchLayoutTestsmediarestorefrompagecachehtml">branches/safari-601.1-branch/LayoutTests/media/restore-from-page-cache.html</a></li>
<li><a href="#branchessafari6011branchSourceWebCoreChangeLog">branches/safari-601.1-branch/Source/WebCore/ChangeLog</a></li>
<li><a href="#branchessafari6011branchSourceWebCoredomGenericEventQueuecpp">branches/safari-601.1-branch/Source/WebCore/dom/GenericEventQueue.cpp</a></li>
<li><a href="#branchessafari6011branchSourceWebCoredomGenericEventQueueh">branches/safari-601.1-branch/Source/WebCore/dom/GenericEventQueue.h</a></li>
<li><a href="#branchessafari6011branchSourceWebCorehtmlHTMLMediaElementcpp">branches/safari-601.1-branch/Source/WebCore/html/HTMLMediaElement.cpp</a></li>
<li><a href="#branchessafari6011branchSourceWebCorehtmlHTMLSourceElementcpp">branches/safari-601.1-branch/Source/WebCore/html/HTMLSourceElement.cpp</a></li>
<li><a href="#branchessafari6011branchSourceWebCorehtmlHTMLSourceElementh">branches/safari-601.1-branch/Source/WebCore/html/HTMLSourceElement.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchessafari6011branchLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1-branch/LayoutTests/ChangeLog (187080 => 187081)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1-branch/LayoutTests/ChangeLog        2015-07-21 04:37:58 UTC (rev 187080)
+++ branches/safari-601.1-branch/LayoutTests/ChangeLog        2015-07-21 04:38:02 UTC (rev 187081)
</span><span class="lines">@@ -1,5 +1,22 @@
</span><span class="cx"> 2015-07-20  Matthew Hanson  &lt;matthew_hanson@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        Merge r187031. rdar://problem/21712311
+
+    2015-07-20  Andreas Kling  &lt;akling@apple.com&gt;
+
+            Improve behavior of media elements in page cache.
+            &lt;https://webkit.org/b/147020&gt;
+            &lt;rdar://problem/21712311&gt;
+
+            Reviewed by Chris Dumez.
+
+            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:
+
+2015-07-20  Matthew Hanson  &lt;matthew_hanson@apple.com&gt;
+
</ins><span class="cx">         Merge r186988. rdar://problem/21567820
</span><span class="cx"> 
</span><span class="cx">     2015-07-18  David Kilzer  &lt;ddkilzer@apple.com&gt;
</span></span></pre></div>
<a id="branchessafari6011branchLayoutTestsmediarestorefrompagecacheexpectedtxt"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1-branch/LayoutTests/media/restore-from-page-cache-expected.txt (187080 => 187081)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1-branch/LayoutTests/media/restore-from-page-cache-expected.txt        2015-07-21 04:37:58 UTC (rev 187080)
+++ branches/safari-601.1-branch/LayoutTests/media/restore-from-page-cache-expected.txt        2015-07-21 04:38:02 UTC (rev 187081)
</span><span class="lines">@@ -5,8 +5,12 @@
</span><span class="cx"> EVENT(canplaythrough)
</span><span class="cx"> EXPECTED (loadCount == '0') OK
</span><span class="cx"> *** Page going into cache
</span><ins>+*** Changing playbackRate just before going into cache, to schedule a ratechange event.
+*** Changing volume just before going into cache, to schedule a volumechange event.
</ins><span class="cx"> *** Page returned from cache
</span><span class="cx"> EXPECTED (loadCount == '1') OK
</span><span class="cx"> EXPECTED (videoComputedStyle.width == '320px') OK
</span><span class="cx"> EXPECTED (videoComputedStyle.height == '240px') OK
</span><ins>+*** ratechange event fired. This should happen AFTER returning from cache.
+*** volumechange event fired. This should happen AFTER returning from cache.
</ins><span class="cx"> 
</span></span></pre></div>
<a id="branchessafari6011branchLayoutTestsmediarestorefrompagecachehtml"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1-branch/LayoutTests/media/restore-from-page-cache.html (187080 => 187081)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1-branch/LayoutTests/media/restore-from-page-cache.html        2015-07-21 04:37:58 UTC (rev 187080)
+++ branches/safari-601.1-branch/LayoutTests/media/restore-from-page-cache.html        2015-07-21 04:38:02 UTC (rev 187081)
</span><span class="lines">@@ -33,17 +33,33 @@
</span><span class="cx">                     setTimeout(function() { if (window.testRunner) testRunner.notifyDone(); }, 200);
</span><span class="cx">                 }
</span><span class="cx">             }
</span><del>-                
</del><ins>+
+            function pagehide()
+            {
+                // Have the video element generate some events that need to be suspended.
+                // We use multiple events to verify that they fire in the correct order.
+                consoleWrite(&quot;*** Changing playbackRate just before going into cache, to schedule a ratechange event.&quot;);
+                document.getElementsByTagName(&quot;video&quot;)[0].playbackRate = 2; 
+                consoleWrite(&quot;*** Changing volume just before going into cache, to schedule a volumechange event.&quot;);
+                document.getElementsByTagName(&quot;video&quot;)[0].volume = 0.5; 
+            }
+
</ins><span class="cx">             function canplaythrough() 
</span><span class="cx">             {
</span><span class="cx">                 testExpected(&quot;loadCount&quot;, 0);
</span><span class="cx">                 if (!loadCount) {
</span><ins>+                    video = document.getElementsByTagName('video')[0];
</ins><span class="cx">                     consoleWrite(&quot;*** Page going into cache&quot;);
</span><span class="cx">                     setTimeout('window.location = &quot;data:text/html,&lt;script&gt;history.back()&lt;&quot; + &quot;/script&gt;&quot;', 0);
</span><span class="cx">                 }
</span><span class="cx">                 ++loadCount;
</span><span class="cx">             }
</span><span class="cx"> 
</span><ins>+            function propertyChangeCallback(evt)
+            {
+                consoleWrite(&quot;*** &quot; + evt.type +  &quot; event fired. This should happen AFTER returning from cache.&quot;);
+            }
+
</ins><span class="cx">             function setup()
</span><span class="cx">             {
</span><span class="cx">                 video = mediaElement = document.getElementsByTagName('video')[0];
</span><span class="lines">@@ -52,9 +68,13 @@
</span><span class="cx">                 waitForEvent('canplaythrough', canplaythrough);
</span><span class="cx">                 
</span><span class="cx">                 video.src = mediaFile;
</span><ins>+
+                video.onratechange = propertyChangeCallback;
+                video.onvolumechange = propertyChangeCallback;
</ins><span class="cx">             }
</span><span class="cx"> 
</span><span class="cx">             window.onpageshow = pageshow;
</span><ins>+            window.onpagehide = pagehide;
</ins><span class="cx">         &lt;/script&gt;
</span><span class="cx">     &lt;/head&gt;
</span><span class="cx">     &lt;body&gt;
</span></span></pre></div>
<a id="branchessafari6011branchSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1-branch/Source/WebCore/ChangeLog (187080 => 187081)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1-branch/Source/WebCore/ChangeLog        2015-07-21 04:37:58 UTC (rev 187080)
+++ branches/safari-601.1-branch/Source/WebCore/ChangeLog        2015-07-21 04:38:02 UTC (rev 187081)
</span><span class="lines">@@ -1,5 +1,59 @@
</span><span class="cx"> 2015-07-20  Matthew Hanson  &lt;matthew_hanson@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        Merge r187031. rdar://problem/21712311
+
+    2015-07-20  Andreas Kling  &lt;akling@apple.com&gt;
+
+            Improve behavior of media elements in page cache.
+            &lt;https://webkit.org/b/147020&gt;
+            &lt;rdar://problem/21712311&gt;
+
+            Reviewed by Chris Dumez.
+
+            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.
+
+2015-07-20  Matthew Hanson  &lt;matthew_hanson@apple.com&gt;
+
</ins><span class="cx">         Merge r187025. rdar://problem/21878275
</span><span class="cx"> 
</span><span class="cx">     2015-07-18  Ada Chan  &lt;adachan@apple.com&gt;
</span></span></pre></div>
<a id="branchessafari6011branchSourceWebCoredomGenericEventQueuecpp"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1-branch/Source/WebCore/dom/GenericEventQueue.cpp (187080 => 187081)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1-branch/Source/WebCore/dom/GenericEventQueue.cpp        2015-07-21 04:37:58 UTC (rev 187080)
+++ branches/safari-601.1-branch/Source/WebCore/dom/GenericEventQueue.cpp        2015-07-21 04:38:02 UTC (rev 187081)
</span><span class="lines">@@ -45,20 +45,22 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool GenericEventQueue::enqueueEvent(PassRefPtr&lt;Event&gt; event)
</del><ins>+void GenericEventQueue::enqueueEvent(PassRefPtr&lt;Event&gt; event)
</ins><span class="cx"> {
</span><span class="cx">     if (m_isClosed)
</span><del>-        return false;
</del><ins>+        return;
</ins><span class="cx"> 
</span><span class="cx">     if (event-&gt;target() == &amp;m_owner)
</span><span class="cx">         event-&gt;setTarget(0);
</span><span class="cx"> 
</span><span class="cx">     m_pendingEvents.append(event);
</span><ins>+
+    if (m_isSuspended)
+        return;
+
</ins><span class="cx">     pendingQueues().append(m_weakPtrFactory.createWeakPtr());
</span><span class="cx">     if (!sharedTimer().isActive())
</span><span class="cx">         sharedTimer().startOneShot(0);
</span><del>-
-    return true;
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> Timer&amp; GenericEventQueue::sharedTimer()
</span><span class="lines">@@ -120,4 +122,26 @@
</span><span class="cx">     return !m_pendingEvents.isEmpty();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void GenericEventQueue::suspend()
+{
+    ASSERT(!m_isSuspended);
+    m_isSuspended = true;
+    m_weakPtrFactory.revokeAll();
</ins><span class="cx"> }
</span><ins>+
+void GenericEventQueue::resume()
+{
+    ASSERT(m_isSuspended);
+    m_isSuspended = false;
+
+    if (m_pendingEvents.isEmpty())
+        return;
+
+    for (unsigned i = 0; i &lt; m_pendingEvents.size(); ++i)
+        pendingQueues().append(m_weakPtrFactory.createWeakPtr());
+
+    if (!sharedTimer().isActive())
+        sharedTimer().startOneShot(0);
+}
+
+}
</ins></span></pre></div>
<a id="branchessafari6011branchSourceWebCoredomGenericEventQueueh"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1-branch/Source/WebCore/dom/GenericEventQueue.h (187080 => 187081)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1-branch/Source/WebCore/dom/GenericEventQueue.h        2015-07-21 04:37:58 UTC (rev 187080)
+++ branches/safari-601.1-branch/Source/WebCore/dom/GenericEventQueue.h        2015-07-21 04:38:02 UTC (rev 187081)
</span><span class="lines">@@ -42,12 +42,15 @@
</span><span class="cx">     explicit GenericEventQueue(EventTarget&amp;);
</span><span class="cx">     ~GenericEventQueue();
</span><span class="cx"> 
</span><del>-    bool enqueueEvent(PassRefPtr&lt;Event&gt;);
</del><ins>+    void enqueueEvent(PassRefPtr&lt;Event&gt;);
</ins><span class="cx">     void close();
</span><span class="cx"> 
</span><span class="cx">     void cancelAllEvents();
</span><span class="cx">     bool hasPendingEvents() const;
</span><span class="cx"> 
</span><ins>+    void suspend();
+    void resume();
+
</ins><span class="cx"> private:
</span><span class="cx">     static Timer&amp; sharedTimer();
</span><span class="cx">     static void sharedTimerFired();
</span><span class="lines">@@ -59,6 +62,7 @@
</span><span class="cx">     Deque&lt;RefPtr&lt;Event&gt;&gt; m_pendingEvents;
</span><span class="cx">     WeakPtrFactory&lt;GenericEventQueue&gt; m_weakPtrFactory;
</span><span class="cx">     bool m_isClosed;
</span><ins>+    bool m_isSuspended { false };
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre></div>
<a id="branchessafari6011branchSourceWebCorehtmlHTMLMediaElementcpp"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1-branch/Source/WebCore/html/HTMLMediaElement.cpp (187080 => 187081)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1-branch/Source/WebCore/html/HTMLMediaElement.cpp        2015-07-21 04:37:58 UTC (rev 187080)
+++ branches/safari-601.1-branch/Source/WebCore/html/HTMLMediaElement.cpp        2015-07-21 04:38:02 UTC (rev 187081)
</span><span class="lines">@@ -4890,10 +4890,7 @@
</span><span class="cx">         renderer()-&gt;updateFromElement();
</span><span class="cx">     
</span><span class="cx">     stopPeriodicTimers();
</span><del>-    cancelPendingEventsAndCallbacks();
</del><span class="cx"> 
</span><del>-    m_asyncEventQueue.close();
-
</del><span class="cx">     updateSleepDisabling();
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -4903,6 +4900,8 @@
</span><span class="cx"> 
</span><span class="cx">     stopWithoutDestroyingMediaPlayer();
</span><span class="cx"> 
</span><ins>+    m_asyncEventQueue.close();
+
</ins><span class="cx">     // Once an active DOM object has been stopped it can not be restarted, so we can deallocate
</span><span class="cx">     // the media player now. Note that userCancelledLoad will already called clearMediaPlayer
</span><span class="cx">     // if the media was not fully loaded, but we need the same cleanup if the file was completely
</span><span class="lines">@@ -4918,6 +4917,8 @@
</span><span class="cx">     {
</span><span class="cx">         case PageCache:
</span><span class="cx">             stopWithoutDestroyingMediaPlayer();
</span><ins>+            m_asyncEventQueue.suspend();
+            setShouldBufferData(false);
</ins><span class="cx">             m_mediaSession-&gt;addBehaviorRestriction(MediaElementSession::RequirePageConsentToResumeMedia);
</span><span class="cx">             break;
</span><span class="cx">         case DocumentWillBePaused:
</span><span class="lines">@@ -4935,6 +4936,10 @@
</span><span class="cx"> 
</span><span class="cx">     m_inActiveDocument = true;
</span><span class="cx"> 
</span><ins>+    m_asyncEventQueue.resume();
+
+    setShouldBufferData(true);
+
</ins><span class="cx">     if (!m_mediaSession-&gt;pageAllowsPlaybackAfterResuming(*this))
</span><span class="cx">         document().addMediaCanStartListener(this);
</span><span class="cx">     else
</span></span></pre></div>
<a id="branchessafari6011branchSourceWebCorehtmlHTMLSourceElementcpp"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1-branch/Source/WebCore/html/HTMLSourceElement.cpp (187080 => 187081)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1-branch/Source/WebCore/html/HTMLSourceElement.cpp        2015-07-21 04:37:58 UTC (rev 187080)
+++ branches/safari-601.1-branch/Source/WebCore/html/HTMLSourceElement.cpp        2015-07-21 04:38:02 UTC (rev 187081)
</span><span class="lines">@@ -40,6 +40,7 @@
</span><span class="cx"> 
</span><span class="cx"> inline HTMLSourceElement::HTMLSourceElement(const QualifiedName&amp; tagName, Document&amp; document)
</span><span class="cx">     : HTMLElement(tagName, document)
</span><ins>+    , ActiveDOMObject(&amp;document)
</ins><span class="cx">     , m_errorEventTimer(*this, &amp;HTMLSourceElement::errorEventTimerFired)
</span><span class="cx"> {
</span><span class="cx">     LOG(Media, &quot;HTMLSourceElement::HTMLSourceElement - %p&quot;, this);
</span><span class="lines">@@ -48,7 +49,9 @@
</span><span class="cx"> 
</span><span class="cx"> Ref&lt;HTMLSourceElement&gt; HTMLSourceElement::create(const QualifiedName&amp; tagName, Document&amp; document)
</span><span class="cx"> {
</span><del>-    return adoptRef(*new HTMLSourceElement(tagName, document));
</del><ins>+    Ref&lt;HTMLSourceElement&gt; sourceElement = adoptRef(*new HTMLSourceElement(tagName, document));
+    sourceElement-&gt;suspendIfNeeded();
+    return sourceElement;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> Node::InsertionNotificationRequest HTMLSourceElement::insertedInto(ContainerNode&amp; insertionPoint)
</span><span class="lines">@@ -121,6 +124,37 @@
</span><span class="cx">     return attribute.name() == srcAttr || HTMLElement::isURLAttribute(attribute);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+const char* HTMLSourceElement::activeDOMObjectName() const
+{
+    return &quot;HTMLSourceElement&quot;;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool HTMLSourceElement::canSuspendForPageCache() const
+{
+    return true;
+}
+
+void HTMLSourceElement::suspend(ReasonForSuspension why)
+{
+    if (why == PageCache) {
+        m_shouldRescheduleErrorEventOnResume = m_errorEventTimer.isActive();
+        m_errorEventTimer.stop();
+    }
+}
+
+void HTMLSourceElement::resume()
+{
+    if (m_shouldRescheduleErrorEventOnResume) {
+        m_errorEventTimer.startOneShot(0);
+        m_shouldRescheduleErrorEventOnResume = false;
+    }
+}
+
+void HTMLSourceElement::stop()
+{
+    cancelPendingErrorEvent();
+}
+
+}
+
</ins><span class="cx"> #endif
</span></span></pre></div>
<a id="branchessafari6011branchSourceWebCorehtmlHTMLSourceElementh"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1-branch/Source/WebCore/html/HTMLSourceElement.h (187080 => 187081)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1-branch/Source/WebCore/html/HTMLSourceElement.h        2015-07-21 04:37:58 UTC (rev 187080)
+++ branches/safari-601.1-branch/Source/WebCore/html/HTMLSourceElement.h        2015-07-21 04:38:02 UTC (rev 187081)
</span><span class="lines">@@ -32,7 +32,7 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-class HTMLSourceElement final : public HTMLElement {
</del><ins>+class HTMLSourceElement final : public HTMLElement, public ActiveDOMObject {
</ins><span class="cx"> public:
</span><span class="cx">     static Ref&lt;HTMLSourceElement&gt; create(const QualifiedName&amp;, Document&amp;);
</span><span class="cx"> 
</span><span class="lines">@@ -52,9 +52,17 @@
</span><span class="cx">     virtual void removedFrom(ContainerNode&amp;) override;
</span><span class="cx">     virtual bool isURLAttribute(const Attribute&amp;) const override;
</span><span class="cx"> 
</span><ins>+    // ActiveDOMObject.
+    const char* activeDOMObjectName() const override;
+    bool canSuspendForPageCache() const override;
+    void suspend(ReasonForSuspension) override;
+    void resume() override;
+    void stop() override;
+
</ins><span class="cx">     void errorEventTimerFired();
</span><span class="cx"> 
</span><span class="cx">     Timer m_errorEventTimer;
</span><ins>+    bool m_shouldRescheduleErrorEventOnResume { false };
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } //namespace
</span></span></pre>
</div>
</div>

</body>
</html>