<!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" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { 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 #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#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>
<title>[19980] trunk/WebCore</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/19980">19980</a></dd>
<dt>Author</dt> <dd>aroben</dd>
<dt>Date</dt> <dd>2007-03-06 01:57:06 -0800 (Tue, 06 Mar 2007)</dd>
</dl>

<h3>Log Message</h3>
<pre>        Reviewed by Anders.

        Added a parameter to all StringTruncator methods to specify whether
        rounding hacks should be on or off.

        No layout test possible.

        * platform/StringTruncator.cpp:
        (WebCore::stringWidth): Added disableRoundingHacks parameter.
        (WebCore::truncateString): Ditto.
        (WebCore::StringTruncator::centerTruncate): Ditto.
        (WebCore::StringTruncator::rightTruncate): Ditto.
        (WebCore::StringTruncator::width): Ditto.
        * platform/StringTruncator.h: Ditto.
        * platform/mac/FileChooserMac.mm:
        (WebCore::FileChooser::basenameForWidth): Pass in false to
        centerTruncate so that the truncation matches the way the text will be
        rendered.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkWebCoreChangeLog">trunk/WebCore/ChangeLog</a></li>
<li><a href="#trunkWebCoreplatformStringTruncatorcpp">trunk/WebCore/platform/StringTruncator.cpp</a></li>
<li><a href="#trunkWebCoreplatformStringTruncatorh">trunk/WebCore/platform/StringTruncator.h</a></li>
<li><a href="#trunkWebCoreplatformmacFileChooserMacmm">trunk/WebCore/platform/mac/FileChooserMac.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/ChangeLog (19979 => 19980)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/ChangeLog        2007-03-06 09:05:42 UTC (rev 19979)
+++ trunk/WebCore/ChangeLog        2007-03-06 09:57:06 UTC (rev 19980)
</span><span class="lines">@@ -1,3 +1,24 @@
</span><ins>+2007-03-06  Adam Roben  &lt;aroben@apple.com&gt;
+
+        Reviewed by Anders.
+
+        Added a parameter to all StringTruncator methods to specify whether
+        rounding hacks should be on or off.
+
+        No layout test possible.
+
+        * platform/StringTruncator.cpp:
+        (WebCore::stringWidth): Added disableRoundingHacks parameter.
+        (WebCore::truncateString): Ditto.
+        (WebCore::StringTruncator::centerTruncate): Ditto.
+        (WebCore::StringTruncator::rightTruncate): Ditto.
+        (WebCore::StringTruncator::width): Ditto.
+        * platform/StringTruncator.h: Ditto.
+        * platform/mac/FileChooserMac.mm:
+        (WebCore::FileChooser::basenameForWidth): Pass in false to
+        centerTruncate so that the truncation matches the way the text will be
+        rendered.
+
</ins><span class="cx"> 2007-03-06  Anders Carlsson  &lt;acarlsson@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Reviewed by Maciej.
</span></span></pre></div>
<a id="trunkWebCoreplatformStringTruncatorcpp"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/platform/StringTruncator.cpp (19979 => 19980)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/platform/StringTruncator.cpp        2007-03-06 09:05:42 UTC (rev 19979)
+++ trunk/WebCore/platform/StringTruncator.cpp        2007-03-06 09:57:06 UTC (rev 19980)
</span><span class="lines">@@ -93,22 +93,23 @@
</span><span class="cx">     return truncatedLength;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static float stringWidth(const Font&amp; renderer, const UChar* characters, unsigned length)
</del><ins>+static float stringWidth(const Font&amp; renderer, const UChar* characters, unsigned length, bool disableRoundingHacks)
</ins><span class="cx"> {
</span><span class="cx">     TextRun run(characters, length);
</span><span class="cx">     TextStyle style;
</span><del>-    style.disableRoundingHacks();
</del><ins>+    if (disableRoundingHacks)
+        style.disableRoundingHacks();
</ins><span class="cx">     return renderer.floatWidth(run, style);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static String truncateString(const String&amp; string, float maxWidth, const Font&amp; font, TruncationFunction truncateToBuffer)
</del><ins>+static String truncateString(const String&amp; string, float maxWidth, const Font&amp; font, TruncationFunction truncateToBuffer, bool disableRoundingHacks)
</ins><span class="cx"> {
</span><span class="cx">     if (string.isEmpty())
</span><span class="cx">         return string;
</span><span class="cx">     
</span><span class="cx">     ASSERT(maxWidth &gt;= 0);
</span><span class="cx">     
</span><del>-    float currentEllipsisWidth = stringWidth(font, &amp;horizontalEllipsis, 1);
</del><ins>+    float currentEllipsisWidth = stringWidth(font, &amp;horizontalEllipsis, 1, disableRoundingHacks);
</ins><span class="cx">     
</span><span class="cx">     UChar stringBuffer[STRING_BUFFER_SIZE];
</span><span class="cx">     unsigned truncatedLength;
</span><span class="lines">@@ -124,7 +125,7 @@
</span><span class="cx">         truncatedLength = length;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    float width = stringWidth(font, stringBuffer, truncatedLength);
</del><ins>+    float width = stringWidth(font, stringBuffer, truncatedLength, disableRoundingHacks);
</ins><span class="cx">     if (width &lt;= maxWidth)
</span><span class="cx">         return string;
</span><span class="cx"> 
</span><span class="lines">@@ -160,7 +161,7 @@
</span><span class="cx">         
</span><span class="cx">         truncatedLength = truncateToBuffer(string, length, keepCount, stringBuffer);
</span><span class="cx"> 
</span><del>-        width = stringWidth(font, stringBuffer, truncatedLength);
</del><ins>+        width = stringWidth(font, stringBuffer, truncatedLength, disableRoundingHacks);
</ins><span class="cx">         if (width &lt;= maxWidth) {
</span><span class="cx">             keepCountForLargestKnownToFit = keepCount;
</span><span class="cx">             widthForLargestKnownToFit = width;
</span><span class="lines">@@ -182,19 +183,19 @@
</span><span class="cx">     return String(stringBuffer, truncatedLength);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-String StringTruncator::centerTruncate(const String&amp; string, float maxWidth, const Font&amp; font)
</del><ins>+String StringTruncator::centerTruncate(const String&amp; string, float maxWidth, const Font&amp; font, bool disableRoundingHacks)
</ins><span class="cx"> {
</span><del>-    return truncateString(string, maxWidth, font, centerTruncateToBuffer);
</del><ins>+    return truncateString(string, maxWidth, font, centerTruncateToBuffer, disableRoundingHacks);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-String StringTruncator::rightTruncate(const String&amp; string, float maxWidth, const Font&amp; font)
</del><ins>+String StringTruncator::rightTruncate(const String&amp; string, float maxWidth, const Font&amp; font, bool disableRoundingHacks)
</ins><span class="cx"> {
</span><del>-    return truncateString(string, maxWidth, font, rightTruncateToBuffer);
</del><ins>+    return truncateString(string, maxWidth, font, rightTruncateToBuffer, disableRoundingHacks);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-float StringTruncator::width(const String&amp; string, const Font&amp; font)
</del><ins>+float StringTruncator::width(const String&amp; string, const Font&amp; font, bool disableRoundingHacks)
</ins><span class="cx"> {
</span><del>-    return stringWidth(font, string.characters(), string.length());
</del><ins>+    return stringWidth(font, string.characters(), string.length(), disableRoundingHacks);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkWebCoreplatformStringTruncatorh"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/platform/StringTruncator.h (19979 => 19980)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/platform/StringTruncator.h        2007-03-06 09:05:42 UTC (rev 19979)
+++ trunk/WebCore/platform/StringTruncator.h        2007-03-06 09:57:06 UTC (rev 19980)
</span><span class="lines">@@ -36,9 +36,9 @@
</span><span class="cx">     
</span><span class="cx">     class StringTruncator {
</span><span class="cx">     public:
</span><del>-        static String centerTruncate(const String&amp;, float maxWidth, const Font&amp;);
-        static String rightTruncate(const String&amp;, float maxWidth, const Font&amp;);
-        static float width(const String&amp;, const Font&amp;);
</del><ins>+        static String centerTruncate(const String&amp;, float maxWidth, const Font&amp;, bool disableRoundingHacks = true);
+        static String rightTruncate(const String&amp;, float maxWidth, const Font&amp;, bool disableRoundingHacks = true);
+        static float width(const String&amp;, const Font&amp;, bool disableRoundingHacks = true);
</ins><span class="cx">     };
</span><span class="cx">     
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkWebCoreplatformmacFileChooserMacmm"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/platform/mac/FileChooserMac.mm (19979 => 19980)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/platform/mac/FileChooserMac.mm        2007-03-06 09:05:42 UTC (rev 19979)
+++ trunk/WebCore/platform/mac/FileChooserMac.mm        2007-03-06 09:57:06 UTC (rev 19980)
</span><span class="lines">@@ -122,7 +122,7 @@
</span><span class="cx">     else
</span><span class="cx">         strToTruncate = [[NSFileManager defaultManager] displayNameAtPath:m_filename];
</span><span class="cx"> 
</span><del>-    return StringTruncator::centerTruncate(strToTruncate, width, font);
</del><ins>+    return StringTruncator::centerTruncate(strToTruncate, width, font, false);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre>
</div>
</div>

</body>
</html>