<!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>[186621] branches/safari-600.8-branch/Source/WebCore</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/186621">186621</a></dd>
<dt>Author</dt> <dd>matthew_hanson@apple.com</dd>
<dt>Date</dt> <dd>2015-07-09 14:03:00 -0700 (Thu, 09 Jul 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Merge <a href="http://trac.webkit.org/projects/webkit/changeset/186554">r186554</a>. rdar://problem/21716400</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#branchessafari6008branchSourceWebCoreChangeLog">branches/safari-600.8-branch/Source/WebCore/ChangeLog</a></li>
<li><a href="#branchessafari6008branchSourceWebCorehtmlHTMLMediaElementcpp">branches/safari-600.8-branch/Source/WebCore/html/HTMLMediaElement.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchessafari6008branchSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-600.8-branch/Source/WebCore/ChangeLog (186620 => 186621)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.8-branch/Source/WebCore/ChangeLog        2015-07-09 21:02:56 UTC (rev 186620)
+++ branches/safari-600.8-branch/Source/WebCore/ChangeLog        2015-07-09 21:03:00 UTC (rev 186621)
</span><span class="lines">@@ -1,5 +1,23 @@
</span><span class="cx"> 2015-07-09  Matthew Hanson  &lt;matthew_hanson@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        Merge r186554. rdar://problem/21716400
+
+    2015-07-08  Matthew Hanson  &lt;matthew_hanson@apple.com&gt;
+
+            Merge r182918. rdar://problem/21716544
+
+        2015-04-16  Brady Eidson  &lt;beidson@apple.com&gt;
+
+                Media element can manipulate DOM during Document destruction.
+                rdar://problem/20553898 and https://bugs.webkit.org/show_bug.cgi?id=143780
+
+                Reviewed by Jer Noble.
+
+                * html/HTMLMediaElement.cpp:
+                (WebCore::HTMLMediaElement::configureMediaControls): Bail if the element has no active document.
+
+2015-07-09  Matthew Hanson  &lt;matthew_hanson@apple.com&gt;
+
</ins><span class="cx">         Merge r186553. rdar://problem/21716372
</span><span class="cx"> 
</span><span class="cx">     2015-07-08  Matthew Hanson  &lt;matthew_hanson@apple.com&gt;
</span></span></pre></div>
<a id="branchessafari6008branchSourceWebCorehtmlHTMLMediaElementcpp"></a>
<div class="modfile"><h4>Modified: branches/safari-600.8-branch/Source/WebCore/html/HTMLMediaElement.cpp (186620 => 186621)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.8-branch/Source/WebCore/html/HTMLMediaElement.cpp        2015-07-09 21:02:56 UTC (rev 186620)
+++ branches/safari-600.8-branch/Source/WebCore/html/HTMLMediaElement.cpp        2015-07-09 21:03:00 UTC (rev 186621)
</span><span class="lines">@@ -155,7 +155,7 @@
</span><span class="cx"> {
</span><span class="cx">     value &amp;= ~flags;
</span><span class="cx"> }
</span><del>-    
</del><ins>+
</ins><span class="cx"> #if !LOG_DISABLED
</span><span class="cx"> static String urlForLoggingMedia(const URL&amp; url)
</span><span class="cx"> {
</span><span class="lines">@@ -173,7 +173,7 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> #ifndef LOG_MEDIA_EVENTS
</span><del>-// Default to not logging events because so many are generated they can overwhelm the rest of 
</del><ins>+// Default to not logging events because so many are generated they can overwhelm the rest of
</ins><span class="cx"> // the logging.
</span><span class="cx"> #define LOG_MEDIA_EVENTS 0
</span><span class="cx"> #endif
</span><span class="lines">@@ -245,7 +245,7 @@
</span><span class="cx">         ASSERT(m_mediaElement);
</span><span class="cx">         m_mediaElement-&gt;endIgnoringTrackDisplayUpdateRequests();
</span><span class="cx">     }
</span><del>-    
</del><ins>+
</ins><span class="cx"> private:
</span><span class="cx">     HTMLMediaElement* m_mediaElement;
</span><span class="cx"> };
</span><span class="lines">@@ -643,7 +643,7 @@
</span><span class="cx"> {
</span><span class="cx">     HTMLElement::finishParsingChildren();
</span><span class="cx">     m_parsingInProgress = false;
</span><del>-    
</del><ins>+
</ins><span class="cx"> #if ENABLE(VIDEO_TRACK)
</span><span class="cx">     if (!RuntimeEnabledFeatures::sharedFeatures().webkitVideoTrackEnabled())
</span><span class="cx">         return;
</span><span class="lines">@@ -786,7 +786,7 @@
</span><span class="cx">     LOG(Media, &quot;HTMLMediaElement::scheduleEvent - scheduling '%s'&quot;, eventName.string().ascii().data());
</span><span class="cx"> #endif
</span><span class="cx">     RefPtr&lt;Event&gt; event = Event::create(eventName, false, true);
</span><del>-    
</del><ins>+
</ins><span class="cx">     // Don't set the event target, the event queue will set it in GenericEventQueue::timerFired and setting it here
</span><span class="cx">     // will trigger an ASSERT if this element has been marked for deletion.
</span><span class="cx"> 
</span><span class="lines">@@ -817,7 +817,7 @@
</span><span class="cx">     m_pendingActionFlags = 0;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-PassRefPtr&lt;MediaError&gt; HTMLMediaElement::error() const 
</del><ins>+PassRefPtr&lt;MediaError&gt; HTMLMediaElement::error() const
</ins><span class="cx"> {
</span><span class="cx">     return m_error;
</span><span class="cx"> }
</span><span class="lines">@@ -874,7 +874,7 @@
</span><span class="cx">             canPlay = ASCIILiteral(&quot;probably&quot;);
</span><span class="cx">             break;
</span><span class="cx">     }
</span><del>-    
</del><ins>+
</ins><span class="cx">     LOG(Media, &quot;HTMLMediaElement::canPlayType(%s, %s, %s) -&gt; %s&quot;, mimeType.utf8().data(), keySystem.utf8().data(), url.stringCenterEllipsizedToLength().utf8().data(), canPlay.utf8().data());
</span><span class="cx"> 
</span><span class="cx">     return canPlay;
</span><span class="lines">@@ -883,9 +883,9 @@
</span><span class="cx"> void HTMLMediaElement::load()
</span><span class="cx"> {
</span><span class="cx">     Ref&lt;HTMLMediaElement&gt; protect(*this); // loadInternal may result in a 'beforeload' event, which can make arbitrary DOM mutations.
</span><del>-    
</del><ins>+
</ins><span class="cx">     LOG(Media, &quot;HTMLMediaElement::load()&quot;);
</span><del>-    
</del><ins>+
</ins><span class="cx">     if (!m_mediaSession-&gt;dataLoadingPermitted(*this))
</span><span class="cx">         return;
</span><span class="cx">     if (ScriptController::processingUserGesture())
</span><span class="lines">@@ -917,7 +917,7 @@
</span><span class="cx">     m_loadState = WaitingForSource;
</span><span class="cx">     m_currentSourceNode = 0;
</span><span class="cx"> 
</span><del>-    // 2 - If there are any tasks from the media element's media element event task source in 
</del><ins>+    // 2 - If there are any tasks from the media element's media element event task source in
</ins><span class="cx">     // one of the task queues, then remove those tasks.
</span><span class="cx">     cancelPendingEventsAndCallbacks();
</span><span class="cx"> 
</span><span class="lines">@@ -999,7 +999,7 @@
</span><span class="cx">     m_lastSeekTime = MediaTime::zeroTime();
</span><span class="cx"> 
</span><span class="cx">     // The spec doesn't say to block the load event until we actually run the asynchronous section
</span><del>-    // algorithm, but do it now because we won't start that until after the timer fires and the 
</del><ins>+    // algorithm, but do it now because we won't start that until after the timer fires and the
</ins><span class="cx">     // event may have already fired by then.
</span><span class="cx">     MediaPlayer::Preload effectivePreload = m_mediaSession-&gt;effectivePreloadForElement(*this);
</span><span class="cx">     if (effectivePreload != MediaPlayer::None)
</span><span class="lines">@@ -1033,8 +1033,8 @@
</span><span class="cx"> 
</span><span class="cx">     clearFlags(m_pendingActionFlags, LoadMediaResource);
</span><span class="cx"> 
</span><del>-    // Once the page has allowed an element to load media, it is free to load at will. This allows a 
-    // playlist that starts in a foreground tab to continue automatically if the tab is subsequently 
</del><ins>+    // Once the page has allowed an element to load media, it is free to load at will. This allows a
+    // playlist that starts in a foreground tab to continue automatically if the tab is subsequently
</ins><span class="cx">     // put into the background.
</span><span class="cx">     m_mediaSession-&gt;removeBehaviorRestriction(HTMLMediaSession::RequirePageConsentToLoadMedia);
</span><span class="cx"> 
</span><span class="lines">@@ -1068,16 +1068,16 @@
</span><span class="cx">     // 3 - If the media element has a src attribute, then let mode be attribute.
</span><span class="cx">     Mode mode = attribute;
</span><span class="cx">     if (!fastHasAttribute(srcAttr)) {
</span><del>-        // Otherwise, if the media element does not have a src attribute but has a source 
-        // element child, then let mode be children and let candidate be the first such 
</del><ins>+        // Otherwise, if the media element does not have a src attribute but has a source
+        // element child, then let mode be children and let candidate be the first such
</ins><span class="cx">         // source element child in tree order.
</span><span class="cx">         if (auto firstSource = childrenOfType&lt;HTMLSourceElement&gt;(*this).first()) {
</span><span class="cx">             mode = children;
</span><span class="cx">             m_nextChildNodeToConsider = firstSource;
</span><span class="cx">             m_currentSourceNode = 0;
</span><span class="cx">         } else {
</span><del>-            // Otherwise the media element has neither a src attribute nor a source element 
-            // child: set the networkState to NETWORK_EMPTY, and abort these steps; the 
</del><ins>+            // Otherwise the media element has neither a src attribute nor a source element
+            // child: set the networkState to NETWORK_EMPTY, and abort these steps; the
</ins><span class="cx">             // synchronous section ends.
</span><span class="cx">             m_loadState = WaitingForSource;
</span><span class="cx">             setShouldDelayLoadEvent(false);
</span><span class="lines">@@ -1088,7 +1088,7 @@
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    // 4 - Set the media element's delaying-the-load-event flag to true (this delays the load event), 
</del><ins>+    // 4 - Set the media element's delaying-the-load-event flag to true (this delays the load event),
</ins><span class="cx">     // and set its networkState to NETWORK_LOADING.
</span><span class="cx">     setShouldDelayLoadEvent(true);
</span><span class="cx">     m_networkState = NETWORK_LOADING;
</span><span class="lines">@@ -1179,8 +1179,8 @@
</span><span class="cx">         mediaLoadingFailed(MediaPlayer::FormatError);
</span><span class="cx">         return;
</span><span class="cx">     }
</span><del>-    
-    // The resource fetch algorithm 
</del><ins>+
+    // The resource fetch algorithm
</ins><span class="cx">     m_networkState = NETWORK_LOADING;
</span><span class="cx"> 
</span><span class="cx">     // If the url should be loaded from the application cache, pass the url of the cached file
</span><span class="lines">@@ -1212,7 +1212,7 @@
</span><span class="cx">         m_mediaSession-&gt;removeBehaviorRestriction(HTMLMediaSession::RequireUserGestureForRateChange);
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-    if (m_sendProgressEvents) 
</del><ins>+    if (m_sendProgressEvents)
</ins><span class="cx">         startProgressEventTimer();
</span><span class="cx"> 
</span><span class="cx">     bool privateMode = document().page() &amp;&amp; document().page()-&gt;usesEphemeralSession();
</span><span class="lines">@@ -1509,7 +1509,7 @@
</span><span class="cx">             HTMLTrackElement* trackElement = static_cast&lt;LoadableTextTrack*&gt;(affectedTracks[i])-&gt;trackElement();
</span><span class="cx">             ASSERT(trackElement);
</span><span class="cx">             event-&gt;setTarget(trackElement);
</span><del>-            
</del><ins>+
</ins><span class="cx">             m_asyncEventQueue.enqueueEvent(event.release());
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="lines">@@ -1535,7 +1535,7 @@
</span><span class="cx"> {
</span><span class="cx">     // 4.8.10.12.1 Text track model
</span><span class="cx">     // ...
</span><del>-    // The text tracks of a media element are ready if all the text tracks whose mode was not 
</del><ins>+    // The text tracks of a media element are ready if all the text tracks whose mode was not
</ins><span class="cx">     // in the disabled state when the element's resource selection algorithm last started now
</span><span class="cx">     // have a text track readiness state of loaded or failed to load.
</span><span class="cx">     for (unsigned i = 0; i &lt; m_textTracksWhenResourceSelectionBegan.size(); ++i) {
</span><span class="lines">@@ -1586,10 +1586,10 @@
</span><span class="cx">     // If this is the first added track, create the list of text tracks.
</span><span class="cx">     if (!m_textTracks)
</span><span class="cx">         m_textTracks = TextTrackList::create(this, ActiveDOMObject::scriptExecutionContext());
</span><del>-    
</del><ins>+
</ins><span class="cx">     // Mark this track as &quot;configured&quot; so configureTextTracks won't change the mode again.
</span><span class="cx">     track-&gt;setHasBeenConfigured(true);
</span><del>-    
</del><ins>+
</ins><span class="cx">     if (track-&gt;mode() != TextTrack::disabledKeyword() &amp;&amp; trackIsLoaded)
</span><span class="cx">         textTrackAddCues(track, track-&gt;cues());
</span><span class="cx"> 
</span><span class="lines">@@ -1597,7 +1597,7 @@
</span><span class="cx">     if (platformTextTrackMenu())
</span><span class="cx">         platformTextTrackMenu()-&gt;trackWasSelected(track-&gt;platformTextTrack());
</span><span class="cx"> #endif
</span><del>-    
</del><ins>+
</ins><span class="cx">     configureTextTrackDisplay(AssumeTextTrackVisibilityChanged);
</span><span class="cx"> 
</span><span class="cx">     if (m_textTracks &amp;&amp; m_textTracks-&gt;contains(track))
</span><span class="lines">@@ -1636,7 +1636,7 @@
</span><span class="cx">         updateActiveTextTrackCues(currentMediaTime());
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void HTMLMediaElement::textTrackAddCues(TextTrack* track, const TextTrackCueList* cues) 
</del><ins>+void HTMLMediaElement::textTrackAddCues(TextTrack* track, const TextTrackCueList* cues)
</ins><span class="cx"> {
</span><span class="cx">     if (track-&gt;mode() == TextTrack::disabledKeyword())
</span><span class="cx">         return;
</span><span class="lines">@@ -1646,7 +1646,7 @@
</span><span class="cx">         textTrackAddCue(track, cues-&gt;item(i));
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void HTMLMediaElement::textTrackRemoveCues(TextTrack*, const TextTrackCueList* cues) 
</del><ins>+void HTMLMediaElement::textTrackRemoveCues(TextTrack*, const TextTrackCueList* cues)
</ins><span class="cx"> {
</span><span class="cx">     TrackDisplayUpdateScope scope(this);
</span><span class="cx">     for (size_t i = 0; i &lt; cues-&gt;length(); ++i)
</span><span class="lines">@@ -1766,8 +1766,8 @@
</span><span class="cx">     m_loadState = WaitingForSource;
</span><span class="cx">     m_currentSourceNode = 0;
</span><span class="cx"> 
</span><del>-    // 4.8.10.5 
-    // 6 - Reaching this step indicates that the media resource failed to load or that the given 
</del><ins>+    // 4.8.10.5
+    // 6 - Reaching this step indicates that the media resource failed to load or that the given
</ins><span class="cx">     // URL could not be resolved. In one atomic operation, run the following steps:
</span><span class="cx"> 
</span><span class="cx">     // 6.1 - Set the error attribute to a new MediaError object whose code attribute is set to
</span><span class="lines">@@ -1790,7 +1790,7 @@
</span><span class="cx">     // 8 - Set the element's delaying-the-load-event flag to false. This stops delaying the load event.
</span><span class="cx">     setShouldDelayLoadEvent(false);
</span><span class="cx"> 
</span><del>-    // 9 - Abort these steps. Until the load() method is invoked or the src attribute is changed, 
</del><ins>+    // 9 - Abort these steps. Until the load() method is invoked or the src attribute is changed,
</ins><span class="cx">     // the element won't attempt to load another resource.
</span><span class="cx"> 
</span><span class="cx">     updateDisplayState();
</span><span class="lines">@@ -1807,7 +1807,7 @@
</span><span class="cx">     stopPeriodicTimers();
</span><span class="cx">     m_loadState = WaitingForSource;
</span><span class="cx"> 
</span><del>-    // 2 - Set the error attribute to a new MediaError object whose code attribute is 
</del><ins>+    // 2 - Set the error attribute to a new MediaError object whose code attribute is
</ins><span class="cx">     // set to MEDIA_ERR_NETWORK/MEDIA_ERR_DECODE.
</span><span class="cx">     if (error == MediaPlayer::NetworkError)
</span><span class="cx">         m_error = MediaError::create(MediaError::MEDIA_ERR_NETWORK);
</span><span class="lines">@@ -1903,20 +1903,20 @@
</span><span class="cx"> void HTMLMediaElement::mediaLoadingFailed(MediaPlayer::NetworkState error)
</span><span class="cx"> {
</span><span class="cx">     stopPeriodicTimers();
</span><del>-    
</del><ins>+
</ins><span class="cx">     // If we failed while trying to load a &lt;source&gt; element, the movie was never parsed, and there are more
</span><span class="cx">     // &lt;source&gt; children, schedule the next one
</span><span class="cx">     if (m_readyState &lt; HAVE_METADATA &amp;&amp; m_loadState == LoadingFromSourceElement) {
</span><del>-        
</del><ins>+
</ins><span class="cx">         // resource selection algorithm
</span><span class="cx">         // Step 9.Otherwise.9 - Failed with elements: Queue a task, using the DOM manipulation task source, to fire a simple event named error at the candidate element.
</span><span class="cx">         if (m_currentSourceNode)
</span><span class="cx">             m_currentSourceNode-&gt;scheduleErrorEvent();
</span><span class="cx">         else
</span><span class="cx">             LOG(Media, &quot;HTMLMediaElement::setNetworkState - error event not sent, &lt;source&gt; was removed&quot;);
</span><del>-        
</del><ins>+
</ins><span class="cx">         // 9.Otherwise.10 - Asynchronously await a stable state. The synchronous section consists of all the remaining steps of this algorithm until the algorithm says the synchronous section has ended.
</span><del>-        
</del><ins>+
</ins><span class="cx">         // 9.Otherwise.11 - Forget the media element's media-resource-specific tracks.
</span><span class="cx">         forgetResourceSpecificTracks();
</span><span class="cx"> 
</span><span class="lines">@@ -1927,15 +1927,15 @@
</span><span class="cx">             LOG(Media, &quot;HTMLMediaElement::setNetworkState - no more &lt;source&gt; elements, waiting&quot;);
</span><span class="cx">             waitForSourceChange();
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         return;
</span><span class="cx">     }
</span><del>-    
</del><ins>+
</ins><span class="cx">     if ((error == MediaPlayer::NetworkError &amp;&amp; m_readyState &gt;= HAVE_METADATA) || error == MediaPlayer::DecodeError)
</span><span class="cx">         mediaLoadingFailedFatally(error);
</span><span class="cx">     else if ((error == MediaPlayer::FormatError || error == MediaPlayer::NetworkError) &amp;&amp; m_loadState == LoadingFromSrcAttr)
</span><span class="cx">         noneSupported();
</span><del>-    
</del><ins>+
</ins><span class="cx">     updateDisplayState();
</span><span class="cx">     if (hasMediaControls()) {
</span><span class="cx">         mediaControls()-&gt;reset();
</span><span class="lines">@@ -2029,7 +2029,7 @@
</span><span class="cx">         return;
</span><span class="cx">     bool tracksAreReady = true;
</span><span class="cx"> #endif
</span><del>-    
</del><ins>+
</ins><span class="cx">     if (tracksAreReady)
</span><span class="cx">         m_readyState = newState;
</span><span class="cx">     else {
</span><span class="lines">@@ -2040,7 +2040,7 @@
</span><span class="cx">         else
</span><span class="cx">             m_readyState = HAVE_CURRENT_DATA;
</span><span class="cx">     }
</span><del>-    
</del><ins>+
</ins><span class="cx">     if (oldState &gt; m_readyStateMaximum)
</span><span class="cx">         m_readyStateMaximum = oldState;
</span><span class="cx"> 
</span><span class="lines">@@ -2186,7 +2186,7 @@
</span><span class="cx">     initializer.keySystem = keySystem;
</span><span class="cx">     initializer.sessionId = sessionId;
</span><span class="cx">     initializer.message = Uint8Array::create(message, messageLength);
</span><del>-    initializer.defaultURL = defaultURL; 
</del><ins>+    initializer.defaultURL = defaultURL;
</ins><span class="cx">     initializer.bubbles = false;
</span><span class="cx">     initializer.cancelable = false;
</span><span class="cx"> 
</span><span class="lines">@@ -2420,7 +2420,7 @@
</span><span class="cx">     MediaTime positiveTolerance = m_pendingSeek-&gt;positiveTolerance;
</span><span class="cx">     m_pendingSeek = nullptr;
</span><span class="cx"> 
</span><del>-    // 6 - If the new playback position is later than the end of the media resource, then let it be the end 
</del><ins>+    // 6 - If the new playback position is later than the end of the media resource, then let it be the end
</ins><span class="cx">     // of the media resource instead.
</span><span class="cx">     time = std::min(time, durationMediaTime());
</span><span class="cx"> 
</span><span class="lines">@@ -2431,7 +2431,7 @@
</span><span class="cx">     // Ask the media engine for the time value in the movie's time scale before comparing with current time. This
</span><span class="cx">     // is necessary because if the seek time is not equal to currentTime but the delta is less than the movie's
</span><span class="cx">     // time scale, we will ask the media engine to &quot;seek&quot; to the current movie time, which may be a noop and
</span><del>-    // not generate a timechanged callback. This means m_seeking will never be cleared and we will never 
</del><ins>+    // not generate a timechanged callback. This means m_seeking will never be cleared and we will never
</ins><span class="cx">     // fire a 'seeked' event.
</span><span class="cx"> #if !LOG_DISABLED
</span><span class="cx">     MediaTime mediaTime = m_player-&gt;mediaTimeForTimeValue(time);
</span><span class="lines">@@ -2441,13 +2441,13 @@
</span><span class="cx">     time = m_player-&gt;mediaTimeForTimeValue(time);
</span><span class="cx"> 
</span><span class="cx">     // 8 - If the (possibly now changed) new playback position is not in one of the ranges given in the
</span><del>-    // seekable attribute, then let it be the position in one of the ranges given in the seekable attribute 
</del><ins>+    // seekable attribute, then let it be the position in one of the ranges given in the seekable attribute
</ins><span class="cx">     // that is the nearest to the new playback position. ... If there are no ranges given in the seekable
</span><span class="cx">     // attribute then set the seeking IDL attribute to false and abort these steps.
</span><span class="cx">     RefPtr&lt;TimeRanges&gt; seekableRanges = seekable();
</span><span class="cx"> 
</span><span class="cx">     // Short circuit seeking to the current time by just firing the events if no seek is required.
</span><del>-    // Don't skip calling the media engine if we are in poster mode because a seek should always 
</del><ins>+    // Don't skip calling the media engine if we are in poster mode because a seek should always
</ins><span class="cx">     // cancel poster display.
</span><span class="cx">     bool noSeekRequired = !seekableRanges-&gt;length() || (time == now &amp;&amp; displayMode() != Poster);
</span><span class="cx"> 
</span><span class="lines">@@ -2724,7 +2724,7 @@
</span><span class="cx">     LOG(Media, &quot;HTMLMediaElement::setWebkitPreservesPitch(%s)&quot;, boolString(preservesPitch));
</span><span class="cx"> 
</span><span class="cx">     m_webkitPreservesPitch = preservesPitch;
</span><del>-    
</del><ins>+
</ins><span class="cx">     if (!m_player)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="lines">@@ -2734,7 +2734,7 @@
</span><span class="cx"> bool HTMLMediaElement::ended() const
</span><span class="cx"> {
</span><span class="cx">     // 4.8.10.8 Playing the media resource
</span><del>-    // The ended attribute must return true if the media element has ended 
</del><ins>+    // The ended attribute must return true if the media element has ended
</ins><span class="cx">     // playback and the direction of playback is forwards, and false otherwise.
</span><span class="cx">     return endedPlayback() &amp;&amp; effectivePlaybackRate() &gt; 0;
</span><span class="cx"> }
</span><span class="lines">@@ -2790,12 +2790,12 @@
</span><span class="cx"> void HTMLMediaElement::playInternal()
</span><span class="cx"> {
</span><span class="cx">     LOG(Media, &quot;HTMLMediaElement::playInternal&quot;);
</span><del>-    
</del><ins>+
</ins><span class="cx">     if (!m_mediaSession-&gt;clientWillBeginPlayback()) {
</span><span class="cx">         LOG(Media, &quot;  returning because of interruption&quot;);
</span><span class="cx">         return;
</span><span class="cx">     }
</span><del>-    
</del><ins>+
</ins><span class="cx">     // 4.8.10.9. Playing the media resource
</span><span class="cx">     if (!m_player || m_networkState == NETWORK_EMPTY)
</span><span class="cx">         scheduleDelayedAction(LoadMediaResource);
</span><span class="lines">@@ -2843,7 +2843,7 @@
</span><span class="cx">         LOG(Media, &quot;  returning because of interruption&quot;);
</span><span class="cx">         return;
</span><span class="cx">     }
</span><del>-    
</del><ins>+
</ins><span class="cx">     // 4.8.10.9. Playing the media resource
</span><span class="cx">     if (!m_player || m_networkState == NETWORK_EMPTY) {
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="lines">@@ -3027,7 +3027,7 @@
</span><span class="cx">         ec = INDEX_SIZE_ERR;
</span><span class="cx">         return;
</span><span class="cx">     }
</span><del>-    
</del><ins>+
</ins><span class="cx"> #if !PLATFORM(IOS)
</span><span class="cx">     if (m_volume != vol) {
</span><span class="cx">         m_volume = vol;
</span><span class="lines">@@ -3075,7 +3075,7 @@
</span><span class="cx">     if (canPlay()) {
</span><span class="cx">         updatePlaybackRate();
</span><span class="cx">         playInternal();
</span><del>-    } else 
</del><ins>+    } else
</ins><span class="cx">         pauseInternal();
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -3085,13 +3085,13 @@
</span><span class="cx"> 
</span><span class="cx">     if (!paused()) {
</span><span class="cx">         if (ended()) {
</span><del>-            // Because a media element stays in non-paused state when it reaches end, playback resumes 
-            // when the slider is dragged from the end to another position unless we pause first. Do 
</del><ins>+            // Because a media element stays in non-paused state when it reaches end, playback resumes
+            // when the slider is dragged from the end to another position unless we pause first. Do
</ins><span class="cx">             // a &quot;hard pause&quot; so an event is generated, since we want to stay paused after scrubbing finishes.
</span><span class="cx">             pause();
</span><span class="cx">         } else {
</span><span class="cx">             // Not at the end but we still want to pause playback so the media engine doesn't try to
</span><del>-            // continue playing during scrubbing. Pause without generating an event as we will 
</del><ins>+            // continue playing during scrubbing. Pause without generating an event as we will
</ins><span class="cx">             // unpause after scrubbing finishes.
</span><span class="cx">             setPausedInternal(true);
</span><span class="cx">         }
</span><span class="lines">@@ -3183,7 +3183,7 @@
</span><span class="cx">             pauseInternal();
</span><span class="cx">         }
</span><span class="cx">     }
</span><del>-    
</del><ins>+
</ins><span class="cx">     scheduleTimeupdateEvent(true);
</span><span class="cx"> 
</span><span class="cx">     if (!effectivePlaybackRate())
</span><span class="lines">@@ -3261,12 +3261,12 @@
</span><span class="cx"> {
</span><span class="cx">     if (!RuntimeEnabledFeatures::sharedFeatures().webkitVideoTrackEnabled())
</span><span class="cx">         return;
</span><del>-    
</del><ins>+
</ins><span class="cx">     // 4.8.10.12.2 Sourcing in-band text tracks
</span><span class="cx">     // 1. Associate the relevant data with a new text track and its corresponding new TextTrack object.
</span><span class="cx">     RefPtr&lt;InbandTextTrack&gt; textTrack = InbandTextTrack::create(ActiveDOMObject::scriptExecutionContext(), this, prpTrack);
</span><span class="cx">     textTrack-&gt;setMediaElement(this);
</span><del>-    
</del><ins>+
</ins><span class="cx">     // 2. Set the new text track's kind, label, and language based on the semantics of the relevant data,
</span><span class="cx">     // as defined by the relevant specification. If there is no label in that data, then the label must
</span><span class="cx">     // be set to the empty string.
</span><span class="lines">@@ -3277,15 +3277,15 @@
</span><span class="cx">     // 5. Populate the new text track's list of cues with the cues parsed so far, folllowing the guidelines for exposing
</span><span class="cx">     // cues, and begin updating it dynamically as necessary.
</span><span class="cx">     //   - Thess are all done by the media engine.
</span><del>-    
</del><ins>+
</ins><span class="cx">     // 6. Set the new text track's readiness state to loaded.
</span><span class="cx">     textTrack-&gt;setReadinessState(TextTrack::Loaded);
</span><del>-    
</del><ins>+
</ins><span class="cx">     // 7. Set the new text track's mode to the mode consistent with the user's preferences and the requirements of
</span><span class="cx">     // the relevant specification for the data.
</span><span class="cx">     //  - This will happen in configureTextTracks()
</span><span class="cx">     scheduleDelayedAction(ConfigureTextTracks);
</span><del>-    
</del><ins>+
</ins><span class="cx">     // 8. Add the new text track to the media element's list of text tracks.
</span><span class="cx">     // 9. Fire an event with the name addtrack, that does not bubble and is not cancelable, and that uses the TrackEvent
</span><span class="cx">     // interface, with the track attribute initialized to the text track's TextTrack object, at the media element's
</span><span class="lines">@@ -3338,7 +3338,7 @@
</span><span class="cx">         size_t i;
</span><span class="cx">         for (i = 0; i &lt; m_textTracks-&gt;length(); ++i) {
</span><span class="cx">             textTrack = m_textTracks-&gt;item(i);
</span><del>-            
</del><ins>+
</ins><span class="cx">             if (textTrack-&gt;platformTextTrack() == platformTrack)
</span><span class="cx">                 break;
</span><span class="cx">         }
</span><span class="lines">@@ -3353,11 +3353,11 @@
</span><span class="cx"> {
</span><span class="cx">     if (!m_textTracks || !m_textTracks-&gt;length())
</span><span class="cx">         return Vector&lt;RefPtr&lt;PlatformTextTrack&gt;&gt;();
</span><del>-    
</del><ins>+
</ins><span class="cx">     Vector&lt;RefPtr&lt;PlatformTextTrack&gt;&gt; platformTracks;
</span><span class="cx">     for (size_t i = 0; i &lt; m_textTracks-&gt;length(); ++i)
</span><span class="cx">         platformTracks.append(m_textTracks-&gt;item(i)-&gt;platformTextTrack());
</span><del>-    
</del><ins>+
</ins><span class="cx">     return platformTracks;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -3365,7 +3365,7 @@
</span><span class="cx"> {
</span><span class="cx">     if (!m_textTracks || !m_textTracks-&gt;length() || !platformTextTrackMenu())
</span><span class="cx">         return;
</span><del>-    
</del><ins>+
</ins><span class="cx">     m_platformMenu-&gt;tracksDidChange();
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -3386,7 +3386,7 @@
</span><span class="cx">     return m_platformMenu.get();
</span><span class="cx"> }
</span><span class="cx"> #endif // #if USE(PLATFORM_TEXT_TRACK_MENU)
</span><del>-    
</del><ins>+
</ins><span class="cx"> void HTMLMediaElement::closeCaptionTracksChanged()
</span><span class="cx"> {
</span><span class="cx">     if (hasMediaControls())
</span><span class="lines">@@ -3492,7 +3492,7 @@
</span><span class="cx">     // 3. If the language argument was omitted, let language be the empty string.
</span><span class="cx">     // 4. Create a new TextTrack object.
</span><span class="cx"> 
</span><del>-    // 5. Create a new text track corresponding to the new object, and set its text track kind to kind, its text 
</del><ins>+    // 5. Create a new text track corresponding to the new object, and set its text track kind to kind, its text
</ins><span class="cx">     // track label to label, its text track language to language...
</span><span class="cx">     RefPtr&lt;TextTrack&gt; textTrack = TextTrack::create(ActiveDOMObject::scriptExecutionContext(), this, kind, emptyString(), label, language);
</span><span class="cx"> 
</span><span class="lines">@@ -3522,7 +3522,7 @@
</span><span class="cx">     return m_audioTracks.get();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-TextTrackList* HTMLMediaElement::textTracks() 
</del><ins>+TextTrackList* HTMLMediaElement::textTracks()
</ins><span class="cx"> {
</span><span class="cx">     if (!RuntimeEnabledFeatures::sharedFeatures().webkitVideoTrackEnabled())
</span><span class="cx">         return 0;
</span><span class="lines">@@ -3552,15 +3552,15 @@
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     // 4.8.10.12.3 Sourcing out-of-band text tracks
</span><del>-    // When a track element's parent element changes and the new parent is a media element, 
-    // then the user agent must add the track element's corresponding text track to the 
</del><ins>+    // When a track element's parent element changes and the new parent is a media element,
+    // then the user agent must add the track element's corresponding text track to the
</ins><span class="cx">     // media element's list of text tracks ... [continues in TextTrackList::append]
</span><span class="cx">     RefPtr&lt;TextTrack&gt; textTrack = trackElement-&gt;track();
</span><span class="cx">     if (!textTrack)
</span><span class="cx">         return;
</span><del>-    
</del><ins>+
</ins><span class="cx">     addTextTrack(textTrack.release());
</span><del>-    
</del><ins>+
</ins><span class="cx">     // Do not schedule the track loading until parsing finishes so we don't start before all tracks
</span><span class="cx">     // in the markup have been added.
</span><span class="cx">     if (!m_parsingInProgress)
</span><span class="lines">@@ -3587,15 +3587,15 @@
</span><span class="cx">     RefPtr&lt;TextTrack&gt; textTrack = trackElement-&gt;track();
</span><span class="cx">     if (!textTrack)
</span><span class="cx">         return;
</span><del>-    
</del><ins>+
</ins><span class="cx">     textTrack-&gt;setHasBeenConfigured(false);
</span><span class="cx"> 
</span><span class="cx">     if (!m_textTracks)
</span><span class="cx">         return;
</span><del>-    
</del><ins>+
</ins><span class="cx">     // 4.8.10.12.3 Sourcing out-of-band text tracks
</span><del>-    // When a track element's parent element changes and the old parent was a media element, 
-    // then the user agent must remove the track element's corresponding text track from the 
</del><ins>+    // When a track element's parent element changes and the old parent was a media element,
+    // then the user agent must remove the track element's corresponding text track from the
</ins><span class="cx">     // media element's list of text tracks.
</span><span class="cx">     removeTextTrack(textTrack.get());
</span><span class="cx"> 
</span><span class="lines">@@ -3675,7 +3675,7 @@
</span><span class="cx"> 
</span><span class="cx">     if (!trackToEnable &amp;&amp; defaultTrack)
</span><span class="cx">         trackToEnable = defaultTrack;
</span><del>-    
</del><ins>+
</ins><span class="cx">     // If no track matches the user's preferred language, none was marked as 'default', and there is a forced subtitle track
</span><span class="cx">     // in the same language as the language of the primary audio track, enable it.
</span><span class="cx">     if (!trackToEnable &amp;&amp; forcedSubitleTrack)
</span><span class="lines">@@ -3686,7 +3686,7 @@
</span><span class="cx">         if (!trackToEnable &amp;&amp; !defaultTrack &amp;&amp; group.visibleTrack)
</span><span class="cx">             trackToEnable = group.visibleTrack;
</span><span class="cx">     }
</span><del>-    
</del><ins>+
</ins><span class="cx">     // If no track matches the user's preferred language and non was marked 'default', enable the first track
</span><span class="cx">     // because the user has explicitly stated a preference for this kind of track.
</span><span class="cx">     if (!trackToEnable &amp;&amp; fallbackTrack)
</span><span class="lines">@@ -3696,7 +3696,7 @@
</span><span class="cx">         m_subtitleTrackLanguage = trackToEnable-&gt;language();
</span><span class="cx">     else
</span><span class="cx">         m_subtitleTrackLanguage = emptyString();
</span><del>-    
</del><ins>+
</ins><span class="cx">     if (currentlyEnabledTracks.size()) {
</span><span class="cx">         for (size_t i = 0; i &lt; currentlyEnabledTracks.size(); ++i) {
</span><span class="cx">             RefPtr&lt;TextTrack&gt; textTrack = currentlyEnabledTracks[i];
</span><span class="lines">@@ -3722,12 +3722,12 @@
</span><span class="cx"> static JSC::JSValue controllerJSValue(JSC::ExecState&amp; exec, JSDOMGlobalObject&amp; globalObject, HTMLMediaElement&amp; media)
</span><span class="cx"> {
</span><span class="cx">     auto mediaJSWrapper = toJS(&amp;exec, &amp;globalObject, &amp;media);
</span><del>-    
</del><ins>+
</ins><span class="cx">     // Retrieve the controller through the JS object graph
</span><span class="cx">     JSC::JSObject* mediaJSWrapperObject = JSC::jsDynamicCast&lt;JSC::JSObject*&gt;(mediaJSWrapper);
</span><span class="cx">     if (!mediaJSWrapperObject)
</span><span class="cx">         return JSC::jsNull();
</span><del>-    
</del><ins>+
</ins><span class="cx">     JSC::Identifier controlsHost(&amp;exec.vm(), &quot;controlsHost&quot;);
</span><span class="cx">     JSC::JSValue controlsHostJSWrapper = mediaJSWrapperObject-&gt;get(&amp;exec, controlsHost);
</span><span class="cx">     if (exec.hadException())
</span><span class="lines">@@ -3744,7 +3744,7 @@
</span><span class="cx"> 
</span><span class="cx">     return controllerJSWrapper;
</span><span class="cx"> }
</span><del>-    
</del><ins>+
</ins><span class="cx"> void HTMLMediaElement::updateCaptionContainer()
</span><span class="cx"> {
</span><span class="cx">     LOG(Media, &quot;HTMLMediaElement::updateCaptionContainer&quot;);
</span><span class="lines">@@ -3796,7 +3796,7 @@
</span><span class="cx">         exec-&gt;clearException();
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><del>-    
</del><ins>+
</ins><span class="cx"> void HTMLMediaElement::setSelectedTextTrack(TextTrack* trackToSelect)
</span><span class="cx"> {
</span><span class="cx">     TextTrackList* trackList = textTracks();
</span><span class="lines">@@ -3806,7 +3806,7 @@
</span><span class="cx">     if (trackToSelect != TextTrack::captionMenuOffItem() &amp;&amp; trackToSelect != TextTrack::captionMenuAutomaticItem()) {
</span><span class="cx">         if (!trackList-&gt;contains(trackToSelect))
</span><span class="cx">             return;
</span><del>-        
</del><ins>+
</ins><span class="cx">         for (int i = 0, length = trackList-&gt;length(); i &lt; length; ++i) {
</span><span class="cx">             TextTrack* track = trackList-&gt;item(i);
</span><span class="cx">             if (!trackToSelect || track != trackToSelect)
</span><span class="lines">@@ -3872,19 +3872,19 @@
</span><span class="cx">             currentGroup-&gt;defaultTrack = textTrack;
</span><span class="cx"> 
</span><span class="cx">         // Do not add this track to the group if it has already been automatically configured
</span><del>-        // as we only want to call configureTextTrack once per track so that adding another 
-        // track after the initial configuration doesn't reconfigure every track - only those 
-        // that should be changed by the new addition. For example all metadata tracks are 
-        // disabled by default, and we don't want a track that has been enabled by script 
</del><ins>+        // as we only want to call configureTextTrack once per track so that adding another
+        // track after the initial configuration doesn't reconfigure every track - only those
+        // that should be changed by the new addition. For example all metadata tracks are
+        // disabled by default, and we don't want a track that has been enabled by script
</ins><span class="cx">         // to be disabled automatically when a new metadata track is added later.
</span><span class="cx">         if (textTrack-&gt;hasBeenConfigured())
</span><span class="cx">             continue;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (textTrack-&gt;language().length())
</span><span class="cx">             currentGroup-&gt;hasSrcLang = true;
</span><span class="cx">         currentGroup-&gt;tracks.append(textTrack);
</span><span class="cx">     }
</span><del>-    
</del><ins>+
</ins><span class="cx">     if (captionAndSubtitleTracks.tracks.size())
</span><span class="cx">         configureTextTrackGroup(captionAndSubtitleTracks);
</span><span class="cx">     if (descriptionTracks.tracks.size())
</span><span class="lines">@@ -3966,7 +3966,7 @@
</span><span class="cx"> #endif
</span><span class="cx">         if (mediaURL.isEmpty())
</span><span class="cx">             goto check_again;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (source-&gt;fastHasAttribute(mediaAttr)) {
</span><span class="cx">             MediaQueryEvaluator screenEval(&quot;screen&quot;, document().frame(), renderer() ? &amp;renderer()-&gt;style() : nullptr);
</span><span class="cx">             RefPtr&lt;MediaQuerySet&gt; media = MediaQuerySet::createAllowingDescriptionSyntax(source-&gt;media());
</span><span class="lines">@@ -3974,7 +3974,7 @@
</span><span class="cx">             if (shouldLog)
</span><span class="cx">                 LOG(Media, &quot;HTMLMediaElement::selectNextSourceChild - 'media' is %s&quot;, source-&gt;media().utf8().data());
</span><span class="cx"> #endif
</span><del>-            if (!screenEval.eval(media.get())) 
</del><ins>+            if (!screenEval.eval(media.get()))
</ins><span class="cx">                 goto check_again;
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="lines">@@ -4052,13 +4052,13 @@
</span><span class="cx">         LOG(Media, &quot;HTMLMediaElement::sourceWasAdded - 'src' is %s&quot;, urlForLoggingMedia(url).utf8().data());
</span><span class="cx">     }
</span><span class="cx"> #endif
</span><del>-    
</del><ins>+
</ins><span class="cx">     // We should only consider a &lt;source&gt; element when there is not src attribute at all.
</span><span class="cx">     if (fastHasAttribute(srcAttr))
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    // 4.8.8 - If a source element is inserted as a child of a media element that has no src 
-    // attribute and whose networkState has the value NETWORK_EMPTY, the user agent must invoke 
</del><ins>+    // 4.8.8 - If a source element is inserted as a child of a media element that has no src
+    // attribute and whose networkState has the value NETWORK_EMPTY, the user agent must invoke
</ins><span class="cx">     // the media element's resource selection algorithm.
</span><span class="cx">     if (networkState() == HTMLMediaElement::NETWORK_EMPTY) {
</span><span class="cx">         scheduleDelayedAction(LoadMediaResource);
</span><span class="lines">@@ -4074,17 +4074,17 @@
</span><span class="cx"> 
</span><span class="cx">     if (m_nextChildNodeToConsider)
</span><span class="cx">         return;
</span><del>-    
</del><ins>+
</ins><span class="cx">     // 4.8.9.5, resource selection algorithm, source elements section:
</span><span class="cx">     // 21. Wait until the node after pointer is a node other than the end of the list. (This step might wait forever.)
</span><span class="cx">     // 22. Asynchronously await a stable state...
</span><del>-    // 23. Set the element's delaying-the-load-event flag back to true (this delays the load event again, in case 
</del><ins>+    // 23. Set the element's delaying-the-load-event flag back to true (this delays the load event again, in case
</ins><span class="cx">     // it hasn't been fired yet).
</span><span class="cx">     setShouldDelayLoadEvent(true);
</span><span class="cx"> 
</span><span class="cx">     // 24. Set the networkState back to NETWORK_LOADING.
</span><span class="cx">     m_networkState = NETWORK_LOADING;
</span><del>-    
</del><ins>+
</ins><span class="cx">     // 25. Jump back to the find next candidate step above.
</span><span class="cx">     m_nextChildNodeToConsider = source;
</span><span class="cx">     scheduleNextSourceChild();
</span><span class="lines">@@ -4110,7 +4110,7 @@
</span><span class="cx">         LOG(Media, &quot;HTMLMediaElement::sourceRemoved - m_nextChildNodeToConsider set to %p&quot;, m_nextChildNodeToConsider.get());
</span><span class="cx">     } else if (source == m_currentSourceNode) {
</span><span class="cx">         // Clear the current source node pointer, but don't change the movie as the spec says:
</span><del>-        // 4.8.8 - Dynamically modifying a source element and its attribute when the element is already 
</del><ins>+        // 4.8.8 - Dynamically modifying a source element and its attribute when the element is already
</ins><span class="cx">         // inserted in a video or audio element will have no effect.
</span><span class="cx">         m_currentSourceNode = 0;
</span><span class="cx">         LOG(Media, &quot;HTMLMediaElement::sourceRemoved - m_currentSourceNode set to 0&quot;);
</span><span class="lines">@@ -4133,8 +4133,8 @@
</span><span class="cx">     // 4.8.10.9 step 14 &amp; 15.  Needed if no ReadyState change is associated with the seek.
</span><span class="cx">     if (m_seeking &amp;&amp; m_readyState &gt;= HAVE_CURRENT_DATA &amp;&amp; !m_player-&gt;seeking())
</span><span class="cx">         finishSeek();
</span><del>-    
-    // Always call scheduleTimeupdateEvent when the media engine reports a time discontinuity, 
</del><ins>+
+    // Always call scheduleTimeupdateEvent when the media engine reports a time discontinuity,
</ins><span class="cx">     // it will only queue a 'timeupdate' event if we haven't already posted one at the current
</span><span class="cx">     // movie time.
</span><span class="cx">     else
</span><span class="lines">@@ -4143,7 +4143,7 @@
</span><span class="cx">     MediaTime now = currentMediaTime();
</span><span class="cx">     MediaTime dur = durationMediaTime();
</span><span class="cx">     double playbackRate = effectivePlaybackRate();
</span><del>-    
</del><ins>+
</ins><span class="cx">     // When the current playback position reaches the end of the media resource then the user agent must follow these steps:
</span><span class="cx">     if (dur.isValid() &amp;&amp; dur) {
</span><span class="cx">         // If the media element has a loop attribute specified and does not have a current media controller,
</span><span class="lines">@@ -4362,7 +4362,7 @@
</span><span class="cx"> void HTMLMediaElement::mediaPlayerCharacteristicChanged(MediaPlayer*)
</span><span class="cx"> {
</span><span class="cx">     LOG(Media, &quot;HTMLMediaElement::mediaPlayerCharacteristicChanged&quot;);
</span><del>-    
</del><ins>+
</ins><span class="cx">     beginProcessingMediaPlayerCallback();
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(VIDEO_TRACK)
</span><span class="lines">@@ -4421,7 +4421,7 @@
</span><span class="cx"> {
</span><span class="cx">     if (isBlockedOnMediaController())
</span><span class="cx">         return false;
</span><del>-    
</del><ins>+
</ins><span class="cx">     if (!couldPlayIfEnoughData())
</span><span class="cx">         return false;
</span><span class="cx"> 
</span><span class="lines">@@ -4456,8 +4456,8 @@
</span><span class="cx"> 
</span><span class="cx">     // 4.8.10.8 Playing the media resource
</span><span class="cx"> 
</span><del>-    // A media element is said to have ended playback when the element's 
-    // readyState attribute is HAVE_METADATA or greater, 
</del><ins>+    // A media element is said to have ended playback when the element's
+    // readyState attribute is HAVE_METADATA or greater,
</ins><span class="cx">     if (m_readyState &lt; HAVE_METADATA)
</span><span class="cx">         return false;
</span><span class="cx"> 
</span><span class="lines">@@ -4468,7 +4468,7 @@
</span><span class="cx">     if (effectivePlaybackRate() &gt; 0)
</span><span class="cx">         return dur &gt; MediaTime::zeroTime() &amp;&amp; now &gt;= dur &amp;&amp; (!loop() || m_mediaController);
</span><span class="cx"> 
</span><del>-    // or the current playback position is the earliest possible position and the direction 
</del><ins>+    // or the current playback position is the earliest possible position and the direction
</ins><span class="cx">     // of playback is backwards
</span><span class="cx">     if (effectivePlaybackRate() &lt; 0)
</span><span class="cx">         return now &lt;= MediaTime::zeroTime();
</span><span class="lines">@@ -4483,7 +4483,7 @@
</span><span class="cx">         if (!seekableRanges-&gt;contain(currentTime()))
</span><span class="cx">             return true;
</span><span class="cx">     }
</span><del>-    
</del><ins>+
</ins><span class="cx">     return false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -4504,7 +4504,7 @@
</span><span class="cx"> {
</span><span class="cx">     return m_player ? m_player-&gt;maxTimeSeekable() : MediaTime::zeroTime();
</span><span class="cx"> }
</span><del>-    
</del><ins>+
</ins><span class="cx"> void HTMLMediaElement::updateVolume()
</span><span class="cx"> {
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="lines">@@ -4554,7 +4554,7 @@
</span><span class="cx">         m_activityToken = nullptr;
</span><span class="cx">         return;
</span><span class="cx">     }
</span><del>-    
</del><ins>+
</ins><span class="cx">     bool shouldBePlaying = potentiallyPlaying();
</span><span class="cx">     bool playerPaused = m_player-&gt;paused();
</span><span class="cx"> 
</span><span class="lines">@@ -4605,7 +4605,7 @@
</span><span class="cx">             mediaControls()-&gt;playbackStopped();
</span><span class="cx">         m_activityToken = nullptr;
</span><span class="cx">     }
</span><del>-    
</del><ins>+
</ins><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx">     m_requestingPlay = false;
</span><span class="cx"> #endif
</span><span class="lines">@@ -4656,9 +4656,9 @@
</span><span class="cx">     closeMediaSource();
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-    // 4 - If the media element's readyState attribute has a value equal to HAVE_NOTHING, set the 
-    // element's networkState attribute to the NETWORK_EMPTY value and queue a task to fire a 
-    // simple event named emptied at the element. Otherwise, set the element's networkState 
</del><ins>+    // 4 - If the media element's readyState attribute has a value equal to HAVE_NOTHING, set the
+    // element's networkState attribute to the NETWORK_EMPTY value and queue a task to fire a
+    // simple event named emptied at the element. Otherwise, set the element's networkState
</ins><span class="cx">     // attribute to the NETWORK_IDLE value.
</span><span class="cx">     if (m_readyState == HAVE_NOTHING) {
</span><span class="cx">         m_networkState = NETWORK_EMPTY;
</span><span class="lines">@@ -4717,7 +4717,7 @@
</span><span class="cx"> 
</span><span class="cx"> bool HTMLMediaElement::canSuspend() const
</span><span class="cx"> {
</span><del>-    return true; 
</del><ins>+    return true;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void HTMLMediaElement::stop()
</span><span class="lines">@@ -4725,7 +4725,7 @@
</span><span class="cx">     LOG(Media, &quot;HTMLMediaElement::stop&quot;);
</span><span class="cx">     if (m_isFullscreen)
</span><span class="cx">         exitFullscreen();
</span><del>-    
</del><ins>+
</ins><span class="cx">     m_inActiveDocument = false;
</span><span class="cx"> 
</span><span class="cx">     // Stop the playback without generating events
</span><span class="lines">@@ -4736,7 +4736,7 @@
</span><span class="cx"> 
</span><span class="cx">     if (renderer())
</span><span class="cx">         renderer()-&gt;updateFromElement();
</span><del>-    
</del><ins>+
</ins><span class="cx">     stopPeriodicTimers();
</span><span class="cx">     cancelPendingEventsAndCallbacks();
</span><span class="cx"> 
</span><span class="lines">@@ -4871,7 +4871,7 @@
</span><span class="cx">         m_mediaSession-&gt;setHasPlaybackTargetAvailabilityListeners(*this, true);
</span><span class="cx"> 
</span><span class="cx">     LOG(Media, &quot;HTMLMediaElement::addEventListener('webkitplaybacktargetavailabilitychanged')&quot;);
</span><del>-    
</del><ins>+
</ins><span class="cx">     enqueuePlaybackTargetAvailabilityChangedEvent(); // Ensure the event listener gets at least one event.
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="lines">@@ -4909,24 +4909,24 @@
</span><span class="cx"> {
</span><span class="cx">     return m_player ? m_player-&gt;maxFastForwardRate() : 0;
</span><span class="cx"> }
</span><del>-    
</del><ins>+
</ins><span class="cx"> bool HTMLMediaElement::isFullscreen() const
</span><span class="cx"> {
</span><span class="cx">     if (m_isFullscreen)
</span><span class="cx">         return true;
</span><del>-    
</del><ins>+
</ins><span class="cx"> #if ENABLE(FULLSCREEN_API)
</span><span class="cx">     if (document().webkitIsFullScreen() &amp;&amp; document().webkitCurrentFullScreenElement() == this)
</span><span class="cx">         return true;
</span><span class="cx"> #endif
</span><del>-    
</del><ins>+
</ins><span class="cx">     return false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void HTMLMediaElement::toggleFullscreenState()
</span><span class="cx"> {
</span><span class="cx">     LOG(Media, &quot;HTMLMediaElement::toggleFullscreenState - isFullscreen() is %s&quot;, boolString(isFullscreen()));
</span><del>-    
</del><ins>+
</ins><span class="cx">     if (isFullscreen())
</span><span class="cx">         exitFullscreen();
</span><span class="cx">     else
</span><span class="lines">@@ -5011,7 +5011,7 @@
</span><span class="cx">     m_videoFullscreenLayer = platformLayer;
</span><span class="cx">     if (!m_player)
</span><span class="cx">         return;
</span><del>-    
</del><ins>+
</ins><span class="cx">     m_player-&gt;setVideoFullscreenLayer(platformLayer);
</span><span class="cx">     setNeedsStyleRecalc(SyntheticStyleChange);
</span><span class="cx"> #if ENABLE(VIDEO_TRACK)
</span><span class="lines">@@ -5019,7 +5019,7 @@
</span><span class="cx">         updateTextTrackDisplay();
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><del>-    
</del><ins>+
</ins><span class="cx"> void HTMLMediaElement::setVideoFullscreenFrame(FloatRect frame)
</span><span class="cx"> {
</span><span class="cx">     m_videoFullscreenFrame = frame;
</span><span class="lines">@@ -5073,7 +5073,7 @@
</span><span class="cx"> #endif
</span><span class="cx">     if (!hasMediaControls() &amp;&amp; !createMediaControls())
</span><span class="cx">         return;
</span><del>-    
</del><ins>+
</ins><span class="cx">     mediaControls()-&gt;updateTextTrackDisplay();
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="lines">@@ -5165,8 +5165,8 @@
</span><span class="cx">     else
</span><span class="cx">         document().decrementLoadEventDelayCount();
</span><span class="cx"> }
</span><del>-    
</del><span class="cx"> 
</span><ins>+
</ins><span class="cx"> void HTMLMediaElement::getSitesInMediaCache(Vector&lt;String&gt;&amp; sites)
</span><span class="cx"> {
</span><span class="cx">     MediaPlayer::getSitesInMediaCache(sites);
</span><span class="lines">@@ -5252,14 +5252,14 @@
</span><span class="cx"> void HTMLMediaElement::configureMediaControls()
</span><span class="cx"> {
</span><span class="cx"> #if ENABLE(MEDIA_CONTROLS_SCRIPT)
</span><del>-    if (!controls() || !inDocument())
</del><ins>+    if (!controls() || !inDocument() || !inActiveDocument())
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     ensureUserAgentShadowRoot();
</span><span class="cx">     return;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-    if (!controls() || !inDocument()) {
</del><ins>+    if (!controls() || !inDocument() || !inActiveDocument()) {
</ins><span class="cx">         if (hasMediaControls())
</span><span class="cx">             mediaControls()-&gt;hide();
</span><span class="cx">         return;
</span><span class="lines">@@ -5311,7 +5311,7 @@
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     mediaControls()-&gt;changedClosedCaptionsVisibility();
</span><del>-    
</del><ins>+
</ins><span class="cx">     if (RuntimeEnabledFeatures::sharedFeatures().webkitVideoTrackEnabled()) {
</span><span class="cx">         updateTextTrackDisplay();
</span><span class="cx">         updateActiveTextTrackCues(currentMediaTime());
</span><span class="lines">@@ -5355,7 +5355,7 @@
</span><span class="cx">     // captions and non-default tracks should be displayed based on language
</span><span class="cx">     // preferences if the user has turned captions on).
</span><span class="cx">     for (unsigned i = 0; i &lt; m_textTracks-&gt;length(); ++i) {
</span><del>-        
</del><ins>+
</ins><span class="cx">         RefPtr&lt;TextTrack&gt; textTrack = m_textTracks-&gt;item(i);
</span><span class="cx">         String kind = textTrack-&gt;kind();
</span><span class="cx"> 
</span><span class="lines">@@ -5437,7 +5437,7 @@
</span><span class="cx">         return;
</span><span class="cx">     m_mediaGroup = group;
</span><span class="cx"> 
</span><del>-    // When a media element is created with a mediagroup attribute, and when a media element's mediagroup 
</del><ins>+    // When a media element is created with a mediagroup attribute, and when a media element's mediagroup
</ins><span class="cx">     // attribute is set, changed, or removed, the user agent must run the following steps:
</span><span class="cx">     // 1. Let m [this] be the media element in question.
</span><span class="cx">     // 2. Let m have no current media controller, if it currently has one.
</span><span class="lines">@@ -5448,14 +5448,14 @@
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     // 4. If there is another media element whose Document is the same as m's Document (even if one or both
</span><del>-    // of these elements are not actually in the Document), 
</del><ins>+    // of these elements are not actually in the Document),
</ins><span class="cx">     HashSet&lt;HTMLMediaElement*&gt; elements = documentToElementSetMap().get(&amp;document());
</span><span class="cx">     for (HashSet&lt;HTMLMediaElement*&gt;::iterator i = elements.begin(); i != elements.end(); ++i) {
</span><span class="cx">         if (*i == this)
</span><span class="cx">             continue;
</span><span class="cx"> 
</span><span class="cx">         // and which also has a mediagroup attribute, and whose mediagroup attribute has the same value as
</span><del>-        // the new value of m's mediagroup attribute,        
</del><ins>+        // the new value of m's mediagroup attribute,
</ins><span class="cx">         if ((*i)-&gt;mediaGroup() == group) {
</span><span class="cx">             //  then let controller be that media element's current media controller.
</span><span class="cx">             setController((*i)-&gt;controller());
</span><span class="lines">@@ -5508,13 +5508,13 @@
</span><span class="cx">     if (!m_mediaController)
</span><span class="cx">         return false;
</span><span class="cx"> 
</span><del>-    // A media element is blocked on its media controller if the MediaController is a blocked 
</del><ins>+    // A media element is blocked on its media controller if the MediaController is a blocked
</ins><span class="cx">     // media controller,
</span><span class="cx">     if (m_mediaController-&gt;isBlocked())
</span><span class="cx">         return true;
</span><span class="cx"> 
</span><del>-    // or if its media controller position is either before the media resource's earliest possible 
-    // position relative to the MediaController's timeline or after the end of the media resource 
</del><ins>+    // or if its media controller position is either before the media resource's earliest possible
+    // position relative to the MediaController's timeline or after the end of the media resource
</ins><span class="cx">     // relative to the MediaController's timeline.
</span><span class="cx">     double mediaControllerPosition = m_mediaController-&gt;currentTime();
</span><span class="cx">     if (mediaControllerPosition &lt; 0 || mediaControllerPosition &gt; duration())
</span><span class="lines">@@ -5600,14 +5600,14 @@
</span><span class="cx"> {
</span><span class="cx">     Vector&lt;RefPtr&lt;PlatformTextTrack&gt;&gt; outOfBandTrackSources;
</span><span class="cx">     for (auto&amp; trackElement : childrenOfType&lt;HTMLTrackElement&gt;(*this)) {
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!trackElement.fastHasAttribute(srcAttr))
</span><span class="cx">             continue;
</span><del>-        
</del><ins>+
</ins><span class="cx">         URL url = trackElement.getNonEmptyURLAttribute(srcAttr);
</span><span class="cx">         if (url.isEmpty())
</span><span class="cx">             continue;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!document().contentSecurityPolicy()-&gt;allowMediaFromSource(url, trackElement.isInUserAgentShadowTree()))
</span><span class="cx">             continue;
</span><span class="cx"> 
</span><span class="lines">@@ -5622,9 +5622,9 @@
</span><span class="cx">             platformKind = PlatformTextTrack::Forced;
</span><span class="cx">         else
</span><span class="cx">             continue;
</span><del>-        
</del><ins>+
</ins><span class="cx">         const AtomicString&amp; mode = trackElement.track()-&gt;mode();
</span><del>-        
</del><ins>+
</ins><span class="cx">         PlatformTextTrack::TrackMode platformMode = PlatformTextTrack::Disabled;
</span><span class="cx">         if (TextTrack::hiddenKeyword() == mode)
</span><span class="cx">             platformMode = PlatformTextTrack::Hidden;
</span><span class="lines">@@ -5632,10 +5632,10 @@
</span><span class="cx">             platformMode = PlatformTextTrack::Disabled;
</span><span class="cx">         else if (TextTrack::showingKeyword() == mode)
</span><span class="cx">             platformMode = PlatformTextTrack::Showing;
</span><del>-        
</del><ins>+
</ins><span class="cx">         outOfBandTrackSources.append(PlatformTextTrack::createOutOfBand(trackElement.label(), trackElement.srclang(), url.string(), platformMode, platformKind, trackElement.track()-&gt;uniqueId(), trackElement.isDefault()));
</span><span class="cx">     }
</span><del>-    
</del><ins>+
</ins><span class="cx">     return outOfBandTrackSources;
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="lines">@@ -5908,7 +5908,7 @@
</span><span class="cx"> 
</span><span class="cx">     auto mediaJSWrapper = toJS(exec, globalObject, this);
</span><span class="cx">     auto mediaControlsHostJSWrapper = toJS(exec, globalObject, m_mediaControlsHost.get());
</span><del>-    
</del><ins>+
</ins><span class="cx">     JSC::MarkedArgumentBuffer argList;
</span><span class="cx">     argList.append(toJS(exec, globalObject, root));
</span><span class="cx">     argList.append(mediaJSWrapper);
</span><span class="lines">@@ -5928,7 +5928,7 @@
</span><span class="cx">     // Connect the Media, MediaControllerHost, and Controller so the GC knows about their relationship
</span><span class="cx">     JSC::JSObject* mediaJSWrapperObject = mediaJSWrapper.toObject(exec);
</span><span class="cx">     JSC::Identifier controlsHost(&amp;exec-&gt;vm(), &quot;controlsHost&quot;);
</span><del>-    
</del><ins>+
</ins><span class="cx">     ASSERT(!mediaJSWrapperObject-&gt;hasProperty(exec, controlsHost));
</span><span class="cx"> 
</span><span class="cx">     mediaJSWrapperObject-&gt;putDirect(exec-&gt;vm(), controlsHost, mediaControlsHostJSWrapper, JSC::DontDelete | JSC::DontEnum | JSC::ReadOnly);
</span><span class="lines">@@ -5936,7 +5936,7 @@
</span><span class="cx">     JSC::JSObject* mediaControlsHostJSWrapperObject = JSC::jsDynamicCast&lt;JSC::JSObject*&gt;(mediaControlsHostJSWrapper);
</span><span class="cx">     if (!mediaControlsHostJSWrapperObject)
</span><span class="cx">         return;
</span><del>-    
</del><ins>+
</ins><span class="cx">     JSC::Identifier controller(&amp;exec-&gt;vm(), &quot;controller&quot;);
</span><span class="cx"> 
</span><span class="cx">     ASSERT(!controllerObject-&gt;hasProperty(exec, controller));
</span><span class="lines">@@ -5986,7 +5986,7 @@
</span><span class="cx"> {
</span><span class="cx">     if (m_player)
</span><span class="cx">         return m_player-&gt;fileSize();
</span><del>-    
</del><ins>+
</ins><span class="cx">     return 0;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -6029,12 +6029,12 @@
</span><span class="cx">     if (paused())
</span><span class="cx">         play();
</span><span class="cx"> }
</span><del>-    
</del><ins>+
</ins><span class="cx"> String HTMLMediaElement::mediaSessionTitle() const
</span><span class="cx"> {
</span><span class="cx">     if (fastHasAttribute(titleAttr))
</span><span class="cx">         return fastGetAttribute(titleAttr);
</span><del>-    
</del><ins>+
</ins><span class="cx">     return m_currentSrc;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -6083,7 +6083,7 @@
</span><span class="cx">     AtomicString elementValue = fastGetAttribute(attributeName);
</span><span class="cx">     if (elementValue.isNull())
</span><span class="cx">         return false;
</span><del>-    
</del><ins>+
</ins><span class="cx">     if (Settings* settings = document().settings()) {
</span><span class="cx">         if (attributeName == HTMLNames::x_itunes_inherit_uri_query_componentAttr &amp;&amp; !settings-&gt;enableInheritURIQueryComponent())
</span><span class="cx">             return false;
</span><span class="lines">@@ -6091,7 +6091,7 @@
</span><span class="cx"> 
</span><span class="cx">     if (value)
</span><span class="cx">         *value = elementValue;
</span><del>-    
</del><ins>+
</ins><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>