<!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>[242360] 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/242360">242360</a></dd>
<dt>Author</dt> <dd>darin@apple.com</dd>
<dt>Date</dt> <dd>2019-03-04 08:58:33 -0800 (Mon, 04 Mar 2019)</dd>
</dl>

<h3>Log Message</h3>
<pre>Prepare to improve handling of conversion of float to strings
https://bugs.webkit.org/show_bug.cgi?id=195262

Reviewed by Daniel Bates.

Source/WTF:

* wtf/dtoa.cpp:
(WTF::truncateTrailingZeros): Renamed from
formatStringTruncatingTrailingZerosIfNeeded and removed the calls
to double_conversion::StringBuilder::Finalizer, since the caller
already does that.
(WTF::numberToFixedPrecisionString): Added an overload for float
and updated to use the new truncateTrailingZeros.
(WTF::numberToFixedWidthString): Added an overload for float.

* wtf/text/AtomicString.cpp:
(WTF::AtomicString::number): Added float overload. This is a
behavior change, but in all cases for the better. The old behavior
was to convert to double first and then do "shortest form"
conversion, and it's always better to just do that as float.
* wtf/text/AtomicString.h: Added float overload of AtomicString::number.

* wtf/text/StringBuilder.cpp:
(WTF::StringBuilder::appendFixedPrecisionNumber): Added float
overload.
(WTF::StringBuilder::appendShortestFormNumber): Renamed from
appendECMAScriptNumber and did the above.
(WTF::StringBuilder::appendFixedWidthNumber): Ditto.
* wtf/text/StringBuilder.h: Added overloads for float and
appendShortestFormNumber. The appendNumber and appendECMAScriptNumber
functions are now inlines in the header, since they are expressed
entirely in terms of the other functions.

* wtf/text/WTFString.cpp:
(WTF::String::numberToStringFixedPrecision): Added float overload.
Removed unnecessary explicit conversion to String.
(WTF::String::numberToStringShortest): Renamed from
numberToStringECMAScript and did the above.
(WTF::String::numberToStringFixedWidth): Ditto.

* wtf/text/WTFString.h: Added overloads for float and
numberToStringShortest. The number and numberToStringECMAScript
functions are now inlines in the header, since they are expressed
entirely in terms of the other functions.

LayoutTests:

