Specify fixed precision explicitly to prepare to change String::number and StringBuil...
authordarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 11 Mar 2019 17:11:13 +0000 (17:11 +0000)
committerdarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 11 Mar 2019 17:11:13 +0000 (17:11 +0000)
commit8394bb47677c039e9952f5f3d922e608203be263
treece9d7f17f98db1741124ced45fe22795586f4d23
parent3434c15afca4a2188227bb4b1945b30405c52c24
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.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@242713 268f45cc-cd09-0410-ab3c-d52691b4dbfc
37 files changed:
Source/JavaScriptCore/API/tests/ExecutionTimeLimitTest.cpp
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/runtime/NumberPrototype.cpp
Source/JavaScriptCore/runtime/Options.cpp
Source/WTF/ChangeLog
Source/WTF/wtf/Logger.h
Source/WTF/wtf/MediaTime.cpp
Source/WTF/wtf/text/ValueToString.h
Source/WebCore/ChangeLog
Source/WebCore/accessibility/AccessibilityNodeObject.cpp
Source/WebCore/accessibility/AccessibilityScrollbar.cpp
Source/WebCore/css/CSSFontVariationValue.cpp
Source/WebCore/css/CSSGradientValue.cpp
Source/WebCore/css/CSSKeyframeRule.cpp
Source/WebCore/css/CSSTimingFunctionValue.cpp
Source/WebCore/css/parser/CSSParserToken.cpp
Source/WebCore/html/HTMLImageElement.cpp
Source/WebCore/inspector/InspectorOverlay.cpp
Source/WebCore/loader/ResourceLoadStatistics.cpp
Source/WebCore/page/PrintContext.cpp
Source/WebCore/page/cocoa/ResourceUsageOverlayCocoa.mm
Source/WebCore/platform/LayoutUnit.h
Source/WebCore/platform/graphics/Color.cpp
Source/WebCore/platform/graphics/ExtendedColor.cpp
Source/WebCore/svg/SVGAngleValue.cpp
Source/WebCore/svg/SVGNumberListValues.cpp
Source/WebCore/svg/SVGPathStringBuilder.cpp
Source/WebCore/svg/SVGPointListValues.cpp
Source/WebCore/svg/SVGTransformValue.cpp
Source/WebCore/svg/properties/SVGPropertyTraits.h
Source/WebCore/testing/Internals.cpp
Source/WebCore/xml/XPathValue.cpp
Source/WebKit/ChangeLog
Source/WebKit/NetworkProcess/cache/NetworkCache.cpp
Source/WebKit/NetworkProcess/cache/NetworkCacheEntry.cpp
Source/WebKit/Shared/Gamepad/GamepadData.cpp
Source/WebKit/UIProcess/WebPageProxy.cpp