<!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>[204005] trunk</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/204005">204005</a></dd>
<dt>Author</dt> <dd>timothy_horton@apple.com</dd>
<dt>Date</dt> <dd>2016-08-01 18:39:26 -0700 (Mon, 01 Aug 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>&lt;attachment&gt; action label doesn't wrap, but needs to for some localizations
https://bugs.webkit.org/show_bug.cgi?id=160431
&lt;rdar://problem/27526464&gt;

Reviewed by Simon Fraser.

Test: fast/attachment/attachment-wrapping-action.html

* rendering/RenderThemeIOS.mm:
(WebCore::AttachmentInfo::buildWrappedLines):
(WebCore::AttachmentInfo::AttachmentInfo):
(WebCore::AttachmentInfo::buildTitleLines): Deleted.
Rework buildTitleLines into buildWrappedLines so that we have a
generic way to add lines that wrap up to N lines and then center-truncate.

Make use of it for the action text, and follow the same rules/width as
the title text already does.

* fast/attachment/attachment-wrapping-action-expected-mismatch.html: Added.
* fast/attachment/attachment-wrapping-action.html: Added.
Add a test that ensures that the action label wraps by filling one with
non-breaking and breaking spaces, which will wrap onto two lines, and one
with just a single space, which will always fit in one line, and ensuring
that they do not match.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsTestExpectations">trunk/LayoutTests/TestExpectations</a></li>
<li><a href="#trunkLayoutTestsplatformiossimulatorTestExpectations">trunk/LayoutTests/platform/ios-simulator/TestExpectations</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderThemeIOSmm">trunk/Source/WebCore/rendering/RenderThemeIOS.mm</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfastattachmentattachmentwrappingactionexpectedmismatchhtml">trunk/LayoutTests/fast/attachment/attachment-wrapping-action-expected-mismatch.html</a></li>
<li><a href="#trunkLayoutTestsfastattachmentattachmentwrappingactionhtml">trunk/LayoutTests/fast/attachment/attachment-wrapping-action.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (204004 => 204005)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-08-02 00:31:26 UTC (rev 204004)
+++ trunk/LayoutTests/ChangeLog        2016-08-02 01:39:26 UTC (rev 204005)
</span><span class="lines">@@ -1,3 +1,18 @@
</span><ins>+2016-08-01  Tim Horton  &lt;timothy_horton@apple.com&gt;
+
+        &lt;attachment&gt; action label doesn't wrap, but needs to for some localizations
+        https://bugs.webkit.org/show_bug.cgi?id=160431
+        &lt;rdar://problem/27526464&gt;
+
+        Reviewed by Simon Fraser.
+
+        * fast/attachment/attachment-wrapping-action-expected-mismatch.html: Added.
+        * fast/attachment/attachment-wrapping-action.html: Added.
+        Add a test that ensures that the action label wraps by filling one with
+        non-breaking and breaking spaces, which will wrap onto two lines, and one
+        with just a single space, which will always fit in one line, and ensuring
+        that they do not match.
+
</ins><span class="cx"> 2016-08-01  Chris Dumez  &lt;cdumez@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [iOS] Fix fast/events/touch/document-create-touch-list-ios.html
</span></span></pre></div>
<a id="trunkLayoutTestsTestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/TestExpectations (204004 => 204005)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/TestExpectations        2016-08-02 00:31:26 UTC (rev 204004)
+++ trunk/LayoutTests/TestExpectations        2016-08-02 01:39:26 UTC (rev 204005)
</span><span class="lines">@@ -58,6 +58,9 @@
</span><span class="cx"> # This test only makes sense on Mac
</span><span class="cx"> fast/attachment/attachment-subtitle-resize.html
</span><span class="cx"> 
</span><ins>+# This test only makes sense on iOS
+fast/attachment/attachment-wrapping-action.html
+
</ins><span class="cx"> #//////////////////////////////////////////////////////////////////////////////////////////
</span><span class="cx"> # End platform-specific tests.
</span><span class="cx"> #//////////////////////////////////////////////////////////////////////////////////////////
</span></span></pre></div>
<a id="trunkLayoutTestsfastattachmentattachmentwrappingactionexpectedmismatchhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/attachment/attachment-wrapping-action-expected-mismatch.html (0 => 204005)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/attachment/attachment-wrapping-action-expected-mismatch.html                                (rev 0)
+++ trunk/LayoutTests/fast/attachment/attachment-wrapping-action-expected-mismatch.html        2016-08-02 01:39:26 UTC (rev 204005)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;script&gt;
+    if (window.internals)
+        window.internals.settings.setAttachmentElementEnabled(true)
+&lt;/script&gt;
+&lt;body&gt;
+&lt;attachment action=&quot; &quot; title=&quot;title&quot;&gt;&lt;/attachment&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastattachmentattachmentwrappingactionhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/attachment/attachment-wrapping-action.html (0 => 204005)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/attachment/attachment-wrapping-action.html                                (rev 0)
+++ trunk/LayoutTests/fast/attachment/attachment-wrapping-action.html        2016-08-02 01:39:26 UTC (rev 204005)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;script&gt;
+    if (window.internals)
+        window.internals.settings.setAttachmentElementEnabled(true)
+&lt;/script&gt;
+&lt;body&gt;
+&lt;attachment action=&quot;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot; title=&quot;title&quot;&gt;&lt;/attachment&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformiossimulatorTestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/ios-simulator/TestExpectations (204004 => 204005)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/ios-simulator/TestExpectations        2016-08-02 00:31:26 UTC (rev 204004)
+++ trunk/LayoutTests/platform/ios-simulator/TestExpectations        2016-08-02 01:39:26 UTC (rev 204005)
</span><span class="lines">@@ -3158,3 +3158,5 @@
</span><span class="cx"> media/W3C/audio/canPlayType/canPlayType_supported_but_no_codecs_parameter_1.html [ Failure ]
</span><span class="cx"> 
</span><span class="cx"> media/video-seek-to-current-time.html [ Failure ]
</span><ins>+
+fast/attachment/attachment-wrapping-action.html [ Pass ]
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (204004 => 204005)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-08-02 00:31:26 UTC (rev 204004)
+++ trunk/Source/WebCore/ChangeLog        2016-08-02 01:39:26 UTC (rev 204005)
</span><span class="lines">@@ -1,3 +1,23 @@
</span><ins>+2016-08-01  Tim Horton  &lt;timothy_horton@apple.com&gt;
+
+        &lt;attachment&gt; action label doesn't wrap, but needs to for some localizations
+        https://bugs.webkit.org/show_bug.cgi?id=160431
+        &lt;rdar://problem/27526464&gt;
+
+        Reviewed by Simon Fraser.
+
+        Test: fast/attachment/attachment-wrapping-action.html
+
+        * rendering/RenderThemeIOS.mm:
+        (WebCore::AttachmentInfo::buildWrappedLines):
+        (WebCore::AttachmentInfo::AttachmentInfo):
+        (WebCore::AttachmentInfo::buildTitleLines): Deleted.
+        Rework buildTitleLines into buildWrappedLines so that we have a
+        generic way to add lines that wrap up to N lines and then center-truncate.
+
+        Make use of it for the action text, and follow the same rules/width as
+        the title text already does.
+
</ins><span class="cx"> 2016-08-01  Anders Carlsson  &lt;andersca@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Build fix.
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderThemeIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderThemeIOS.mm (204004 => 204005)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderThemeIOS.mm        2016-08-02 00:31:26 UTC (rev 204004)
+++ trunk/Source/WebCore/rendering/RenderThemeIOS.mm        2016-08-02 01:39:26 UTC (rev 204005)
</span><span class="lines">@@ -1380,8 +1380,8 @@
</span><span class="cx"> 
</span><span class="cx"> const CGFloat attachmentItemMargin = 8;
</span><span class="cx"> 
</span><del>-const CGFloat attachmentTitleMaximumWidth = 140;
-const CFIndex attachmentTitleMaximumLineCount = 2;
</del><ins>+const CGFloat attachmentWrappingTextMaximumWidth = 140;
+const CFIndex attachmentWrappingTextMaximumLineCount = 2;
</ins><span class="cx"> 
</span><span class="cx"> static RetainPtr&lt;CTFontRef&gt; attachmentActionFont()
</span><span class="cx"> {
</span><span class="lines">@@ -1432,7 +1432,7 @@
</span><span class="cx">     CGFloat contentYOrigin { 0 };
</span><span class="cx"> 
</span><span class="cx"> private:
</span><del>-    void buildTitleLines(const RenderAttachment&amp;, unsigned maximumLineCount);
</del><ins>+    void buildWrappedLines(const String&amp;, CTFontRef, UIColor *, unsigned maximumLineCount);
</ins><span class="cx">     void buildSingleLine(const String&amp;, CTFontRef, UIColor *);
</span><span class="cx"> 
</span><span class="cx">     void addLine(CTLineRef);
</span><span class="lines">@@ -1453,28 +1453,25 @@
</span><span class="cx">     lines.append(labelLine);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void AttachmentInfo::buildTitleLines(const RenderAttachment&amp; attachment, unsigned maximumLineCount)
</del><ins>+void AttachmentInfo::buildWrappedLines(const String&amp; text, CTFontRef font, UIColor *color, unsigned maximumLineCount)
</ins><span class="cx"> {
</span><del>-    RetainPtr&lt;CTFontRef&gt; font = attachmentTitleFont();
-
-    String title = attachment.attachmentElement().attachmentTitle();
-    if (title.isEmpty())
</del><ins>+    if (text.isEmpty())
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     NSDictionary *textAttributes = @{
</span><del>-        (id)kCTFontAttributeName: (id)font.get(),
-        (id)kCTForegroundColorAttributeName: attachmentTitleColor()
</del><ins>+        (id)kCTFontAttributeName: (id)font,
+        (id)kCTForegroundColorAttributeName: color
</ins><span class="cx">     };
</span><del>-    RetainPtr&lt;NSAttributedString&gt; attributedTitle = adoptNS([[NSAttributedString alloc] initWithString:title attributes:textAttributes]);
-    RetainPtr&lt;CTFramesetterRef&gt; titleFramesetter = adoptCF(CTFramesetterCreateWithAttributedString((CFAttributedStringRef)attributedTitle.get()));
</del><ins>+    RetainPtr&lt;NSAttributedString&gt; attributedText = adoptNS([[NSAttributedString alloc] initWithString:text attributes:textAttributes]);
+    RetainPtr&lt;CTFramesetterRef&gt; framesetter = adoptCF(CTFramesetterCreateWithAttributedString((CFAttributedStringRef)attributedText.get()));
</ins><span class="cx"> 
</span><span class="cx">     CFRange fitRange;
</span><del>-    CGSize titleTextSize = CTFramesetterSuggestFrameSizeWithConstraints(titleFramesetter.get(), CFRangeMake(0, 0), nullptr, CGSizeMake(attachmentTitleMaximumWidth, CGFLOAT_MAX), &amp;fitRange);
</del><ins>+    CGSize textSize = CTFramesetterSuggestFrameSizeWithConstraints(framesetter.get(), CFRangeMake(0, 0), nullptr, CGSizeMake(attachmentWrappingTextMaximumWidth, CGFLOAT_MAX), &amp;fitRange);
</ins><span class="cx"> 
</span><del>-    RetainPtr&lt;CGPathRef&gt; titlePath = adoptCF(CGPathCreateWithRect(CGRectMake(0, 0, titleTextSize.width, titleTextSize.height), nullptr));
-    RetainPtr&lt;CTFrameRef&gt; titleFrame = adoptCF(CTFramesetterCreateFrame(titleFramesetter.get(), fitRange, titlePath.get(), nullptr));
</del><ins>+    RetainPtr&lt;CGPathRef&gt; textPath = adoptCF(CGPathCreateWithRect(CGRectMake(0, 0, textSize.width, textSize.height), nullptr));
+    RetainPtr&lt;CTFrameRef&gt; textFrame = adoptCF(CTFramesetterCreateFrame(framesetter.get(), fitRange, textPath.get(), nullptr));
</ins><span class="cx"> 
</span><del>-    CFArrayRef ctLines = CTFrameGetLines(titleFrame.get());
</del><ins>+    CFArrayRef ctLines = CTFrameGetLines(textFrame.get());
</ins><span class="cx">     CFIndex lineCount = CFArrayGetCount(ctLines);
</span><span class="cx">     if (!lineCount)
</span><span class="cx">         return;
</span><span class="lines">@@ -1492,12 +1489,12 @@
</span><span class="cx">     // Combine it into one last line, and center-truncate it.
</span><span class="cx">     CTLineRef firstRemainingLine = (CTLineRef)CFArrayGetValueAtIndex(ctLines, lineIndex);
</span><span class="cx">     CFIndex remainingRangeStart = CTLineGetStringRange(firstRemainingLine).location;
</span><del>-    NSRange remainingRange = NSMakeRange(remainingRangeStart, [attributedTitle length] - remainingRangeStart);
-    NSAttributedString *remainingString = [attributedTitle attributedSubstringFromRange:remainingRange];
</del><ins>+    NSRange remainingRange = NSMakeRange(remainingRangeStart, [attributedText length] - remainingRangeStart);
+    NSAttributedString *remainingString = [attributedText attributedSubstringFromRange:remainingRange];
</ins><span class="cx">     RetainPtr&lt;CTLineRef&gt; remainingLine = adoptCF(CTLineCreateWithAttributedString((CFAttributedStringRef)remainingString));
</span><span class="cx">     RetainPtr&lt;NSAttributedString&gt; ellipsisString = adoptNS([[NSAttributedString alloc] initWithString:@&quot;\u2026&quot; attributes:textAttributes]);
</span><span class="cx">     RetainPtr&lt;CTLineRef&gt; ellipsisLine = adoptCF(CTLineCreateWithAttributedString((CFAttributedStringRef)ellipsisString.get()));
</span><del>-    RetainPtr&lt;CTLineRef&gt; truncatedLine = adoptCF(CTLineCreateTruncatedLine(remainingLine.get(), attachmentTitleMaximumWidth, kCTLineTruncationMiddle, ellipsisLine.get()));
</del><ins>+    RetainPtr&lt;CTLineRef&gt; truncatedLine = adoptCF(CTLineCreateTruncatedLine(remainingLine.get(), attachmentWrappingTextMaximumWidth, kCTLineTruncationMiddle, ellipsisLine.get()));
</ins><span class="cx"> 
</span><span class="cx">     if (!truncatedLine)
</span><span class="cx">         truncatedLine = remainingLine;
</span><span class="lines">@@ -1587,6 +1584,7 @@
</span><span class="cx"> 
</span><span class="cx">     hasProgress = getAttachmentProgress(attachment, progress);
</span><span class="cx"> 
</span><ins>+    String title = attachment.attachmentElement().attachmentTitle();
</ins><span class="cx">     String action = attachment.attachmentElement().attributeWithoutSynchronization(actionAttr);
</span><span class="cx">     String subtitle = attachment.attachmentElement().attributeWithoutSynchronization(subtitleAttr);
</span><span class="cx"> 
</span><span class="lines">@@ -1605,10 +1603,10 @@
</span><span class="cx">             yOffset += iconRect.height() + attachmentItemMargin;
</span><span class="cx">         }
</span><span class="cx">     } else
</span><del>-        buildSingleLine(action, attachmentActionFont().get(), attachmentActionColor(attachment));
</del><ins>+        buildWrappedLines(action, attachmentActionFont().get(), attachmentActionColor(attachment), attachmentWrappingTextMaximumLineCount);
</ins><span class="cx"> 
</span><span class="cx">     bool forceSingleLineTitle = !action.isEmpty() || !subtitle.isEmpty() || hasProgress;
</span><del>-    buildTitleLines(attachment, forceSingleLineTitle ? 1 : attachmentTitleMaximumLineCount);
</del><ins>+    buildWrappedLines(title, attachmentTitleFont().get(), attachmentTitleColor(), forceSingleLineTitle ? 1 : attachmentWrappingTextMaximumLineCount);
</ins><span class="cx">     buildSingleLine(subtitle, attachmentSubtitleFont().get(), attachmentSubtitleColor());
</span><span class="cx"> 
</span><span class="cx">     if (!lines.isEmpty()) {
</span></span></pre>
</div>
</div>

</body>
</html>