<!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>[23931] trunk</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/23931">23931</a></dd>
<dt>Author</dt> <dd>weinig</dd>
<dt>Date</dt> <dd>2007-07-02 13:41:11 -0700 (Mon, 02 Jul 2007)</dd>
</dl>

<h3>Log Message</h3>
<pre>JavaScriptCore:

        Reviewed by Kevin McCullough.

        Fourth round of fixes for implicit 64-32 bit conversion errors.
        &lt;rdar://problem/5292262&gt;

        Add custom piDouble and piFloat constants to use instead of M_PI.

        * kjs/math_object.cpp:
        (MathObjectImp::getValueProperty):
        * wtf/MathExtras.h:
        (wtf_atan2):

WebCore:

        Reviewed by Darin.

        Fifth round of fixes for implicit 64-32 bit conversion errors.
        &lt;rdar://problem/5292262&gt;

        Add toFloat() method to string classes and use it where appropriate.

        * WebCore.xcodeproj/project.pbxproj:
        * css/cssparser.cpp:
        (WebCore::CSSParser::lex):
        * ksvg2/svg/SVGAngle.cpp:
        (WebCore::SVGAngle::setValueAsString):
        * platform/AtomicString.h:
        (WebCore::AtomicString::toFloat):
        * platform/DeprecatedString.cpp:
        (WebCore::DeprecatedString::toFloat):
        * platform/DeprecatedString.h:
        * platform/FloatConversionUtilities.h: Added.
        (WebCore::narrowPrecisionToFloat):
        (WebCore::narrowPrecisionToCGFloat):
        * platform/PlatformString.h:
        * platform/String.cpp:
        (WebCore::String::toFloat):
        * platform/StringImpl.cpp:
        (WebCore::StringImpl::toFloat):
        * platform/StringImpl.h:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkJavaScriptCoreChangeLog">trunk/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkWebCoreChangeLog">trunk/WebCore/ChangeLog</a></li>
