Simplify StringBuilder API/align with makeString by removing appendFixed* functions...
authorweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 2 Jan 2020 19:31:56 +0000 (19:31 +0000)
committerweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 2 Jan 2020 19:31:56 +0000 (19:31 +0000)
https://bugs.webkit.org/show_bug.cgi?id=205671

Reviewed by Alex Christensen.

Source/JavaScriptCore:

* API/tests/ExecutionTimeLimitTest.cpp:
(testExecutionTimeLimit):
* runtime/Options.cpp:
(JSC::OptionReader::Option::dump const):
Replace all uses of builder.appendFixedPrecisionNumber(...) with builder.append(FormattedNumber::fixedPrecision(...)).

Source/WebCore:

* css/CSSFontVariationValue.cpp:
* css/CSSKeyframeRule.cpp:
* css/CSSTimingFunctionValue.cpp:
* css/parser/CSSParserToken.cpp:
* html/HTMLImageElement.cpp:
* page/scrolling/AxisScrollSnapOffsets.cpp:
* platform/graphics/Color.cpp:
* platform/graphics/ExtendedColor.cpp:
* platform/graphics/ca/win/PlatformCALayerWin.cpp:
* platform/graphics/freetype/FontCacheFreeType.cpp:
* svg/SVGNumberList.h:
* svg/SVGPathStringBuilder.cpp:
* svg/SVGPointList.h:
* svg/SVGTransformValue.h:
* svg/properties/SVGPropertyTraits.h:
* testing/Internals.cpp:
Replace all uses of builder.appendFixedPrecisionNumber(...) with builder.append(FormattedNumber::fixedPrecision(...))
and builder.appendFixedWidthNumber(...) with with builder.append(FormattedNumber::fixedWidth(...))

Source/WebKit:

* NetworkProcess/cache/NetworkCache.cpp:
(WebKit::NetworkCache::Cache::dumpContentsToFile):
* NetworkProcess/cache/NetworkCacheEntry.cpp:
(WebKit::NetworkCache::Entry::asJSON const):
* Shared/Gamepad/GamepadData.cpp:
(WebKit::GamepadData::loggingString const):
Replace all uses of builder.appendFixedPrecisionNumber(...) with builder.append(FormattedNumber::fixedPrecision(...)).

Source/WTF:

In an ongoing attempt to simplify the StringBuilder interface and unify it's functionality with makeString,
this change removes appendFixedPrecisionNumber() and appendFixedWidthNumber(), replacing their uses
with direct calls to append(), using a FormattedNumber object to direct it to the appropriate StringTypeAdapter.

* wtf/text/StringBuilder.h:
* wtf/text/StringBuilder.cpp:
(WTF::StringBuilder::appendFixedPrecisionNumber): Deleted.
(WTF::StringBuilder::appendFixedWidthNumber): Deleted.
Remove StringBuilder::appendFixedPrecisionNumber() and StringBuilder::appendFixedWidthNumber(). The same functionality
is available and more flexible by passing FormattedNumbers to the variadic append() function.

* wtf/text/TextStream.cpp:
(WTF::TextStream::operator<<):
* wtf/MediaTime.cpp:
(WTF::MediaTime::toString const):
Replace all uses of builder.appendFixedPrecisionNumber(...) with builder.append(FormattedNumber::fixedPrecision(...))
and builder.appendFixedWidthNumber(...) with with builder.append(FormattedNumber::fixedWidth(...))

Tools:

* WebKitTestRunner/InjectedBundle/atk/AccessibilityUIElementAtk.cpp:
Replace all uses of builder.appendFixedPrecisionNumber(...) with builder.append(FormattedNumber::fixedPrecision(...)).

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@253975 268f45cc-cd09-0410-ab3c-d52691b4dbfc

31 files changed:
Source/JavaScriptCore/API/tests/ExecutionTimeLimitTest.cpp
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/runtime/Options.cpp
Source/WTF/ChangeLog
Source/WTF/wtf/MediaTime.cpp
Source/WTF/wtf/text/StringBuilder.cpp
Source/WTF/wtf/text/StringBuilder.h
Source/WTF/wtf/text/TextStream.cpp
Source/WebCore/ChangeLog
Source/WebCore/css/CSSFontVariationValue.cpp
Source/WebCore/css/CSSKeyframeRule.cpp
Source/WebCore/css/CSSTimingFunctionValue.cpp
Source/WebCore/css/parser/CSSParserToken.cpp
Source/WebCore/html/HTMLImageElement.cpp
Source/WebCore/page/scrolling/AxisScrollSnapOffsets.cpp
Source/WebCore/platform/graphics/Color.cpp
Source/WebCore/platform/graphics/ExtendedColor.cpp
Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.cpp
Source/WebCore/platform/graphics/freetype/FontCacheFreeType.cpp
Source/WebCore/svg/SVGNumberList.h
Source/WebCore/svg/SVGPathStringBuilder.cpp
Source/WebCore/svg/SVGPointList.h
Source/WebCore/svg/SVGTransformValue.h
Source/WebCore/svg/properties/SVGPropertyTraits.h
Source/WebCore/testing/Internals.cpp
Source/WebKit/ChangeLog
Source/WebKit/NetworkProcess/cache/NetworkCache.cpp
Source/WebKit/NetworkProcess/cache/NetworkCacheEntry.cpp
Source/WebKit/Shared/Gamepad/GamepadData.cpp
Tools/ChangeLog
Tools/WebKitTestRunner/InjectedBundle/atk/AccessibilityUIElementAtk.cpp

