<!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>[171758] branches/safari-600.1.4-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/171758">171758</a></dd>
<dt>Author</dt> <dd>matthew_hanson@apple.com</dd>
<dt>Date</dt> <dd>2014-07-29 13:54:02 -0700 (Tue, 29 Jul 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Merge <a href="http://trac.webkit.org/projects/webkit/changeset/171700">r171700</a>. &lt;rdar://problem/17844901&gt;</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#branchessafari60014branchSourceWebCoreChangeLog">branches/safari-600.1.4-branch/Source/WebCore/ChangeLog</a></li>
<li><a href="#branchessafari60014branchSourceWebCorehtmlshadowMediaControlElementscpp">branches/safari-600.1.4-branch/Source/WebCore/html/shadow/MediaControlElements.cpp</a></li>
<li><a href="#branchessafari60014branchSourceWebCorehtmltrackInbandGenericTextTrackcpp">branches/safari-600.1.4-branch/Source/WebCore/html/track/InbandGenericTextTrack.cpp</a></li>
<li><a href="#branchessafari60014branchSourceWebCorehtmltrackTextTrackCueGenericcpp">branches/safari-600.1.4-branch/Source/WebCore/html/track/TextTrackCueGeneric.cpp</a></li>
<li><a href="#branchessafari60014branchSourceWebCoreplatformgraphicsavfoundationInbandTextTrackPrivateAVFcpp">branches/safari-600.1.4-branch/Source/WebCore/platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchessafari60014branchSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-600.1.4-branch/Source/WebCore/ChangeLog (171757 => 171758)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1.4-branch/Source/WebCore/ChangeLog        2014-07-29 20:36:29 UTC (rev 171757)
+++ branches/safari-600.1.4-branch/Source/WebCore/ChangeLog        2014-07-29 20:54:02 UTC (rev 171758)
</span><span class="lines">@@ -1,5 +1,33 @@
</span><span class="cx"> 2014-07-29  Matthew Hanson  &lt;matthew_hanson@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        Merge r171700. &lt;rdar://problem/17844901&gt;
+
+    2014-07-27  Brent Fulgham  &lt;bfulgham@apple.com&gt;
+    
+            [Mac, iOS] Paint-on closed captions get out-of-order in Safari
+            https://bugs.webkit.org/show_bug.cgi?id=135332
+            &lt;rdar://problem/15317278&gt;
+    
+            Reviewed by Brent Fulgham.
+    
+            * html/shadow/MediaControlElements.cpp:
+            (WebCore::MediaControlTextTrackContainerElement::updateDisplay): If the
+            number of active cues is greater than the current set of CSS boxes representing
+            the cues, throw away the CSS boxes and re-layout all the cues.
+            * html/track/InbandGenericTextTrack.cpp:
+            (WebCore::InbandGenericTextTrack::addGenericCue): Add some logging.
+            (WebCore::InbandGenericTextTrack::removeGenericCue): Ditto.
+            * html/track/TextTrackCueGeneric.cpp:
+            (WebCore::TextTrackCueGeneric::isOrderedBefore): Revise ordering rules so that we put
+            newer cues earlier in the layout order so they are drawn towards the bottom
+            of the screen. Only do this for Generic captions.
+            * platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp:
+            (WebCore::InbandTextTrackPrivateAVF::processAttributedStrings): Adjust logging
+            messages.
+            (WebCore::InbandTextTrackPrivateAVF::removeCompletedCues): Add logging.
+    
+2014-07-29  Matthew Hanson  &lt;matthew_hanson@apple.com&gt;
+
</ins><span class="cx">         Merge r171675. &lt;rdar://problem/17826572&gt;
</span><span class="cx"> 
</span><span class="cx">     2014-07-28  Yusuke Suzuki  &lt;utatane.tea@gmail.com&gt;
</span></span></pre></div>
<a id="branchessafari60014branchSourceWebCorehtmlshadowMediaControlElementscpp"></a>
<div class="modfile"><h4>Modified: branches/safari-600.1.4-branch/Source/WebCore/html/shadow/MediaControlElements.cpp (171757 => 171758)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1.4-branch/Source/WebCore/html/shadow/MediaControlElements.cpp        2014-07-29 20:36:29 UTC (rev 171757)
+++ branches/safari-600.1.4-branch/Source/WebCore/html/shadow/MediaControlElements.cpp        2014-07-29 20:54:02 UTC (rev 171758)
</span><span class="lines">@@ -42,6 +42,7 @@
</span><span class="cx"> #include &quot;ImageBuffer.h&quot;
</span><span class="cx"> #include &quot;Language.h&quot;
</span><span class="cx"> #include &quot;LocalizedStrings.h&quot;
</span><ins>+#include &quot;Logging.h&quot;
</ins><span class="cx"> #include &quot;MediaControls.h&quot;
</span><span class="cx"> #include &quot;PageGroup.h&quot;
</span><span class="cx"> #include &quot;RenderLayer.h&quot;
</span><span class="lines">@@ -1303,6 +1304,13 @@
</span><span class="cx">     // within the TextTrackCue instance itself. If parameters of the cue change,
</span><span class="cx">     // the display tree is cleared.
</span><span class="cx"> 
</span><ins>+    // If the number of CSS boxes in the output is less than the number of cues
+    // we wish to render (e.g., we are adding another cue in a set of roll-up
+    // cues), remove all the existing CSS boxes representing the cues and re-add
+    // them so that the new cue is at the bottom.
+    if (childNodeCount() &lt; activeCues.size())
+        removeChildren();
+    
</ins><span class="cx">     // 10. For each text track cue cue in cues that has not yet had
</span><span class="cx">     // corresponding CSS boxes added to output, in text track cue order, run the
</span><span class="cx">     // following substeps:
</span><span class="lines">@@ -1320,6 +1328,8 @@
</span><span class="cx">         if (!cue-&gt;track() || !cue-&gt;track()-&gt;isRendered() || !cue-&gt;isActive() || cue-&gt;text().isEmpty())
</span><span class="cx">             continue;
</span><span class="cx"> 
</span><ins>+        LOG(Media, &quot;MediaControlTextTrackContainerElement::updateDisplay(%p) - adding and positioning cue #%zu: \&quot;%s\&quot;, start=%.2f, end=%.2f, line=%.2f&quot;, this, i, cue-&gt;text().utf8().data(), cue-&gt;startTime(), cue-&gt;endTime(), cue-&gt;line());
+
</ins><span class="cx">         RefPtr&lt;VTTCueBox&gt; displayBox = cue-&gt;getDisplayTree(m_videoDisplaySize.size());
</span><span class="cx"> #if ENABLE(WEBVTT_REGIONS)
</span><span class="cx">         if (cue-&gt;track()-&gt;mode() == TextTrack::disabledKeyword())
</span></span></pre></div>
<a id="branchessafari60014branchSourceWebCorehtmltrackInbandGenericTextTrackcpp"></a>
<div class="modfile"><h4>Modified: branches/safari-600.1.4-branch/Source/WebCore/html/track/InbandGenericTextTrack.cpp (171757 => 171758)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1.4-branch/Source/WebCore/html/track/InbandGenericTextTrack.cpp        2014-07-29 20:36:29 UTC (rev 171757)
+++ branches/safari-600.1.4-branch/Source/WebCore/html/track/InbandGenericTextTrack.cpp        2014-07-29 20:54:02 UTC (rev 171758)
</span><span class="lines">@@ -160,6 +160,8 @@
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    LOG(Media, &quot;InbandGenericTextTrack::addGenericCue added cue: start=%.2f, end=%.2f, content=\&quot;%s\&quot;\n&quot;, cueData-&gt;startTime(), cueData-&gt;endTime(), cueData-&gt;content().utf8().data());
+
</ins><span class="cx">     if (cueData-&gt;status() != GenericCueData::Complete)
</span><span class="cx">         m_cueMap.add(cueData.get(), cue.get());
</span><span class="cx"> 
</span><span class="lines">@@ -184,8 +186,10 @@
</span><span class="cx">     if (cue) {
</span><span class="cx">         LOG(Media, &quot;InbandGenericTextTrack::removeGenericCue removing cue: start=%.2f, end=%.2f, content=\&quot;%s\&quot;\n&quot;, cueData-&gt;startTime(), cueData-&gt;endTime(), cueData-&gt;content().utf8().data());
</span><span class="cx">         removeCue(cue.get(), IGNORE_EXCEPTION);
</span><del>-    } else
</del><ins>+    } else {
+        LOG(Media, &quot;InbandGenericTextTrack::removeGenericCue UNABLE to find cue: start=%.2f, end=%.2f, content=\&quot;%s\&quot;\n&quot;, cueData-&gt;startTime(), cueData-&gt;endTime(), cueData-&gt;content().utf8().data());
</ins><span class="cx">         m_cueMap.remove(cueData);
</span><ins>+    }
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void InbandGenericTextTrack::removeCue(TextTrackCue* cue, ExceptionCode&amp; ec)
</span></span></pre></div>
<a id="branchessafari60014branchSourceWebCorehtmltrackTextTrackCueGenericcpp"></a>
<div class="modfile"><h4>Modified: branches/safari-600.1.4-branch/Source/WebCore/html/track/TextTrackCueGeneric.cpp (171757 => 171758)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1.4-branch/Source/WebCore/html/track/TextTrackCueGeneric.cpp        2014-07-29 20:36:29 UTC (rev 171757)
+++ branches/safari-600.1.4-branch/Source/WebCore/html/track/TextTrackCueGeneric.cpp        2014-07-29 20:54:02 UTC (rev 171758)
</span><span class="lines">@@ -202,9 +202,6 @@
</span><span class="cx"> 
</span><span class="cx"> bool TextTrackCueGeneric::isOrderedBefore(const TextTrackCue* that) const
</span><span class="cx"> {
</span><del>-    if (VTTCue::isOrderedBefore(that))
-        return true;
-
</del><span class="cx">     if (that-&gt;cueType() == Generic &amp;&amp; startTime() == that-&gt;startTime() &amp;&amp; endTime() == that-&gt;endTime()) {
</span><span class="cx">         // Further order generic cues by their calculated line value.
</span><span class="cx">         std::pair&lt;double, double&gt; thisPosition = getPositionCoordinates();
</span><span class="lines">@@ -212,7 +209,10 @@
</span><span class="cx">         return thisPosition.second &gt; thatPosition.second || (thisPosition.second == thatPosition.second &amp;&amp; thisPosition.first &lt; thatPosition.first);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    return false;
</del><ins>+    if (that-&gt;cueType() == Generic)
+        return startTime() &gt; that-&gt;startTime();
+    
+    return VTTCue::isOrderedBefore(that);
</ins><span class="cx"> }
</span><span class="cx">     
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="branchessafari60014branchSourceWebCoreplatformgraphicsavfoundationInbandTextTrackPrivateAVFcpp"></a>
<div class="modfile"><h4>Modified: branches/safari-600.1.4-branch/Source/WebCore/platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp (171757 => 171758)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1.4-branch/Source/WebCore/platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp        2014-07-29 20:36:29 UTC (rev 171757)
+++ branches/safari-600.1.4-branch/Source/WebCore/platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp        2014-07-29 20:54:02 UTC (rev 171758)
</span><span class="lines">@@ -435,7 +435,7 @@
</span><span class="cx">                     if (!arrivingCue-&gt;doesExtendCueData(*cueData))
</span><span class="cx">                         nonExtensionCues.append(arrivingCue);
</span><span class="cx">                     else
</span><del>-                        LOG(Media, &quot;InbandTextTrackPrivateAVF::processCue(%p) - found an extension cue (\&quot;%s\&quot;) for time = %.2f, position =  %.2f, line =  %.2f&quot;, this, arrivingCue-&gt;content().utf8().data(), arrivingCue-&gt;startTime(), arrivingCue-&gt;position(), arrivingCue-&gt;line());
</del><ins>+                        LOG(Media, &quot;InbandTextTrackPrivateAVF::processCue(%p) - found an extension cue (\&quot;%s\&quot;) for time = %.2f, end = %.2f, position =  %.2f, line =  %.2f&quot;, this, arrivingCue-&gt;content().utf8().data(), arrivingCue-&gt;startTime(), arrivingCue-&gt;endTime(), arrivingCue-&gt;position(), arrivingCue-&gt;line());
</ins><span class="cx">                 }
</span><span class="cx"> 
</span><span class="cx">                 bool currentCueIsExtended = (arrivingCues.size() != nonExtensionCues.size());
</span><span class="lines">@@ -449,7 +449,7 @@
</span><span class="cx">                     cueData-&gt;setEndTime(m_currentCueEndTime);
</span><span class="cx">                     cueData-&gt;setStatus(GenericCueData::Complete);
</span><span class="cx"> 
</span><del>-                    LOG(Media, &quot;InbandTextTrackPrivateAVF::processCue(%p) - updating cue: start=%.2f, end=%.2f, content=\&quot;%s\&quot;&quot;, this, cueData-&gt;startTime(), m_currentCueEndTime, cueData-&gt;content().utf8().data());
</del><ins>+                    LOG(Media, &quot;InbandTextTrackPrivateAVF::processCue(%p) - updating cue \&quot;%s\&quot;: start=%.2f, end=%.2f&quot;, this, cueData-&gt;content().utf8().data(), cueData-&gt;startTime(), m_currentCueEndTime);
</ins><span class="cx">                     client()-&gt;updateGenericCue(this, cueData.get());
</span><span class="cx">                 } else {
</span><span class="cx">                     // We have to assume that the implicit duration is invalid for cues delivered during a seek because the AVF decode pipeline may not
</span><span class="lines">@@ -472,7 +472,7 @@
</span><span class="cx"> 
</span><span class="cx">         m_cues.append(cueData);
</span><span class="cx">         
</span><del>-        LOG(Media, &quot;InbandTextTrackPrivateAVF::processCue(%p) - adding cue for time = %.2f, position =  %.2f, line =  %.2f&quot;, this, cueData-&gt;startTime(), cueData-&gt;position(), cueData-&gt;line());
</del><ins>+        LOG(Media, &quot;InbandTextTrackPrivateAVF::processCue(%p) - adding cue \&quot;%s\&quot; for time = %.2f, end = %.2f, position =  %.2f, line =  %.2f&quot;, this, cueData-&gt;content().utf8().data(), cueData-&gt;startTime(), cueData-&gt;endTime(), cueData-&gt;position(), cueData-&gt;line());
</ins><span class="cx"> 
</span><span class="cx">         client()-&gt;addGenericCue(this, cueData.release());
</span><span class="cx">     }
</span><span class="lines">@@ -503,6 +503,8 @@
</span><span class="cx">             if (m_cues[currentCue]-&gt;status() != GenericCueData::Complete)
</span><span class="cx">                 continue;
</span><span class="cx"> 
</span><ins>+            LOG(Media, &quot;InbandTextTrackPrivateAVF::removeCompletedCues(%p) - removing cue \&quot;%s\&quot;: start=%.2f, end=%.2f&quot;, this, m_cues[currentCue]-&gt;content().utf8().data(), m_cues[currentCue]-&gt;startTime(), m_cues[currentCue]-&gt;endTime());
+
</ins><span class="cx">             m_cues.remove(currentCue);
</span><span class="cx">         }
</span><span class="cx">     }
</span></span></pre>
</div>
</div>

</body>
</html>