⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 242713 in webkit


Ignore:
Timestamp:
Mar 11, 2019, 10:11:13 AM (7 years ago)
Author:
Darin Adler
Message:

Specify fixed precision explicitly to prepare to change String::number and StringBuilder::appendNumber floating point behavior
https://bugs.webkit.org/show_bug.cgi?id=195533

Reviewed by Brent Fulgham.

Source/JavaScriptCore:

  • API/tests/ExecutionTimeLimitTest.cpp:

(testExecutionTimeLimit): Use appendFixedPrecisionNumber.

  • runtime/NumberPrototype.cpp:

(JSC::numberProtoFuncToPrecision): Use numberToStringFixedPrecision.

  • runtime/Options.cpp:

(JSC::Option::dump const): Use appendFixedPrecisionNumber.

Source/WebCore:

  • accessibility/AccessibilityNodeObject.cpp:

(WebCore::AccessibilityNodeObject::changeValueByStep): Use numberToStringFixedPrecision.
(WebCore::AccessibilityNodeObject::changeValueByPercent): Ditto.

  • accessibility/AccessibilityScrollbar.cpp:

(WebCore::AccessibilityScrollbar::setValue): Ditto.

  • css/CSSFontVariationValue.cpp:

(WebCore::CSSFontVariationValue::customCSSText const): Use appendFixedPrecisionNumber.

  • css/CSSGradientValue.cpp:

(WebCore::CSSLinearGradientValue::customCSSText const): Ditto.
(WebCore::CSSRadialGradientValue::customCSSText const): Ditto.

  • css/CSSKeyframeRule.cpp:

(WebCore::StyleRuleKeyframe::keyText const): Ditto.

  • css/CSSTimingFunctionValue.cpp:

(WebCore::CSSCubicBezierTimingFunctionValue::customCSSText const): Ditto.
(WebCore::CSSSpringTimingFunctionValue::customCSSText const): Ditto.

  • css/parser/CSSParserToken.cpp:

(WebCore::CSSParserToken::serialize const): Ditto.

  • html/HTMLImageElement.cpp:

(WebCore::HTMLImageElement::completeURLsInAttributeValue const): Ditto.

  • inspector/InspectorOverlay.cpp:

(WebCore::InspectorOverlay::drawRulers): Use numberToStringFixedPrecision.

  • loader/ResourceLoadStatistics.cpp:

(WebCore::ResourceLoadStatistics::toString const): Use appendFixedPrecisionNumber.

  • page/PrintContext.cpp:

(WebCore::PrintContext::pageProperty): Use numberToStringFixedPrecision.

  • page/cocoa/ResourceUsageOverlayCocoa.mm:

(WebCore::gcTimerString): Use numberToStringFixedPrecision.

  • platform/LayoutUnit.h:

(WTF::ValueToString<WebCore::LayoutUnit>::string): Ditto.

  • platform/graphics/Color.cpp:

(WebCore::Color::cssText const): Use appendFixedPrecisionNumber.

  • platform/graphics/ExtendedColor.cpp:

(WebCore::ExtendedColor::cssText const): Ditto.

  • svg/SVGAngleValue.cpp:

(WebCore::SVGAngleValue::valueAsString const): Use numberToStringFixedPrecision.

  • svg/SVGNumberListValues.cpp:

(WebCore::SVGNumberListValues::valueAsString const): Use appendFixedPrecisionNumber.

  • svg/SVGPathStringBuilder.cpp:

(WebCore::appendNumber): Ditto.
(WebCore::appendPoint): Ditto.

  • svg/SVGPointListValues.cpp:

(WebCore::SVGPointListValues::valueAsString const): Ditto.

  • svg/SVGTransformValue.cpp:

(WebCore::SVGTransformValue::valueAsString const): Ditto.

  • svg/properties/SVGPropertyTraits.h:

(WebCore::SVGPropertyTraits<float>::toString): Use numberToStringFixedPrecision.
(WebCore::SVGPropertyTraits<FloatPoint>::toString): Use appendFixedPrecisionNumber.
(WebCore::SVGPropertyTraits<FloatRect>::toString): Ditto.

  • testing/Internals.cpp:

(WebCore::Internals::dumpMarkerRects): Use appendFixedPrecisionNumber.
(WebCore::Internals::getCurrentCursorInfo): Ditto.

  • xml/XPathValue.cpp:

(WebCore::XPath::Value::toString const): Use numberToStringFixedPrecision.

Source/WebKit:

  • NetworkProcess/cache/NetworkCache.cpp:

(WebKit::NetworkCache::Cache::dumpContentsToFile): Use appendFixedPrecisionNumber.

  • NetworkProcess/cache/NetworkCacheEntry.cpp:

(WebKit::NetworkCache::Entry::asJSON const): Ditto.

  • Shared/Gamepad/GamepadData.cpp:

(WebKit::GamepadData::loggingString const): Ditto.

  • UIProcess/WebPageProxy.cpp:

(WebKit::WebPageProxy::logDiagnosticMessageWithValue): Use numberToStringFixedPrecision.

Source/WTF:

Soon, we will change String::number and StringBuilder::appendNumber for floating
point to use "shortest form" serialization instead of the current default, which is
"6-digit fixed precision stripping trailing zeros". To prepare to do this safely
without accidentally changing any behavior, changing callers to call the explicit
versions. Later, we may want to return and change many of them to use shortest form
instead, but that may require rebaselining tests, and in some extreme cases, getting
rid of flawed logic that converts between different single and double precision
floating point; such problems may be hidden by fixed precision serialization.

Since "shortest form" is already the behavior for AtomicString::number and
for makeString, no changes required for clients of either of those.

  • wtf/Logger.h:

(WTF::LogArgument::toString): Use numberToStringFixedPrecision.

  • wtf/MediaTime.cpp:

(WTF::MediaTime::toString const): Use appendFixedPrecisionNumber.

  • wtf/text/ValueToString.h:

(WTF::ValueToString<float>::string): Use numberToStringFixedPrecision.
(WTF::ValueToString<double>::string): Ditto.

Location:
trunk/Source
Files:
37 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/API/tests/ExecutionTimeLimitTest.cpp

    r236032 r242713  
    195195            StringBuilder scriptBuilder;
    196196            scriptBuilder.appendLiteral("function foo() { var startTime = currentCPUTime(); while (true) { for (var i = 0; i < 1000; i++); if (currentCPUTime() - startTime > ");
    197             scriptBuilder.appendNumber(timeAfterWatchdogShouldHaveFired.seconds());
     197            scriptBuilder.appendFixedPrecisionNumber(timeAfterWatchdogShouldHaveFired.seconds());
    198198            scriptBuilder.appendLiteral(") break; } } foo();");
    199199
     
    236236                                     "if (i % 1000 === 0) {"
    237237                                        "if (currentCPUTime() - startTime >");
    238             scriptBuilder.appendNumber(timeAfterWatchdogShouldHaveFired.seconds());
     238            scriptBuilder.appendFixedPrecisionNumber(timeAfterWatchdogShouldHaveFired.seconds());
    239239            scriptBuilder.appendLiteral("       ) { return; }");
    240240            scriptBuilder.appendLiteral("    }");
     
    276276            StringBuilder scriptBuilder;
    277277            scriptBuilder.appendLiteral("function foo() { var startTime = currentCPUTime(); try { while (true) { for (var i = 0; i < 1000; i++); if (currentCPUTime() - startTime > ");
    278             scriptBuilder.appendNumber(timeAfterWatchdogShouldHaveFired.seconds());
     278            scriptBuilder.appendFixedPrecisionNumber(timeAfterWatchdogShouldHaveFired.seconds());
    279279            scriptBuilder.appendLiteral(") break; } } catch(e) { } } foo();");
    280280
     
    315315            StringBuilder scriptBuilder;
    316316            scriptBuilder.appendLiteral("function foo() { var startTime = currentCPUTime(); while (true) { for (var i = 0; i < 1000; i++); if (currentCPUTime() - startTime > ");
    317             scriptBuilder.appendNumber(timeAfterWatchdogShouldHaveFired.seconds());
     317            scriptBuilder.appendFixedPrecisionNumber(timeAfterWatchdogShouldHaveFired.seconds());
    318318            scriptBuilder.appendLiteral(") break; } } foo();");
    319319           
     
    354354            StringBuilder scriptBuilder;
    355355            scriptBuilder.appendLiteral("function foo() { var startTime = currentCPUTime(); while (true) { for (var i = 0; i < 1000; i++); if (currentCPUTime() - startTime > ");
    356             scriptBuilder.appendNumber(timeAfterWatchdogShouldHaveFired.seconds());
     356            scriptBuilder.appendFixedPrecisionNumber(timeAfterWatchdogShouldHaveFired.seconds());
    357357            scriptBuilder.appendLiteral(") break; } } foo();");
    358358
     
    393393            StringBuilder scriptBuilder;
    394394            scriptBuilder.appendLiteral("function foo() { var startTime = currentCPUTime(); while (true) { for (var i = 0; i < 1000; i++); if (currentCPUTime() - startTime > ");
    395             scriptBuilder.appendNumber(maxBusyLoopTime.seconds()); // in seconds.
     395            scriptBuilder.appendFixedPrecisionNumber(maxBusyLoopTime.seconds()); // in seconds.
    396396            scriptBuilder.appendLiteral(") break; } } foo();");
    397397
     
    436436            StringBuilder scriptBuilder;
    437437            scriptBuilder.appendLiteral("function foo() { var startTime = currentCPUTime(); while (true) { for (var i = 0; i < 1000; i++); if (currentCPUTime() - startTime > ");
    438             scriptBuilder.appendNumber(timeAfterWatchdogShouldHaveFired.seconds());
     438            scriptBuilder.appendFixedPrecisionNumber(timeAfterWatchdogShouldHaveFired.seconds());
    439439            scriptBuilder.appendLiteral(") break; } } foo();");
    440440
  • trunk/Source/JavaScriptCore/ChangeLog

    r242699 r242713  
     12019-03-11  Darin Adler  <darin@apple.com>
     2
     3        Specify fixed precision explicitly to prepare to change String::number and StringBuilder::appendNumber floating point behavior
     4        https://bugs.webkit.org/show_bug.cgi?id=195533
     5
     6        Reviewed by Brent Fulgham.
     7
     8        * API/tests/ExecutionTimeLimitTest.cpp:
     9        (testExecutionTimeLimit): Use appendFixedPrecisionNumber.
     10        * runtime/NumberPrototype.cpp:
     11        (JSC::numberProtoFuncToPrecision): Use numberToStringFixedPrecision.
     12        * runtime/Options.cpp:
     13        (JSC::Option::dump const): Use appendFixedPrecisionNumber.
     14
    1152019-03-10  Ross Kirsling  <ross.kirsling@sony.com>
    216
  • trunk/Source/JavaScriptCore/runtime/NumberPrototype.cpp

    r242330 r242713  
    506506        return throwVMError(exec, scope, createRangeError(exec, "toPrecision() argument must be between 1 and 21"_s));
    507507
    508     return JSValue::encode(jsString(exec, String::number(x, significantFigures, KeepTrailingZeros)));
     508    return JSValue::encode(jsString(exec, String::numberToStringFixedPrecision(x, significantFigures, KeepTrailingZeros)));
    509509}
    510510
  • trunk/Source/JavaScriptCore/runtime/Options.cpp

    r241769 r242713  
    907907        break;
    908908    case Options::Type::doubleType:
    909         builder.appendNumber(m_entry.doubleVal);
     909        builder.appendFixedPrecisionNumber(m_entry.doubleVal);
    910910        break;
    911911    case Options::Type::int32Type:
  • trunk/Source/WTF/ChangeLog

    r242706 r242713  
     12019-03-11  Darin Adler  <darin@apple.com>
     2
     3        Specify fixed precision explicitly to prepare to change String::number and StringBuilder::appendNumber floating point behavior
     4        https://bugs.webkit.org/show_bug.cgi?id=195533
     5
     6        Reviewed by Brent Fulgham.
     7
     8        Soon, we will change String::number and StringBuilder::appendNumber for floating
     9        point to use "shortest form" serialization instead of the current default, which is
     10        "6-digit fixed precision stripping trailing zeros". To prepare to do this safely
     11        without accidentally changing any behavior, changing callers to call the explicit
     12        versions. Later, we may want to return and change many of them to use shortest form
     13        instead, but that may require rebaselining tests, and in some extreme cases, getting
     14        rid of flawed logic that converts between different single and double precision
     15        floating point; such problems may be hidden by fixed precision serialization.
     16
     17        Since "shortest form" is already the behavior for AtomicString::number and
     18        for makeString, no changes required for clients of either of those.
     19
     20        * wtf/Logger.h:
     21        (WTF::LogArgument::toString): Use numberToStringFixedPrecision.
     22        * wtf/MediaTime.cpp:
     23        (WTF::MediaTime::toString const): Use appendFixedPrecisionNumber.
     24        * wtf/text/ValueToString.h:
     25        (WTF::ValueToString<float>::string): Use numberToStringFixedPrecision.
     26        (WTF::ValueToString<double>::string): Ditto.
     27
    1282019-03-11  Truitt Savell  <tsavell@apple.com>
    229
  • trunk/Source/WTF/wtf/Logger.h

    r241751 r242713  
    3737    template<typename U = T> static typename std::enable_if<std::is_same<U, unsigned long>::value, String>::type toString(unsigned long argument) { return String::number(argument); }
    3838    template<typename U = T> static typename std::enable_if<std::is_same<U, long>::value, String>::type toString(long argument) { return String::number(argument); }
    39     template<typename U = T> static typename std::enable_if<std::is_same<U, float>::value, String>::type toString(float argument) { return String::number(argument); }
    40     template<typename U = T> static typename std::enable_if<std::is_same<U, double>::value, String>::type toString(double argument) { return String::number(argument); }
     39    template<typename U = T> static typename std::enable_if<std::is_same<U, float>::value, String>::type toString(float argument) { return String::numberToStringFixedPrecision(argument); }
     40    template<typename U = T> static typename std::enable_if<std::is_same<U, double>::value, String>::type toString(double argument) { return String::numberToStringFixedPrecision(argument); }
    4141    template<typename U = T> static typename std::enable_if<std::is_same<typename std::remove_reference<U>::type, AtomicString>::value, String>::type toString(const AtomicString& argument) { return argument.string(); }
    4242    template<typename U = T> static typename std::enable_if<std::is_same<typename std::remove_reference<U>::type, String>::value, String>::type toString(String argument) { return argument; }
  • trunk/Source/WTF/wtf/MediaTime.cpp

    r241148 r242713  
    594594        builder.appendLiteral(" = ");
    595595    }
    596     builder.appendNumber(toDouble());
     596    builder.appendFixedPrecisionNumber(toDouble());
    597597    builder.append('}');
    598598    return builder.toString();
  • trunk/Source/WTF/wtf/text/ValueToString.h

    r220621 r242713  
    3636namespace WTF {
    3737
    38 template<class T>
    39 struct ValueToString;
     38template<typename> struct ValueToString;
    4039
    41 template <>
    42 struct ValueToString<int> {
    43     static String string(const int value) { return String::number(value); }
     40template<> struct ValueToString<int> {
     41    static String string(int value) { return String::number(value); }
    4442};
    4543
    46 template <>
    47 struct ValueToString<float> {
    48     static String string(const float value) { return String::number(value); }
     44template<> struct ValueToString<float> {
     45    static String string(float value) { return String::numberToStringFixedPrecision(value); }
    4946};
    5047
    51 template <>
    52 struct ValueToString<double> {
    53     static String string(const double value) { return String::number(value); }
     48template<> struct ValueToString<double> {
     49    static String string(double value) { return String::numberToStringFixedPrecision(value); }
    5450};
    5551
  • trunk/Source/WebCore/ChangeLog

    r242703 r242713  
     12019-03-11  Darin Adler  <darin@apple.com>
     2
     3        Specify fixed precision explicitly to prepare to change String::number and StringBuilder::appendNumber floating point behavior
     4        https://bugs.webkit.org/show_bug.cgi?id=195533
     5
     6        Reviewed by Brent Fulgham.
     7
     8        * accessibility/AccessibilityNodeObject.cpp:
     9        (WebCore::AccessibilityNodeObject::changeValueByStep): Use numberToStringFixedPrecision.
     10        (WebCore::AccessibilityNodeObject::changeValueByPercent): Ditto.
     11        * accessibility/AccessibilityScrollbar.cpp:
     12        (WebCore::AccessibilityScrollbar::setValue): Ditto.
     13        * css/CSSFontVariationValue.cpp:
     14        (WebCore::CSSFontVariationValue::customCSSText const): Use appendFixedPrecisionNumber.
     15        * css/CSSGradientValue.cpp:
     16        (WebCore::CSSLinearGradientValue::customCSSText const): Ditto.
     17        (WebCore::CSSRadialGradientValue::customCSSText const): Ditto.
     18        * css/CSSKeyframeRule.cpp:
     19        (WebCore::StyleRuleKeyframe::keyText const): Ditto.
     20        * css/CSSTimingFunctionValue.cpp:
     21        (WebCore::CSSCubicBezierTimingFunctionValue::customCSSText const): Ditto.
     22        (WebCore::CSSSpringTimingFunctionValue::customCSSText const): Ditto.
     23        * css/parser/CSSParserToken.cpp:
     24        (WebCore::CSSParserToken::serialize const): Ditto.
     25        * html/HTMLImageElement.cpp:
     26        (WebCore::HTMLImageElement::completeURLsInAttributeValue const): Ditto.
     27        * inspector/InspectorOverlay.cpp:
     28        (WebCore::InspectorOverlay::drawRulers): Use numberToStringFixedPrecision.
     29        * loader/ResourceLoadStatistics.cpp:
     30        (WebCore::ResourceLoadStatistics::toString const): Use appendFixedPrecisionNumber.
     31        * page/PrintContext.cpp:
     32        (WebCore::PrintContext::pageProperty): Use numberToStringFixedPrecision.
     33        * page/cocoa/ResourceUsageOverlayCocoa.mm:
     34        (WebCore::gcTimerString): Use numberToStringFixedPrecision.
     35        * platform/LayoutUnit.h:
     36        (WTF::ValueToString<WebCore::LayoutUnit>::string): Ditto.
     37        * platform/graphics/Color.cpp:
     38        (WebCore::Color::cssText const): Use appendFixedPrecisionNumber.
     39        * platform/graphics/ExtendedColor.cpp:
     40        (WebCore::ExtendedColor::cssText const): Ditto.
     41        * svg/SVGAngleValue.cpp:
     42        (WebCore::SVGAngleValue::valueAsString const): Use numberToStringFixedPrecision.
     43        * svg/SVGNumberListValues.cpp:
     44        (WebCore::SVGNumberListValues::valueAsString const): Use appendFixedPrecisionNumber.
     45        * svg/SVGPathStringBuilder.cpp:
     46        (WebCore::appendNumber): Ditto.
     47        (WebCore::appendPoint): Ditto.
     48        * svg/SVGPointListValues.cpp:
     49        (WebCore::SVGPointListValues::valueAsString const): Ditto.
     50        * svg/SVGTransformValue.cpp:
     51        (WebCore::SVGTransformValue::valueAsString const): Ditto.
     52        * svg/properties/SVGPropertyTraits.h:
     53        (WebCore::SVGPropertyTraits<float>::toString): Use numberToStringFixedPrecision.
     54        (WebCore::SVGPropertyTraits<FloatPoint>::toString): Use appendFixedPrecisionNumber.
     55        (WebCore::SVGPropertyTraits<FloatRect>::toString): Ditto.
     56        * testing/Internals.cpp:
     57        (WebCore::Internals::dumpMarkerRects): Use appendFixedPrecisionNumber.
     58        (WebCore::Internals::getCurrentCursorInfo): Ditto.
     59        * xml/XPathValue.cpp:
     60        (WebCore::XPath::Value::toString const): Use numberToStringFixedPrecision.
     61
    1622019-03-11  Philippe Normand  <pnormand@igalia.com>
    263
  • trunk/Source/WebCore/accessibility/AccessibilityNodeObject.cpp

    r241989 r242713  
    10991099    value += increase ? step : -step;
    11001100
    1101     setValue(String::number(value));
     1101    setValue(String::numberToStringFixedPrecision(value));
    11021102
    11031103    axObjectCache()->postNotification(node(), AXObjectCache::AXValueChanged);
     
    11111111
    11121112    // Make sure the specified percent will cause a change of one integer step or larger.
    1113     if (fabs(step) < 1)
    1114         step = fabs(percentChange) * (1 / percentChange);
     1113    if (std::abs(step) < 1)
     1114        step = std::abs(percentChange) * (1 / percentChange);
    11151115
    11161116    value += step;
    1117     setValue(String::number(value));
     1117    setValue(String::numberToStringFixedPrecision(value));
    11181118
    11191119    axObjectCache()->postNotification(node(), AXObjectCache::AXValueChanged);
  • trunk/Source/WebCore/accessibility/AccessibilityScrollbar.cpp

    r229112 r242713  
    9999   
    100100    float newValue = value * m_scrollbar->maximum();
    101     if (dispatchAccessibleSetValueEvent(String::number(newValue)))
     101    if (dispatchAccessibleSetValueEvent(String::numberToStringFixedPrecision(newValue)))
    102102        return;
    103103    m_scrollbar->scrollableArea().scrollToOffsetWithoutAnimation(m_scrollbar->orientation(), newValue);
  • trunk/Source/WebCore/css/CSSFontVariationValue.cpp

    r231165 r242713  
    4848        builder.append(c);
    4949    builder.appendLiteral("\" ");
    50     builder.appendNumber(m_value);
     50    builder.appendFixedPrecisionNumber(m_value);
    5151    return builder.toString();
    5252}
  • trunk/Source/WebCore/css/CSSGradientValue.cpp

    r235999 r242713  
    694694            } else {
    695695                result.appendLiteral("color-stop(");
    696                 result.appendNumber(position);
     696                result.appendFixedPrecisionNumber(position);
    697697                result.appendLiteral(", ");
    698698                result.append(stop.m_color->cssText());
     
    975975            } else {
    976976                result.appendLiteral("color-stop(");
    977                 result.appendNumber(position);
     977                result.appendFixedPrecisionNumber(position);
    978978                result.appendLiteral(", ");
    979979                result.append(stop.m_color->cssText());
  • trunk/Source/WebCore/css/CSSKeyframeRule.cpp

    r223728 r242713  
    6464        if (i)
    6565            keyText.append(',');
    66         keyText.appendNumber(m_keys.at(i) * 100);
     66        keyText.appendFixedPrecisionNumber(m_keys.at(i) * 100);
    6767        keyText.append('%');
    6868    }
  • trunk/Source/WebCore/css/CSSTimingFunctionValue.cpp

    r236998 r242713  
    3535    StringBuilder builder;
    3636    builder.appendLiteral("cubic-bezier(");
    37     builder.appendNumber(m_x1);
     37    builder.appendFixedPrecisionNumber(m_x1);
    3838    builder.appendLiteral(", ");
    39     builder.appendNumber(m_y1);
     39    builder.appendFixedPrecisionNumber(m_y1);
    4040    builder.appendLiteral(", ");
    41     builder.appendNumber(m_x2);
     41    builder.appendFixedPrecisionNumber(m_x2);
    4242    builder.appendLiteral(", ");
    43     builder.appendNumber(m_y2);
     43    builder.appendFixedPrecisionNumber(m_y2);
    4444    builder.append(')');   
    4545    return builder.toString();
     
    7272    StringBuilder builder;
    7373    builder.appendLiteral("spring(");
    74     builder.appendNumber(m_mass);
     74    builder.appendFixedPrecisionNumber(m_mass);
    7575    builder.append(' ');
    76     builder.appendNumber(m_stiffness);
     76    builder.appendFixedPrecisionNumber(m_stiffness);
    7777    builder.append(' ');
    78     builder.appendNumber(m_damping);
     78    builder.appendFixedPrecisionNumber(m_damping);
    7979    builder.append(' ');
    80     builder.appendNumber(m_initialVelocity);
     80    builder.appendFixedPrecisionNumber(m_initialVelocity);
    8181    builder.append(')');
    8282    return builder.toString();
  • trunk/Source/WebCore/css/parser/CSSParserToken.cpp

    r241256 r242713  
    420420        if (m_numericSign == PlusSign)
    421421            builder.append('+');
    422         builder.appendNumber(numericValue());
     422        builder.appendFixedPrecisionNumber(numericValue());
    423423        break;
    424424    case PercentageToken:
    425         builder.appendNumber(numericValue());
     425        builder.appendFixedPrecisionNumber(numericValue());
    426426        builder.append('%');
    427427        break;
    428428    case DimensionToken:
    429429        // This will incorrectly serialize e.g. 4e3e2 as 4000e2
    430         builder.appendNumber(numericValue());
     430        builder.appendFixedPrecisionNumber(numericValue());
    431431        serializeIdentifier(value().toString(), builder);
    432432        break;
  • trunk/Source/WebCore/html/HTMLImageElement.cpp

    r242391 r242713  
    552552            if (candidate.density != UninitializedDescriptor) {
    553553                result.append(' ');
    554                 result.appendNumber(candidate.density);
     554                result.appendFixedPrecisionNumber(candidate.density);
    555555                result.append('x');
    556556            }
  • trunk/Source/WebCore/inspector/InspectorOverlay.cpp

    r242019 r242713  
    783783                GraphicsContextStateSaver verticalLabelStateSaver(context);
    784784                context.translate(zoom(x) + 0.5f, scrollY);
    785                 context.drawText(font, TextRun(String::number(x)), { 2, rulerLabelSize });
     785                context.drawText(font, TextRun(String::numberToStringFixedPrecision(x)), { 2, rulerLabelSize });
    786786            }
    787787
     
    793793                context.translate(scrollX, zoom(y) + 0.5f);
    794794                context.rotate(-piOverTwoFloat);
    795                 context.drawText(font, TextRun(String::number(y)), { 2, rulerLabelSize });
     795                context.drawText(font, TextRun(String::numberToStringFixedPrecision(y)), { 2, rulerLabelSize });
    796796            }
    797797        }
  • trunk/Source/WebCore/loader/ResourceLoadStatistics.cpp

    r242603 r242713  
    413413    builder.append('\n');
    414414    builder.appendLiteral("    lastSeen: ");
    415     builder.appendNumber(lastSeen.secondsSinceEpoch().value());
     415    builder.appendFixedPrecisionNumber(lastSeen.secondsSinceEpoch().value());
    416416    builder.append('\n');
    417417   
     
    420420    builder.append('\n');
    421421    builder.appendLiteral("    mostRecentUserInteraction: ");
    422     builder.appendNumber(mostRecentUserInteractionTime.secondsSinceEpoch().value());
     422    builder.appendFixedPrecisionNumber(mostRecentUserInteractionTime.secondsSinceEpoch().value());
    423423    builder.append('\n');
    424424    appendBoolean(builder, "grandfathered", grandfathered);
  • trunk/Source/WebCore/page/PrintContext.cpp

    r241244 r242713  
    327327        if (style->marginLeft().isAuto())
    328328            return "auto"_s;
    329         return String::number(style->marginLeft().value());
     329        return String::numberToStringFixedPrecision(style->marginLeft().value());
    330330    }
    331331    if (!strcmp(propertyName, "line-height"))
    332         return String::number(style->lineHeight().value());
     332        return String::numberToStringFixedPrecision(style->lineHeight().value());
    333333    if (!strcmp(propertyName, "font-size"))
    334334        return String::number(style->fontDescription().computedPixelSize());
  • trunk/Source/WebCore/page/cocoa/ResourceUsageOverlayCocoa.mm

    r242308 r242713  
    440440    if (std::isnan(timerFireDate))
    441441        return "[not scheduled]"_s;
    442     return String::number((timerFireDate - now).seconds());
     442    return String::numberToStringFixedPrecision((timerFireDate - now).seconds());
    443443}
    444444
  • trunk/Source/WebCore/platform/LayoutUnit.h

    r238463 r242713  
    834834
    835835#ifndef NDEBUG
     836
    836837namespace WTF {
     838
    837839// This structure is used by PODIntervalTree for debugging.
    838 template <>
    839 struct ValueToString<WebCore::LayoutUnit> {
    840     static String string(const WebCore::LayoutUnit value) { return String::number(value.toFloat()); }
     840template<> struct ValueToString<WebCore::LayoutUnit> {
     841    static String string(WebCore::LayoutUnit value) { return String::numberToStringFixedPrecision(value.toFloat()); }
    841842};
    842843
    843844} // namespace WTF
     845
    844846#endif
  • trunk/Source/WebCore/platform/graphics/Color.cpp

    r242316 r242713  
    378378    if (colorHasAlpha) {
    379379        builder.appendLiteral(", ");
    380         builder.appendNumber(alpha() / 255.0f);
     380        builder.appendFixedPrecisionNumber(alpha() / 255.0f);
    381381    }
    382382       
  • trunk/Source/WebCore/platform/graphics/ExtendedColor.cpp

    r241244 r242713  
    5757    }
    5858
    59     builder.appendNumber(red());
     59    builder.appendFixedPrecisionNumber(red());
    6060    builder.append(' ');
    6161
    62     builder.appendNumber(green());
     62    builder.appendFixedPrecisionNumber(green());
    6363    builder.append(' ');
    6464
    65     builder.appendNumber(blue());
     65    builder.appendFixedPrecisionNumber(blue());
    6666    if (!WTF::areEssentiallyEqual(alpha(), 1.0f)) {
    6767        builder.appendLiteral(" / ");
    68         builder.appendNumber(alpha());
     68        builder.appendFixedPrecisionNumber(alpha());
    6969    }
    7070    builder.append(')');
  • trunk/Source/WebCore/svg/SVGAngleValue.cpp

    r241244 r242713  
    7474    case SVG_ANGLETYPE_UNSPECIFIED:
    7575    case SVG_ANGLETYPE_UNKNOWN:
    76         return String::number(m_valueInSpecifiedUnits);
     76        return String::numberToStringFixedPrecision(m_valueInSpecifiedUnits);
    7777    }
    7878
  • trunk/Source/WebCore/svg/SVGNumberListValues.cpp

    r208863 r242713  
    5353            builder.append(' ');
    5454
    55         builder.appendNumber(at(i));
     55        builder.appendFixedPrecisionNumber(at(i));
    5656    }
    5757
  • trunk/Source/WebCore/svg/SVGPathStringBuilder.cpp

    r223728 r242713  
    5858static void appendNumber(StringBuilder& stringBuilder, float number)
    5959{
    60     stringBuilder.appendNumber(number);
     60    stringBuilder.appendFixedPrecisionNumber(number);
    6161    stringBuilder.append(' ');
    6262}
     
    6464static void appendPoint(StringBuilder& stringBuilder, const FloatPoint& point)
    6565{
    66     stringBuilder.appendNumber(point.x());
     66    stringBuilder.appendFixedPrecisionNumber(point.x());
    6767    stringBuilder.append(' ');
    68     stringBuilder.appendNumber(point.y());
     68    stringBuilder.appendFixedPrecisionNumber(point.y());
    6969    stringBuilder.append(' ');
    7070}
  • trunk/Source/WebCore/svg/SVGPointListValues.cpp

    r208863 r242713  
    3737
    3838        const auto& point = at(i);
    39         builder.appendNumber(point.x());
     39        builder.appendFixedPrecisionNumber(point.x());
    4040        builder.append(' ');
    41         builder.appendNumber(point.y());
     41        builder.appendFixedPrecisionNumber(point.y());
    4242    }
    4343
  • trunk/Source/WebCore/svg/SVGTransformValue.cpp

    r223728 r242713  
    168168        StringBuilder builder;
    169169        builder.append(prefix);
    170         builder.appendNumber(m_matrix.a());
    171         builder.append(' ');
    172         builder.appendNumber(m_matrix.b());
    173         builder.append(' ');
    174         builder.appendNumber(m_matrix.c());
    175         builder.append(' ');
    176         builder.appendNumber(m_matrix.d());
    177         builder.append(' ');
    178         builder.appendNumber(m_matrix.e());
    179         builder.append(' ');
    180         builder.appendNumber(m_matrix.f());
     170        builder.appendFixedPrecisionNumber(m_matrix.a());
     171        builder.append(' ');
     172        builder.appendFixedPrecisionNumber(m_matrix.b());
     173        builder.append(' ');
     174        builder.appendFixedPrecisionNumber(m_matrix.c());
     175        builder.append(' ');
     176        builder.appendFixedPrecisionNumber(m_matrix.d());
     177        builder.append(' ');
     178        builder.appendFixedPrecisionNumber(m_matrix.e());
     179        builder.append(' ');
     180        builder.appendFixedPrecisionNumber(m_matrix.f());
    181181        builder.append(')');
    182182        return builder.toString();
     
    185185        StringBuilder builder;
    186186        builder.append(prefix);
    187         builder.appendNumber(m_matrix.e());
    188         builder.append(' ');
    189         builder.appendNumber(m_matrix.f());
     187        builder.appendFixedPrecisionNumber(m_matrix.e());
     188        builder.append(' ');
     189        builder.appendFixedPrecisionNumber(m_matrix.f());
    190190        builder.append(')');
    191191        return builder.toString();
     
    194194        StringBuilder builder;
    195195        builder.append(prefix);
    196         builder.appendNumber(m_matrix.xScale());
    197         builder.append(' ');
    198         builder.appendNumber(m_matrix.yScale());
     196        builder.appendFixedPrecisionNumber(m_matrix.xScale());
     197        builder.append(' ');
     198        builder.appendFixedPrecisionNumber(m_matrix.yScale());
    199199        builder.append(')');
    200200        return builder.toString();
     
    208208        StringBuilder builder;
    209209        builder.append(prefix);
    210         builder.appendNumber(m_angle);
     210        builder.appendFixedPrecisionNumber(m_angle);
    211211        if (cx || cy) {
    212212            builder.append(' ');
    213             builder.appendNumber(cx);
     213            builder.appendFixedPrecisionNumber(cx);
    214214            builder.append(' ');
    215             builder.appendNumber(cy);
     215            builder.appendFixedPrecisionNumber(cy);
    216216        }
    217217        builder.append(')');
     
    222222        StringBuilder builder;
    223223        builder.append(prefix);
    224         builder.appendNumber(m_angle);
     224        builder.appendFixedPrecisionNumber(m_angle);
    225225        builder.append(')');
    226226        return builder.toString();
  • trunk/Source/WebCore/svg/properties/SVGPropertyTraits.h

    r239427 r242713  
    104104        return number;
    105105    }
    106     static String toString(float type) { return String::number(type); }
     106    static String toString(float type) { return String::numberToStringFixedPrecision(type); }
    107107};
    108108
     
    141141    {
    142142        StringBuilder builder;
    143         builder.appendNumber(type.x());
     143        builder.appendFixedPrecisionNumber(type.x());
    144144        builder.append(' ');
    145         builder.appendNumber(type.y());
     145        builder.appendFixedPrecisionNumber(type.y());
    146146        return builder.toString();
    147147    }
     
    168168    {
    169169        StringBuilder builder;
    170         builder.appendNumber(type.x());
     170        builder.appendFixedPrecisionNumber(type.x());
    171171        builder.append(' ');
    172         builder.appendNumber(type.y());
     172        builder.appendFixedPrecisionNumber(type.y());
    173173        builder.append(' ');
    174         builder.appendNumber(type.width());
     174        builder.appendFixedPrecisionNumber(type.width());
    175175        builder.append(' ');
    176         builder.appendNumber(type.height());
     176        builder.appendFixedPrecisionNumber(type.height());
    177177        return builder.toString();
    178178    }
  • trunk/Source/WebCore/testing/Internals.cpp

    r242155 r242713  
    16071607    for (const auto& rect : rects) {
    16081608        rectString.append('(');
    1609         rectString.appendNumber(rect.x());
     1609        rectString.appendFixedPrecisionNumber(rect.x());
    16101610        rectString.appendLiteral(", ");
    1611         rectString.appendNumber(rect.y());
     1611        rectString.appendFixedPrecisionNumber(rect.y());
    16121612        rectString.appendLiteral(", ");
    1613         rectString.appendNumber(rect.width());
     1613        rectString.appendFixedPrecisionNumber(rect.width());
    16141614        rectString.appendLiteral(", ");
    1615         rectString.appendNumber(rect.height());
     1615        rectString.appendFixedPrecisionNumber(rect.height());
    16161616        rectString.appendLiteral(") ");
    16171617    }
     
    33293329        FloatSize size = cursor.image()->size();
    33303330        result.appendLiteral(" image=");
    3331         result.appendNumber(size.width());
     3331        result.appendFixedPrecisionNumber(size.width());
    33323332        result.append('x');
    3333         result.appendNumber(size.height());
     3333        result.appendFixedPrecisionNumber(size.height());
    33343334    }
    33353335#if ENABLE(MOUSE_CURSOR_SCALE)
    33363336    if (cursor.imageScaleFactor() != 1) {
    33373337        result.appendLiteral(" scale=");
    3338         result.appendNumber(cursor.imageScaleFactor(), 8);
     3338        result.appendFixedPrecisionNumber(cursor.imageScaleFactor(), 8);
    33393339    }
    33403340#endif
  • trunk/Source/WebCore/xml/XPathValue.cpp

    r233122 r242713  
    127127            if (std::isinf(m_number))
    128128                return std::signbit(m_number) ? "-Infinity"_s : "Infinity"_s;
    129             return String::number(m_number);
     129            return String::numberToStringFixedPrecision(m_number);
    130130        case BooleanValue:
    131131            return m_bool ? "true"_s : "false"_s;
  • trunk/Source/WebKit/ChangeLog

    r242712 r242713  
     12019-03-11  Darin Adler  <darin@apple.com>
     2
     3        Specify fixed precision explicitly to prepare to change String::number and StringBuilder::appendNumber floating point behavior
     4        https://bugs.webkit.org/show_bug.cgi?id=195533
     5
     6        Reviewed by Brent Fulgham.
     7
     8        * NetworkProcess/cache/NetworkCache.cpp:
     9        (WebKit::NetworkCache::Cache::dumpContentsToFile): Use appendFixedPrecisionNumber.
     10        * NetworkProcess/cache/NetworkCacheEntry.cpp:
     11        (WebKit::NetworkCache::Entry::asJSON const): Ditto.
     12        * Shared/Gamepad/GamepadData.cpp:
     13        (WebKit::GamepadData::loggingString const): Ditto.
     14        * UIProcess/WebPageProxy.cpp:
     15        (WebKit::WebPageProxy::logDiagnosticMessageWithValue): Use numberToStringFixedPrecision.
     16
    1172019-03-11  John Wilander  <wilander@apple.com>
    218
  • trunk/Source/WebKit/NetworkProcess/cache/NetworkCache.cpp

    r240437 r242713  
    550550            epilogue.appendLiteral(",\n");
    551551            epilogue.appendLiteral("\"averageWorth\": ");
    552             epilogue.appendNumber(totals.count ? totals.worth / totals.count : 0);
     552            epilogue.appendFixedPrecisionNumber(totals.count ? totals.worth / totals.count : 0);
    553553            epilogue.appendLiteral("\n");
    554554            epilogue.appendLiteral("}\n}\n");
  • trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheEntry.cpp

    r239671 r242713  
    220220    json.appendLiteral(",\n");
    221221    json.appendLiteral("\"worth\": ");
    222     json.appendNumber(info.worth);
     222    json.appendFixedPrecisionNumber(info.worth);
    223223    json.appendLiteral(",\n");
    224224    json.appendLiteral("\"partition\": ");
     
    226226    json.appendLiteral(",\n");
    227227    json.appendLiteral("\"timestamp\": ");
    228     json.appendNumber(m_timeStamp.secondsSinceEpoch().milliseconds());
     228    json.appendFixedPrecisionNumber(m_timeStamp.secondsSinceEpoch().milliseconds());
    229229    json.appendLiteral(",\n");
    230230    json.appendLiteral("\"URL\": ");
  • trunk/Source/WebKit/Shared/Gamepad/GamepadData.cpp

    r239427 r242713  
    101101        builder.appendNumber(i);
    102102        builder.appendLiteral(": ");
    103         builder.appendNumber(m_axisValues[i]);
     103        builder.appendFixedPrecisionNumber(m_axisValues[i]);
    104104    }
    105105
     
    109109        builder.appendNumber(i);
    110110        builder.appendLiteral(": ");
    111         builder.appendNumber(m_buttonValues[i]);
     111        builder.appendFixedPrecisionNumber(m_buttonValues[i]);
    112112    }
    113113
  • trunk/Source/WebKit/UIProcess/WebPageProxy.cpp

    r242705 r242713  
    64436443        return;
    64446444
    6445     effectiveClient->logDiagnosticMessageWithValue(this, message, description, String::number(value, significantFigures));
     6445    effectiveClient->logDiagnosticMessageWithValue(this, message, description, String::numberToStringFixedPrecision(value, significantFigures));
    64466446}
    64476447
Note: See TracChangeset for help on using the changeset viewer.