index 31f4e52..8547a98 100644 (file)
@@ -200,7 +200,7 @@ int testExecutionTimeLimit()
 
             StringBuilder scriptBuilder;
             scriptBuilder.appendLiteral("function foo() { var startTime = currentCPUTime(); while (true) { for (var i = 0; i < 1000; i++); if (currentCPUTime() - startTime > ");
-            scriptBuilder.appendFixedPrecisionNumber(timeAfterWatchdogShouldHaveFired.seconds());
+            scriptBuilder.append(FormattedNumber::fixedPrecision(timeAfterWatchdogShouldHaveFired.seconds()));
             scriptBuilder.appendLiteral(") break; } } foo();");
 
             JSStringRef script = JSStringCreateWithUTF8CString(scriptBuilder.toString().utf8().data());
@@ -241,7 +241,7 @@ int testExecutionTimeLimit()
                                      "'use strict';"
                                      "if (i % 1000 === 0) {"
                                         "if (currentCPUTime() - startTime >");
-            scriptBuilder.appendFixedPrecisionNumber(timeAfterWatchdogShouldHaveFired.seconds());
+            scriptBuilder.append(FormattedNumber::fixedPrecision(timeAfterWatchdogShouldHaveFired.seconds()));
             scriptBuilder.appendLiteral("       ) { return; }");
             scriptBuilder.appendLiteral("    }");
             scriptBuilder.appendLiteral("    return recurse(i + 1); }");
@@ -281,7 +281,7 @@ int testExecutionTimeLimit()
             
             StringBuilder scriptBuilder;
             scriptBuilder.appendLiteral("function foo() { var startTime = currentCPUTime(); try { while (true) { for (var i = 0; i < 1000; i++); if (currentCPUTime() - startTime > ");
-            scriptBuilder.appendFixedPrecisionNumber(timeAfterWatchdogShouldHaveFired.seconds());
+            scriptBuilder.append(FormattedNumber::fixedPrecision(timeAfterWatchdogShouldHaveFired.seconds()));
             scriptBuilder.appendLiteral(") break; } } catch(e) { } } foo();");
 
             JSStringRef script = JSStringCreateWithUTF8CString(scriptBuilder.toString().utf8().data());
@@ -320,7 +320,7 @@ int testExecutionTimeLimit()
             
             StringBuilder scriptBuilder;
             scriptBuilder.appendLiteral("function foo() { var startTime = currentCPUTime(); while (true) { for (var i = 0; i < 1000; i++); if (currentCPUTime() - startTime > ");
-            scriptBuilder.appendFixedPrecisionNumber(timeAfterWatchdogShouldHaveFired.seconds());
+            scriptBuilder.append(FormattedNumber::fixedPrecision(timeAfterWatchdogShouldHaveFired.seconds()));
             scriptBuilder.appendLiteral(") break; } } foo();");
             
             JSStringRef script = JSStringCreateWithUTF8CString(scriptBuilder.toString().utf8().data());
@@ -359,7 +359,7 @@ int testExecutionTimeLimit()
             
             StringBuilder scriptBuilder;
             scriptBuilder.appendLiteral("function foo() { var startTime = currentCPUTime(); while (true) { for (var i = 0; i < 1000; i++); if (currentCPUTime() - startTime > ");
-            scriptBuilder.appendFixedPrecisionNumber(timeAfterWatchdogShouldHaveFired.seconds());
+            scriptBuilder.append(FormattedNumber::fixedPrecision(timeAfterWatchdogShouldHaveFired.seconds()));
             scriptBuilder.appendLiteral(") break; } } foo();");
 
             JSStringRef script = JSStringCreateWithUTF8CString(scriptBuilder.toString().utf8().data());
@@ -398,7 +398,7 @@ int testExecutionTimeLimit()
 
             StringBuilder scriptBuilder;
             scriptBuilder.appendLiteral("function foo() { var startTime = currentCPUTime(); while (true) { for (var i = 0; i < 1000; i++); if (currentCPUTime() - startTime > ");
-            scriptBuilder.appendFixedPrecisionNumber(maxBusyLoopTime.seconds()); // in seconds.
+            scriptBuilder.append(FormattedNumber::fixedPrecision(maxBusyLoopTime.seconds())); // in seconds.
             scriptBuilder.appendLiteral(") break; } } foo();");
 
             JSStringRef script = JSStringCreateWithUTF8CString(scriptBuilder.toString().utf8().data());
@@ -441,7 +441,7 @@ int testExecutionTimeLimit()
 
             StringBuilder scriptBuilder;
             scriptBuilder.appendLiteral("function foo() { var startTime = currentCPUTime(); while (true) { for (var i = 0; i < 1000; i++); if (currentCPUTime() - startTime > ");
-            scriptBuilder.appendFixedPrecisionNumber(timeAfterWatchdogShouldHaveFired.seconds());
+            scriptBuilder.append(FormattedNumber::fixedPrecision(timeAfterWatchdogShouldHaveFired.seconds()));
             scriptBuilder.appendLiteral(") break; } } foo();");
 
             JSStringRef script = JSStringCreateWithUTF8CString(scriptBuilder.toString().utf8().data());
index 00a6f8a..b5151f4 100644 (file)
@@ -1,3 +1,16 @@
+2020-01-02  Sam Weinig  <weinig@apple.com>
+
+        Simplify StringBuilder API/align with makeString by removing appendFixed* functions and using FormatNumber struct instead
+        https://bugs.webkit.org/show_bug.cgi?id=205671
+
+        Reviewed by Alex Christensen.
+
+        * API/tests/ExecutionTimeLimitTest.cpp:
+        (testExecutionTimeLimit):
+        * runtime/Options.cpp:
+        (JSC::OptionReader::Option::dump const):
+        Replace all uses of builder.appendFixedPrecisionNumber(...) with builder.append(FormattedNumber::fixedPrecision(...)).
+
 2020-01-01  Mark Lam  <mark.lam@apple.com>
 
         Declare some classes as final.
