Ignore:
Timestamp:
Jan 14, 2020, 9:16:03 AM (5 years ago)
Author:
Darin Adler
Message:

Use even more "shortest form" formatting, and less "fixed precision" and "fixed width"
https://bugs.webkit.org/show_bug.cgi?id=198918

Reviewed by Sam Weinig.

Source/JavaScriptCore:

  • API/tests/ExecutionTimeLimitTest.cpp:

(testExecutionTimeLimit): Rewrote the string creation code to use makeString instead
of StringBuilder and no longer use any fixed precision.

  • runtime/Options.cpp:

(JSC::OptionReader::Option::dump const): Dump doubles with shortest form instead of
fixed precision.

Source/WebCore:

The places left untouched are the ones where changing behavior has some kind of unwanted
observable effect for one of two reasons. Otherwise, switched almost all call sites.

1) Substantial number of test results that depend on the current behavior.

2) Poor rounding resulting in conversion from float to double and back (or similar) that

results in values with tiny fractional residue like "6.000001".

  • accessibility/AccessibilityNodeObject.cpp:

(WebCore::AccessibilityNodeObject::changeValueByStep): Use shortest instead of fixed.
(WebCore::AccessibilityNodeObject::changeValueByPercent): Ditto.

  • css/CSSAspectRatioValue.cpp:

(WebCore::CSSAspectRatioValue::customCSSText const): Ditto.

  • css/CSSFontVariationValue.cpp:

(WebCore::CSSFontVariationValue::customCSSText const): Ditto. Also use makeString instead of
StringBuilder for better efficiency.

  • css/CSSGradientValue.cpp:

(WebCore::appendGradientStops): Ditto.

  • css/CSSKeyframeRule.cpp:

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

  • css/CSSTimingFunctionValue.cpp:

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

  • css/MediaQueryEvaluator.cpp:

(WebCore::aspectRatioValueAsString): Ditto.

  • css/TransformFunctions.h: Removed unnneeded forward declarations.
  • css/parser/CSSParserToken.cpp:

(WebCore::CSSParserToken::serialize const): Use shortest instead of fixed.

  • html/HTMLImageElement.cpp:

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

  • html/track/VTTCue.cpp:

(WebCore::VTTCueBox::applyCSSProperties): Use shortest instead of fixed.
Also wrote a FIXME abot this strange code that uses "calc()" to do math on two numbers,
math that could instead be done by the code converting the numbers to a style string.

  • inspector/InspectorOverlay.cpp:

(WebCore::InspectorOverlay::drawRulers): Use shortest instead of fixed.

  • page/CaptionUserPreferencesMediaAF.cpp:

(WebCore::CaptionUserPreferencesMediaAF::windowRoundedCornerRadiusCSS const): Ditto.

  • page/scrolling/AxisScrollSnapOffsets.cpp:

(WebCore::snapOffsetsToString): Ditto.
(WebCore::snapOffsetRangesToString): Ditto.
(WebCore::snapPortOrAreaToString): Ditto.

  • platform/graphics/Color.cpp:

(WebCore::decimalDigit): Added.
(WebCore::serializedFractionDigitsForFractionalAlphaValue): Added.
(WebCore::Color::cssText const): Rewrote to generate the same results using
makeString rather than StringBuilder, and integer math rather than converting from
integer to floating point and then doing floating point math.

  • platform/graphics/ExtendedColor.cpp:

(WebCore::ExtendedColor::cssText const): Use shortest instead of fixed.

  • rendering/RenderLayerCompositor.cpp:

(WebCore::RenderLayerCompositor::logLayerInfo): Ditto.

  • svg/SVGAngleValue.cpp:

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

  • svg/SVGLengthList.h: Added now-needed include of StringBuilder.h.
  • svg/SVGLengthValue.cpp:

(WebCore::SVGLengthValue::valueAsString const): Use shortest instead of fixed.

  • svg/SVGNumberList.h: Ditto.
  • svg/SVGPathStringBuilder.cpp:

(WebCore::appendFlag): Use multiple-argument append for better efficiency.
(WebCore::appendNumber): Added a comment about why we can't yet convert this to use
shortest instead of fixed: code that parses floats but then creates a CG path
that stores things as double and does math as double then converts back to float
results in float values that didn't round trip well and have fractions. This is
smoothed away (hidden) by using fixed precision to conver them to strings.
(WebCore::appendPoint): Call appendNumber to cut down on repeated code.

  • svg/SVGPointList.h: Use shortest instead of fixed.
  • svg/SVGTransformValue.h:

(WebCore::SVGTransformValue::prefixForTransfromType): Return a string literal
instead of a WTF::String to avoid creating and destroying an object each time.
(WebCore::SVGTransformValue::appendFixedPrecisionNumbers): Added a comment explaining
why we need to continue to use fixed precision here. Same issue with CGAffineTransform
using double as we have with CGPath above.

  • svg/properties/SVGPropertyTraits.h:

(WebCore::SVGPropertyTraits<float>::toString): Use shortest instead of fixed.
(WebCore::SVGPropertyTraits<FloatPoint>::toString): Ditto.
(WebCore::SVGPropertyTraits<FloatRect>::toString): Ditto.

  • testing/Internals.cpp:

(WebCore::Internals::dumpMarkerRects): Added a comment explaining why we have to use
fixed precision here. There are many test results that we would need to update.
(WebCore::Internals::configurationForViewport): Ditto.
(WebCore::Internals::getCurrentCursorInfo): Use shortest instead of fixed.

  • xml/XPathValue.cpp:

(WebCore::XPath::Value::toString const): Ditto.

Source/WebKit:

  • NetworkProcess/cache/NetworkCache.cpp:

(WebKit::NetworkCache::Cache::dumpContentsToFile): Use shortest instead of fixed.
Also use makeString instead of StringBuilder.

  • NetworkProcess/cache/NetworkCacheEntry.cpp:

(WebKit::NetworkCache::Entry::asJSON const): Use shortest instead of fixed.
Also use multiple-argument append on StringBuilder to make the function shorter
and easier to read.

  • Shared/Gamepad/GamepadData.cpp:

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

  • UIProcess/ViewGestureController.cpp:

(WebKit::ViewGestureController::SnapshotRemovalTracker::startWatchdog):
Use shortest instead of fixed.

Source/WTF:

  • wtf/Logger.h:

(WTF::LogArgument::toString): Log floating point numbers as shortest form instead of fixed precision.

  • wtf/MediaTime.cpp:

(WTF::MediaTime::toString const): Convert time to string as shortest form instead of fixed precision.
Also use multiple-argument append for great simplicity and clarity.

LayoutTests:

  • platform/mac/svg/dom/length-list-parser-expected.png: Removed. Not sure how many other pixel

results we have like this, but this included an ancient style Aqua scrollbar so hasn't matched
anything for years and would clearly not have any value for regression testing.

  • svg/dom/length-list-parser-expected.txt: Updated to expect logging of a 7 digit length as an

integer rather than rounded as "d.ddddd+6".

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/css/CSSGradientValue.cpp

    r254164 r254514  
    701701            builder.append(", to(", stop.m_color->cssText(), ')');
    702702        else
    703             builder.append(", color-stop(", FormattedNumber::fixedPrecision(position), ", ", stop.m_color->cssText(), ')');
     703            builder.append(", color-stop(", position, ", ", stop.m_color->cssText(), ')');
    704704    }
    705705}
Note: See TracChangeset for help on using the changeset viewer.