* svg/dom/SVGAngle-expected.txt:
* svg/dom/SVGAngle.html:
* svg/dom/SVGLength-px-expected.txt:
* svg/dom/SVGLength-px-with-context-expected.txt:
* svg/dom/SVGLength-px-with-context.html:
* svg/dom/SVGLength-px.html:
Remove checks that depend on the precision and number of serialization.
The current tests depend on behavior that we'd like to change in the future and
some of them had already been updated since the behavior is different in different
web browsers. Tricky issue because of the mix of single and double precision in
the SVG engine and the JavaScript language, and straightforward to keep the tests
useful without this unnecessary dependency. Generally we check the units of the
result of valueAsString, and not the numeric result. Another idea would be to
check the numeric part of the result by converting it back to a number and
comparing it as a number rather than as a string.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestssvgdomSVGAngleexpectedtxt">trunk/LayoutTests/svg/dom/SVGAngle-expected.txt</a></li>
<li><a href="#trunkLayoutTestssvgdomSVGAnglehtml">trunk/LayoutTests/svg/dom/SVGAngle.html</a></li>
<li><a href="#trunkLayoutTestssvgdomSVGLengthpxexpectedtxt">trunk/LayoutTests/svg/dom/SVGLength-px-expected.txt</a></li>
<li><a href="#trunkLayoutTestssvgdomSVGLengthpxwithcontextexpectedtxt">trunk/LayoutTests/svg/dom/SVGLength-px-with-context-expected.txt</a></li>
<li><a href="#trunkLayoutTestssvgdomSVGLengthpxwithcontexthtml">trunk/LayoutTests/svg/dom/SVGLength-px-with-context.html</a></li>
<li><a href="#trunkLayoutTestssvgdomSVGLengthpxhtml">trunk/LayoutTests/svg/dom/SVGLength-px.html</a></li>
<li><a href="#trunkSourceWTFChangeLog">trunk/Source/WTF/ChangeLog</a></li>
<li><a href="#trunkSourceWTFwtfdtoacpp">trunk/Source/WTF/wtf/dtoa.cpp</a></li>
<li><a href="#trunkSourceWTFwtftextAtomicStringcpp">trunk/Source/WTF/wtf/text/AtomicString.cpp</a></li>
<li><a href="#trunkSourceWTFwtftextAtomicStringh">trunk/Source/WTF/wtf/text/AtomicString.h</a></li>
<li><a href="#trunkSourceWTFwtftextStringBuildercpp">trunk/Source/WTF/wtf/text/StringBuilder.cpp</a></li>
<li><a href="#trunkSourceWTFwtftextStringBuilderh">trunk/Source/WTF/wtf/text/StringBuilder.h</a></li>
<li><a href="#trunkSourceWTFwtftextWTFStringcpp">trunk/Source/WTF/wtf/text/WTFString.cpp</a></li>
<li><a href="#trunkSourceWTFwtftextWTFStringh">trunk/Source/WTF/wtf/text/WTFString.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (242359 => 242360)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog      2019-03-04 16:57:38 UTC (rev 242359)
+++ trunk/LayoutTests/ChangeLog 2019-03-04 16:58:33 UTC (rev 242360)
</span><span class="lines">@@ -1,3 +1,26 @@
</span><ins>+2019-03-03  Darin Adler  <darin@apple.com>
+
+        Prepare to improve handling of conversion of float to strings
+        https://bugs.webkit.org/show_bug.cgi?id=195262
+
+        Reviewed by Daniel Bates.
+
+        * svg/dom/SVGAngle-expected.txt:
+        * svg/dom/SVGAngle.html:
+        * svg/dom/SVGLength-px-expected.txt:
+        * svg/dom/SVGLength-px-with-context-expected.txt:
+        * svg/dom/SVGLength-px-with-context.html:
+        * svg/dom/SVGLength-px.html:
+        Remove checks that depend on the precision and number of serialization.
+        The current tests depend on behavior that we'd like to change in the future and
+        some of them had already been updated since the behavior is different in different
+        web browsers. Tricky issue because of the mix of single and double precision in
+        the SVG engine and the JavaScript language, and straightforward to keep the tests
+        useful without this unnecessary dependency. Generally we check the units of the
+        result of valueAsString, and not the numeric result. Another idea would be to
+        check the numeric part of the result by converting it back to a number and
+        comparing it as a number rather than as a string.
+
</ins><span class="cx"> 2019-03-04  Truitt Savell  <tsavell@apple.com>
</span><span class="cx"> 
</span><span class="cx">         webkit.org/b/195210 resolve by r242308, unskipping tests.
</span></span></pre></div>
<a id="trunkLayoutTestssvgdomSVGAngleexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/svg/dom/SVGAngle-expected.txt (242359 => 242360)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/svg/dom/SVGAngle-expected.txt  2019-03-04 16:57:38 UTC (rev 242359)
+++ trunk/LayoutTests/svg/dom/SVGAngle-expected.txt     2019-03-04 16:58:33 UTC (rev 242360)
</span><span class="lines">@@ -66,7 +66,7 @@
</span><span class="cx"> 
</span><span class="cx"> Check valid arguments for 'newValueSpecifiedUnits', that should only modify the 'valueAsString'
</span><span class="cx"> PASS angle.newValueSpecifiedUnits(SVGAngle.SVG_ANGLETYPE_RAD, parseFloat(Math.PI.toFixed(5))) is undefined.
</span><del>-PASS angle.valueAsString is "3.14159rad"
</del><ins>+PASS angle.valueAsString.slice(-3) is "rad"
</ins><span class="cx"> PASS angle.value.toFixed(1) is "180.0"
</span><span class="cx"> PASS angle.valueInSpecifiedUnits.toFixed(5) is Math.PI.toFixed(5)
</span><span class="cx"> PASS angle.unitType is SVGAngle.SVG_ANGLETYPE_RAD
</span><span class="lines">@@ -170,7 +170,7 @@
</span><span class="cx"> PASS angle.convertToSpecifiedUnits(SVGAngle.SVG_ANGLETYPE_RAD) is undefined.
</span><span class="cx"> PASS angle.value.toFixed(1) is "180.0"
</span><span class="cx"> PASS angle.valueInSpecifiedUnits.toFixed(5) is "3.14159"
</span><del>-PASS angle.valueAsString is "3.14159rad"
</del><ins>+PASS angle.valueAsString.slice(-3) is "rad"
</ins><span class="cx"> PASS angle.unitType is SVGAngle.SVG_ANGLETYPE_RAD
</span><span class="cx"> 
</span><span class="cx"> Now try converting the RAD value into an unknown value, that should fail and throw
</span><span class="lines">@@ -177,7 +177,7 @@
</span><span class="cx"> PASS angle.convertToSpecifiedUnits(SVGAngle.SVG_ANGLETYPE_UNKNOWN) threw exception NotSupportedError: The operation is not supported..
</span><span class="cx"> PASS angle.value.toFixed(1) is "180.0"
</span><span class="cx"> PASS angle.valueInSpecifiedUnits.toFixed(5) is "3.14159"
</span><del>-PASS angle.valueAsString is "3.14159rad"
</del><ins>+PASS angle.valueAsString.slice(-3) is "rad"
</ins><span class="cx"> PASS angle.unitType is SVGAngle.SVG_ANGLETYPE_RAD
</span><span class="cx"> 
</span><span class="cx"> Now convert the RAD value into a DEG value, and assure that all properties have been synchronized
</span></span></pre></div>
<a id="trunkLayoutTestssvgdomSVGAnglehtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/svg/dom/SVGAngle.html (242359 => 242360)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/svg/dom/SVGAngle.html  2019-03-04 16:57:38 UTC (rev 242359)
+++ trunk/LayoutTests/svg/dom/SVGAngle.html     2019-03-04 16:58:33 UTC (rev 242360)
</span><span class="lines">@@ -89,7 +89,8 @@
</span><span class="cx"> debug("");
</span><span class="cx"> debug("Check valid arguments for 'newValueSpecifiedUnits', that should only modify the 'valueAsString'");
</span><span class="cx"> shouldBeUndefined("angle.newValueSpecifiedUnits(SVGAngle.SVG_ANGLETYPE_RAD, parseFloat(Math.PI.toFixed(5)))");
</span><del>-shouldBeEqualToString("angle.valueAsString", Math.PI.toFixed(5) + "rad");
</del><ins>+// Exact result of valueAsString depends on precision, no trivial way to correctly test it, especially across engines.
+shouldBeEqualToString("angle.valueAsString.slice(-3)", "rad");
</ins><span class="cx"> shouldBeEqualToString("angle.value.toFixed(1)", "180.0");
</span><span class="cx"> shouldBe("angle.valueInSpecifiedUnits.toFixed(5)", "Math.PI.toFixed(5)");
</span><span class="cx"> shouldBe("angle.unitType", "SVGAngle.SVG_ANGLETYPE_RAD");
</span><span class="lines">@@ -213,7 +214,8 @@
</span><span class="cx"> shouldBeUndefined("angle.convertToSpecifiedUnits(SVGAngle.SVG_ANGLETYPE_RAD)");
</span><span class="cx"> shouldBeEqualToString("angle.value.toFixed(1)", "180.0");
</span><span class="cx"> shouldBeEqualToString("angle.valueInSpecifiedUnits.toFixed(5)", Math.PI.toFixed(5));
</span><del>-shouldBeEqualToString("angle.valueAsString", Math.PI.toFixed(5) + "rad");
</del><ins>+// Exact result of valueAsString depends on precision, no trivial way to correctly test it, especially across engines.
+shouldBeEqualToString("angle.valueAsString.slice(-3)", "rad");
</ins><span class="cx"> shouldBe("angle.unitType", "SVGAngle.SVG_ANGLETYPE_RAD");
</span><span class="cx"> 
</span><span class="cx"> debug("");
</span><span class="lines">@@ -221,7 +223,8 @@
</span><span class="cx"> shouldThrow("angle.convertToSpecifiedUnits(SVGAngle.SVG_ANGLETYPE_UNKNOWN)");
</span><span class="cx"> shouldBeEqualToString("angle.value.toFixed(1)", "180.0");
</span><span class="cx"> shouldBeEqualToString("angle.valueInSpecifiedUnits.toFixed(5)", Math.PI.toFixed(5));
</span><del>-shouldBeEqualToString("angle.valueAsString", Math.PI.toFixed(5) + "rad");
</del><ins>+// Exact result of valueAsString depends on precision, no trivial way to correctly test it, especially across engines.
+shouldBeEqualToString("angle.valueAsString.slice(-3)", "rad");
</ins><span class="cx"> shouldBe("angle.unitType", "SVGAngle.SVG_ANGLETYPE_RAD");
</span><span class="cx"> 
</span><span class="cx"> debug("");
</span></span></pre></div>
<a id="trunkLayoutTestssvgdomSVGLengthpxexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/svg/dom/SVGLength-px-expected.txt (242359 => 242360)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/svg/dom/SVGLength-px-expected.txt      2019-03-04 16:57:38 UTC (rev 242359)
+++ trunk/LayoutTests/svg/dom/SVGLength-px-expected.txt 2019-03-04 16:58:33 UTC (rev 242360)
</span><span class="lines">@@ -48,7 +48,7 @@
</span><span class="cx"> 
</span><span class="cx"> Convert from px to cm
</span><span class="cx"> PASS length.convertToSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_CM) is undefined.
</span><del>-PASS length.valueAsString is "0.0529167cm"
</del><ins>+PASS length.valueAsString.slice(-2) is "cm"
</ins><span class="cx"> PASS length.valueInSpecifiedUnits.toFixed(7) is "0.0529167"
</span><span class="cx"> PASS length.value.toFixed(1) is "2.0"
</span><span class="cx"> PASS length.unitType is SVGLength.SVG_LENGTHTYPE_CM
</span><span class="lines">@@ -57,7 +57,7 @@
</span><span class="cx"> 
</span><span class="cx"> Convert from px to mm
</span><span class="cx"> PASS length.convertToSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_MM) is undefined.
</span><del>-PASS length.valueAsString is "0.529167mm"
</del><ins>+PASS length.valueAsString.slice(-2) is "mm"
</ins><span class="cx"> PASS length.valueInSpecifiedUnits.toFixed(6) is "0.529167"
</span><span class="cx"> PASS length.value.toFixed(1) is "2.0"
</span><span class="cx"> PASS length.unitType is SVGLength.SVG_LENGTHTYPE_MM
</span><span class="lines">@@ -66,7 +66,7 @@
</span><span class="cx"> 
</span><span class="cx"> Convert from px to in
</span><span class="cx"> PASS length.convertToSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_IN) is undefined.
</span><del>-PASS length.valueAsString is "0.0208333in"
</del><ins>+PASS length.valueAsString.slice(-2) is "in"
</ins><span class="cx"> PASS length.valueInSpecifiedUnits.toFixed(7) is "0.0208333"
</span><span class="cx"> PASS length.value.toFixed(1) is "2.0"
</span><span class="cx"> PASS length.unitType is SVGLength.SVG_LENGTHTYPE_IN
</span></span></pre></div>
<a id="trunkLayoutTestssvgdomSVGLengthpxwithcontextexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/svg/dom/SVGLength-px-with-context-expected.txt (242359 => 242360)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/svg/dom/SVGLength-px-with-context-expected.txt 2019-03-04 16:57:38 UTC (rev 242359)
+++ trunk/LayoutTests/svg/dom/SVGLength-px-with-context-expected.txt    2019-03-04 16:58:33 UTC (rev 242360)
</span><span class="lines">@@ -21,7 +21,7 @@
</span><span class="cx"> 
</span><span class="cx"> Convert from px to percentage
</span><span class="cx"> PASS length.convertToSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_PERCENTAGE) is undefined.
</span><del>-PASS length.valueAsString is "1.33333%"
</del><ins>+PASS length.valueAsString.slice(-1) is "%"
</ins><span class="cx"> PASS length.valueInSpecifiedUnits.toFixed(5) is "1.33333"
</span><span class="cx"> PASS length.value.toFixed(1) is "2.0"
</span><span class="cx"> PASS length.unitType is SVGLength.SVG_LENGTHTYPE_PERCENTAGE
</span><span class="lines">@@ -30,7 +30,7 @@
</span><span class="cx"> 
</span><span class="cx"> Convert from px to ems
</span><span class="cx"> PASS length.convertToSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_EMS) is undefined.
</span><del>-PASS length.valueAsString is "0.166667em"
</del><ins>+PASS length.valueAsString.slice(-2) is "em"
</ins><span class="cx"> PASS length.valueInSpecifiedUnits.toFixed(6) is "0.166667"
</span><span class="cx"> PASS length.value.toFixed(1) is "2.0"
</span><span class="cx"> PASS length.unitType is SVGLength.SVG_LENGTHTYPE_EMS
</span><span class="lines">@@ -39,6 +39,7 @@
</span><span class="cx"> 
</span><span class="cx"> Convert from px to exs
</span><span class="cx"> PASS length.convertToSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_EXS) is undefined.
</span><ins>+PASS length.valueAsString.slice(-2) is "ex"
</ins><span class="cx"> PASS length.valueInSpecifiedUnits.toFixed(1) is "0.2"
</span><span class="cx"> PASS length.value.toFixed(1) is "2.0"
</span><span class="cx"> PASS length.unitType is SVGLength.SVG_LENGTHTYPE_EXS
</span><span class="lines">@@ -47,7 +48,7 @@
</span><span class="cx"> 
</span><span class="cx"> Convert from px to cm
</span><span class="cx"> PASS length.convertToSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_CM) is undefined.
</span><del>-PASS length.valueAsString is "0.0529167cm"
</del><ins>+PASS length.valueAsString.slice(-2) is "cm"
</ins><span class="cx"> PASS length.valueInSpecifiedUnits.toFixed(7) is "0.0529167"
</span><span class="cx"> PASS length.value.toFixed(1) is "2.0"
</span><span class="cx"> PASS length.unitType is SVGLength.SVG_LENGTHTYPE_CM
</span><span class="lines">@@ -56,7 +57,7 @@
</span><span class="cx"> 
</span><span class="cx"> Convert from px to mm
</span><span class="cx"> PASS length.convertToSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_MM) is undefined.
</span><del>-PASS length.valueAsString is "0.529167mm"
</del><ins>+PASS length.valueAsString.slice(-2) is "mm"
</ins><span class="cx"> PASS length.valueInSpecifiedUnits.toFixed(6) is "0.529167"
</span><span class="cx"> PASS length.value.toFixed(1) is "2.0"
</span><span class="cx"> PASS length.unitType is SVGLength.SVG_LENGTHTYPE_MM
</span><span class="lines">@@ -65,7 +66,7 @@
</span><span class="cx"> 
</span><span class="cx"> Convert from px to in
</span><span class="cx"> PASS length.convertToSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_IN) is undefined.
</span><del>-PASS length.valueAsString is "0.0208333in"
</del><ins>+PASS length.valueAsString.slice(-2) is "in"
</ins><span class="cx"> PASS length.valueInSpecifiedUnits.toFixed(7) is "0.0208333"
</span><span class="cx"> PASS length.value.toFixed(1) is "2.0"
</span><span class="cx"> PASS length.unitType is SVGLength.SVG_LENGTHTYPE_IN
</span><span class="lines">@@ -83,6 +84,7 @@
</span><span class="cx"> 
</span><span class="cx"> Convert from px to pc
</span><span class="cx"> PASS length.convertToSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_PC) is undefined.
</span><ins>+PASS length.valueAsString.slice(-2) is "pc"
</ins><span class="cx"> PASS length.valueInSpecifiedUnits.toFixed(3) is "0.125"
</span><span class="cx"> PASS length.value.toFixed(1) is "2.0"
</span><span class="cx"> PASS length.unitType is SVGLength.SVG_LENGTHTYPE_PC
</span></span></pre></div>
<a id="trunkLayoutTestssvgdomSVGLengthpxwithcontexthtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/svg/dom/SVGLength-px-with-context.html (242359 => 242360)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/svg/dom/SVGLength-px-with-context.html 2019-03-04 16:57:38 UTC (rev 242359)
+++ trunk/LayoutTests/svg/dom/SVGLength-px-with-context.html    2019-03-04 16:58:33 UTC (rev 242360)
</span><span class="lines">@@ -80,7 +80,8 @@
</span><span class="cx"> debug("Convert from px to percentage");
</span><span class="cx"> shouldBeUndefined("length.convertToSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_PERCENTAGE)");
</span><span class="cx"> referenceValue = Number(2 / svgWidth * 100).toFixed(5);
</span><del>-shouldBeEqualToString("length.valueAsString", referenceValue + "%");
</del><ins>+// Exact result of valueAsString depends on precision, no trivial way to correctly test it, especially across engines.
+shouldBeEqualToString("length.valueAsString.slice(-1)", "%");
</ins><span class="cx"> shouldBeEqualToString("length.valueInSpecifiedUnits.toFixed(5)", referenceValue);
</span><span class="cx"> shouldBeEqualToString("length.value.toFixed(1)", "2.0");
</span><span class="cx"> shouldBe("length.unitType", "SVGLength.SVG_LENGTHTYPE_PERCENTAGE");
</span><span class="lines">@@ -93,7 +94,8 @@
</span><span class="cx"> debug("Convert from px to ems");
</span><span class="cx"> shouldBeUndefined("length.convertToSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_EMS)");
</span><span class="cx"> referenceValue = Number(2 / fontSize).toFixed(6);
</span><del>-shouldBeEqualToString("length.valueAsString", referenceValue + "em");
</del><ins>+// Exact result of valueAsString depends on precision, no trivial way to correctly test it, especially across engines.
+shouldBeEqualToString("length.valueAsString.slice(-2)", "em");
</ins><span class="cx"> shouldBeEqualToString("length.valueInSpecifiedUnits.toFixed(6)", referenceValue);
</span><span class="cx"> shouldBeEqualToString("length.value.toFixed(1)", "2.0");
</span><span class="cx"> shouldBe("length.unitType", "SVGLength.SVG_LENGTHTYPE_EMS");
</span><span class="lines">@@ -106,7 +108,8 @@
</span><span class="cx"> debug("Convert from px to exs");
</span><span class="cx"> shouldBeUndefined("length.convertToSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_EXS)");
</span><span class="cx"> referenceValue = Number(2 / calculateXHeight()).toFixed(1);
</span><del>-// Don't check valueAsString here, it's unreliable across browsers.
</del><ins>+// Exact result of valueAsString depends on precision, no trivial way to correctly test it, especially across engines.
+shouldBeEqualToString("length.valueAsString.slice(-2)", "ex");
</ins><span class="cx"> shouldBeEqualToString("length.valueInSpecifiedUnits.toFixed(1)", referenceValue);
</span><span class="cx"> shouldBeEqualToString("length.value.toFixed(1)", "2.0");
</span><span class="cx"> shouldBe("length.unitType", "SVGLength.SVG_LENGTHTYPE_EXS");
</span><span class="lines">@@ -119,7 +122,8 @@
</span><span class="cx"> debug("Convert from px to cm");
</span><span class="cx"> shouldBeUndefined("length.convertToSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_CM)");
</span><span class="cx"> referenceValue = Number(2 * 2.54 / cssPixelsPerInch).toFixed(7);
</span><del>-shouldBeEqualToString("length.valueAsString", referenceValue + "cm");
</del><ins>+// Exact result of valueAsString depends on precision, no trivial way to correctly test it, especially across engines.
+shouldBeEqualToString("length.valueAsString.slice(-2)", "cm");
</ins><span class="cx"> shouldBeEqualToString("length.valueInSpecifiedUnits.toFixed(7)", referenceValue);
</span><span class="cx"> shouldBeEqualToString("length.value.toFixed(1)", "2.0");
</span><span class="cx"> shouldBe("length.unitType", "SVGLength.SVG_LENGTHTYPE_CM");
</span><span class="lines">@@ -132,7 +136,8 @@
</span><span class="cx"> debug("Convert from px to mm");
</span><span class="cx"> shouldBeUndefined("length.convertToSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_MM)");
</span><span class="cx"> referenceValue = Number(2 * 25.4 / cssPixelsPerInch).toFixed(6);
</span><del>-shouldBeEqualToString("length.valueAsString", referenceValue + "mm");
</del><ins>+// Exact result of valueAsString depends on precision, no trivial way to correctly test it, especially across engines.
+shouldBeEqualToString("length.valueAsString.slice(-2)", "mm");
</ins><span class="cx"> shouldBeEqualToString("length.valueInSpecifiedUnits.toFixed(6)", referenceValue);
</span><span class="cx"> shouldBeEqualToString("length.value.toFixed(1)", "2.0");
</span><span class="cx"> shouldBe("length.unitType", "SVGLength.SVG_LENGTHTYPE_MM");
</span><span class="lines">@@ -145,7 +150,8 @@
</span><span class="cx"> debug("Convert from px to in");
</span><span class="cx"> shouldBeUndefined("length.convertToSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_IN)");
</span><span class="cx"> referenceValue = Number(2 / cssPixelsPerInch).toFixed(7);
</span><del>-shouldBeEqualToString("length.valueAsString", referenceValue + "in");
</del><ins>+// Exact result of valueAsString depends on precision, no trivial way to correctly test it, especially across engines.
+shouldBeEqualToString("length.valueAsString.slice(-2)", "in");
</ins><span class="cx"> shouldBeEqualToString("length.valueInSpecifiedUnits.toFixed(7)", referenceValue);
</span><span class="cx"> shouldBeEqualToString("length.value.toFixed(1)", "2.0");
</span><span class="cx"> shouldBe("length.unitType", "SVGLength.SVG_LENGTHTYPE_IN");
</span><span class="lines">@@ -171,7 +177,8 @@
</span><span class="cx"> debug("Convert from px to pc");
</span><span class="cx"> shouldBeUndefined("length.convertToSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_PC)");
</span><span class="cx"> referenceValue = Number(2 / cssPixelsPerInch * 6).toFixed(3);
</span><del>-// Don't check valueAsString here, it's unreliable across browsers.
</del><ins>+// Exact result of valueAsString depends on precision, no trivial way to correctly test it, especially across engines.
+shouldBeEqualToString("length.valueAsString.slice(-2)", "pc");
</ins><span class="cx"> shouldBeEqualToString("length.valueInSpecifiedUnits.toFixed(3)", referenceValue);
</span><span class="cx"> shouldBeEqualToString("length.value.toFixed(1)", "2.0");
</span><span class="cx"> shouldBe("length.unitType", "SVGLength.SVG_LENGTHTYPE_PC");
</span></span></pre></div>
<a id="trunkLayoutTestssvgdomSVGLengthpxhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/svg/dom/SVGLength-px.html (242359 => 242360)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/svg/dom/SVGLength-px.html      2019-03-04 16:57:38 UTC (rev 242359)
+++ trunk/LayoutTests/svg/dom/SVGLength-px.html 2019-03-04 16:58:33 UTC (rev 242360)
</span><span class="lines">@@ -93,7 +93,8 @@
</span><span class="cx"> debug("Convert from px to cm");
</span><span class="cx"> shouldBeUndefined("length.convertToSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_CM)");
</span><span class="cx"> referenceValue = Number(2 * 2.54 / cssPixelsPerInch).toFixed(7);
</span><del>-shouldBeEqualToString("length.valueAsString", referenceValue + "cm");
</del><ins>+// Exact result of valueAsString depends on precision, no trivial way to correctly test it, especially across engines.
+shouldBeEqualToString("length.valueAsString.slice(-2)", "cm");
</ins><span class="cx"> shouldBeEqualToString("length.valueInSpecifiedUnits.toFixed(7)", referenceValue);
</span><span class="cx"> shouldBeEqualToString("length.value.toFixed(1)", "2.0");
</span><span class="cx"> shouldBe("length.unitType", "SVGLength.SVG_LENGTHTYPE_CM");
</span><span class="lines">@@ -106,7 +107,8 @@
</span><span class="cx"> debug("Convert from px to mm");
</span><span class="cx"> shouldBeUndefined("length.convertToSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_MM)");
</span><span class="cx"> referenceValue = Number(2 * 25.4 / cssPixelsPerInch).toFixed(6);
</span><del>-shouldBeEqualToString("length.valueAsString", referenceValue + "mm");
</del><ins>+// Exact result of valueAsString depends on precision, no trivial way to correctly test it, especially across engines.
+shouldBeEqualToString("length.valueAsString.slice(-2)", "mm");
</ins><span class="cx"> shouldBeEqualToString("length.valueInSpecifiedUnits.toFixed(6)", referenceValue);
</span><span class="cx"> shouldBeEqualToString("length.value.toFixed(1)", "2.0");
</span><span class="cx"> shouldBe("length.unitType", "SVGLength.SVG_LENGTHTYPE_MM");
</span><span class="lines">@@ -119,7 +121,8 @@
</span><span class="cx"> debug("Convert from px to in");
</span><span class="cx"> shouldBeUndefined("length.convertToSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_IN)");
</span><span class="cx"> referenceValue = Number(2 / cssPixelsPerInch).toFixed(7);
</span><del>-shouldBeEqualToString("length.valueAsString", referenceValue + "in");
</del><ins>+// Exact result of valueAsString depends on precision, no trivial way to correctly test it, especially across engines.
+shouldBeEqualToString("length.valueAsString.slice(-2)", "in");
</ins><span class="cx"> shouldBeEqualToString("length.valueInSpecifiedUnits.toFixed(7)", referenceValue);
</span><span class="cx"> shouldBeEqualToString("length.value.toFixed(1)", "2.0");
</span><span class="cx"> shouldBe("length.unitType", "SVGLength.SVG_LENGTHTYPE_IN");
</span></span></pre></div>
<a id="trunkSourceWTFChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/ChangeLog (242359 => 242360)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/ChangeLog       2019-03-04 16:57:38 UTC (rev 242359)
+++ trunk/Source/WTF/ChangeLog  2019-03-04 16:58:33 UTC (rev 242360)
</span><span class="lines">@@ -1,3 +1,49 @@
</span><ins>+2019-03-03  Darin Adler  <darin@apple.com>
+
+        Prepare to improve handling of conversion of float to strings
+        https://bugs.webkit.org/show_bug.cgi?id=195262
+
+        Reviewed by Daniel Bates.
+
+        * wtf/dtoa.cpp:
+        (WTF::truncateTrailingZeros): Renamed from
+        formatStringTruncatingTrailingZerosIfNeeded and removed the calls
+        to double_conversion::StringBuilder::Finalizer, since the caller
+        already does that.
+        (WTF::numberToFixedPrecisionString): Added an overload for float
+        and updated to use the new truncateTrailingZeros.
+        (WTF::numberToFixedWidthString): Added an overload for float.
+
+        * wtf/text/AtomicString.cpp:
+        (WTF::AtomicString::number): Added float overload. This is a
+        behavior change, but in all cases for the better. The old behavior
+        was to convert to double first and then do "shortest form"
+        conversion, and it's always better to just do that as float.
+        * wtf/text/AtomicString.h: Added float overload of AtomicString::number.
+
+        * wtf/text/StringBuilder.cpp:
+        (WTF::StringBuilder::appendFixedPrecisionNumber): Added float
+        overload.
+        (WTF::StringBuilder::appendShortestFormNumber): Renamed from
+        appendECMAScriptNumber and did the above.
+        (WTF::StringBuilder::appendFixedWidthNumber): Ditto.
+        * wtf/text/StringBuilder.h: Added overloads for float and
+        appendShortestFormNumber. The appendNumber and appendECMAScriptNumber
+        functions are now inlines in the header, since they are expressed
+        entirely in terms of the other functions.
+
+        * wtf/text/WTFString.cpp:
+        (WTF::String::numberToStringFixedPrecision): Added float overload.
+        Removed unnecessary explicit conversion to String.
+        (WTF::String::numberToStringShortest): Renamed from
+        numberToStringECMAScript and did the above.
+        (WTF::String::numberToStringFixedWidth): Ditto.
+
+        * wtf/text/WTFString.h: Added overloads for float and
+        numberToStringShortest. The number and numberToStringECMAScript
+        functions are now inlines in the header, since they are expressed
+        entirely in terms of the other functions.
+
</ins><span class="cx"> 2019-03-04  Andy Estes  <aestes@apple.com>
</span><span class="cx"> 
</span><span class="cx">         [Apple Pay] Move WebPaymentCoordinatorProxy from Source/WebKit/UIProcess to Source/WebKit/Shared
</span></span></pre></div>
<a id="trunkSourceWTFwtfdtoacpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/dtoa.cpp (242359 => 242360)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/dtoa.cpp    2019-03-04 16:57:38 UTC (rev 242359)
+++ trunk/Source/WTF/wtf/dtoa.cpp       2019-03-04 16:58:33 UTC (rev 242360)
</span><span class="lines">@@ -38,7 +38,7 @@
</span><span class="cx">     return builder.Finalize();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static inline const char* formatStringTruncatingTrailingZerosIfNeeded(NumberToStringBuffer& buffer, double_conversion::StringBuilder& builder)
</del><ins>+static inline void truncateTrailingZeros(NumberToStringBuffer& buffer, double_conversion::StringBuilder& builder)
</ins><span class="cx"> {
</span><span class="cx">     size_t length = builder.position();
</span><span class="cx">     size_t decimalPointPosition = 0;
</span><span class="lines">@@ -49,7 +49,7 @@
</span><span class="cx"> 
</span><span class="cx">     // No decimal separator found, early exit.
</span><span class="cx">     if (decimalPointPosition == length)
</span><del>-        return builder.Finalize();
</del><ins>+        return;
</ins><span class="cx"> 
</span><span class="cx">     size_t pastMantissa = decimalPointPosition + 1;
</span><span class="cx">     for (; pastMantissa < length; ++pastMantissa) {
</span><span class="lines">@@ -65,7 +65,7 @@
</span><span class="cx"> 
</span><span class="cx">     // No trailing zeros found to strip.
</span><span class="cx">     if (truncatedLength == pastMantissa)
</span><del>-        return builder.Finalize();
</del><ins>+        return;
</ins><span class="cx"> 
</span><span class="cx">     // If we removed all trailing zeros, remove the decimal point as well.
</span><span class="cx">     if (truncatedLength == decimalPointPosition + 1)
</span><span class="lines">@@ -73,12 +73,18 @@
</span><span class="cx"> 
</span><span class="cx">     // Truncate the mantissa, and return the final result.
</span><span class="cx">     builder.RemoveCharacters(truncatedLength, pastMantissa);
</span><del>-    return builder.Finalize();
</del><span class="cx"> }
</span><span class="cx"> 
</span><del>-const char* numberToFixedPrecisionString(double d, unsigned significantFigures, NumberToStringBuffer& buffer, bool truncateTrailingZeros)
</del><ins>+const char* numberToFixedPrecisionString(float number, unsigned significantFigures, NumberToStringBuffer& buffer, bool shouldTruncateTrailingZeros)
</ins><span class="cx"> {
</span><del>-    // Mimic sprintf("%.[precision]g", ...), but use dtoas rounding facilities.
</del><ins>+    // For now, just call the double precision version.
+    // Do that here instead of at callers to pave the way to add a more efficient code path later.
+    return numberToFixedPrecisionString(static_cast<double>(number), significantFigures, buffer, shouldTruncateTrailingZeros);
+}
+
+const char* numberToFixedPrecisionString(double d, unsigned significantFigures, NumberToStringBuffer& buffer, bool shouldTruncateTrailingZeros)
+{
+    // Mimic sprintf("%.[precision]g", ...).
</ins><span class="cx">     // "g": Signed value printed in f or e format, whichever is more compact for the given value and precision.
</span><span class="cx">     // The e format is used only when the exponent of the value is less than –4 or greater than or equal to the
</span><span class="cx">     // precision argument. Trailing zeros are truncated, and the decimal point appears only if one or more digits follow it.
</span><span class="lines">@@ -86,14 +92,21 @@
</span><span class="cx">     double_conversion::StringBuilder builder(&buffer[0], sizeof(buffer));
</span><span class="cx">     auto& converter = double_conversion::DoubleToStringConverter::EcmaScriptConverter();
</span><span class="cx">     converter.ToPrecision(d, significantFigures, &builder);
</span><del>-    if (!truncateTrailingZeros)
-        return builder.Finalize();
-    return formatStringTruncatingTrailingZerosIfNeeded(buffer, builder);
</del><ins>+    if (shouldTruncateTrailingZeros)
+        truncateTrailingZeros(buffer, builder);
+    return builder.Finalize();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+const char* numberToFixedWidthString(float number, unsigned decimalPlaces, NumberToStringBuffer& buffer)
+{
+    // For now, just call the double precision version.
+    // Do that here instead of at callers to pave the way to add a more efficient code path later.
+    return numberToFixedWidthString(static_cast<double>(number), decimalPlaces, buffer);
+}
+
</ins><span class="cx"> const char* numberToFixedWidthString(double d, unsigned decimalPlaces, NumberToStringBuffer& buffer)
</span><span class="cx"> {
</span><del>-    // Mimic sprintf("%.[precision]f", ...), but use dtoas rounding facilities.
</del><ins>+    // Mimic sprintf("%.[precision]f", ...).
</ins><span class="cx">     // "f": Signed value having the form [ – ]dddd.dddd, where dddd is one or more decimal digits.
</span><span class="cx">     // The number of digits before the decimal point depends on the magnitude of the number, and
</span><span class="cx">     // the number of digits after the decimal point depends on the requested precision.
</span></span></pre></div>
<a id="trunkSourceWTFwtftextAtomicStringcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/text/AtomicString.cpp (242359 => 242360)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/text/AtomicString.cpp       2019-03-04 16:57:38 UTC (rev 242359)
+++ trunk/Source/WTF/wtf/text/AtomicString.cpp  2019-03-04 16:58:33 UTC (rev 242360)
</span><span class="lines">@@ -101,6 +101,12 @@
</span><span class="cx">     return numberToStringUnsigned<AtomicString>(number);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+AtomicString AtomicString::number(float number)
+{
+    NumberToStringBuffer buffer;
+    return numberToString(number, buffer);
+}
+
</ins><span class="cx"> AtomicString AtomicString::number(double number)
</span><span class="cx"> {
</span><span class="cx">     NumberToStringBuffer buffer;
</span></span></pre></div>
<a id="trunkSourceWTFwtftextAtomicStringh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/text/AtomicString.h (242359 => 242360)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/text/AtomicString.h 2019-03-04 16:57:38 UTC (rev 242359)
+++ trunk/Source/WTF/wtf/text/AtomicString.h    2019-03-04 16:58:33 UTC (rev 242360)
</span><span class="lines">@@ -107,6 +107,7 @@
</span><span class="cx">     WTF_EXPORT_PRIVATE static AtomicString number(unsigned);
</span><span class="cx">     WTF_EXPORT_PRIVATE static AtomicString number(unsigned long);
</span><span class="cx">     WTF_EXPORT_PRIVATE static AtomicString number(unsigned long long);
</span><ins>+    WTF_EXPORT_PRIVATE static AtomicString number(float);
</ins><span class="cx">     WTF_EXPORT_PRIVATE static AtomicString number(double);
</span><span class="cx">     // If we need more overloads of the number function, we can add all the others that String has, but these seem to do for now.
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWTFwtftextStringBuildercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/text/StringBuilder.cpp (242359 => 242360)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/text/StringBuilder.cpp      2019-03-04 16:57:38 UTC (rev 242359)
+++ trunk/Source/WTF/wtf/text/StringBuilder.cpp 2019-03-04 16:58:33 UTC (rev 242360)
</span><span class="lines">@@ -378,7 +378,7 @@
</span><span class="cx">     numberToStringSigned<StringBuilder>(number, this);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void StringBuilder::appendNumber(unsigned int number)
</del><ins>+void StringBuilder::appendNumber(unsigned number)
</ins><span class="cx"> {
</span><span class="cx">     numberToStringUnsigned<StringBuilder>(number, this);
</span><span class="cx"> }
</span><span class="lines">@@ -403,18 +403,36 @@
</span><span class="cx">     numberToStringUnsigned<StringBuilder>(number, this);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void StringBuilder::appendNumber(double number, unsigned precision, TrailingZerosTruncatingPolicy trailingZerosTruncatingPolicy)
</del><ins>+void StringBuilder::appendFixedPrecisionNumber(float number, unsigned precision, TrailingZerosTruncatingPolicy policy)
</ins><span class="cx"> {
</span><span class="cx">     NumberToStringBuffer buffer;
</span><del>-    append(numberToFixedPrecisionString(number, precision, buffer, trailingZerosTruncatingPolicy == TruncateTrailingZeros));
</del><ins>+    append(numberToFixedPrecisionString(number, precision, buffer, policy == TruncateTrailingZeros));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void StringBuilder::appendECMAScriptNumber(double number)
</del><ins>+void StringBuilder::appendFixedPrecisionNumber(double number, unsigned precision, TrailingZerosTruncatingPolicy policy)
</ins><span class="cx"> {
</span><span class="cx">     NumberToStringBuffer buffer;
</span><ins>+    append(numberToFixedPrecisionString(number, precision, buffer, policy == TruncateTrailingZeros));
+}
+
+void StringBuilder::appendShortestFormNumber(float number)
+{
+    NumberToStringBuffer buffer;
</ins><span class="cx">     append(numberToString(number, buffer));
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void StringBuilder::appendShortestFormNumber(double number)
+{
+    NumberToStringBuffer buffer;
+    append(numberToString(number, buffer));
+}
+
+void StringBuilder::appendFixedWidthNumber(float number, unsigned decimalPlaces)
+{
+    NumberToStringBuffer buffer;
+    append(numberToFixedWidthString(number, decimalPlaces, buffer));
+}
+
</ins><span class="cx"> void StringBuilder::appendFixedWidthNumber(double number, unsigned decimalPlaces)
</span><span class="cx"> {
</span><span class="cx">     NumberToStringBuffer buffer;
</span></span></pre></div>
<a id="trunkSourceWTFwtftextStringBuilderh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/text/StringBuilder.h (242359 => 242360)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/text/StringBuilder.h        2019-03-04 16:57:38 UTC (rev 242359)
+++ trunk/Source/WTF/wtf/text/StringBuilder.h   2019-03-04 16:58:33 UTC (rev 242360)
</span><span class="lines">@@ -216,15 +216,26 @@
</span><span class="cx">     ALWAYS_INLINE void appendLiteral(const char (&characters)[characterCount]) { append(characters, characterCount - 1); }
</span><span class="cx"> 
</span><span class="cx">     WTF_EXPORT_PRIVATE void appendNumber(int);
</span><del>-    WTF_EXPORT_PRIVATE void appendNumber(unsigned int);
</del><ins>+    WTF_EXPORT_PRIVATE void appendNumber(unsigned);
</ins><span class="cx">     WTF_EXPORT_PRIVATE void appendNumber(long);
</span><span class="cx">     WTF_EXPORT_PRIVATE void appendNumber(unsigned long);
</span><span class="cx">     WTF_EXPORT_PRIVATE void appendNumber(long long);
</span><span class="cx">     WTF_EXPORT_PRIVATE void appendNumber(unsigned long long);
</span><del>-    WTF_EXPORT_PRIVATE void appendNumber(double, unsigned precision = 6, TrailingZerosTruncatingPolicy = TruncateTrailingZeros);
-    WTF_EXPORT_PRIVATE void appendECMAScriptNumber(double);
</del><ins>+    // FIXME: Change appendNumber to be appendShortestFormNumber instead of appendFixedPrecisionNumber.
+    void appendNumber(float);
+    void appendNumber(double, unsigned precision = 6, TrailingZerosTruncatingPolicy = TruncateTrailingZeros);
+
+    WTF_EXPORT_PRIVATE void appendShortestFormNumber(float);
+    WTF_EXPORT_PRIVATE void appendShortestFormNumber(double);
+    WTF_EXPORT_PRIVATE void appendFixedPrecisionNumber(float, unsigned precision = 6, TrailingZerosTruncatingPolicy = TruncateTrailingZeros);
+    WTF_EXPORT_PRIVATE void appendFixedPrecisionNumber(double, unsigned precision = 6, TrailingZerosTruncatingPolicy = TruncateTrailingZeros);
+    WTF_EXPORT_PRIVATE void appendFixedWidthNumber(float, unsigned decimalPlaces);
</ins><span class="cx">     WTF_EXPORT_PRIVATE void appendFixedWidthNumber(double, unsigned decimalPlaces);
</span><span class="cx"> 
</span><ins>+    // FIXME: Delete in favor of the name appendShortestFormNumber or just appendNumber.
+    void appendECMAScriptNumber(float);
+    void appendECMAScriptNumber(double);
+
</ins><span class="cx">     String toString()
</span><span class="cx">     {
</span><span class="cx">         if (!m_string.isNull()) {
</span><span class="lines">@@ -382,6 +393,28 @@
</span><span class="cx">     return m_bufferCharacters16;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+inline void StringBuilder::appendNumber(float number)
+{
+    appendFixedPrecisionNumber(number);
+}
+
+inline void StringBuilder::appendNumber(double number, unsigned precision, TrailingZerosTruncatingPolicy policy)
+{
+    appendFixedPrecisionNumber(number, precision, policy);
+}
+
+inline void StringBuilder::appendECMAScriptNumber(float number)
+{
+    // FIXME: This preserves existing behavior but is not what we want.
+    // In the future, this should either be a compilation error or call appendShortestFormNumber without converting to double.
+    appendShortestFormNumber(static_cast<double>(number));
+}
+
+inline void StringBuilder::appendECMAScriptNumber(double number)
+{
+    appendShortestFormNumber(number);
+}
+
</ins><span class="cx"> template <typename CharType>
</span><span class="cx"> bool equal(const StringBuilder& s, const CharType* buffer, unsigned length)
</span><span class="cx"> {
</span></span></pre></div>
<a id="trunkSourceWTFwtftextWTFStringcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/text/WTFString.cpp (242359 => 242360)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/text/WTFString.cpp  2019-03-04 16:57:38 UTC (rev 242359)
+++ trunk/Source/WTF/wtf/text/WTFString.cpp     2019-03-04 16:58:33 UTC (rev 242360)
</span><span class="lines">@@ -454,7 +454,7 @@
</span><span class="cx">     return numberToStringSigned<String>(number);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-String String::number(unsigned int number)
</del><ins>+String String::number(unsigned number)
</ins><span class="cx"> {
</span><span class="cx">     return numberToStringUnsigned<String>(number);
</span><span class="cx"> }
</span><span class="lines">@@ -479,22 +479,34 @@
</span><span class="cx">     return numberToStringUnsigned<String>(number);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-String String::number(double number, unsigned precision, TrailingZerosTruncatingPolicy trailingZerosTruncatingPolicy)
</del><ins>+String String::numberToStringFixedPrecision(float number, unsigned precision, TrailingZerosTruncatingPolicy trailingZerosTruncatingPolicy)
</ins><span class="cx"> {
</span><span class="cx">     NumberToStringBuffer buffer;
</span><del>-    return String(numberToFixedPrecisionString(number, precision, buffer, trailingZerosTruncatingPolicy == TruncateTrailingZeros));
</del><ins>+    return numberToFixedPrecisionString(number, precision, buffer, trailingZerosTruncatingPolicy == TruncateTrailingZeros);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-String String::numberToStringECMAScript(double number)
</del><ins>+String String::numberToStringFixedPrecision(double number, unsigned precision, TrailingZerosTruncatingPolicy trailingZerosTruncatingPolicy)
</ins><span class="cx"> {
</span><span class="cx">     NumberToStringBuffer buffer;
</span><del>-    return String(numberToString(number, buffer));
</del><ins>+    return numberToFixedPrecisionString(number, precision, buffer, trailingZerosTruncatingPolicy == TruncateTrailingZeros);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+String String::numberToStringShortest(float number)
+{
+    NumberToStringBuffer buffer;
+    return numberToString(number, buffer);
+}
+
+String String::numberToStringShortest(double number)
+{
+    NumberToStringBuffer buffer;
+    return numberToString(number, buffer);
+}
+
</ins><span class="cx"> String String::numberToStringFixedWidth(double number, unsigned decimalPlaces)
</span><span class="cx"> {
</span><span class="cx">     NumberToStringBuffer buffer;
</span><del>-    return String(numberToFixedWidthString(number, decimalPlaces, buffer));
</del><ins>+    return numberToFixedWidthString(number, decimalPlaces, buffer);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> int String::toIntStrict(bool* ok, int base) const
</span></span></pre></div>
<a id="trunkSourceWTFwtftextWTFStringh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/text/WTFString.h (242359 => 242360)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/text/WTFString.h    2019-03-04 16:57:38 UTC (rev 242359)
+++ trunk/Source/WTF/wtf/text/WTFString.h       2019-03-04 16:58:33 UTC (rev 242360)
</span><span class="lines">@@ -175,13 +175,21 @@
</span><span class="cx">     WTF_EXPORT_PRIVATE static String number(unsigned long);
</span><span class="cx">     WTF_EXPORT_PRIVATE static String number(long long);
</span><span class="cx">     WTF_EXPORT_PRIVATE static String number(unsigned long long);
</span><ins>+    // FIXME: Change number to be numberToStringShortest instead of numberToStringFixedPrecision.
+    static String number(float);
+    static String number(double, unsigned precision = 6, TrailingZerosTruncatingPolicy = TruncateTrailingZeros);
</ins><span class="cx"> 
</span><del>-    WTF_EXPORT_PRIVATE static String number(double, unsigned precision = 6, TrailingZerosTruncatingPolicy = TruncateTrailingZeros);
-
-    // Number to String conversion following the ECMAScript definition.
-    WTF_EXPORT_PRIVATE static String numberToStringECMAScript(double);
</del><ins>+    WTF_EXPORT_PRIVATE static String numberToStringShortest(float);
+    WTF_EXPORT_PRIVATE static String numberToStringShortest(double);
+    WTF_EXPORT_PRIVATE static String numberToStringFixedPrecision(float, unsigned precision = 6, TrailingZerosTruncatingPolicy = TruncateTrailingZeros);
+    WTF_EXPORT_PRIVATE static String numberToStringFixedPrecision(double, unsigned precision = 6, TrailingZerosTruncatingPolicy = TruncateTrailingZeros);
+    WTF_EXPORT_PRIVATE static String numberToStringFixedWidth(float, unsigned decimalPlaces);
</ins><span class="cx">     WTF_EXPORT_PRIVATE static String numberToStringFixedWidth(double, unsigned decimalPlaces);
</span><span class="cx"> 
</span><ins>+    // FIXME: Delete in favor of the name numberToStringShortest or just number.
+    static String numberToStringECMAScript(float);
+    static String numberToStringECMAScript(double);
+
</ins><span class="cx">     // Find a single character or string, also with match function & latin1 forms.
</span><span class="cx">     size_t find(UChar character, unsigned start = 0) const { return m_impl ? m_impl->find(character, start) : notFound; }
</span><span class="cx"> 
</span><span class="lines">@@ -630,6 +638,28 @@
</span><span class="cx">     return startsWithLettersIgnoringASCIICase(string.impl(), lowercaseLetters);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+inline String String::number(float number)
+{
+    return numberToStringFixedPrecision(number);
+}
+
+inline String String::number(double number, unsigned precision, TrailingZerosTruncatingPolicy policy)
+{
+    return numberToStringFixedPrecision(number, precision, policy);
+}
+
+inline String String::numberToStringECMAScript(float number)
+{
+    // FIXME: This preserves existing behavior but is not what we want.
+    // In the future, this should either be a compilation error or call numberToStringShortest without converting to double.
+    return numberToStringShortest(static_cast<double>(number));
+}
+
+inline String String::numberToStringECMAScript(double number)
+{
+    return numberToStringShortest(number);
+}
+
</ins><span class="cx"> inline namespace StringLiterals {
</span><span class="cx"> 
</span><span class="cx"> inline String operator"" _str(const char* characters, size_t)
</span></span></pre>
</div>
</div>

</body>
</html>