index 91ed739..008bdab 100644 (file)
@@ -1007,7 +1007,7 @@ void OptionReader::Option::dump(StringBuilder& builder) const
         builder.appendNumber(m_size);
         break;
     case Options::Type::Double:
-        builder.appendFixedPrecisionNumber(m_double);
+        builder.append(FormattedNumber::fixedPrecision(m_double));
         break;
     case Options::Type::Int32:
         builder.appendNumber(m_int32);
index 7289d70..d870871 100644 (file)
@@ -1,3 +1,28 @@
+2020-01-02  Sam Weinig  <weinig@apple.com>
+
+        Simplify StringBuilder API/align with makeString by removing appendFixed* functions and using FormatNumber struct instead
+        https://bugs.webkit.org/show_bug.cgi?id=205671
+
+        Reviewed by Alex Christensen.
+
+        In an ongoing attempt to simplify the StringBuilder interface and unify it's functionality with makeString,
+        this change removes appendFixedPrecisionNumber() and appendFixedWidthNumber(), replacing their uses
+        with direct calls to append(), using a FormattedNumber object to direct it to the appropriate StringTypeAdapter.
+
+        * wtf/text/StringBuilder.h:
+        * wtf/text/StringBuilder.cpp:
+        (WTF::StringBuilder::appendFixedPrecisionNumber): Deleted.
+        (WTF::StringBuilder::appendFixedWidthNumber): Deleted.
+        Remove StringBuilder::appendFixedPrecisionNumber() and StringBuilder::appendFixedWidthNumber(). The same functionality
+        is available and more flexible by passing FormattedNumbers to the variadic append() function.
+        
+        * wtf/text/TextStream.cpp:
+        (WTF::TextStream::operator<<):
+        * wtf/MediaTime.cpp:
+        (WTF::MediaTime::toString const):
+        Replace all uses of builder.appendFixedPrecisionNumber(...) with builder.append(FormattedNumber::fixedPrecision(...))
+        and builder.appendFixedWidthNumber(...) with with builder.append(FormattedNumber::fixedWidth(...))
+
 2019-12-20  Darin Adler  <darin@apple.com>
 
         Tidy a bit of StringBuilder usage
index 2845d78..6eddfb6 100644 (file)
@@ -594,7 +594,7 @@ String MediaTime::toString() const
         builder.appendNumber(m_timeScale);
         builder.appendLiteral(" = ");
     }
-    builder.appendFixedPrecisionNumber(toDouble());
+    builder.append(FormattedNumber::fixedPrecision(toDouble()));
     if (isInvalid())
         builder.appendLiteral(", invalid");
     builder.append('}');
index d649739..e6790ca 100644 (file)
@@ -422,18 +422,6 @@ void StringBuilder::appendNumber(unsigned long long number)
     numberToStringUnsigned<StringBuilder>(number, this);
 }
 
-void StringBuilder::appendFixedPrecisionNumber(float number, unsigned precision, TrailingZerosTruncatingPolicy policy)
-{
-    NumberToStringBuffer buffer;
-    append(numberToFixedPrecisionString(number, precision, buffer, policy == TruncateTrailingZeros));
-}
-
-void StringBuilder::appendFixedPrecisionNumber(double number, unsigned precision, TrailingZerosTruncatingPolicy policy)
-{
-    NumberToStringBuffer buffer;
-    append(numberToFixedPrecisionString(number, precision, buffer, policy == TruncateTrailingZeros));
-}
-
 void StringBuilder::appendNumber(float number)
 {
     NumberToStringBuffer buffer;
@@ -446,18 +434,6 @@ void StringBuilder::appendNumber(double number)
     append(numberToString(number, buffer));
 }
 
-void StringBuilder::appendFixedWidthNumber(float number, unsigned decimalPlaces)
-{
-    NumberToStringBuffer buffer;
-    append(numberToFixedWidthString(number, decimalPlaces, buffer));
-}
-
-void StringBuilder::appendFixedWidthNumber(double number, unsigned decimalPlaces)
-{
-    NumberToStringBuffer buffer;
-    append(numberToFixedWidthString(number, decimalPlaces, buffer));
-}
-
 bool StringBuilder::canShrink() const
 {
     if (hasOverflowed())
index 1536d22..8f00ed6 100644 (file)
@@ -228,11 +228,6 @@ public:
     WTF_EXPORT_PRIVATE void appendNumber(float);
     WTF_EXPORT_PRIVATE void appendNumber(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);
-    WTF_EXPORT_PRIVATE void appendFixedWidthNumber(double, unsigned decimalPlaces);
-
     template<typename... StringTypes> void append(StringTypes...);
 
     String toString()
index f9f4cfe..a220ae7 100644 (file)
@@ -93,7 +93,7 @@ TextStream& TextStream::operator<<(float f)
     if (m_formattingFlags & Formatting::NumberRespectingIntegers)
         return *this << FormatNumberRespectingIntegers(f);
 
-    m_text.appendFixedWidthNumber(f, 2);
+    m_text.append(FormattedNumber::fixedWidth(f, 2));
     return *this;
 }
 