<li><a href="#trunkWebCoreWebCorexcodeprojprojectpbxproj">trunk/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkWebCorecsscssparsercpp">trunk/WebCore/css/cssparser.cpp</a></li>
<li><a href="#trunkWebCoreksvg2svgSVGAnglecpp">trunk/WebCore/ksvg2/svg/SVGAngle.cpp</a></li>
<li><a href="#trunkWebCoreplatformAtomicStringh">trunk/WebCore/platform/AtomicString.h</a></li>
<li><a href="#trunkWebCoreplatformDeprecatedStringcpp">trunk/WebCore/platform/DeprecatedString.cpp</a></li>
<li><a href="#trunkWebCoreplatformDeprecatedStringh">trunk/WebCore/platform/DeprecatedString.h</a></li>
<li><a href="#trunkWebCoreplatformPlatformStringh">trunk/WebCore/platform/PlatformString.h</a></li>
<li><a href="#trunkWebCoreplatformStringcpp">trunk/WebCore/platform/String.cpp</a></li>
<li><a href="#trunkWebCoreplatformStringImplcpp">trunk/WebCore/platform/StringImpl.cpp</a></li>
<li><a href="#trunkWebCoreplatformStringImplh">trunk/WebCore/platform/StringImpl.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkWebCoreplatformFloatConversionUtilitiesh">trunk/WebCore/platform/FloatConversionUtilities.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/JavaScriptCore/ChangeLog (23930 => 23931)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JavaScriptCore/ChangeLog        2007-07-02 18:44:00 UTC (rev 23930)
+++ trunk/JavaScriptCore/ChangeLog        2007-07-02 20:41:11 UTC (rev 23931)
</span><span class="lines">@@ -2,7 +2,7 @@
</span><span class="cx"> 
</span><span class="cx">         Reviewed by Kevin McCullough.
</span><span class="cx"> 
</span><del>-        Third round of fixes for implicit 64-32 bit conversion errors.
</del><ins>+        Fourth round of fixes for implicit 64-32 bit conversion errors.
</ins><span class="cx">         &lt;rdar://problem/5292262&gt;
</span><span class="cx"> 
</span><span class="cx">         Add custom piDouble and piFloat constants to use instead of M_PI.
</span></span></pre></div>
<a id="trunkWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/ChangeLog (23930 => 23931)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/ChangeLog        2007-07-02 18:44:00 UTC (rev 23930)
+++ trunk/WebCore/ChangeLog        2007-07-02 20:41:11 UTC (rev 23931)
</span><span class="lines">@@ -1,8 +1,37 @@
</span><span class="cx"> 2007-07-02  Sam Weinig  &lt;sam@webkit.org&gt;
</span><span class="cx"> 
</span><ins>+        Reviewed by Darin.
+
+        Fifth round of fixes for implicit 64-32 bit conversion errors.
+        &lt;rdar://problem/5292262&gt;
+
+        Add toFloat() method to string classes and use it where appropriate.
+
+        * WebCore.xcodeproj/project.pbxproj:
+        * css/cssparser.cpp:
+        (WebCore::CSSParser::lex):
+        * ksvg2/svg/SVGAngle.cpp:
+        (WebCore::SVGAngle::setValueAsString):
+        * platform/AtomicString.h:
+        (WebCore::AtomicString::toFloat):
+        * platform/DeprecatedString.cpp:
+        (WebCore::DeprecatedString::toFloat):
+        * platform/DeprecatedString.h:
+        * platform/FloatConversionUtilities.h: Added.
+        (WebCore::narrowPrecisionToFloat):
+        (WebCore::narrowPrecisionToCGFloat):
+        * platform/PlatformString.h:
+        * platform/String.cpp:
+        (WebCore::String::toFloat):
+        * platform/StringImpl.cpp:
+        (WebCore::StringImpl::toFloat):
+        * platform/StringImpl.h:
+
+2007-07-02  Sam Weinig  &lt;sam@webkit.org&gt;
+
</ins><span class="cx">         Reviewed by Kevin McCullough.
</span><span class="cx"> 
</span><del>-        Third round of fixes for implicit 64-32 bit conversion errors.
</del><ins>+        Fourth round of fixes for implicit 64-32 bit conversion errors.
</ins><span class="cx">         &lt;rdar://problem/5292262&gt;
</span><span class="cx"> 
</span><span class="cx">         Use new piDouble and piFloat constants instead of M_PI.
</span></span></pre></div>
<a id="trunkWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/WebCore.xcodeproj/project.pbxproj (23930 => 23931)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/WebCore.xcodeproj/project.pbxproj        2007-07-02 18:44:00 UTC (rev 23930)
+++ trunk/WebCore/WebCore.xcodeproj/project.pbxproj        2007-07-02 20:41:11 UTC (rev 23931)
</span><span class="lines">@@ -2756,6 +2756,7 @@
</span><span class="cx">                 BC1A37BE097C715F0019F3D8 /* DOMTraversal.h in Headers */ = {isa = PBXBuildFile; fileRef = BC1A37A8097C715F0019F3D8 /* DOMTraversal.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 BC1A37BF097C715F0019F3D8 /* DOMUtility.mm in Sources */ = {isa = PBXBuildFile; fileRef = BC1A37A9097C715F0019F3D8 /* DOMUtility.mm */; };
</span><span class="cx">                 BC1A37C0097C715F0019F3D8 /* DOMViews.h in Headers */ = {isa = PBXBuildFile; fileRef = BC1A37AA097C715F0019F3D8 /* DOMViews.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><ins>+                BC1B8EAB0C39808F00C5B5ED /* FloatConversionUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = BC1B8EAA0C39808F00C5B5ED /* FloatConversionUtilities.h */; };
</ins><span class="cx">                 BC20FB7F0C0E8E6C00D1447F /* JSCSSValueCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC20FB7E0C0E8E6C00D1447F /* JSCSSValueCustom.cpp */; };
</span><span class="cx">                 BC305C790C076BB300CD20F0 /* JSHTMLObjectElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC305C770C076BB300CD20F0 /* JSHTMLObjectElement.cpp */; };
</span><span class="cx">                 BC305C7A0C076BB300CD20F0 /* JSHTMLObjectElement.h in Headers */ = {isa = PBXBuildFile; fileRef = BC305C780C076BB300CD20F0 /* JSHTMLObjectElement.h */; };
</span><span class="lines">@@ -6072,6 +6073,7 @@
</span><span class="cx">                 BC1A37A8097C715F0019F3D8 /* DOMTraversal.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = DOMTraversal.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 BC1A37A9097C715F0019F3D8 /* DOMUtility.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = DOMUtility.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 BC1A37AA097C715F0019F3D8 /* DOMViews.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = DOMViews.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                BC1B8EAA0C39808F00C5B5ED /* FloatConversionUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FloatConversionUtilities.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 BC20FB7E0C0E8E6C00D1447F /* JSCSSValueCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSCSSValueCustom.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 BC305C770C076BB300CD20F0 /* JSHTMLObjectElement.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLObjectElement.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 BC305C780C076BB300CD20F0 /* JSHTMLObjectElement.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSHTMLObjectElement.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -9506,6 +9508,7 @@
</span><span class="cx">                                 A79546420B5C4CB4007B438F /* DragData.cpp */,
</span><span class="cx">                                 A7CFB3D00B7ED10A0070C32D /* DragImage.h */,
</span><span class="cx">                                 A7CFB3CF0B7ED10A0070C32D /* DragImage.cpp */,
</span><ins>+                                BC1B8EAA0C39808F00C5B5ED /* FloatConversionUtilities.h */,
</ins><span class="cx">                                 934FE9E40B5CA539003E4A73 /* FileChooser.cpp */,
</span><span class="cx">                                 066C772A0AB603B700238CC4 /* FileChooser.h */,
</span><span class="cx">                                 BC6D6DD009AF906600F59759 /* Font.cpp */,
</span><span class="lines">@@ -11640,6 +11643,7 @@
</span><span class="cx">                                 BC94D1570C275CAB006BC617 /* GlobalHistory.h in Headers */,
</span><span class="cx">                                 BC5A86850C33676000EEA649 /* DOMSelection.h in Headers */,
</span><span class="cx">                                 BC5A86B60C3367E800EEA649 /* JSDOMSelection.h in Headers */,
</span><ins>+                                BC1B8EAB0C39808F00C5B5ED /* FloatConversionUtilities.h in Headers */,
</ins><span class="cx">                         );
</span><span class="cx">                         runOnlyForDeploymentPostprocessing = 0;
</span><span class="cx">                 };
</span></span></pre></div>
<a id="trunkWebCorecsscssparsercpp"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/css/cssparser.cpp (23930 => 23931)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/css/cssparser.cpp        2007-07-02 18:44:00 UTC (rev 23930)
+++ trunk/WebCore/css/cssparser.cpp        2007-07-02 20:41:11 UTC (rev 23931)
</span><span class="lines">@@ -3012,7 +3012,7 @@
</span><span class="cx">         length--;
</span><span class="cx">     case FLOAT:
</span><span class="cx">     case INTEGER:
</span><del>-        yylval-&gt;val = DeprecatedString((DeprecatedChar *)t, length).toDouble();
</del><ins>+        yylval-&gt;val = DeprecatedString((DeprecatedChar*)t, length).toFloat();
</ins><span class="cx">         break;
</span><span class="cx"> 
</span><span class="cx">     default:
</span></span></pre></div>
<a id="trunkWebCoreksvg2svgSVGAnglecpp"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/ksvg2/svg/SVGAngle.cpp (23930 => 23931)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/ksvg2/svg/SVGAngle.cpp        2007-07-02 18:44:00 UTC (rev 23930)
+++ trunk/WebCore/ksvg2/svg/SVGAngle.cpp        2007-07-02 20:41:11 UTC (rev 23931)
</span><span class="lines">@@ -88,7 +88,7 @@
</span><span class="cx">     m_valueAsString = s;
</span><span class="cx"> 
</span><span class="cx">     bool bOK;
</span><del>-    m_valueInSpecifiedUnits = m_valueAsString.toDouble(&amp;bOK);
</del><ins>+    m_valueInSpecifiedUnits = m_valueAsString.toFloat(&amp;bOK);
</ins><span class="cx">     m_unitType = SVG_ANGLETYPE_UNSPECIFIED;
</span><span class="cx"> 
</span><span class="cx">     if (!bOK) {
</span></span></pre></div>
<a id="trunkWebCoreplatformAtomicStringh"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/platform/AtomicString.h (23930 => 23931)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/platform/AtomicString.h        2007-07-02 18:44:00 UTC (rev 23930)
+++ trunk/WebCore/platform/AtomicString.h        2007-07-02 20:41:11 UTC (rev 23931)
</span><span class="lines">@@ -69,6 +69,7 @@
</span><span class="cx">     
</span><span class="cx">     int toInt(bool* ok = 0) const { return m_string.toInt(ok); }
</span><span class="cx">     double toDouble(bool* ok = 0) const { return m_string.toDouble(ok); }
</span><ins>+    float toFloat(bool* ok = 0) const { return m_string.toFloat(ok); }
</ins><span class="cx">     bool percentage(int&amp; p) const { return m_string.percentage(p); }
</span><span class="cx">     Length* toLengthArray(int&amp; len) const { return m_string.toLengthArray(len); }
</span><span class="cx">     Length* toCoordsArray(int&amp; len) const { return m_string.toCoordsArray(len); }
</span></span></pre></div>
<a id="trunkWebCoreplatformDeprecatedStringcpp"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/platform/DeprecatedString.cpp (23930 => 23931)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/platform/DeprecatedString.cpp        2007-07-02 18:44:00 UTC (rev 23930)
+++ trunk/WebCore/platform/DeprecatedString.cpp        2007-07-02 20:41:11 UTC (rev 23931)
</span><span class="lines">@@ -27,6 +27,7 @@
</span><span class="cx"> #include &quot;DeprecatedString.h&quot;
</span><span class="cx"> 
</span><span class="cx"> #include &quot;CString.h&quot;
</span><ins>+#include &quot;FloatConversionUtilities.h&quot;
</ins><span class="cx"> #include &quot;Logging.h&quot;
</span><span class="cx"> #include &quot;PlatformString.h&quot;
</span><span class="cx"> #include &quot;RegularExpression.h&quot;
</span><span class="lines">@@ -1487,6 +1488,12 @@
</span><span class="cx">     return val;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+float DeprecatedString::toFloat(bool* ok) const
+{
+    // FIXME: this will return ok even when the string does not fit into a float
+    return narrowPrecisionToFloat(toDouble(ok));
+}
+
</ins><span class="cx"> DeprecatedString DeprecatedString::left(unsigned len) const
</span><span class="cx"> {
</span><span class="cx">     return mid(0, len);
</span></span></pre></div>
<a id="trunkWebCoreplatformDeprecatedStringh"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/platform/DeprecatedString.h (23930 => 23931)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/platform/DeprecatedString.h        2007-07-02 18:44:00 UTC (rev 23930)
+++ trunk/WebCore/platform/DeprecatedString.h        2007-07-02 20:41:11 UTC (rev 23931)
</span><span class="lines">@@ -351,6 +351,7 @@
</span><span class="cx">     int toInt(bool *ok = 0, int base = 10) const;
</span><span class="cx">     unsigned toUInt(bool *ok = 0, int base = 10) const;
</span><span class="cx">     double toDouble(bool *ok = 0) const;
</span><ins>+    float toFloat(bool* ok = 0) const;
</ins><span class="cx"> 
</span><span class="cx">     static DeprecatedString number(int);
</span><span class="cx">     static DeprecatedString number(unsigned);
</span></span></pre></div>
<a id="trunkWebCoreplatformFloatConversionUtilitiesh"></a>
<div class="addfile"><h4>Added: trunk/WebCore/platform/FloatConversionUtilities.h (0 => 23931)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/platform/FloatConversionUtilities.h                                (rev 0)
+++ trunk/WebCore/platform/FloatConversionUtilities.h        2007-07-02 20:41:11 UTC (rev 23931)
</span><span class="lines">@@ -0,0 +1,58 @@
</span><ins>+/*
+ * Copyright (C) 2007 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. 
+ * 3.  Neither the name of Apple Computer, Inc. (&quot;Apple&quot;) nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS &quot;AS IS&quot; 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 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.
+ */
+
+#ifndef FloatConversionUtilities_h
+#define FloatConversionUtilities_h
+
+#include &lt;wtf/Platform.h&gt;
+
+namespace WebCore {
+
+    template&lt;typename T&gt;
+    float narrowPrecisionToFloat(T);
+
+    template&lt;&gt;
+    inline float narrowPrecisionToFloat(double number)
+    {
+        return static_cast&lt;float&gt;(number);
+    }
+
+#if PLATFORM(CG)
+    template&lt;typename T&gt;
+    CGFloat narrowPrecisionToCGFloat(T);
+
+    template&lt;&gt;
+    inline CGFloat narrowPrecisionToCGFloat(double number)
+    {
+        return static_cast&lt;CGFloat&gt;(number);
+    }
+#endif
+
+} // namespace WebCore
+
+#endif // FloatConversionUtilities_h
</ins></span></pre></div>
<a id="trunkWebCoreplatformPlatformStringh"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/platform/PlatformString.h (23930 => 23931)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/platform/PlatformString.h        2007-07-02 18:44:00 UTC (rev 23930)
+++ trunk/WebCore/platform/PlatformString.h        2007-07-02 20:41:11 UTC (rev 23931)
</span><span class="lines">@@ -139,6 +139,7 @@
</span><span class="cx"> 
</span><span class="cx">     int toInt(bool* ok = 0) const;
</span><span class="cx">     double toDouble(bool* ok = 0) const;
</span><ins>+    float toFloat(bool* ok = 0) const;
</ins><span class="cx">     Length* toLengthArray(int&amp; len) const;
</span><span class="cx">     Length* toCoordsArray(int&amp; len) const;
</span><span class="cx">     bool percentage(int &amp;_percentage) const;
</span></span></pre></div>
<a id="trunkWebCoreplatformStringcpp"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/platform/String.cpp (23930 => 23931)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/platform/String.cpp        2007-07-02 18:44:00 UTC (rev 23930)
+++ trunk/WebCore/platform/String.cpp        2007-07-02 20:41:11 UTC (rev 23931)
</span><span class="lines">@@ -369,6 +369,16 @@
</span><span class="cx">     return m_impl-&gt;toDouble(ok);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+float String::toFloat(bool* ok) const
+{
+    if (!m_impl) {
+        if (ok)
+            *ok = false;
+        return 0.0f;
+    }
+    return m_impl-&gt;toFloat(ok);
+}
+
</ins><span class="cx"> String String::copy() const
</span><span class="cx"> {
</span><span class="cx">     if (!m_impl)
</span></span></pre></div>
<a id="trunkWebCoreplatformStringImplcpp"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/platform/StringImpl.cpp (23930 => 23931)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/platform/StringImpl.cpp        2007-07-02 18:44:00 UTC (rev 23930)
+++ trunk/WebCore/platform/StringImpl.cpp        2007-07-02 20:41:11 UTC (rev 23931)
</span><span class="lines">@@ -29,6 +29,7 @@
</span><span class="cx"> #include &quot;CString.h&quot;
</span><span class="cx"> #include &quot;CharacterNames.h&quot;
</span><span class="cx"> #include &quot;DeprecatedString.h&quot;
</span><ins>+#include &quot;FloatConversionUtilities.h&quot;
</ins><span class="cx"> #include &quot;Length.h&quot;
</span><span class="cx"> #include &quot;StringHash.h&quot;
</span><span class="cx"> #include &quot;TextBreakIterator.h&quot;
</span><span class="lines">@@ -642,6 +643,12 @@
</span><span class="cx">     return val;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+float StringImpl::toFloat(bool* ok) const
+{
+    // FIXME: this will return ok even when the string does not fit into a float
+    return narrowPrecisionToFloat(toDouble(ok));
+}
+
</ins><span class="cx"> static bool equal(const UChar* a, const char* b, int length)
</span><span class="cx"> {
</span><span class="cx">     ASSERT(length &gt;= 0);
</span></span></pre></div>
<a id="trunkWebCoreplatformStringImplh"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/platform/StringImpl.h (23930 => 23931)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/platform/StringImpl.h        2007-07-02 18:44:00 UTC (rev 23930)
+++ trunk/WebCore/platform/StringImpl.h        2007-07-02 20:41:11 UTC (rev 23931)
</span><span class="lines">@@ -101,6 +101,7 @@
</span><span class="cx"> 
</span><span class="cx">     int toInt(bool* ok = 0) const; // ignores trailing garbage, unlike DeprecatedString
</span><span class="cx">     double toDouble(bool* ok = 0) const;
</span><ins>+    float toFloat(bool* ok = 0) const;
</ins><span class="cx"> 
</span><span class="cx">     Length* toCoordsArray(int&amp; len) const;
</span><span class="cx">     Length* toLengthArray(int&amp; len) const;
</span></span></pre>
</div>
</div>

</body>
</html>