<!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>[172224] trunk/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/172224">172224</a></dd>
<dt>Author</dt> <dd>roger_fong@apple.com</dd>
<dt>Date</dt> <dd>2014-08-07 12:34:10 -0700 (Thu, 07 Aug 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Increase width of caption container if a larger font size is selected from user prefs.
https://bugs.webkit.org/show_bug.cgi?id=135677.

Reviewed by Brent Fulgham.

* html/shadow/MediaControlElements.cpp:
(WebCore::MediaControlTextTrackContainerElement::updateDisplay):
Upon creation of a VTTCueBox make sure to supply the font size set by the user prefs.
* html/track/TextTrackCueGeneric.cpp:
(WebCore::TextTrackCueGenericBoxElement::applyCSSProperties):
Increase the width of the cue box based on user prefs font size selection.

* html/track/VTTCue.h:
Keep track of the font size set in the user prefs for use when the cue boxes are created.
(WebCore::VTTCueBox::setFontSizeFromCaptionUserPrefs):
* html/track/VTTCue.cpp:
(WebCore::VTTCueBox::applyCSSProperties):
Increase the width of the cue box based on user prefs font size selection.
(WebCore::VTTCue::getDisplayTree):
(WebCore::VTTCue::setFontSize):
If the font size set is important then we don't want to use the font size set by user prefs, set it to 0.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorehtmlshadowMediaControlElementscpp">trunk/Source/WebCore/html/shadow/MediaControlElements.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmltrackTextTrackCueGenericcpp">trunk/Source/WebCore/html/track/TextTrackCueGeneric.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmltrackVTTCuecpp">trunk/Source/WebCore/html/track/VTTCue.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmltrackVTTCueh">trunk/Source/WebCore/html/track/VTTCue.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (172223 => 172224)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-08-07 19:33:54 UTC (rev 172223)
+++ trunk/Source/WebCore/ChangeLog        2014-08-07 19:34:10 UTC (rev 172224)
</span><span class="lines">@@ -1,3 +1,27 @@
</span><ins>+2014-08-06  Roger Fong  &lt;roger_fong@apple.com&gt;
+
+        Increase width of caption container if a larger font size is selected from user prefs.
+        https://bugs.webkit.org/show_bug.cgi?id=135677.
+
+        Reviewed by Brent Fulgham.
+
+        * html/shadow/MediaControlElements.cpp:
+        (WebCore::MediaControlTextTrackContainerElement::updateDisplay):
+        Upon creation of a VTTCueBox make sure to supply the font size set by the user prefs.
+        * html/track/TextTrackCueGeneric.cpp:
+        (WebCore::TextTrackCueGenericBoxElement::applyCSSProperties):
+        Increase the width of the cue box based on user prefs font size selection.
+
+        * html/track/VTTCue.h:
+        Keep track of the font size set in the user prefs for use when the cue boxes are created.
+        (WebCore::VTTCueBox::setFontSizeFromCaptionUserPrefs):
+        * html/track/VTTCue.cpp:
+        (WebCore::VTTCueBox::applyCSSProperties):
+        Increase the width of the cue box based on user prefs font size selection.
+        (WebCore::VTTCue::getDisplayTree):
+        (WebCore::VTTCue::setFontSize):
+        If the font size set is important then we don't want to use the font size set by user prefs, set it to 0.
+
</ins><span class="cx"> 2014-08-07  Alex Christensen  &lt;achristensen@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Unreviewed build fix after r172220.
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlshadowMediaControlElementscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/shadow/MediaControlElements.cpp (172223 => 172224)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/shadow/MediaControlElements.cpp        2014-08-07 19:33:54 UTC (rev 172223)
+++ trunk/Source/WebCore/html/shadow/MediaControlElements.cpp        2014-08-07 19:34:10 UTC (rev 172224)
</span><span class="lines">@@ -1179,7 +1179,7 @@
</span><span class="cx"> 
</span><span class="cx">         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());
</span><span class="cx"> 
</span><del>-        RefPtr&lt;VTTCueBox&gt; displayBox = cue-&gt;getDisplayTree(m_videoDisplaySize.size());
</del><ins>+        RefPtr&lt;VTTCueBox&gt; displayBox = cue-&gt;getDisplayTree(m_videoDisplaySize.size(), m_fontSize);
</ins><span class="cx"> #if ENABLE(WEBVTT_REGIONS)
</span><span class="cx">         if (cue-&gt;track()-&gt;mode() == TextTrack::disabledKeyword())
</span><span class="cx">             continue;
</span></span></pre></div>
<a id="trunkSourceWebCorehtmltrackTextTrackCueGenericcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/track/TextTrackCueGeneric.cpp (172223 => 172224)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/track/TextTrackCueGeneric.cpp        2014-08-07 19:33:54 UTC (rev 172223)
+++ trunk/Source/WebCore/html/track/TextTrackCueGeneric.cpp        2014-08-07 19:34:10 UTC (rev 172224)
</span><span class="lines">@@ -30,6 +30,7 @@
</span><span class="cx"> #include &quot;TextTrackCueGeneric.h&quot;
</span><span class="cx"> 
</span><span class="cx"> #include &quot;CSSPropertyNames.h&quot;
</span><ins>+#include &quot;CSSStyleDeclaration.h&quot;
</ins><span class="cx"> #include &quot;CSSValueKeywords.h&quot;
</span><span class="cx"> #include &quot;HTMLNames.h&quot;
</span><span class="cx"> #include &quot;HTMLSpanElement.h&quot;
</span><span class="lines">@@ -37,7 +38,9 @@
</span><span class="cx"> #include &quot;Logging.h&quot;
</span><span class="cx"> #include &quot;RenderObject.h&quot;
</span><span class="cx"> #include &quot;ScriptExecutionContext.h&quot;
</span><ins>+#include &quot;StyleProperties.h&quot;
</ins><span class="cx"> #include &quot;TextTrackCue.h&quot;
</span><ins>+#include &lt;wtf/MathExtras.h&gt;
</ins><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="lines">@@ -75,16 +78,27 @@
</span><span class="cx">         setInlineStyleProperty(CSSPropertyLeft, static_cast&lt;float&gt;(cue-&gt;position()), CSSPrimitiveValue::CSS_PERCENTAGE);
</span><span class="cx">         setInlineStyleProperty(CSSPropertyTop, static_cast&lt;float&gt;(cue-&gt;line()), CSSPrimitiveValue::CSS_PERCENTAGE);
</span><span class="cx"> 
</span><ins>+        float authorFontSize = std::max(VTTCueBox::DEFAULTFONTSIZE, static_cast&lt;float&gt;(videoSize.height() * cue-&gt;baseFontSizeRelativeToVideoHeight() / 100));
+        if (cue-&gt;fontSizeMultiplier())
+            authorFontSize *= cue-&gt;fontSizeMultiplier() / 100;
+
+        float multiplier = std::max(1.0f, m_fontSizeFromCaptionUserPrefs / authorFontSize);
</ins><span class="cx">         if (cue-&gt;getWritingDirection() == VTTCue::Horizontal)
</span><del>-            setInlineStyleProperty(CSSPropertyWidth, size, CSSPrimitiveValue::CSS_PERCENTAGE);
</del><ins>+            setInlineStyleProperty(CSSPropertyWidth, size * multiplier, CSSPrimitiveValue::CSS_PERCENTAGE);
</ins><span class="cx">         else
</span><del>-            setInlineStyleProperty(CSSPropertyHeight, size,  CSSPrimitiveValue::CSS_PERCENTAGE);
</del><ins>+            setInlineStyleProperty(CSSPropertyHeight, size * multiplier,  CSSPrimitiveValue::CSS_PERCENTAGE);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if (cue-&gt;getWritingDirection() == VTTCue::Horizontal)
</del><ins>+    std::pair&lt;float, float&gt; position = m_cue.getCSSPosition();
+    if (cue-&gt;getWritingDirection() == VTTCue::Horizontal) {
</ins><span class="cx">         setInlineStyleProperty(CSSPropertyMinWidth, &quot;-webkit-min-content&quot;);
</span><del>-    else
</del><ins>+        double maxWidth = videoSize.width() * (100.0 - position.first) / 100.0;
+        setInlineStyleProperty(CSSPropertyMaxWidth, maxWidth, CSSPrimitiveValue::CSS_PX);
+    } else {
</ins><span class="cx">         setInlineStyleProperty(CSSPropertyMinHeight, &quot;-webkit-min-content&quot;);
</span><ins>+        double maxHeight = videoSize.height() * (100.0 - position.second) / 100.0;
+        setInlineStyleProperty(CSSPropertyMaxHeight, maxHeight, CSSPrimitiveValue::CSS_PX);
+    }
</ins><span class="cx"> 
</span><span class="cx">     if (cue-&gt;foregroundColor().isValid())
</span><span class="cx">         cueElement-&gt;setInlineStyleProperty(CSSPropertyColor, cue-&gt;foregroundColor().serialized());
</span></span></pre></div>
<a id="trunkSourceWebCorehtmltrackVTTCuecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/track/VTTCue.cpp (172223 => 172224)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/track/VTTCue.cpp        2014-08-07 19:33:54 UTC (rev 172223)
+++ trunk/Source/WebCore/html/track/VTTCue.cpp        2014-08-07 19:34:10 UTC (rev 172224)
</span><span class="lines">@@ -138,7 +138,7 @@
</span><span class="cx">     return &amp;m_cue;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void VTTCueBox::applyCSSProperties(const IntSize&amp;)
</del><ins>+void VTTCueBox::applyCSSProperties(const IntSize&amp; videoSize)
</ins><span class="cx"> {
</span><span class="cx">     // FIXME: Apply all the initial CSS positioning properties. http://wkb.ug/79916
</span><span class="cx"> #if ENABLE(WEBVTT_REGIONS)
</span><span class="lines">@@ -170,15 +170,20 @@
</span><span class="cx">     // the 'left' property must be set to left
</span><span class="cx">     setInlineStyleProperty(CSSPropertyLeft, static_cast&lt;double&gt;(position.first), CSSPrimitiveValue::CSS_PERCENTAGE);
</span><span class="cx"> 
</span><ins>+    float multiplier = std::max(1.0f, m_fontSizeFromCaptionUserPrefs / VTTCueBox::DEFAULTFONTSIZE);
</ins><span class="cx">     // the 'width' property must be set to width, and the 'height' property  must be set to height
</span><span class="cx">     if (m_cue.vertical() == horizontalKeyword()) {
</span><del>-        setInlineStyleProperty(CSSPropertyWidth, static_cast&lt;double&gt;(m_cue.getCSSSize()), CSSPrimitiveValue::CSS_PERCENTAGE);
</del><ins>+        setInlineStyleProperty(CSSPropertyWidth, static_cast&lt;double&gt;(m_cue.getCSSSize() * multiplier), CSSPrimitiveValue::CSS_PERCENTAGE);
</ins><span class="cx">         setInlineStyleProperty(CSSPropertyHeight, CSSValueAuto);
</span><span class="cx">         setInlineStyleProperty(CSSPropertyMinWidth, &quot;-webkit-min-content&quot;);
</span><ins>+        double maxWidth = videoSize.width() * (100.0 - position.first) / 100.0;
+        setInlineStyleProperty(CSSPropertyMaxWidth, maxWidth, CSSPrimitiveValue::CSS_PX);
</ins><span class="cx">     } else {
</span><span class="cx">         setInlineStyleProperty(CSSPropertyWidth, CSSValueAuto);
</span><del>-        setInlineStyleProperty(CSSPropertyHeight, static_cast&lt;double&gt;(m_cue.getCSSSize()),  CSSPrimitiveValue::CSS_PERCENTAGE);
</del><ins>+        setInlineStyleProperty(CSSPropertyHeight, static_cast&lt;double&gt;(m_cue.getCSSSize() * multiplier),  CSSPrimitiveValue::CSS_PERCENTAGE);
</ins><span class="cx">         setInlineStyleProperty(CSSPropertyMinHeight, &quot;-webkit-min-content&quot;);
</span><ins>+        double maxHeight = videoSize.height() * (100.0 - position.second) / 100.0;
+        setInlineStyleProperty(CSSPropertyMaxHeight, maxHeight, CSSPrimitiveValue::CSS_PX);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     // The 'text-align' property on the (root) List of WebVTT Node Objects must
</span><span class="lines">@@ -186,7 +191,7 @@
</span><span class="cx">     // whose first cell is the value of the corresponding cue's text track cue
</span><span class="cx">     // alignment:
</span><span class="cx">     setInlineStyleProperty(CSSPropertyTextAlign, m_cue.getCSSAlignment());
</span><del>-
</del><ins>+    
</ins><span class="cx">     if (!m_cue.snapToLines()) {
</span><span class="cx">         // 10.13.1 Set up x and y:
</span><span class="cx">         // Note: x and y are set through the CSS left and top above.
</span><span class="lines">@@ -777,7 +782,7 @@
</span><span class="cx">     m_cueHighlightBox-&gt;appendChild(referenceTree);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-VTTCueBox* VTTCue::getDisplayTree(const IntSize&amp; videoSize)
</del><ins>+VTTCueBox* VTTCue::getDisplayTree(const IntSize&amp; videoSize, int fontSize)
</ins><span class="cx"> {
</span><span class="cx">     RefPtr&lt;VTTCueBox&gt; displayTree = displayTreeInternal();
</span><span class="cx">     if (!m_displayTreeShouldChange || !track()-&gt;isRendered())
</span><span class="lines">@@ -808,13 +813,7 @@
</span><span class="cx">     // WebVTT Ruby Text Objects must be wrapped in anonymous boxes whose
</span><span class="cx">     // 'display' property has the value 'ruby-base'.
</span><span class="cx"> 
</span><del>-    // FIXME(BUG 79916): Text runs must be wrapped according to the CSS
-    // line-wrapping rules, except that additionally, regardless of the value of
-    // the 'white-space' property, lines must be wrapped at the edge of their
-    // containing blocks, even if doing so requires splitting a word where there
-    // is no line breaking opportunity. (Thus, normally text wraps as needed,
-    // but if there is a particularly long word, it does not overflow as it
-    // normally would in CSS, it is instead forcibly wrapped at the box's edge.)
</del><ins>+    displayTree-&gt;setFontSizeFromCaptionUserPrefs(fontSize);
</ins><span class="cx">     displayTree-&gt;applyCSSProperties(videoSize);
</span><span class="cx"> 
</span><span class="cx">     m_displayTreeShouldChange = false;
</span><span class="lines">@@ -1143,6 +1142,9 @@
</span><span class="cx">     
</span><span class="cx">     LOG(Media, &quot;TextTrackCue::setFontSize - setting cue font size to %i&quot;, fontSize);
</span><span class="cx"> 
</span><ins>+    if (important)
+        displayTreeInternal()-&gt;setFontSizeFromCaptionUserPrefs(0);
+    
</ins><span class="cx">     displayTreeInternal()-&gt;setInlineStyleProperty(CSSPropertyFontSize, fontSize, CSSPrimitiveValue::CSS_PX, important);
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorehtmltrackVTTCueh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/track/VTTCue.h (172223 => 172224)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/track/VTTCue.h        2014-08-07 19:33:54 UTC (rev 172223)
+++ trunk/Source/WebCore/html/track/VTTCue.h        2014-08-07 19:34:10 UTC (rev 172224)
</span><span class="lines">@@ -59,6 +59,7 @@
</span><span class="cx">     virtual void applyCSSProperties(const IntSize&amp; videoSize);
</span><span class="cx"> 
</span><span class="cx">     static const AtomicString&amp; vttCueBoxShadowPseudoId();
</span><ins>+    virtual void setFontSizeFromCaptionUserPrefs(int fontSize) { m_fontSizeFromCaptionUserPrefs = fontSize; }
</ins><span class="cx"> 
</span><span class="cx"> protected:
</span><span class="cx">     VTTCueBox(Document&amp;, VTTCue&amp;);
</span><span class="lines">@@ -66,8 +67,14 @@
</span><span class="cx">     virtual RenderPtr&lt;RenderElement&gt; createElementRenderer(PassRef&lt;RenderStyle&gt;) override;
</span><span class="cx"> 
</span><span class="cx">     VTTCue&amp; m_cue;
</span><ins>+    int m_fontSizeFromCaptionUserPrefs;
+
+    static const float DEFAULTFONTSIZE;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><ins>+// This default value must be the same as the one specified in mediaControlsApple.css for -webkit-media-controls-closed-captions-container
+const float VTTCueBox::DEFAULTFONTSIZE = 10;
+
</ins><span class="cx"> // ----------------------------
</span><span class="cx"> 
</span><span class="cx"> class VTTCue : public TextTrackCue {
</span><span class="lines">@@ -115,7 +122,7 @@
</span><span class="cx">     virtual void setIsActive(bool);
</span><span class="cx"> 
</span><span class="cx">     bool hasDisplayTree() const { return m_displayTree; }
</span><del>-    VTTCueBox* getDisplayTree(const IntSize&amp; videoSize);
</del><ins>+    VTTCueBox* getDisplayTree(const IntSize&amp; videoSize, int fontSize);
</ins><span class="cx">     HTMLSpanElement* element() const { return m_cueHighlightBox.get(); }
</span><span class="cx"> 
</span><span class="cx">     void updateDisplayTree(double);
</span></span></pre>
</div>
</div>

</body>
</html>