@@ -102,7 +102,7 @@ TextStream& TextStream::operator<<(double d)
     if (m_formattingFlags & Formatting::NumberRespectingIntegers)
         return *this << FormatNumberRespectingIntegers(d);
 
-    m_text.appendFixedWidthNumber(d, 2);
+    m_text.append(FormattedNumber::fixedWidth(d, 2));
     return *this;
 }
 
@@ -128,7 +128,7 @@ TextStream& TextStream::operator<<(const String& string)
 TextStream& TextStream::operator<<(const FormatNumberRespectingIntegers& numberToFormat)
 {
     if (hasFractions(numberToFormat.value)) {
-        m_text.appendFixedWidthNumber(numberToFormat.value, 2);
+        m_text.append(FormattedNumber::fixedWidth(numberToFormat.value, 2));
         return *this;
     }
 
index ca57566..d80da68 100644 (file)
@@ -1,3 +1,29 @@
+2020-01-02  Sam Weinig  <weinig@apple.com>
+
+        Simplify StringBuilder API/align with makeString by removing appendFixed* functions and using FormatNumber struct instead
+        https://bugs.webkit.org/show_bug.cgi?id=205671
+
+        Reviewed by Alex Christensen.
+
+        * css/CSSFontVariationValue.cpp:
+        * css/CSSKeyframeRule.cpp:
+        * css/CSSTimingFunctionValue.cpp:
+        * css/parser/CSSParserToken.cpp:
+        * html/HTMLImageElement.cpp:
+        * page/scrolling/AxisScrollSnapOffsets.cpp:
+        * platform/graphics/Color.cpp:
+        * platform/graphics/ExtendedColor.cpp:
+        * platform/graphics/ca/win/PlatformCALayerWin.cpp:
+        * platform/graphics/freetype/FontCacheFreeType.cpp:
+        * svg/SVGNumberList.h:
+        * svg/SVGPathStringBuilder.cpp:
+        * svg/SVGPointList.h:
+        * svg/SVGTransformValue.h:
+        * svg/properties/SVGPropertyTraits.h:
+        * testing/Internals.cpp:
+        Replace all uses of builder.appendFixedPrecisionNumber(...) with builder.append(FormattedNumber::fixedPrecision(...))
+        and builder.appendFixedWidthNumber(...) with with builder.append(FormattedNumber::fixedWidth(...))
+
 2020-01-01  Joonghun Park  <jh718.park@samsung.com>
 
         Unreviewed. Remove the build warning below since r253939.
index 9fcd0b1..4372a73 100644 (file)
@@ -47,7 +47,7 @@ String CSSFontVariationValue::customCSSText() const
     for (char c : m_tag)
         builder.append(c);
     builder.appendLiteral("\" ");
-    builder.appendFixedPrecisionNumber(m_value);
+    builder.append(FormattedNumber::fixedPrecision(m_value));
     return builder.toString();
 }
 
index 69d24a6..4d700aa 100644 (file)
@@ -63,7 +63,7 @@ String StyleRuleKeyframe::keyText() const
     for (size_t i = 0; i < m_keys.size(); ++i) {
         if (i)
             keyText.append(',');
-        keyText.appendFixedPrecisionNumber(m_keys.at(i) * 100);
+        keyText.append(FormattedNumber::fixedPrecision(m_keys.at(i) * 100));
         keyText.append('%');
     }
 
index 65bae81..0b54c91 100644 (file)
@@ -34,13 +34,13 @@ String CSSCubicBezierTimingFunctionValue::customCSSText() const
 {
     StringBuilder builder;
     builder.appendLiteral("cubic-bezier(");
-    builder.appendFixedPrecisionNumber(m_x1);
+    builder.append(FormattedNumber::fixedPrecision(m_x1));
     builder.appendLiteral(", ");
-    builder.appendFixedPrecisionNumber(m_y1);
+    builder.append(FormattedNumber::fixedPrecision(m_y1));
     builder.appendLiteral(", ");
-    builder.appendFixedPrecisionNumber(m_x2);
+    builder.append(FormattedNumber::fixedPrecision(m_x2));
     builder.appendLiteral(", ");
-    builder.appendFixedPrecisionNumber(m_y2);
+    builder.append(FormattedNumber::fixedPrecision(m_y2));
     builder.append(')');    
     return builder.toString();
 }
@@ -71,13 +71,13 @@ String CSSSpringTimingFunctionValue::customCSSText() const
 {
     StringBuilder builder;
     builder.appendLiteral("spring(");
-    builder.appendFixedPrecisionNumber(m_mass);
+    builder.append(FormattedNumber::fixedPrecision(m_mass));
     builder.append(' ');
-    builder.appendFixedPrecisionNumber(m_stiffness);
+    builder.append(FormattedNumber::fixedPrecision(m_stiffness));
     builder.append(' ');
-    builder.appendFixedPrecisionNumber(m_damping);
+    builder.append(FormattedNumber::fixedPrecision(m_damping));
     builder.append(' ');
-    builder.appendFixedPrecisionNumber(m_initialVelocity);
+    builder.append(FormattedNumber::fixedPrecision(m_initialVelocity));
     builder.append(')');
     return builder.toString();
 }
index a8632fa..9e60c83 100644 (file)
@@ -421,15 +421,15 @@ void CSSParserToken::serialize(StringBuilder& builder) const
         // These won't properly preserve the NumericValueType flag
         if (m_numericSign == PlusSign)
             builder.append('+');
-        builder.appendFixedPrecisionNumber(numericValue());
+        builder.append(FormattedNumber::fixedPrecision(numericValue()));
         break;
     case PercentageToken:
-        builder.appendFixedPrecisionNumber(numericValue());
+        builder.append(FormattedNumber::fixedPrecision(numericValue()));
         builder.append('%');
         break;
     case DimensionToken:
         // This will incorrectly serialize e.g. 4e3e2 as 4000e2
-        builder.appendFixedPrecisionNumber(numericValue());
+        builder.append(FormattedNumber::fixedPrecision(numericValue()));
         serializeIdentifier(value().toString(), builder);
         break;
     case UnicodeRangeToken:
index 79c3425..435b8c8 100644 (file)
@@ -573,7 +573,7 @@ String HTMLImageElement::completeURLsInAttributeValue(const URL& base, const Att
             result.append(URL(base, candidate.string.toString()).string());
             if (candidate.density != UninitializedDescriptor) {
                 result.append(' ');
-                result.appendFixedPrecisionNumber(candidate.density);
+                result.append(FormattedNumber::fixedPrecision(candidate.density));
                 result.append('x');
             }
             if (candidate.resourceWidth != UninitializedDescriptor) {
index bf47775..76f0467 100644 (file)
@@ -79,7 +79,7 @@ static String snapOffsetsToString(const Vector<LayoutUnit>& snapOffsets)
     StringBuilder builder;
     builder.appendLiteral("[ ");
     for (auto& offset : snapOffsets) {
-        builder.appendFixedWidthNumber(offset.toFloat(), 1);
+        builder.append(FormattedNumber::fixedWidth(offset.toFloat(), 1));
         builder.append(' ');
     }
     builder.append(']');
@@ -92,9 +92,9 @@ static String snapOffsetRangesToString(const Vector<ScrollOffsetRange<LayoutUnit
     builder.appendLiteral("[ ");
     for (auto& range : ranges) {
         builder.append('(');
-        builder.appendFixedWidthNumber(range.start.toFloat(), 1);
+        builder.append(FormattedNumber::fixedWidth(range.start.toFloat(), 1));
         builder.appendLiteral(", ");
-        builder.appendFixedWidthNumber(range.end.toFloat(), 1);
+        builder.append(FormattedNumber::fixedWidth(range.end.toFloat(), 1));
         builder.appendLiteral(") ");
     }
     builder.append(']');
index ec143a0..ea2d348 100644 (file)
@@ -354,7 +354,7 @@ String Color::cssText() const
         float rounded = round(alpha * 100 / 255.0f) / 100;
         if (round(rounded * 255) != alpha)
             rounded = round(alpha * 1000 / 255.0f) / 1000;
-        builder.appendFixedPrecisionNumber(rounded);
+        builder.append(FormattedNumber::fixedPrecision(rounded));
     }
         
     builder.append(')');
index eb0e02d..e09d287 100644 (file)
@@ -56,16 +56,16 @@ String ExtendedColor::cssText() const
         return WTF::emptyString();
     }
 
-    builder.appendFixedPrecisionNumber(red());
+    builder.append(FormattedNumber::fixedPrecision(red()));
     builder.append(' ');
 
-    builder.appendFixedPrecisionNumber(green());
+    builder.append(FormattedNumber::fixedPrecision(green()));
     builder.append(' ');
 
-    builder.appendFixedPrecisionNumber(blue());
+    builder.append(FormattedNumber::fixedPrecision(blue()));
     if (!WTF::areEssentiallyEqual(alpha(), 1.0f)) {
         builder.appendLiteral(" / ");
-        builder.appendFixedPrecisionNumber(alpha());
+        builder.append(FormattedNumber::fixedPrecision(alpha()));
     }
     builder.append(')');
 
index f2fdf52..636d20d 100644 (file)
@@ -704,37 +704,37 @@ static void printIndent(StringBuilder& builder, int indent)
 static void printTransform(StringBuilder& builder, const CATransform3D& transform)
 {
     builder.append('[');
-    builder.appendFixedPrecisionNumber(transform.m11);
+    builder.append(FormattedNumber::fixedPrecision(transform.m11));
     builder.append(' ');
-    builder.appendFixedPrecisionNumber(transform.m12);
+    builder.append(FormattedNumber::fixedPrecision(transform.m12));
     builder.append(' ');
-    builder.appendFixedPrecisionNumber(transform.m13);
+    builder.append(FormattedNumber::fixedPrecision(transform.m13));
     builder.append(' ');
-    builder.appendFixedPrecisionNumber(transform.m14);
+    builder.append(FormattedNumber::fixedPrecision(transform.m14));
     builder.append("; ");
-    builder.appendFixedPrecisionNumber(transform.m21);
+    builder.append(FormattedNumber::fixedPrecision(transform.m21));
     builder.append(' ');
-    builder.appendFixedPrecisionNumber(transform.m22);
+    builder.append(FormattedNumber::fixedPrecision(transform.m22));
     builder.append(' ');
-    builder.appendFixedPrecisionNumber(transform.m23);
+    builder.append(FormattedNumber::fixedPrecision(transform.m23));
     builder.append(' ');
-    builder.appendFixedPrecisionNumber(transform.m24);
+    builder.append(FormattedNumber::fixedPrecision(transform.m24));
     builder.append("; ");
-    builder.appendFixedPrecisionNumber(transform.m31);
+    builder.append(FormattedNumber::fixedPrecision(transform.m31));
     builder.append(' ');
-    builder.appendFixedPrecisionNumber(transform.m32);
+    builder.append(FormattedNumber::fixedPrecision(transform.m32));
     builder.append(' ');
-    builder.appendFixedPrecisionNumber(transform.m33);
+    builder.append(FormattedNumber::fixedPrecision(transform.m33));
     builder.append(' ');
-    builder.appendFixedPrecisionNumber(transform.m34);
+    builder.append(FormattedNumber::fixedPrecision(transform.m34));
     builder.append("; ");
-    builder.appendFixedPrecisionNumber(transform.m41);
+    builder.append(FormattedNumber::fixedPrecision(transform.m41));
     builder.append(' ');
-    builder.appendFixedPrecisionNumber(transform.m42);
+    builder.append(FormattedNumber::fixedPrecision(transform.m42));
     builder.append(' ');
-    builder.appendFixedPrecisionNumber(transform.m43);
+    builder.append(FormattedNumber::fixedPrecision(transform.m43));
     builder.append(' ');
-    builder.appendFixedPrecisionNumber(transform.m44);
+    builder.append(FormattedNumber::fixedPrecision(transform.m44));
     builder.append(']');
 }
 
@@ -785,25 +785,25 @@ static void printLayer(StringBuilder& builder, const PlatformCALayer* layer, int
     builder.append("(");
     builder.append(layerTypeName);
     builder.append(" [");
-    builder.appendFixedPrecisionNumber(layerPosition.x());
+    builder.append(FormattedNumber::fixedPrecision(layerPosition.x()));
     builder.append(' ');
-    builder.appendFixedPrecisionNumber(layerPosition.y());
+    builder.append(FormattedNumber::fixedPrecision(layerPosition.y()));
     builder.append(' ');
-    builder.appendFixedPrecisionNumber(layerPosition.z());
+    builder.append(FormattedNumber::fixedPrecision(layerPosition.z()));
     builder.append("] [");
-    builder.appendFixedPrecisionNumber(layerBounds.x());
+    builder.append(FormattedNumber::fixedPrecision(layerBounds.x()));
     builder.append(' ');
-    builder.appendFixedPrecisionNumber(layerBounds.y());
+    builder.append(FormattedNumber::fixedPrecision(layerBounds.y()));
     builder.append(' ');
-    builder.appendFixedPrecisionNumber(layerBounds.width());
+    builder.append(FormattedNumber::fixedPrecision(layerBounds.width()));
     builder.append(' ');
-    builder.appendFixedPrecisionNumber(layerBounds.height());
+    builder.append(FormattedNumber::fixedPrecision(layerBounds.height()));
     builder.append("] [");
-    builder.appendFixedPrecisionNumber(layerAnchorPoint.x());
+    builder.append(FormattedNumber::fixedPrecision(layerAnchorPoint.x()));
     builder.append(' ');
-    builder.appendFixedPrecisionNumber(layerAnchorPoint.y());
+    builder.append(FormattedNumber::fixedPrecision(layerAnchorPoint.y()));
     builder.append(' ');
-    builder.appendFixedPrecisionNumber(layerAnchorPoint.z());
+    builder.append(FormattedNumber::fixedPrecision(layerAnchorPoint.z()));
     builder.append("] superlayer=");
     builder.appendNumber(reinterpret_cast<unsigned long long>(layer->superlayer()));
 
@@ -822,7 +822,7 @@ static void printLayer(StringBuilder& builder, const PlatformCALayer* layer, int
         builder.append('\n');
         printIndent(builder, indent + 1);
         builder.append("(borderWidth ");
-        builder.appendFixedPrecisionNumber(borderWidth);
+        builder.append(FormattedNumber::fixedPrecision(borderWidth));
         builder.append(')');
     }
 
@@ -851,7 +851,7 @@ static void printLayer(StringBuilder& builder, const PlatformCALayer* layer, int
         builder.append('\n');
         printIndent(builder, indent + 1);
         builder.append("(opacity ");
-        builder.appendFixedPrecisionNumber(layerOpacity);
+        builder.append(FormattedNumber::fixedPrecision(layerOpacity));
         builder.append(')');
     }
 
@@ -927,15 +927,15 @@ String PlatformCALayerWin::layerTreeAsString() const
 
     StringBuilder builder;
     builder.append("\n\n** Render tree at time ");
-    builder.appendFixedPrecisionNumber(MonotonicTime::now().secondsSinceEpoch().seconds());
+    builder.append(FormattedNumber::fixedPrecision(MonotonicTime::now().secondsSinceEpoch().seconds()));
     builder.append(" (bounds ");
-    builder.appendFixedPrecisionNumber(rootBounds.origin.x);
+    builder.append(FormattedNumber::fixedPrecision(rootBounds.origin.x));
     builder.append(", ");
-    builder.appendFixedPrecisionNumber(rootBounds.origin.y);
+    builder.append(FormattedNumber::fixedPrecision(rootBounds.origin.y));
     builder.append(' ');
-    builder.appendFixedPrecisionNumber(rootBounds.size.width);
+    builder.append(FormattedNumber::fixedPrecision(rootBounds.size.width));
     builder.append('x');
-    builder.appendFixedPrecisionNumber(rootBounds.size.height);
+    builder.append(FormattedNumber::fixedPrecision(rootBounds.size.height));
     builder.append(") **\n\n");
 
     // Print layer tree from the root
index cae36ad..854a65b 100644 (file)
@@ -651,7 +651,7 @@ String buildVariationSettings(FT_Face face, const FontDescription& fontDescripti
         builder.append(variation.key[2]);
         builder.append(variation.key[3]);
         builder.append('=');
-        builder.appendFixedPrecisionNumber(variation.value);
+        builder.append(FormattedNumber::fixedPrecision(variation.value));
     }
     return builder.toString();
 }
index 5b5d57e..7946012 100644 (file)
@@ -78,7 +78,7 @@ public:
             if (builder.length())
                 builder.append(' ');
 
-            builder.appendFixedPrecisionNumber(number->value());
+            builder.append(FormattedNumber::fixedPrecision(number->value()));
         }
 
         return builder.toString();
