<!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>[166448] 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/166448">166448</a></dd>
<dt>Author</dt> <dd>darin@apple.com</dd>
<dt>Date</dt> <dd>2014-03-28 20:18:27 -0700 (Fri, 28 Mar 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Source/WebCore: Fix recently-introduced off-by-one error in centerTruncateToBuffer
https://bugs.webkit.org/show_bug.cgi?id=130889
&lt;rdar://problem/16408694&gt;

Reviewed by Alexey Proskuryakov.

* platform/graphics/StringTruncator.cpp:
(WebCore::centerTruncateToBuffer): Simplified expression that computes truncatedLength.
Removed incorrect &quot;+ 1&quot; from computation of where to write characters.

Source/WebKit/mac: Fix recently-introduced off-by-one error in centerTruncateToBuffer
https://bugs.webkit.org/show_bug.cgi?id=130889

Reviewed by Alexey Proskuryakov.

* Misc/WebStringTruncator.mm:
(defaultMenuFont): Changed to use NeverDestroyed since I had to touch this file anyway.
(fontFromNSFont): Ditto. Also improved variable names a bit.
(+[WebStringTruncator initialize]): Added threading initialization, needed for main
thread assertions in string truncator code.

Tools: Fix recently-introduced off-by-one error in centerTruncateToBuffer
https://bugs.webkit.org/show_bug.cgi?id=130889

Reviewed by Alexey Proskuryakov.

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: Added StringTruncator.mm.
* TestWebKitAPI/Tests/mac/StringTruncator.mm: Added. One test for each of the
WebStringTruncator methods; should be good for a start. These are dependent on the
metrics of Helvetica 12, but I am hoping that will be consistent across OS X machines.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsStringTruncatorcpp">trunk/Source/WebCore/platform/graphics/StringTruncator.cpp</a></li>
<li><a href="#trunkSourceWebKitmacChangeLog">trunk/Source/WebKit/mac/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitmacMiscWebStringTruncatormm">trunk/Source/WebKit/mac/Misc/WebStringTruncator.mm</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj">trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkToolsTestWebKitAPITestsmacStringTruncatormm">trunk/Tools/TestWebKitAPI/Tests/mac/StringTruncator.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (166447 => 166448)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-03-29 03:08:59 UTC (rev 166447)
+++ trunk/Source/WebCore/ChangeLog        2014-03-29 03:18:27 UTC (rev 166448)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2014-03-28  Darin Adler  &lt;darin@apple.com&gt;
+
+        Fix recently-introduced off-by-one error in centerTruncateToBuffer
+        https://bugs.webkit.org/show_bug.cgi?id=130889
+        &lt;rdar://problem/16408694&gt;
+
+        Reviewed by Alexey Proskuryakov.
+
+        * platform/graphics/StringTruncator.cpp:
+        (WebCore::centerTruncateToBuffer): Simplified expression that computes truncatedLength.
+        Removed incorrect &quot;+ 1&quot; from computation of where to write characters.
+
</ins><span class="cx"> 2014-03-28  Benjamin Poulain  &lt;bpoulain@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Update the code related to SelectorPseudoTypeMap to reflect its new purpose
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsStringTruncatorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/StringTruncator.cpp (166447 => 166448)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/StringTruncator.cpp        2014-03-29 03:08:59 UTC (rev 166447)
+++ trunk/Source/WebCore/platform/graphics/StringTruncator.cpp        2014-03-29 03:18:27 UTC (rev 166448)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2005, 2006, 2007 Apple Inc.  All rights reserved.
</del><ins>+ * Copyright (C) 2005, 2006, 2007, 2014 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -70,6 +70,8 @@
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx">     // FIXME: We should guard this code behind an editing behavior. Then we can remove the PLATFORM(IOS)-guard.
</span><ins>+    // Or just turn it on for all platforms. It seems like good behavior everywhere. Might be better to generalize
+    // it to handle all whitespace, not just &quot;space&quot;.
</ins><span class="cx"> 
</span><span class="cx">     // Strip single character before ellipsis character, when that character is preceded by a space
</span><span class="cx">     if (omitStart &gt; 1 &amp;&amp; string[omitStart - 1] != space &amp;&amp; omitStart &gt; 2 &amp;&amp; string[omitStart - 2] == space)
</span><span class="lines">@@ -87,13 +89,13 @@
</span><span class="cx">         ++omitEnd;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-    unsigned truncatedLength = shouldInsertEllipsis ? omitStart + 1 + (length - omitEnd) : length - (omitEnd - omitStart);
</del><ins>+    unsigned truncatedLength = omitStart + shouldInsertEllipsis + (length - omitEnd);
</ins><span class="cx">     ASSERT(truncatedLength &lt;= length);
</span><span class="cx"> 
</span><span class="cx">     StringView(string).substring(0, omitStart).getCharactersWithUpconvert(buffer);
</span><span class="cx">     if (shouldInsertEllipsis)
</span><span class="cx">         buffer[omitStart++] = horizontalEllipsis;
</span><del>-    StringView(string).substring(omitEnd, length - omitEnd).getCharactersWithUpconvert(&amp;buffer[omitStart + 1]);
</del><ins>+    StringView(string).substring(omitEnd, length - omitEnd).getCharactersWithUpconvert(&amp;buffer[omitStart]);
</ins><span class="cx">     return truncatedLength;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -104,6 +106,8 @@
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx">     // FIXME: We should guard this code behind an editing behavior. Then we can remove the PLATFORM(IOS)-guard.
</span><ins>+    // Or just turn it on for all platforms. It seems like good behavior everywhere. Might be better to generalize
+    // it to handle all whitespace, not just &quot;space&quot;.
</ins><span class="cx"> 
</span><span class="cx">     // Strip single character before ellipsis character, when that character is preceded by a space
</span><span class="cx">     if (keepCount &gt; 1 &amp;&amp; string[keepCount - 1] != space &amp;&amp; keepCount &gt; 2 &amp;&amp; string[keepCount - 2] == space)
</span><span class="lines">@@ -148,10 +152,14 @@
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx">     // FIXME: We should guard this code behind an editing behavior. Then we can remove the PLATFORM(IOS)-guard.
</span><ins>+    // Or just turn it on for all platforms. It seems like good behavior everywhere. Might be better to generalize
+    // it to handle all whitespace, not just &quot;space&quot;.
+
</ins><span class="cx">     // Motivated by &lt;rdar://problem/7439327&gt; truncation should not include a trailing space
</span><del>-    while ((keepLength &gt; 0) &amp;&amp; (string[keepLength - 1] == space))
</del><ins>+    while (keepLength &amp;&amp; string[keepLength - 1] == space)
</ins><span class="cx">         --keepLength;
</span><span class="cx"> #endif
</span><ins>+
</ins><span class="cx">     return keepLength;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -249,11 +257,10 @@
</span><span class="cx">             / (widthForSmallestKnownToNotFit - widthForLargestKnownToFit);
</span><span class="cx">         keepCount = static_cast&lt;unsigned&gt;(maxWidth * ratio);
</span><span class="cx">         
</span><del>-        if (keepCount &lt;= keepCountForLargestKnownToFit) {
</del><ins>+        if (keepCount &lt;= keepCountForLargestKnownToFit)
</ins><span class="cx">             keepCount = keepCountForLargestKnownToFit + 1;
</span><del>-        } else if (keepCount &gt;= keepCountForSmallestKnownToNotFit) {
</del><ins>+        else if (keepCount &gt;= keepCountForSmallestKnownToNotFit)
</ins><span class="cx">             keepCount = keepCountForSmallestKnownToNotFit - 1;
</span><del>-        }
</del><span class="cx">         
</span><span class="cx">         ASSERT_WITH_SECURITY_IMPLICATION(keepCount &lt; length);
</span><span class="cx">         ASSERT(keepCount &gt; 0);
</span></span></pre></div>
<a id="trunkSourceWebKitmacChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/ChangeLog (166447 => 166448)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/ChangeLog        2014-03-29 03:08:59 UTC (rev 166447)
+++ trunk/Source/WebKit/mac/ChangeLog        2014-03-29 03:18:27 UTC (rev 166448)
</span><span class="lines">@@ -1,3 +1,16 @@
</span><ins>+2014-03-28  Darin Adler  &lt;darin@apple.com&gt;
+
+        Fix recently-introduced off-by-one error in centerTruncateToBuffer
+        https://bugs.webkit.org/show_bug.cgi?id=130889
+
+        Reviewed by Alexey Proskuryakov.
+
+        * Misc/WebStringTruncator.mm:
+        (defaultMenuFont): Changed to use NeverDestroyed since I had to touch this file anyway.
+        (fontFromNSFont): Ditto. Also improved variable names a bit.
+        (+[WebStringTruncator initialize]): Added threading initialization, needed for main
+        thread assertions in string truncator code.
+
</ins><span class="cx"> 2014-03-27  Commit Queue  &lt;commit-queue@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Unreviewed, rolling out r166360.
</span></span></pre></div>
<a id="trunkSourceWebKitmacMiscWebStringTruncatormm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/Misc/WebStringTruncator.mm (166447 => 166448)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/Misc/WebStringTruncator.mm        2014-03-29 03:08:59 UTC (rev 166447)
+++ trunk/Source/WebKit/mac/Misc/WebStringTruncator.mm        2014-03-29 03:18:27 UTC (rev 166448)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2005, 2006 Apple Inc.  All rights reserved.
</del><ins>+ * Copyright (C) 2005, 2006, 2014 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -33,66 +33,53 @@
</span><span class="cx"> #import &lt;WebCore/FontCache.h&gt;
</span><span class="cx"> #import &lt;WebCore/FontPlatformData.h&gt;
</span><span class="cx"> #import &lt;WebCore/StringTruncator.h&gt;
</span><del>-#import &lt;wtf/StdLibExtras.h&gt;
-#import &lt;wtf/text/WTFString.h&gt;
</del><ins>+#import &lt;runtime/InitializeThreading.h&gt;
+#import &lt;wtf/MainThread.h&gt;
+#import &lt;wtf/NeverDestroyed.h&gt;
</ins><span class="cx"> 
</span><del>-using namespace WebCore;
-
-static NSFont *defaultMenuFont()
</del><ins>+static WebCore::Font&amp; fontFromNSFont(NSFont *font)
</ins><span class="cx"> {
</span><del>-    static NSFont *defaultMenuFont = nil;
-    if (!defaultMenuFont) {
-        defaultMenuFont = [NSFont menuFontOfSize:0];
-        CFRetain(defaultMenuFont);
-    }
-    return defaultMenuFont;
</del><ins>+    static NeverDestroyed&lt;RetainPtr&lt;NSFont&gt;&gt; currentNSFont;
+    static NeverDestroyed&lt;WebCore::Font&gt; currentFont;
+    if ([font isEqual:currentNSFont.get().get()])
+        return currentFont;
+    currentNSFont.get() = font;
+    currentFont.get() = WebCore::Font(WebCore::FontPlatformData(font, [font pointSize]), ![[NSGraphicsContext currentContext] isDrawingToScreen]);
+    return currentFont;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-static Font&amp; fontFromNSFont(NSFont *font)
-{
-    static NSFont *currentFont;
-    DEPRECATED_DEFINE_STATIC_LOCAL(Font, currentRenderer, ());
-
-    if ([font isEqual:currentFont])
-        return currentRenderer;
-    if (currentFont)
-        CFRelease(currentFont);
-    currentFont = font;
-    CFRetain(currentFont);
-    FontPlatformData f(font, [font pointSize]);
-    currentRenderer = Font(f, ![[NSGraphicsContext currentContext] isDrawingToScreen]);
-    return currentRenderer;
-}
-
</del><span class="cx"> @implementation WebStringTruncator
</span><span class="cx"> 
</span><span class="cx"> + (void)initialize
</span><span class="cx"> {
</span><span class="cx">     InitWebCoreSystemInterface();
</span><ins>+    JSC::initializeThreading();
+    WTF::initializeMainThreadToProcessMainThread();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> + (NSString *)centerTruncateString:(NSString *)string toWidth:(float)maxWidth
</span><span class="cx"> {
</span><del>-    FontCachePurgePreventer fontCachePurgePreventer;
-    return StringTruncator::centerTruncate(string, maxWidth, fontFromNSFont(defaultMenuFont()));
</del><ins>+    static NeverDestroyed&lt;RetainPtr&lt;NSFont&gt;&gt; menuFont = [NSFont menuFontOfSize:0];
+    WebCore::FontCachePurgePreventer fontCachePurgePreventer;
+    return WebCore::StringTruncator::centerTruncate(string, maxWidth, fontFromNSFont(menuFont.get().get()));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> + (NSString *)centerTruncateString:(NSString *)string toWidth:(float)maxWidth withFont:(NSFont *)font
</span><span class="cx"> {
</span><del>-    FontCachePurgePreventer fontCachePurgePreventer;
-    return StringTruncator::centerTruncate(string, maxWidth, fontFromNSFont(font));
</del><ins>+    WebCore::FontCachePurgePreventer fontCachePurgePreventer;
+    return WebCore::StringTruncator::centerTruncate(string, maxWidth, fontFromNSFont(font));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> + (NSString *)rightTruncateString:(NSString *)string toWidth:(float)maxWidth withFont:(NSFont *)font
</span><span class="cx"> {
</span><del>-    FontCachePurgePreventer fontCachePurgePreventer;
-    return StringTruncator::rightTruncate(string, maxWidth, fontFromNSFont(font));
</del><ins>+    WebCore::FontCachePurgePreventer fontCachePurgePreventer;
+    return WebCore::StringTruncator::rightTruncate(string, maxWidth, fontFromNSFont(font));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> + (float)widthOfString:(NSString *)string font:(NSFont *)font
</span><span class="cx"> {
</span><del>-    FontCachePurgePreventer fontCachePurgePreventer;
-    return StringTruncator::width(string, fontFromNSFont(font));
</del><ins>+    WebCore::FontCachePurgePreventer fontCachePurgePreventer;
+    return WebCore::StringTruncator::width(string, fontFromNSFont(font));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> @end
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (166447 => 166448)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2014-03-29 03:08:59 UTC (rev 166447)
+++ trunk/Tools/ChangeLog        2014-03-29 03:18:27 UTC (rev 166448)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2014-03-28  Darin Adler  &lt;darin@apple.com&gt;
+
+        Fix recently-introduced off-by-one error in centerTruncateToBuffer
+        https://bugs.webkit.org/show_bug.cgi?id=130889
+
+        Reviewed by Alexey Proskuryakov.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: Added StringTruncator.mm.
+        * TestWebKitAPI/Tests/mac/StringTruncator.mm: Added. One test for each of the
+        WebStringTruncator methods; should be good for a start. These are dependent on the
+        metrics of Helvetica 12, but I am hoping that will be consistent across OS X machines.
+
</ins><span class="cx"> 2014-03-28  Martin Hock  &lt;mhock@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Unreviewed. Add myself as a committer.
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (166447 => 166448)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj        2014-03-29 03:08:59 UTC (rev 166447)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj        2014-03-29 03:18:27 UTC (rev 166448)
</span><span class="lines">@@ -124,6 +124,7 @@
</span><span class="cx">                 9331407C17B4419000F083B1 /* DidNotHandleKeyDown.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9331407B17B4419000F083B1 /* DidNotHandleKeyDown.cpp */; };
</span><span class="cx">                 9361002914DC95A70061379D /* lots-of-iframes.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 9361002814DC957B0061379D /* lots-of-iframes.html */; };
</span><span class="cx">                 939BA91714103412001A01BD /* DeviceScaleFactorOnBack.mm in Sources */ = {isa = PBXBuildFile; fileRef = 939BA91614103412001A01BD /* DeviceScaleFactorOnBack.mm */; };
</span><ins>+                939BFE3A18E5548900883275 /* StringTruncator.mm in Sources */ = {isa = PBXBuildFile; fileRef = 939BFE3918E5548900883275 /* StringTruncator.mm */; };
</ins><span class="cx">                 93A427A9180D9B0700CD24D7 /* RefPtr.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93A427A8180D9B0700CD24D7 /* RefPtr.cpp */; };
</span><span class="cx">                 93A427AB180DA26400CD24D7 /* Ref.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93A427AA180DA26400CD24D7 /* Ref.cpp */; };
</span><span class="cx">                 93ABA80916DDAB91002DB2FA /* StringHasher.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93ABA80816DDAB91002DB2FA /* StringHasher.cpp */; };
</span><span class="lines">@@ -450,6 +451,7 @@
</span><span class="cx">                 9331407B17B4419000F083B1 /* DidNotHandleKeyDown.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DidNotHandleKeyDown.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 9361002814DC957B0061379D /* lots-of-iframes.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = &quot;lots-of-iframes.html&quot;; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 939BA91614103412001A01BD /* DeviceScaleFactorOnBack.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DeviceScaleFactorOnBack.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                939BFE3918E5548900883275 /* StringTruncator.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = StringTruncator.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 93A427A8180D9B0700CD24D7 /* RefPtr.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RefPtr.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 93A427AA180DA26400CD24D7 /* Ref.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Ref.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 93A427AC180DA60F00CD24D7 /* MoveOnly.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MoveOnly.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -975,13 +977,14 @@
</span><span class="cx">                                 C540F775152E4DA000A40C8C /* SimplifyMarkup.mm */,
</span><span class="cx">                                 291861FD17BD4DC700D4E41E /* StopLoadingFromDidFinishLoading.mm */,
</span><span class="cx">                                 E194E1BA177E5145009C4D4E /* StopLoadingFromDidReceiveResponse.mm */,
</span><del>-                                CE32C7C718184C4900CD8C28 /* WillPerformClientRedirectToURLCrash.mm */,
</del><span class="cx">                                 3799AD3914120A43005EB0C6 /* StringByEvaluatingJavaScriptFromString.mm */,
</span><ins>+                                939BFE3918E5548900883275 /* StringTruncator.mm */,
</ins><span class="cx">                                 37A6895D148A9B50005100FA /* SubresourceErrorCrash.mm */,
</span><span class="cx">                                 E490296714E2E3A4002BEDD1 /* TypingStyleCrash.mm */,
</span><span class="cx">                                 51FBBB4C1513D4E900822738 /* WebViewCanPasteURL.mm */,
</span><span class="cx">                                 C2EB2DD116CAC7AC009B52EE /* WebViewDidCreateJavaScriptContext.mm */,
</span><span class="cx">                                 37E38C33169B7D010084C28C /* WebViewDidRemoveFrameFromHierarchy.mm */,
</span><ins>+                                CE32C7C718184C4900CD8C28 /* WillPerformClientRedirectToURLCrash.mm */,
</ins><span class="cx">                                 1A7BFC0A171A0BDB00BC5F64 /* WillSendSubmitEvent.mm */,
</span><span class="cx">                                 A5E2027215B2181900C13E14 /* WindowlessWebViewWithMedia.mm */,
</span><span class="cx">                         );
</span><span class="lines">@@ -1256,6 +1259,7 @@
</span><span class="cx">                                 14F3B11315E45EAB00210069 /* SaturatedArithmeticOperations.cpp in Sources */,
</span><span class="cx">                                 261516D615B0E60500A2C201 /* SetAndUpdateCacheModel.mm in Sources */,
</span><span class="cx">                                 52B8CF9615868CF000281053 /* SetDocumentURI.mm in Sources */,
</span><ins>+                                939BFE3A18E5548900883275 /* StringTruncator.mm in Sources */,
</ins><span class="cx">                                 7C8DDAAB1735DEEE00EA5AC0 /* CloseThenTerminate.cpp in Sources */,
</span><span class="cx">                                 CDC2C71517970DDB00E627FB /* TimeRanges.cpp in Sources */,
</span><span class="cx">                                 51FCF79A1534AC6D00104491 /* ShouldGoToBackForwardListItem.cpp in Sources */,
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsmacStringTruncatormm"></a>
<div class="addfile"><h4>Added: trunk/Tools/TestWebKitAPI/Tests/mac/StringTruncator.mm (0 => 166448)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/mac/StringTruncator.mm                                (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/mac/StringTruncator.mm        2014-03-29 03:18:27 UTC (rev 166448)
</span><span class="lines">@@ -0,0 +1,46 @@
</span><ins>+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import &quot;config.h&quot;
+#import &quot;PlatformUtilities.h&quot;
+
+#import &lt;WebKit/WebStringTruncator.h&gt;
+
+namespace TestWebKitAPI {
+
+TEST(WebKit1, StringTruncator)
+{
+    @autoreleasepool {
+        EXPECT_STREQ([[WebStringTruncator centerTruncateString:@&quot;abcdefghijklmnopqrstuvwxyz&quot; toWidth:100 withFont:[NSFont fontWithName:@&quot;Helvetica&quot; size:12]] UTF8String], &quot;abcdef…tuvwxyz&quot;);
+        EXPECT_STREQ([[WebStringTruncator centerTruncateString:@&quot;abcdefghijklmnopqrstuvwxyz&quot; toWidth:100] UTF8String], &quot;abcde…uvwxyz&quot;);
+        EXPECT_STREQ([[WebStringTruncator rightTruncateString:@&quot;abcdefghijklmnopqrstuvwxyz&quot; toWidth:100 withFont:[NSFont fontWithName:@&quot;Helvetica&quot; size:12]] UTF8String], &quot;abcdefghijklmno…&quot;);
+        EXPECT_STREQ([[WebStringTruncator centerTruncateString:@&quot;ābcdefghijklmnopqrstuvwxyz&quot; toWidth:100 withFont:[NSFont fontWithName:@&quot;Helvetica&quot; size:12]] UTF8String], &quot;ābcdefg…tuvwxyz&quot;);
+        EXPECT_STREQ([[WebStringTruncator rightTruncateString:@&quot;ābcdefghijklmnopqrstuvwxyz&quot; toWidth:100 withFont:[NSFont fontWithName:@&quot;Helvetica&quot; size:12]] UTF8String], &quot;ābcdefghijklmno…&quot;);
+        EXPECT_EQ([WebStringTruncator widthOfString:@&quot;abcdefghijklmnopqrstuvwxyz&quot; font:[NSFont fontWithName:@&quot;Helvetica&quot; size:12]], 152.736328125);
+        EXPECT_EQ([WebStringTruncator widthOfString:@&quot;ābcdefghijklmnopqrstuvwxyz&quot; font:[NSFont fontWithName:@&quot;Helvetica&quot; size:12]], 152.736328125);
+    }
+}
+
+} // namespace TestWebKitAPI
</ins><span class="cx">Property changes on: trunk/Tools/TestWebKitAPI/Tests/mac/StringTruncator.mm
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
</div>

</body>
</html>