Changeset 254514 in webkit
- Timestamp:
- Jan 14, 2020 9:16:03 AM (4 years ago)
- Location:
- trunk
- Files:
-
- 1 deleted
- 41 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r254513 r254514 1 2020-01-13 Darin Adler <darin@apple.com> 2 3 Use even more "shortest form" formatting, and less "fixed precision" and "fixed width" 4 https://bugs.webkit.org/show_bug.cgi?id=198918 5 6 Reviewed by Sam Weinig. 7 8 * platform/mac/svg/dom/length-list-parser-expected.png: Removed. Not sure how many other pixel 9 results we have like this, but this included an ancient style Aqua scrollbar so hasn't matched 10 anything for years and would clearly not have any value for regression testing. 11 12 * svg/dom/length-list-parser-expected.txt: Updated to expect logging of a 7 digit length as an 13 integer rather than rounded as "d.ddddd+6". 14 1 15 2020-01-14 Chris Lord <clord@igalia.com> 2 16 -
trunk/LayoutTests/svg/dom/length-list-parser-expected.txt
r101056 r254514 5 5 6 6 Parsed as 1 length(s) [ 8.847 ]: 8.847 7 Parsed as 1 length(s) [ 8 .62569e+6 ]: 8625686 3.0-0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001, 90,e4997..,782-4326e. -0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000013e,+e9 e 4829.,063721-0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001.-0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001e6 0727 Parsed as 1 length(s) [ 8625686 ]: 8625686 3.0-0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001, 90,e4997..,782-4326e. -0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000013e,+e9 e 4829.,063721-0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001.-0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001e6 072 8 8 Parsed as 1 length(s) [ 61822 ]: 61822,15-00.166.7 9 9 Parsed as 2 length(s) [ 2, 0.5 ]: 2 .5,658-7 e ,8477553 -
trunk/Source/JavaScriptCore/API/tests/ExecutionTimeLimitTest.cpp
r254480 r254514 199 199 Seconds timeAfterWatchdogShouldHaveFired = 300_ms + tierAdjustment; 200 200 201 StringBuilder scriptBuilder; 202 scriptBuilder.appendLiteral("function foo() { var startTime = currentCPUTime(); while (true) { for (var i = 0; i < 1000; i++); if (currentCPUTime() - startTime > "); 203 scriptBuilder.append(FormattedNumber::fixedPrecision(timeAfterWatchdogShouldHaveFired.seconds())); 204 scriptBuilder.appendLiteral(") break; } } foo();"); 205 206 JSStringRef script = JSStringCreateWithUTF8CString(scriptBuilder.toString().utf8().data()); 201 CString scriptText = makeString( 202 "function foo() {" 203 "var startTime = currentCPUTime();" 204 "while (true) {" 205 "for (var i = 0; i < 1000; i++);" 206 "if (currentCPUTime() - startTime > ", timeAfterWatchdogShouldHaveFired.seconds(), ") break;" 207 "}" 208 "}" 209 "foo();" 210 ).utf8(); 211 212 JSStringRef script = JSStringCreateWithUTF8CString(scriptText.data()); 207 213 exception = nullptr; 208 214 shouldTerminateCallbackWasCalled = false; … … 236 242 Seconds timeAfterWatchdogShouldHaveFired = 300_ms + tierAdjustment; 237 243 238 StringBuilder scriptBuilder; 239 scriptBuilder.appendLiteral("var startTime = currentCPUTime();" 240 "function recurse(i) {" 241 "'use strict';" 242 "if (i % 1000 === 0) {" 243 "if (currentCPUTime() - startTime >"); 244 scriptBuilder.append(FormattedNumber::fixedPrecision(timeAfterWatchdogShouldHaveFired.seconds())); 245 scriptBuilder.appendLiteral(" ) { return; }"); 246 scriptBuilder.appendLiteral(" }"); 247 scriptBuilder.appendLiteral(" return recurse(i + 1); }"); 248 scriptBuilder.appendLiteral("recurse(0);"); 249 250 JSStringRef script = JSStringCreateWithUTF8CString(scriptBuilder.toString().utf8().data()); 244 CString scriptText = makeString( 245 "var startTime = currentCPUTime();" 246 "function recurse(i) {" 247 "'use strict';" 248 "if (i % 1000 === 0) {" 249 "if (currentCPUTime() - startTime >", timeAfterWatchdogShouldHaveFired.seconds(), ") { return; }" 250 "}" 251 "return recurse(i + 1); }" 252 "recurse(0);" 253 ).utf8(); 254 255 JSStringRef script = JSStringCreateWithUTF8CString(scriptText.data()); 251 256 exception = nullptr; 252 257 shouldTerminateCallbackWasCalled = false; … … 280 285 Seconds timeAfterWatchdogShouldHaveFired = 300_ms + tierAdjustment; 281 286 282 StringBuilder scriptBuilder; 283 scriptBuilder.appendLiteral("function foo() { var startTime = currentCPUTime(); try { while (true) { for (var i = 0; i < 1000; i++); if (currentCPUTime() - startTime > "); 284 scriptBuilder.append(FormattedNumber::fixedPrecision(timeAfterWatchdogShouldHaveFired.seconds())); 285 scriptBuilder.appendLiteral(") break; } } catch(e) { } } foo();"); 286 287 JSStringRef script = JSStringCreateWithUTF8CString(scriptBuilder.toString().utf8().data()); 287 CString scriptText = makeString( 288 "function foo() {" 289 "var startTime = currentCPUTime();" 290 "try {" 291 "while (true) {" 292 "for (var i = 0; i < 1000; i++);" 293 "if (currentCPUTime() - startTime > ", timeAfterWatchdogShouldHaveFired.seconds(), ") break;" 294 "}" 295 "} catch(e) { }" 296 "}" 297 "foo();" 298 ).utf8(); 299 300 JSStringRef script = JSStringCreateWithUTF8CString(scriptText.data()); 288 301 exception = nullptr; 289 302 shouldTerminateCallbackWasCalled = false; … … 319 332 Seconds timeAfterWatchdogShouldHaveFired = 300_ms + tierAdjustment; 320 333 321 StringBuilder scriptBuilder; 322 scriptBuilder.appendLiteral("function foo() { var startTime = currentCPUTime(); while (true) { for (var i = 0; i < 1000; i++); if (currentCPUTime() - startTime > "); 323 scriptBuilder.append(FormattedNumber::fixedPrecision(timeAfterWatchdogShouldHaveFired.seconds())); 324 scriptBuilder.appendLiteral(") break; } } foo();"); 325 326 JSStringRef script = JSStringCreateWithUTF8CString(scriptBuilder.toString().utf8().data()); 334 CString scriptText = makeString( 335 "function foo() {" 336 "var startTime = currentCPUTime();" 337 "while (true) {" 338 "for (var i = 0; i < 1000; i++);" 339 "if (currentCPUTime() - startTime > ", timeAfterWatchdogShouldHaveFired.seconds(), ") break;" 340 "}" 341 "}" 342 "foo();" 343 ).utf8(); 344 345 JSStringRef script = JSStringCreateWithUTF8CString(scriptText.data()); 327 346 exception = nullptr; 328 347 shouldTerminateCallbackWasCalled = false; … … 358 377 Seconds timeAfterWatchdogShouldHaveFired = 300_ms + tierAdjustment; 359 378 360 StringBuilder scriptBuilder; 361 scriptBuilder.appendLiteral("function foo() { var startTime = currentCPUTime(); while (true) { for (var i = 0; i < 1000; i++); if (currentCPUTime() - startTime > "); 362 scriptBuilder.append(FormattedNumber::fixedPrecision(timeAfterWatchdogShouldHaveFired.seconds())); 363 scriptBuilder.appendLiteral(") break; } } foo();"); 364 365 JSStringRef script = JSStringCreateWithUTF8CString(scriptBuilder.toString().utf8().data()); 379 CString scriptText = makeString( 380 "function foo() {" 381 "var startTime = currentCPUTime();" 382 "while (true) {" 383 "for (var i = 0; i < 1000; i++);" 384 "if (currentCPUTime() - startTime > ", timeAfterWatchdogShouldHaveFired.seconds(), ") break;" 385 "}" 386 "}" 387 "foo();" 388 ).utf8(); 389 390 JSStringRef script = JSStringCreateWithUTF8CString(scriptText.data()); 366 391 exception = nullptr; 367 392 cancelTerminateCallbackWasCalled = false; … … 397 422 Seconds maxBusyLoopTime = 750_ms + tierAdjustment; 398 423 399 StringBuilder scriptBuilder; 400 scriptBuilder.appendLiteral("function foo() { var startTime = currentCPUTime(); while (true) { for (var i = 0; i < 1000; i++); if (currentCPUTime() - startTime > "); 401 scriptBuilder.append(FormattedNumber::fixedPrecision(maxBusyLoopTime.seconds())); // in seconds. 402 scriptBuilder.appendLiteral(") break; } } foo();"); 403 404 JSStringRef script = JSStringCreateWithUTF8CString(scriptBuilder.toString().utf8().data()); 424 CString scriptText = makeString( 425 "function foo() {" 426 "var startTime = currentCPUTime();" 427 "while (true) {" 428 "for (var i = 0; i < 1000; i++);" 429 "if (currentCPUTime() - startTime > ", maxBusyLoopTime.seconds(), ") break;" 430 "}" 431 "}" 432 "foo();" 433 ).utf8(); 434 435 JSStringRef script = JSStringCreateWithUTF8CString(scriptText.data()); 405 436 exception = nullptr; 406 437 extendTerminateCallbackCalled = 0; … … 440 471 Seconds timeAfterWatchdogShouldHaveFired = 300_ms + tierAdjustment; 441 472 442 StringBuilder scriptBuilder; 443 scriptBuilder.appendLiteral("function foo() { var startTime = currentCPUTime(); while (true) { for (var i = 0; i < 1000; i++); if (currentCPUTime() - startTime > "); 444 scriptBuilder.append(FormattedNumber::fixedPrecision(timeAfterWatchdogShouldHaveFired.seconds())); 445 scriptBuilder.appendLiteral(") break; } } foo();"); 446 447 JSStringRef script = JSStringCreateWithUTF8CString(scriptBuilder.toString().utf8().data()); 473 CString scriptText = makeString( 474 "function foo() {" 475 "var startTime = currentCPUTime();" 476 "while (true) {" 477 "for (var i = 0; i < 1000; i++);" 478 "if (currentCPUTime() - startTime > ", timeAfterWatchdogShouldHaveFired.seconds(), ") break;" 479 "}" 480 "}" 481 "foo();" 482 ).utf8(); 483 484 JSStringRef script = JSStringCreateWithUTF8CString(scriptText.data()); 448 485 exception = nullptr; 449 486 dispatchTerminateCallbackCalled = false; -
trunk/Source/JavaScriptCore/ChangeLog
r254500 r254514 1 2020-01-13 Darin Adler <darin@apple.com> 2 3 Use even more "shortest form" formatting, and less "fixed precision" and "fixed width" 4 https://bugs.webkit.org/show_bug.cgi?id=198918 5 6 Reviewed by Sam Weinig. 7 8 * API/tests/ExecutionTimeLimitTest.cpp: 9 (testExecutionTimeLimit): Rewrote the string creation code to use makeString instead 10 of StringBuilder and no longer use any fixed precision. 11 12 * runtime/Options.cpp: 13 (JSC::OptionReader::Option::dump const): Dump doubles with shortest form instead of 14 fixed precision. 15 1 16 2020-01-14 David Kilzer <ddkilzer@apple.com> 2 17 -
trunk/Source/JavaScriptCore/runtime/Options.cpp
r254480 r254514 1006 1006 break; 1007 1007 case Options::Type::Double: 1008 builder.append( FormattedNumber::fixedPrecision(m_double));1008 builder.append(m_double); 1009 1009 break; 1010 1010 case Options::Type::Int32: -
trunk/Source/WTF/ChangeLog
r254509 r254514 1 2020-01-13 Darin Adler <darin@apple.com> 2 3 Use even more "shortest form" formatting, and less "fixed precision" and "fixed width" 4 https://bugs.webkit.org/show_bug.cgi?id=198918 5 6 Reviewed by Sam Weinig. 7 8 * wtf/Logger.h: 9 (WTF::LogArgument::toString): Log floating point numbers as shortest form instead of fixed precision. 10 11 * wtf/MediaTime.cpp: 12 (WTF::MediaTime::toString const): Convert time to string as shortest form instead of fixed precision. 13 Also use multiple-argument append for great simplicity and clarity. 14 1 15 2020-01-14 Alicia Boya García <aboya@igalia.com> 2 16 -
trunk/Source/WTF/wtf/Logger.h
r253900 r254514 42 42 template<typename U = T> static typename std::enable_if<std::is_same<U, long long>::value, String>::type toString(long long argument) { return String::number(argument); } 43 43 template<typename U = T> static typename std::enable_if<std::is_enum<U>::value, String>::type toString(U argument) { return String::number(static_cast<typename std::underlying_type<U>::type>(argument)); } 44 template<typename U = T> static typename std::enable_if<std::is_same<U, float>::value, String>::type toString(float argument) { return String::number ToStringFixedPrecision(argument); }45 template<typename U = T> static typename std::enable_if<std::is_same<U, double>::value, String>::type toString(double argument) { return String::number ToStringFixedPrecision(argument); }44 template<typename U = T> static typename std::enable_if<std::is_same<U, float>::value, String>::type toString(float argument) { return String::number(argument); } 45 template<typename U = T> static typename std::enable_if<std::is_same<U, double>::value, String>::type toString(double argument) { return String::number(argument); } 46 46 template<typename U = T> static typename std::enable_if<std::is_same<typename std::remove_reference<U>::type, AtomString>::value, String>::type toString(const AtomString& argument) { return argument.string(); } 47 47 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
r254509 r254514 567 567 { 568 568 StringBuilder builder; 569 570 569 builder.append('{'); 571 if (!hasDoubleValue()) { 572 builder.appendNumber(m_timeValue); 573 builder.append('/'); 574 builder.appendNumber(m_timeScale); 575 builder.appendLiteral(" = "); 576 } 577 builder.append(FormattedNumber::fixedPrecision(toDouble())); 570 if (!hasDoubleValue()) 571 builder.append(m_timeValue, '/', m_timeScale, " = "); 572 builder.append(toDouble()); 578 573 if (isInvalid()) 579 574 builder.appendLiteral(", invalid"); -
trunk/Source/WebCore/ChangeLog
r254512 r254514 1 2020-01-13 Darin Adler <darin@apple.com> 2 3 Use even more "shortest form" formatting, and less "fixed precision" and "fixed width" 4 https://bugs.webkit.org/show_bug.cgi?id=198918 5 6 Reviewed by Sam Weinig. 7 8 The places left untouched are the ones where changing behavior has some kind of unwanted 9 observable effect for one of two reasons. Otherwise, switched almost all call sites. 10 11 1) Substantial number of test results that depend on the current behavior. 12 13 2) Poor rounding resulting in conversion from float to double and back (or similar) that 14 results in values with tiny fractional residue like "6.000001". 15 16 * accessibility/AccessibilityNodeObject.cpp: 17 (WebCore::AccessibilityNodeObject::changeValueByStep): Use shortest instead of fixed. 18 (WebCore::AccessibilityNodeObject::changeValueByPercent): Ditto. 19 * css/CSSAspectRatioValue.cpp: 20 (WebCore::CSSAspectRatioValue::customCSSText const): Ditto. 21 * css/CSSFontVariationValue.cpp: 22 (WebCore::CSSFontVariationValue::customCSSText const): Ditto. Also use makeString instead of 23 StringBuilder for better efficiency. 24 * css/CSSGradientValue.cpp: 25 (WebCore::appendGradientStops): Ditto. 26 * css/CSSKeyframeRule.cpp: 27 (WebCore::StyleRuleKeyframe::keyText const): Ditto. 28 * css/CSSTimingFunctionValue.cpp: 29 (WebCore::CSSCubicBezierTimingFunctionValue::customCSSText const): Ditto. 30 * css/MediaQueryEvaluator.cpp: 31 (WebCore::aspectRatioValueAsString): Ditto. 32 33 * css/TransformFunctions.h: Removed unnneeded forward declarations. 34 35 * css/parser/CSSParserToken.cpp: 36 (WebCore::CSSParserToken::serialize const): Use shortest instead of fixed. 37 * html/HTMLImageElement.cpp: 38 (WebCore::HTMLImageElement::completeURLsInAttributeValue const): Ditto. 39 40 * html/track/VTTCue.cpp: 41 (WebCore::VTTCueBox::applyCSSProperties): Use shortest instead of fixed. 42 Also wrote a FIXME abot this strange code that uses "calc()" to do math on two numbers, 43 math that could instead be done by the code converting the numbers to a style string. 44 45 * inspector/InspectorOverlay.cpp: 46 (WebCore::InspectorOverlay::drawRulers): Use shortest instead of fixed. 47 * page/CaptionUserPreferencesMediaAF.cpp: 48 (WebCore::CaptionUserPreferencesMediaAF::windowRoundedCornerRadiusCSS const): Ditto. 49 * page/scrolling/AxisScrollSnapOffsets.cpp: 50 (WebCore::snapOffsetsToString): Ditto. 51 (WebCore::snapOffsetRangesToString): Ditto. 52 (WebCore::snapPortOrAreaToString): Ditto. 53 54 * platform/graphics/Color.cpp: 55 (WebCore::decimalDigit): Added. 56 (WebCore::serializedFractionDigitsForFractionalAlphaValue): Added. 57 (WebCore::Color::cssText const): Rewrote to generate the same results using 58 makeString rather than StringBuilder, and integer math rather than converting from 59 integer to floating point and then doing floating point math. 60 61 * platform/graphics/ExtendedColor.cpp: 62 (WebCore::ExtendedColor::cssText const): Use shortest instead of fixed. 63 * rendering/RenderLayerCompositor.cpp: 64 (WebCore::RenderLayerCompositor::logLayerInfo): Ditto. 65 * svg/SVGAngleValue.cpp: 66 (WebCore::SVGAngleValue::valueAsString const): Ditto. 67 68 * svg/SVGLengthList.h: Added now-needed include of StringBuilder.h. 69 70 * svg/SVGLengthValue.cpp: 71 (WebCore::SVGLengthValue::valueAsString const): Use shortest instead of fixed. 72 * svg/SVGNumberList.h: Ditto. 73 74 * svg/SVGPathStringBuilder.cpp: 75 (WebCore::appendFlag): Use multiple-argument append for better efficiency. 76 (WebCore::appendNumber): Added a comment about why we can't yet convert this to use 77 shortest instead of fixed: code that parses floats but then creates a CG path 78 that stores things as double and does math as double then converts back to float 79 results in float values that didn't round trip well and have fractions. This is 80 smoothed away (hidden) by using fixed precision to conver them to strings. 81 (WebCore::appendPoint): Call appendNumber to cut down on repeated code. 82 83 * svg/SVGPointList.h: Use shortest instead of fixed. 84 85 * svg/SVGTransformValue.h: 86 (WebCore::SVGTransformValue::prefixForTransfromType): Return a string literal 87 instead of a WTF::String to avoid creating and destroying an object each time. 88 (WebCore::SVGTransformValue::appendFixedPrecisionNumbers): Added a comment explaining 89 why we need to continue to use fixed precision here. Same issue with CGAffineTransform 90 using double as we have with CGPath above. 91 92 * svg/properties/SVGPropertyTraits.h: 93 (WebCore::SVGPropertyTraits<float>::toString): Use shortest instead of fixed. 94 (WebCore::SVGPropertyTraits<FloatPoint>::toString): Ditto. 95 (WebCore::SVGPropertyTraits<FloatRect>::toString): Ditto. 96 97 * testing/Internals.cpp: 98 (WebCore::Internals::dumpMarkerRects): Added a comment explaining why we have to use 99 fixed precision here. There are many test results that we would need to update. 100 (WebCore::Internals::configurationForViewport): Ditto. 101 (WebCore::Internals::getCurrentCursorInfo): Use shortest instead of fixed. 102 * xml/XPathValue.cpp: 103 (WebCore::XPath::Value::toString const): Ditto. 104 1 105 2020-01-14 Peng Liu <peng.liu6@apple.com> 2 106 -
trunk/Source/WebCore/accessibility/AccessibilityNodeObject.cpp
r253261 r254514 1105 1105 value += increase ? step : -step; 1106 1106 1107 setValue(String::number ToStringFixedPrecision(value));1107 setValue(String::number(value)); 1108 1108 1109 1109 auto objectCache = axObjectCache(); … … 1123 1123 1124 1124 value += step; 1125 setValue(String::number ToStringFixedPrecision(value));1125 setValue(String::number(value)); 1126 1126 1127 1127 auto objectCache = axObjectCache(); -
trunk/Source/WebCore/css/CSSAspectRatioValue.cpp
r241244 r254514 36 36 String CSSAspectRatioValue::customCSSText() const 37 37 { 38 return makeString( FormattedNumber::fixedPrecision(m_numeratorValue), '/', FormattedNumber::fixedPrecision(m_denominatorValue));38 return makeString(m_numeratorValue, '/', m_denominatorValue); 39 39 } 40 40 -
trunk/Source/WebCore/css/CSSFontVariationValue.cpp
r253975 r254514 30 30 #include "CSSFontVariationValue.h" 31 31 32 #include <wtf/text/StringBuilder.h>33 34 32 namespace WebCore { 35 33 … … 43 41 String CSSFontVariationValue::customCSSText() const 44 42 { 45 StringBuilder builder; 46 builder.append('"'); 47 for (char c : m_tag) 48 builder.append(c); 49 builder.appendLiteral("\" "); 50 builder.append(FormattedNumber::fixedPrecision(m_value)); 51 return builder.toString(); 43 return makeString('"', m_tag[0], m_tag[1], m_tag[2], m_tag[3], "\" ", m_value); 52 44 } 53 45 -
trunk/Source/WebCore/css/CSSGradientValue.cpp
r254164 r254514 701 701 builder.append(", to(", stop.m_color->cssText(), ')'); 702 702 else 703 builder.append(", color-stop(", FormattedNumber::fixedPrecision(position), ", ", stop.m_color->cssText(), ')');703 builder.append(", color-stop(", position, ", ", stop.m_color->cssText(), ')'); 704 704 } 705 705 } -
trunk/Source/WebCore/css/CSSKeyframeRule.cpp
r253975 r254514 60 60 { 61 61 StringBuilder keyText; 62 63 62 for (size_t i = 0; i < m_keys.size(); ++i) { 64 63 if (i) 65 64 keyText.append(','); 66 keyText.append(FormattedNumber::fixedPrecision(m_keys.at(i) * 100)); 67 keyText.append('%'); 65 keyText.append(m_keys[i] * 100, '%'); 68 66 } 69 70 67 return keyText.toString(); 71 68 } -
trunk/Source/WebCore/css/CSSTimingFunctionValue.cpp
r253975 r254514 33 33 String CSSCubicBezierTimingFunctionValue::customCSSText() const 34 34 { 35 StringBuilder builder; 36 builder.appendLiteral("cubic-bezier("); 37 builder.append(FormattedNumber::fixedPrecision(m_x1)); 38 builder.appendLiteral(", "); 39 builder.append(FormattedNumber::fixedPrecision(m_y1)); 40 builder.appendLiteral(", "); 41 builder.append(FormattedNumber::fixedPrecision(m_x2)); 42 builder.appendLiteral(", "); 43 builder.append(FormattedNumber::fixedPrecision(m_y2)); 44 builder.append(')'); 45 return builder.toString(); 35 return makeString("cubic-bezier(", m_x1, ", ", m_y1, ", ", m_x2, ", ", m_y2, ')'); 46 36 } 47 37 -
trunk/Source/WebCore/css/MediaQueryEvaluator.cpp
r253616 r254514 241 241 242 242 auto& aspectRatio = downcast<CSSAspectRatioValue>(*value); 243 return makeString( FormattedNumber::fixedWidth(aspectRatio.numeratorValue(), 6), '/', FormattedNumber::fixedWidth(aspectRatio.denominatorValue(), 6));243 return makeString(aspectRatio.numeratorValue(), '/', aspectRatio.denominatorValue()); 244 244 } 245 245 -
trunk/Source/WebCore/css/TransformFunctions.h
r209805 r254514 37 37 class CSSToLengthConversionData; 38 38 class CSSValue; 39 class RenderStyle;40 41 struct Length;42 39 43 40 bool transformsForValue(const CSSValue&, const CSSToLengthConversionData&, TransformOperations&); -
trunk/Source/WebCore/css/parser/CSSParserToken.cpp
r254046 r254514 422 422 if (m_numericSign == PlusSign) 423 423 builder.append('+'); 424 builder.append( FormattedNumber::fixedPrecision(numericValue()));424 builder.append(numericValue()); 425 425 break; 426 426 case PercentageToken: 427 builder.append(FormattedNumber::fixedPrecision(numericValue())); 428 builder.append('%'); 427 builder.append(numericValue(), '%'); 429 428 break; 430 429 case DimensionToken: 431 430 // This will incorrectly serialize e.g. 4e3e2 as 4000e2 432 builder.append( FormattedNumber::fixedPrecision(numericValue()));431 builder.append(numericValue()); 433 432 serializeIdentifier(value().toString(), builder); 434 433 break; -
trunk/Source/WebCore/html/HTMLImageElement.cpp
r254229 r254514 585 585 result.appendLiteral(", "); 586 586 result.append(URL(base, candidate.string.toString()).string()); 587 if (candidate.density != UninitializedDescriptor) { 588 result.append(' '); 589 result.append(FormattedNumber::fixedPrecision(candidate.density)); 590 result.append('x'); 591 } 592 if (candidate.resourceWidth != UninitializedDescriptor) { 593 result.append(' '); 594 result.appendNumber(candidate.resourceWidth); 595 result.append('w'); 596 } 587 if (candidate.density != UninitializedDescriptor) 588 result.append(' ', candidate.density, 'x'); 589 if (candidate.resourceWidth != UninitializedDescriptor) 590 result.append(' ', candidate.resourceWidth, 'w'); 597 591 } 598 592 return result.toString(); -
trunk/Source/WebCore/html/track/VTTCue.cpp
r252392 r254514 170 170 if (cue->vertical() == horizontalKeyword()) 171 171 setInlineStyleProperty(CSSPropertyLeft, position.first, CSSUnitType::CSS_PERCENTAGE); 172 else if (cue->vertical() == verticalGrowingRightKeyword()) 173 setInlineStyleProperty(CSSPropertyLeft, makeString("calc(-", FormattedNumber::fixedWidth(videoSize.width(), 2), "px - ", FormattedNumber::fixedWidth(cue->getCSSSize(), 2), "px)")); 172 else if (cue->vertical() == verticalGrowingRightKeyword()) { 173 // FIXME: Why use calc to do the math instead of doing the subtraction here? 174 setInlineStyleProperty(CSSPropertyLeft, makeString("calc(-", videoSize.width(), "px - ", cue->getCSSSize(), "px)")); 175 } 174 176 175 177 double authorFontSize = std::min(videoSize.width(), videoSize.height()) * DEFAULTCAPTIONFONTSIZEPERCENTAGE / 100.0; … … 221 223 // maintaining the relative positions of the boxes in boxes to each 222 224 // other. 223 setInlineStyleProperty(CSSPropertyTransform, 224 makeString("translate(", FormattedNumber::fixedWidth(-position.first, 2), "%, ", FormattedNumber::fixedWidth(-position.second, 2), "%)")); 225 setInlineStyleProperty(CSSPropertyTransform, makeString("translate(", -position.first, "%, ", -position.second, "%)")); 225 226 226 227 setInlineStyleProperty(CSSPropertyWhiteSpace, CSSValuePre); -
trunk/Source/WebCore/inspector/InspectorOverlay.cpp
r253916 r254514 792 792 GraphicsContextStateSaver verticalLabelStateSaver(context); 793 793 context.translate(zoom(x) + 0.5f, scrollY); 794 context.drawText(font, TextRun(String::number ToStringFixedPrecision(x)), { 2, drawTopEdge ? rulerLabelSize : rulerLabelSize - rulerSize + font.fontMetrics().height() - 1.0f });794 context.drawText(font, TextRun(String::number(x)), { 2, drawTopEdge ? rulerLabelSize : rulerLabelSize - rulerSize + font.fontMetrics().height() - 1.0f }); 795 795 } 796 796 } … … 830 830 context.translate(scrollX, zoom(y) + 0.5f); 831 831 context.rotate(drawLeftEdge ? -piOverTwoFloat : piOverTwoFloat); 832 context.drawText(font, TextRun(String::number ToStringFixedPrecision(y)), { 2, drawLeftEdge ? rulerLabelSize : rulerLabelSize - rulerSize });832 context.drawText(font, TextRun(String::number(y)), { 2, drawLeftEdge ? rulerLabelSize : rulerLabelSize - rulerSize }); 833 833 } 834 834 } … … 845 845 846 846 auto viewportRect = pageView->visualViewportRect(); 847 auto viewportWidthText = String::numberToStringFixedPrecision(viewportRect.width() / pageZoomFactor); 848 auto viewportHeightText = String::numberToStringFixedPrecision(viewportRect.height() / pageZoomFactor); 849 TextRun viewportTextRun(makeString(viewportWidthText, "px", ' ', multiplicationSign, ' ', viewportHeightText, "px")); 847 TextRun viewportTextRun(makeString(viewportRect.width() / pageZoomFactor, "px", ' ', multiplicationSign, ' ', viewportRect.height() / pageZoomFactor, "px")); 850 848 851 849 const float margin = 4; -
trunk/Source/WebCore/page/CaptionUserPreferencesMediaAF.cpp
r253574 r254514 352 352 353 353 StringBuilder builder; 354 appendCSS(builder, CSSPropertyBorderRadius, makeString( FormattedNumber::fixedWidth(radius, 2), "px"), behavior == kMACaptionAppearanceBehaviorUseValue);354 appendCSS(builder, CSSPropertyBorderRadius, makeString(radius, "px"), behavior == kMACaptionAppearanceBehaviorUseValue); 355 355 return builder.toString(); 356 356 } -
trunk/Source/WebCore/page/scrolling/AxisScrollSnapOffsets.cpp
r253975 r254514 79 79 StringBuilder builder; 80 80 builder.appendLiteral("[ "); 81 for (auto& offset : snapOffsets) { 82 builder.append(FormattedNumber::fixedWidth(offset.toFloat(), 1)); 83 builder.append(' '); 84 } 81 for (auto& offset : snapOffsets) 82 builder.append(offset.toFloat(), ' '); 85 83 builder.append(']'); 86 84 return builder.toString(); … … 91 89 StringBuilder builder; 92 90 builder.appendLiteral("[ "); 93 for (auto& range : ranges) { 94 builder.append('('); 95 builder.append(FormattedNumber::fixedWidth(range.start.toFloat(), 1)); 96 builder.appendLiteral(", "); 97 builder.append(FormattedNumber::fixedWidth(range.end.toFloat(), 1)); 98 builder.appendLiteral(") "); 99 } 91 for (auto& range : ranges) 92 builder.append('(', range.start.toFloat(), ", ", range.end.toFloat(), ") "); 100 93 builder.append(']'); 101 94 return builder.toString(); … … 104 97 static String snapPortOrAreaToString(const LayoutRect& rect) 105 98 { 106 return makeString("{{", 107 FormattedNumber::fixedWidth(rect.x(), 1), ", ", 108 FormattedNumber::fixedWidth(rect.y(), 1), "} {", 109 FormattedNumber::fixedWidth(rect.width(), 1), ", ", 110 FormattedNumber::fixedWidth(rect.height(), 1), "}}"); 99 return makeString("{{", rect.x().toFloat(), ", ", rect.y().toFloat(), "} {", rect.width().toFloat(), ", ", rect.height().toFloat(), "}}"); 111 100 } 112 101 -
trunk/Source/WebCore/platform/graphics/Color.cpp
r254046 r254514 321 321 } 322 322 323 static char decimalDigit(unsigned number) 324 { 325 ASSERT(number < 10); 326 return '0' + number; 327 } 328 329 static std::array<char, 4> serializedFractionDigitsForFractionalAlphaValue(uint8_t alpha) 330 { 331 ASSERT(alpha > 0); 332 ASSERT(alpha < 0xFF); 333 if (((alpha * 100 + 0x7F) / 0xFF * 0xFF + 50) / 100 != alpha) 334 return { { decimalDigit(alpha * 10 / 0xFF % 10), decimalDigit(alpha * 100 / 0xFF % 10), decimalDigit((alpha * 1000 + 0x7F) / 0xFF % 10), '\0' } }; 335 if (int thirdDigit = (alpha * 100 + 0x7F) / 0xFF % 10) 336 return { { decimalDigit(alpha * 10 / 0xFF), decimalDigit(thirdDigit), '\0', '\0' } }; 337 return { { decimalDigit((alpha * 10 + 0x7F) / 0xFF), '\0', '\0', '\0' } }; 338 } 339 323 340 String Color::cssText() const 324 341 { 325 342 if (isExtended()) 326 343 return asExtended().cssText(); 327 328 StringBuilder builder; 329 builder.reserveCapacity(28); 330 bool colorHasAlpha = !isOpaque(); 331 if (colorHasAlpha) 332 builder.appendLiteral("rgba("); 333 else 334 builder.appendLiteral("rgb("); 335 336 builder.appendNumber(static_cast<unsigned char>(red())); 337 builder.appendLiteral(", "); 338 339 builder.appendNumber(static_cast<unsigned char>(green())); 340 builder.appendLiteral(", "); 341 342 builder.appendNumber(static_cast<unsigned char>(blue())); 343 if (colorHasAlpha) { 344 // https://drafts.csswg.org/cssom/#serializing-css-values 345 builder.appendLiteral(", "); 346 int alpha = this->alpha(); 347 float rounded = round(alpha * 100 / 255.0f) / 100; 348 if (round(rounded * 255) != alpha) 349 rounded = round(alpha * 1000 / 255.0f) / 1000; 350 builder.append(FormattedNumber::fixedPrecision(rounded)); 351 } 352 353 builder.append(')'); 354 return builder.toString(); 344 uint8_t alpha = this->alpha(); 345 switch (alpha) { 346 case 0: 347 return makeString("rgba(", red(), ", ", green(), ", ", blue(), ", 0)"); 348 case 0xFF: 349 return makeString("rgb(", red(), ", ", green(), ", ", blue(), ')'); 350 default: 351 return makeString("rgba(", red(), ", ", green(), ", ", blue(), ", 0.", serializedFractionDigitsForFractionalAlphaValue(alpha).data(), ')'); 352 } 355 353 } 356 354 -
trunk/Source/WebCore/platform/graphics/ExtendedColor.cpp
r253975 r254514 27 27 #include "ExtendedColor.h" 28 28 29 #include "ColorSpace.h"30 29 #include <wtf/MathExtras.h> 31 #include <wtf/dtoa.h>32 #include <wtf/text/StringBuilder.h>33 30 34 31 namespace WebCore { … … 41 38 String ExtendedColor::cssText() const 42 39 { 43 StringBuilder builder; 44 builder.reserveCapacity(40); 45 builder.appendLiteral("color("); 46 40 const char* colorSpace; 47 41 switch (m_colorSpace) { 48 42 case ColorSpace::SRGB: 49 builder.appendLiteral("srgb ");43 colorSpace = "srgb"; 50 44 break; 51 45 case ColorSpace::DisplayP3: 52 builder.appendLiteral("display-p3 ");46 colorSpace = "display-p3"; 53 47 break; 54 48 default: … … 57 51 } 58 52 59 builder.append(FormattedNumber::fixedPrecision(red())); 60 builder.append(' '); 61 62 builder.append(FormattedNumber::fixedPrecision(green())); 63 builder.append(' '); 64 65 builder.append(FormattedNumber::fixedPrecision(blue())); 66 if (!WTF::areEssentiallyEqual(alpha(), 1.0f)) { 67 builder.appendLiteral(" / "); 68 builder.append(FormattedNumber::fixedPrecision(alpha())); 69 } 70 builder.append(')'); 71 72 return builder.toString(); 53 if (WTF::areEssentiallyEqual(alpha(), 1.0f)) 54 return makeString("color(", colorSpace, ' ', red(), ' ', green(), ' ', blue(), ')'); 55 return makeString("color(", colorSpace, ' ', red(), ' ', green(), ' ', blue(), " / ", alpha(), ')'); 73 56 } 74 57 -
trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp
r254087 r254514 1392 1392 1393 1393 StringBuilder logString; 1394 logString.append(pad(' ', 12 + depth * 2, hex(reinterpret_cast<uintptr_t>(&layer), Lowercase)), " id ", backing->graphicsLayer()->primaryLayerID(), " (", FormattedNumber::fixedWidth(absoluteBounds.x().toFloat(), 3), ',', FormattedNumber::fixedWidth(absoluteBounds.y().toFloat(), 3), '-', FormattedNumber::fixedWidth(absoluteBounds.maxX().toFloat(), 3), ',', FormattedNumber::fixedWidth(absoluteBounds.maxY().toFloat(), 3), ") ", FormattedNumber::fixedWidth(backing->backingStoreMemoryEstimate() / 1024, 2), "KB");1394 logString.append(pad(' ', 12 + depth * 2, hex(reinterpret_cast<uintptr_t>(&layer), Lowercase)), " id ", backing->graphicsLayer()->primaryLayerID(), " (", absoluteBounds.x().toFloat(), ',', absoluteBounds.y().toFloat(), '-', absoluteBounds.maxX().toFloat(), ',', absoluteBounds.maxY().toFloat(), ") ", FormattedNumber::fixedWidth(backing->backingStoreMemoryEstimate() / 1024, 2), "KB"); 1395 1395 1396 1396 if (!layer.renderer().style().hasAutoUsedZIndex()) -
trunk/Source/WebCore/svg/SVGAngleValue.cpp
r242713 r254514 67 67 switch (m_unitType) { 68 68 case SVG_ANGLETYPE_DEG: 69 return makeString( FormattedNumber::fixedPrecision(m_valueInSpecifiedUnits), "deg");70 case SVG_ANGLETYPE_RAD: 71 return makeString( FormattedNumber::fixedPrecision(m_valueInSpecifiedUnits), "rad");72 case SVG_ANGLETYPE_GRAD: 73 return makeString( FormattedNumber::fixedPrecision(m_valueInSpecifiedUnits), "grad");74 case SVG_ANGLETYPE_UNSPECIFIED: 75 case SVG_ANGLETYPE_UNKNOWN: 76 return String::number ToStringFixedPrecision(m_valueInSpecifiedUnits);69 return makeString(m_valueInSpecifiedUnits, "deg"); 70 case SVG_ANGLETYPE_RAD: 71 return makeString(m_valueInSpecifiedUnits, "rad"); 72 case SVG_ANGLETYPE_GRAD: 73 return makeString(m_valueInSpecifiedUnits, "grad"); 74 case SVG_ANGLETYPE_UNSPECIFIED: 75 case SVG_ANGLETYPE_UNKNOWN: 76 return String::number(m_valueInSpecifiedUnits); 77 77 } 78 78 -
trunk/Source/WebCore/svg/SVGLengthList.h
r249822 r254514 28 28 #include "SVGLength.h" 29 29 #include "SVGValuePropertyList.h" 30 #include <wtf/text/StringBuilder.h> 30 31 31 32 namespace WebCore { -
trunk/Source/WebCore/svg/SVGLengthValue.cpp
r253079 r254514 258 258 String SVGLengthValue::valueAsString() const 259 259 { 260 return makeString( FormattedNumber::fixedPrecision(m_valueInSpecifiedUnits), lengthTypeToString(m_lengthType));260 return makeString(m_valueInSpecifiedUnits, lengthTypeToString(m_lengthType)); 261 261 } 262 262 -
trunk/Source/WebCore/svg/SVGNumberList.h
r253975 r254514 79 79 builder.append(' '); 80 80 81 builder.append( FormattedNumber::fixedPrecision(number->value()));81 builder.append(number->value()); 82 82 } 83 83 -
trunk/Source/WebCore/svg/SVGPathStringBuilder.cpp
r253975 r254514 52 52 static void appendFlag(StringBuilder& stringBuilder, bool flag) 53 53 { 54 stringBuilder.append(flag ? '1' : '0'); 55 stringBuilder.append(' '); 54 stringBuilder.append(flag ? '1' : '0', ' '); 56 55 } 57 56 58 57 static void appendNumber(StringBuilder& stringBuilder, float number) 59 58 { 60 stringBuilder.append(FormattedNumber::fixedPrecision(number));61 stringBuilder.append( ' ');59 // FIXME: Shortest form would be better, but fixed precision is required for now to smooth over precision errors caused by converting float to double and back in CGPath on Cocoa platforms. 60 stringBuilder.append(FormattedNumber::fixedPrecision(number), ' '); 62 61 } 63 62 64 63 static void appendPoint(StringBuilder& stringBuilder, const FloatPoint& point) 65 64 { 66 stringBuilder.append(FormattedNumber::fixedPrecision(point.x())); 67 stringBuilder.append(' '); 68 stringBuilder.append(FormattedNumber::fixedPrecision(point.y())); 69 stringBuilder.append(' '); 65 appendNumber(stringBuilder, point.x()); 66 appendNumber(stringBuilder, point.y()); 70 67 } 71 68 -
trunk/Source/WebCore/svg/SVGPointList.h
r253975 r254514 94 94 builder.append(' '); 95 95 96 builder.append(FormattedNumber::fixedPrecision(point->x())); 97 builder.append(' '); 98 builder.append(FormattedNumber::fixedPrecision(point->y())); 96 builder.append(point->x(), ' ', point->y()); 99 97 } 100 98 -
trunk/Source/WebCore/svg/SVGTransformValue.h
r253975 r254514 2 2 * Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> 3 3 * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org> 4 * Copyright (C) 2019 Apple Inc. 4 * Copyright (C) 2019 Apple Inc. All rights reserved. 5 5 * 6 6 * This library is free software; you can redistribute it and/or … … 207 207 } 208 208 209 static StringprefixForTransfromType(SVGTransformType type)209 static const char* prefixForTransfromType(SVGTransformType type) 210 210 { 211 211 switch (type) { 212 212 case SVG_TRANSFORM_UNKNOWN: 213 return emptyString();213 return ""; 214 214 case SVG_TRANSFORM_MATRIX: 215 return "matrix(" _s;215 return "matrix("; 216 216 case SVG_TRANSFORM_TRANSLATE: 217 return "translate(" _s;217 return "translate("; 218 218 case SVG_TRANSFORM_SCALE: 219 return "scale(" _s;219 return "scale("; 220 220 case SVG_TRANSFORM_ROTATE: 221 return "rotate(" _s;221 return "rotate("; 222 222 case SVG_TRANSFORM_SKEWX: 223 return "skewX(" _s;223 return "skewX("; 224 224 case SVG_TRANSFORM_SKEWY: 225 return "skewY(" _s;225 return "skewY("; 226 226 } 227 227 ASSERT_NOT_REACHED(); 228 return emptyString();228 return ""; 229 229 } 230 230 … … 240 240 if (builder.length() && builder[builder.length() - 1] != '(') 241 241 builder.append(' '); 242 // FIXME: Shortest form would be better, but fixed precision is required for now to smooth over precision errors caused by converting float to double and back since we use AffineTransform to store transforms. 242 243 builder.append(FormattedNumber::fixedPrecision(number)); 243 244 appendFixedPrecisionNumbers(builder, numbers...); -
trunk/Source/WebCore/svg/properties/SVGPropertyTraits.h
r253975 r254514 28 28 #include "QualifiedName.h" 29 29 #include "SVGParserUtilities.h" 30 #include <wtf/text/StringBuilder.h>31 #include <wtf/text/WTFString.h>32 30 33 31 namespace WebCore { … … 104 102 return number; 105 103 } 106 static String toString(float type) { return String::number ToStringFixedPrecision(type); }104 static String toString(float type) { return String::number(type); } 107 105 }; 108 106 … … 140 138 static String toString(const FloatPoint& type) 141 139 { 142 StringBuilder builder; 143 builder.append(FormattedNumber::fixedPrecision(type.x())); 144 builder.append(' '); 145 builder.append(FormattedNumber::fixedPrecision(type.y())); 146 return builder.toString(); 140 return makeString(type.x(), ' ', type.y()); 147 141 } 148 142 }; … … 167 161 static String toString(const FloatRect& type) 168 162 { 169 StringBuilder builder; 170 builder.append(FormattedNumber::fixedPrecision(type.x())); 171 builder.append(' '); 172 builder.append(FormattedNumber::fixedPrecision(type.y())); 173 builder.append(' '); 174 builder.append(FormattedNumber::fixedPrecision(type.width())); 175 builder.append(' '); 176 builder.append(FormattedNumber::fixedPrecision(type.height())); 177 return builder.toString(); 163 return makeString(type.x(), ' ', type.y(), ' ', type.width(), ' ', type.height()); 178 164 } 179 165 }; -
trunk/Source/WebCore/testing/Internals.cpp
r254373 r254514 1692 1692 auto rects = contextDocument()->markers().renderedRectsForMarkers(markerType); 1693 1693 1694 // FIXME: Using fixed precision here for width because of test results that contain numbers with specific precision. Would be nice to update the test results and move to default formatting. 1694 1695 StringBuilder rectString; 1695 1696 rectString.appendLiteral("marker rects: "); 1696 for (const auto& rect : rects) { 1697 rectString.append('('); 1698 rectString.append(FormattedNumber::fixedPrecision(rect.x())); 1699 rectString.appendLiteral(", "); 1700 rectString.append(FormattedNumber::fixedPrecision(rect.y())); 1701 rectString.appendLiteral(", "); 1702 rectString.append(FormattedNumber::fixedPrecision(rect.width())); 1703 rectString.appendLiteral(", "); 1704 rectString.append(FormattedNumber::fixedPrecision(rect.height())); 1705 rectString.appendLiteral(") "); 1706 } 1697 for (const auto& rect : rects) 1698 rectString.append('(', rect.x(), ", ", rect.y(), ", ", FormattedNumber::fixedPrecision(rect.width()), ", ", rect.height(), ") "); 1707 1699 return rectString.toString(); 1708 1700 } … … 1885 1877 restrictScaleFactorToInitialScaleIfNotUserScalable(attributes); 1886 1878 1879 // FIXME: Using fixed precision here because of test results that contain numbers with specific precision. Would be nice to update the test results and move to default formatting. 1887 1880 return makeString("viewport size ", FormattedNumber::fixedPrecision(attributes.layoutSize.width()), 'x', FormattedNumber::fixedPrecision(attributes.layoutSize.height()), " scale ", FormattedNumber::fixedPrecision(attributes.initialScale), " with limits [", FormattedNumber::fixedPrecision(attributes.minimumScale), ", ", FormattedNumber::fixedPrecision(attributes.maximumScale), "] and userScalable ", (attributes.userScalable ? "true" : "false")); 1888 1881 } … … 3447 3440 3448 3441 StringBuilder result; 3449 result.appendLiteral("type="); 3450 result.append(cursorTypeToString(cursor.type())); 3451 result.appendLiteral(" hotSpot="); 3452 result.appendNumber(cursor.hotSpot().x()); 3453 result.append(','); 3454 result.appendNumber(cursor.hotSpot().y()); 3442 result.append("type=", cursorTypeToString(cursor.type()), " hotSpot=", cursor.hotSpot().x(), ',', cursor.hotSpot().y()); 3455 3443 if (cursor.image()) { 3456 3444 FloatSize size = cursor.image()->size(); 3457 result.appendLiteral(" image="); 3458 result.append(FormattedNumber::fixedPrecision(size.width())); 3459 result.append('x'); 3460 result.append(FormattedNumber::fixedPrecision(size.height())); 3445 result.append(" image=", size.width(), 'x', size.height()); 3461 3446 } 3462 3447 #if ENABLE(MOUSE_CURSOR_SCALE) 3463 if (cursor.imageScaleFactor() != 1) { 3464 result.appendLiteral(" scale="); 3465 result.append(FormattedNumber::fixedPrecision(cursor.imageScaleFactor(), 8)); 3466 } 3448 if (cursor.imageScaleFactor() != 1) 3449 result.append(" scale=", cursor.imageScaleFactor()); 3467 3450 #endif 3468 3451 return result.toString(); -
trunk/Source/WebCore/xml/XPathValue.cpp
r242713 r254514 127 127 if (std::isinf(m_number)) 128 128 return std::signbit(m_number) ? "-Infinity"_s : "Infinity"_s; 129 return String::number ToStringFixedPrecision(m_number);129 return String::number(m_number); 130 130 case BooleanValue: 131 131 return m_bool ? "true"_s : "false"_s; -
trunk/Source/WebKit/ChangeLog
r254511 r254514 1 2020-01-13 Darin Adler <darin@apple.com> 2 3 Use even more "shortest form" formatting, and less "fixed precision" and "fixed width" 4 https://bugs.webkit.org/show_bug.cgi?id=198918 5 6 Reviewed by Sam Weinig. 7 8 * NetworkProcess/cache/NetworkCache.cpp: 9 (WebKit::NetworkCache::Cache::dumpContentsToFile): Use shortest instead of fixed. 10 Also use makeString instead of StringBuilder. 11 12 * NetworkProcess/cache/NetworkCacheEntry.cpp: 13 (WebKit::NetworkCache::Entry::asJSON const): Use shortest instead of fixed. 14 Also use multiple-argument append on StringBuilder to make the function shorter 15 and easier to read. 16 * Shared/Gamepad/GamepadData.cpp: 17 (WebKit::GamepadData::loggingString const): Ditto. 18 19 * UIProcess/ViewGestureController.cpp: 20 (WebKit::ViewGestureController::SnapshotRemovalTracker::startWatchdog): 21 Use shortest instead of fixed. 22 1 23 2020-01-14 Víctor Manuel Jáquez Leal <vjaquez@igalia.com> 2 24 -
trunk/Source/WebKit/NetworkProcess/cache/NetworkCache.cpp
r254055 r254514 576 576 m_storage->traverse(resourceType(), flags, [fd, totals, capacity](const Storage::Record* record, const Storage::RecordInfo& info) mutable { 577 577 if (!record) { 578 StringBuilder epilogue; 579 epilogue.appendLiteral("{}\n],\n"); 580 epilogue.appendLiteral("\"totals\": {\n"); 581 epilogue.appendLiteral("\"capacity\": "); 582 epilogue.appendNumber(capacity); 583 epilogue.appendLiteral(",\n"); 584 epilogue.appendLiteral("\"count\": "); 585 epilogue.appendNumber(totals.count); 586 epilogue.appendLiteral(",\n"); 587 epilogue.appendLiteral("\"bodySize\": "); 588 epilogue.appendNumber(totals.bodySize); 589 epilogue.appendLiteral(",\n"); 590 epilogue.appendLiteral("\"averageWorth\": "); 591 epilogue.append(FormattedNumber::fixedPrecision(totals.count ? totals.worth / totals.count : 0)); 592 epilogue.appendLiteral("\n"); 593 epilogue.appendLiteral("}\n}\n"); 594 auto writeData = epilogue.toString().utf8(); 578 CString writeData = makeString( 579 "{}\n" 580 "],\n" 581 "\"totals\": {\n" 582 "\"capacity\": ", capacity, ",\n" 583 "\"count\": ", totals.count, ",\n" 584 "\"bodySize\": ", totals.bodySize, ",\n" 585 "\"averageWorth\": ", totals.count ? totals.worth / totals.count : 0, "\n" 586 "}\n}\n" 587 ).utf8(); 595 588 writeToFile(fd, writeData.data(), writeData.length()); 596 589 closeFile(fd); -
trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheEntry.cpp
r253975 r254514 212 212 void Entry::asJSON(StringBuilder& json, const Storage::RecordInfo& info) const 213 213 { 214 json.appendLiteral("{\n" );215 json.appendLiteral("\"hash\": ");214 json.appendLiteral("{\n" 215 "\"hash\": "); 216 216 json.appendQuotedJSONString(m_key.hashAsString()); 217 json.appendLiteral(",\n"); 218 json.appendLiteral("\"bodySize\": "); 219 json.appendNumber(info.bodySize); 220 json.appendLiteral(",\n"); 221 json.appendLiteral("\"worth\": "); 222 json.append(FormattedNumber::fixedPrecision(info.worth)); 223 json.appendLiteral(",\n"); 224 json.appendLiteral("\"partition\": "); 217 json.append(",\n" 218 "\"bodySize\": ", info.bodySize, ",\n" 219 "\"worth\": ", info.worth, ",\n" 220 "\"partition\": "); 225 221 json.appendQuotedJSONString(m_key.partition()); 226 json.appendLiteral(",\n"); 227 json.appendLiteral("\"timestamp\": "); 228 json.append(FormattedNumber::fixedPrecision(m_timeStamp.secondsSinceEpoch().milliseconds())); 229 json.appendLiteral(",\n"); 230 json.appendLiteral("\"URL\": "); 222 json.append(",\n" 223 "\"timestamp\": ", m_timeStamp.secondsSinceEpoch().milliseconds(), ",\n" 224 "\"URL\": "); 231 225 json.appendQuotedJSONString(m_response.url().string()); 232 json.appendLiteral(",\n" );233 json.appendLiteral("\"bodyHash\": ");226 json.appendLiteral(",\n" 227 "\"bodyHash\": "); 234 228 json.appendQuotedJSONString(info.bodyHash); 235 json.appendLiteral(",\n"); 236 json.appendLiteral("\"bodyShareCount\": "); 237 json.appendNumber(info.bodyShareCount); 238 json.appendLiteral(",\n"); 239 json.appendLiteral("\"headers\": {\n"); 229 json.append(",\n" 230 "\"bodyShareCount\": ", info.bodyShareCount, ",\n" 231 "\"headers\": {\n"); 240 232 bool firstHeader = true; 241 233 for (auto& header : m_response.httpHeaderFields()) { … … 248 240 json.appendQuotedJSONString(header.value); 249 241 } 250 json.appendLiteral("\n}\n"); 251 json.appendLiteral("}"); 252 } 253 254 } 255 } 242 json.appendLiteral("\n" 243 "}\n" 244 "}"); 245 } 246 247 } 248 } -
trunk/Source/WebKit/Shared/Gamepad/GamepadData.cpp
r253975 r254514 88 88 89 89 #if !LOG_DISABLED 90 90 91 String GamepadData::loggingString() const 91 92 { 92 93 StringBuilder builder; 93 94 94 builder.appendNumber(m_axisValues.size()); 95 builder.appendLiteral(" axes, "); 96 builder.appendNumber(m_buttonValues.size()); 97 builder.appendLiteral(" buttons\n"); 95 builder.append(m_axisValues.size(), " axes, ", m_buttonValues.size(), " buttons\n"); 98 96 99 for (size_t i = 0; i < m_axisValues.size(); ++i) { 100 builder.appendLiteral(" Axis "); 101 builder.appendNumber(i); 102 builder.appendLiteral(": "); 103 builder.append(FormattedNumber::fixedPrecision(m_axisValues[i])); 104 } 97 for (size_t i = 0; i < m_axisValues.size(); ++i) 98 builder.append(" Axis ", i, ": ", m_axisValues[i]); 105 99 106 100 builder.append('\n'); 107 for (size_t i = 0; i < m_buttonValues.size(); ++i) { 108 builder.appendLiteral(" Button "); 109 builder.appendNumber(i); 110 builder.appendLiteral(": "); 111 builder.append(FormattedNumber::fixedPrecision(m_buttonValues[i])); 112 } 101 102 for (size_t i = 0; i < m_buttonValues.size(); ++i) 103 builder.append(" Button ", i, ": ", FormattedNumber::fixedPrecision(m_buttonValues[i])); 113 104 114 105 return builder.toString(); 115 106 } 107 116 108 #endif 117 109 -
trunk/Source/WebKit/UIProcess/ViewGestureController.cpp
r253514 r254514 388 388 void ViewGestureController::SnapshotRemovalTracker::startWatchdog(Seconds duration) 389 389 { 390 log(makeString("(re)started watchdog timer for ", FormattedNumber::fixedWidth(duration.seconds(), 1), " seconds"));390 log(makeString("(re)started watchdog timer for ", duration.seconds(), " seconds")); 391 391 m_watchdogTimer.startOneShot(duration); 392 392 }
Note: See TracChangeset
for help on using the changeset viewer.