index a832b9f..093467a 100644 (file)
@@ -57,15 +57,15 @@ static void appendFlag(StringBuilder& stringBuilder, bool flag)
 
 static void appendNumber(StringBuilder& stringBuilder, float number)
 {
-    stringBuilder.appendFixedPrecisionNumber(number);
+    stringBuilder.append(FormattedNumber::fixedPrecision(number));
     stringBuilder.append(' ');
 }
 
 static void appendPoint(StringBuilder& stringBuilder, const FloatPoint& point)
 {
-    stringBuilder.appendFixedPrecisionNumber(point.x());
+    stringBuilder.append(FormattedNumber::fixedPrecision(point.x()));
     stringBuilder.append(' ');
-    stringBuilder.appendFixedPrecisionNumber(point.y());
+    stringBuilder.append(FormattedNumber::fixedPrecision(point.y()));
     stringBuilder.append(' ');
 }
 
index 8c6c50b..01b3022 100644 (file)
@@ -93,9 +93,9 @@ public:
             if (builder.length())
                 builder.append(' ');
 
-            builder.appendFixedPrecisionNumber(point->x());
+            builder.append(FormattedNumber::fixedPrecision(point->x()));
             builder.append(' ');
-            builder.appendFixedPrecisionNumber(point->y());
+            builder.append(FormattedNumber::fixedPrecision(point->y()));
         }
 
         return builder.toString();
index 077350e..d390d09 100644 (file)
@@ -239,7 +239,7 @@ private:
     {
         if (builder.length() && builder[builder.length() - 1] != '(')
             builder.append(' ');
-        builder.appendFixedPrecisionNumber(number);
+        builder.append(FormattedNumber::fixedPrecision(number));
         appendFixedPrecisionNumbers(builder, numbers...);
     }
 
index bb83e77..fafec73 100644 (file)
@@ -140,9 +140,9 @@ struct SVGPropertyTraits<FloatPoint> {
     static String toString(const FloatPoint& type)
     {
         StringBuilder builder;
-        builder.appendFixedPrecisionNumber(type.x());
+        builder.append(FormattedNumber::fixedPrecision(type.x()));
         builder.append(' ');
-        builder.appendFixedPrecisionNumber(type.y());
+        builder.append(FormattedNumber::fixedPrecision(type.y()));
         return builder.toString();
     }
 };
@@ -167,13 +167,13 @@ struct SVGPropertyTraits<FloatRect> {
     static String toString(const FloatRect& type)
     {
         StringBuilder builder;
-        builder.appendFixedPrecisionNumber(type.x());
+        builder.append(FormattedNumber::fixedPrecision(type.x()));
         builder.append(' ');
-        builder.appendFixedPrecisionNumber(type.y());
+        builder.append(FormattedNumber::fixedPrecision(type.y()));
         builder.append(' ');
-        builder.appendFixedPrecisionNumber(type.width());
+        builder.append(FormattedNumber::fixedPrecision(type.width()));
         builder.append(' ');
-        builder.appendFixedPrecisionNumber(type.height());
+        builder.append(FormattedNumber::fixedPrecision(type.height()));
         return builder.toString();
     }
 };
index 7920814..f1a164d 100644 (file)
@@ -1687,13 +1687,13 @@ ExceptionOr<String> Internals::dumpMarkerRects(const String& markerTypeString)
     rectString.appendLiteral("marker rects: ");
     for (const auto& rect : rects) {
         rectString.append('(');
-        rectString.appendFixedPrecisionNumber(rect.x());
+        rectString.append(FormattedNumber::fixedPrecision(rect.x()));
         rectString.appendLiteral(", ");
-        rectString.appendFixedPrecisionNumber(rect.y());
+        rectString.append(FormattedNumber::fixedPrecision(rect.y()));
         rectString.appendLiteral(", ");
-        rectString.appendFixedPrecisionNumber(rect.width());
+        rectString.append(FormattedNumber::fixedPrecision(rect.width()));
         rectString.appendLiteral(", ");
-        rectString.appendFixedPrecisionNumber(rect.height());
+        rectString.append(FormattedNumber::fixedPrecision(rect.height()));
         rectString.appendLiteral(") ");
     }
     return rectString.toString();
@@ -3447,14 +3447,14 @@ ExceptionOr<String> Internals::getCurrentCursorInfo()
     if (cursor.image()) {
         FloatSize size = cursor.image()->size();
         result.appendLiteral(" image=");
-        result.appendFixedPrecisionNumber(size.width());
+        result.append(FormattedNumber::fixedPrecision(size.width()));
         result.append('x');
-        result.appendFixedPrecisionNumber(size.height());
+        result.append(FormattedNumber::fixedPrecision(size.height()));
     }
 #if ENABLE(MOUSE_CURSOR_SCALE)
     if (cursor.imageScaleFactor() != 1) {
         result.appendLiteral(" scale=");
-        result.appendFixedPrecisionNumber(cursor.imageScaleFactor(), 8);
+        result.append(FormattedNumber::fixedPrecision(cursor.imageScaleFactor(), 8));
     }
 #endif
     return result.toString();
index 283e16c..2e8bad6 100644 (file)
@@ -1,3 +1,18 @@
+2020-01-02  Sam Weinig  <weinig@apple.com>
+
+        Simplify StringBuilder API/align with makeString by removing appendFixed* functions and using FormatNumber struct instead
+        https://bugs.webkit.org/show_bug.cgi?id=205671
+
+        Reviewed by Alex Christensen.
+
+        * NetworkProcess/cache/NetworkCache.cpp:
+        (WebKit::NetworkCache::Cache::dumpContentsToFile):
+        * NetworkProcess/cache/NetworkCacheEntry.cpp:
+        (WebKit::NetworkCache::Entry::asJSON const):
+        * Shared/Gamepad/GamepadData.cpp:
+        (WebKit::GamepadData::loggingString const):
+        Replace all uses of builder.appendFixedPrecisionNumber(...) with builder.append(FormattedNumber::fixedPrecision(...)).
+
 2020-01-02  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         [GTK] Make ondemand hardware acceleration policy never leave AC mode
index 275e00e..844db9b 100644 (file)
@@ -588,7 +588,7 @@ void Cache::dumpContentsToFile()
             epilogue.appendNumber(totals.bodySize);
             epilogue.appendLiteral(",\n");
             epilogue.appendLiteral("\"averageWorth\": ");
-            epilogue.appendFixedPrecisionNumber(totals.count ? totals.worth / totals.count : 0);
+            epilogue.append(FormattedNumber::fixedPrecision(totals.count ? totals.worth / totals.count : 0));
             epilogue.appendLiteral("\n");
             epilogue.appendLiteral("}\n}\n");
             auto writeData = epilogue.toString().utf8();
index 1f4144a..26fa30d 100644 (file)
@@ -219,13 +219,13 @@ void Entry::asJSON(StringBuilder& json, const Storage::RecordInfo& info) const
     json.appendNumber(info.bodySize);
     json.appendLiteral(",\n");
     json.appendLiteral("\"worth\": ");
-    json.appendFixedPrecisionNumber(info.worth);
+    json.append(FormattedNumber::fixedPrecision(info.worth));
     json.appendLiteral(",\n");
     json.appendLiteral("\"partition\": ");
     json.appendQuotedJSONString(m_key.partition());
     json.appendLiteral(",\n");
     json.appendLiteral("\"timestamp\": ");
-    json.appendFixedPrecisionNumber(m_timeStamp.secondsSinceEpoch().milliseconds());
+    json.append(FormattedNumber::fixedPrecision(m_timeStamp.secondsSinceEpoch().milliseconds()));
     json.appendLiteral(",\n");
     json.appendLiteral("\"URL\": ");
     json.appendQuotedJSONString(m_response.url().string());
index 365c102..7e43264 100644 (file)
@@ -100,7 +100,7 @@ String GamepadData::loggingString() const
         builder.appendLiteral(" Axis ");
         builder.appendNumber(i);
         builder.appendLiteral(": ");
-        builder.appendFixedPrecisionNumber(m_axisValues[i]);
+        builder.append(FormattedNumber::fixedPrecision(m_axisValues[i]));
     }
 
     builder.append('\n');
@@ -108,7 +108,7 @@ String GamepadData::loggingString() const
         builder.appendLiteral(" Button ");
         builder.appendNumber(i);
         builder.appendLiteral(": ");
-        builder.appendFixedPrecisionNumber(m_buttonValues[i]);
+        builder.append(FormattedNumber::fixedPrecision(m_buttonValues[i]));
     }
 
     return builder.toString();
index f45f23a..4c31299 100644 (file)
@@ -1,3 +1,13 @@
+2020-01-02  Sam Weinig  <weinig@apple.com>
+
+        Simplify StringBuilder API/align with makeString by removing appendFixed* functions and using FormatNumber struct instead
+        https://bugs.webkit.org/show_bug.cgi?id=205671
+
+        Reviewed by Alex Christensen.
+
+        * WebKitTestRunner/InjectedBundle/atk/AccessibilityUIElementAtk.cpp:
+        Replace all uses of builder.appendFixedPrecisionNumber(...) with builder.append(FormattedNumber::fixedPrecision(...)).
+
 2019-12-31  Carlos Alberto Lopez Perez  <clopez@igalia.com>
 
         [WPE] OpenJPEG missing in install dependencies script.
index d3563a2..b8b41d3 100644 (file)
@@ -583,15 +583,15 @@ String attributesOfElement(AccessibilityUIElement* element)
     builder.append('\n');
 
     builder.appendLiteral("AXPosition:  { ");
-    builder.appendFixedPrecisionNumber(element->x(), 6, KeepTrailingZeros);
+    builder.append(FormattedNumber::fixedPrecision(element->x(), 6, KeepTrailingZeros));
     builder.appendLiteral(", ");
-    builder.appendFixedPrecisionNumber(element->y(), 6, KeepTrailingZeros);
+    builder.append(FormattedNumber::fixedPrecision(element->y(), 6, KeepTrailingZeros));
     builder.appendLiteral(" }\n");
 
     builder.appendLiteral("AXSize: { ");
-    builder.appendFixedPrecisionNumber(element->width(), 6, KeepTrailingZeros);
+    builder.append(FormattedNumber::fixedPrecision(element->width(), 6, KeepTrailingZeros));
     builder.appendLiteral(", ");
-    builder.appendFixedPrecisionNumber(element->height(), 6, KeepTrailingZeros);
+    builder.append(FormattedNumber::fixedPrecision(element->height(), 6, KeepTrailingZeros));
     builder.appendLiteral(" }\n");
 
     String title = element->title()->string();