Changeset 129165 in webkit
- Timestamp:
- Sep 20, 2012 2:03:56 PM (12 years ago)
- Location:
- trunk/Source
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WTF/ChangeLog
r129089 r129165 1 2012-09-20 Patrick Gansterer <paroga@webkit.org> 2 3 Add String::numberToStringFixedWidth() 4 https://bugs.webkit.org/show_bug.cgi?id=96330 5 6 Reviewed by Benjamin Poulain. 7 8 Add this new function as replacement for the ShouldRoundDecimalPlaces flag of String::number() 9 and remove the now unnecessary branch in String::number() for the old flags. 10 11 * wtf/text/WTFString.cpp: 12 (WTF::String::number): 13 (WTF::String::numberToStringFixedWidth): 14 * wtf/text/WTFString.h: 15 1 16 2012-09-19 Geoffrey Garen <ggaren@apple.com> 2 17 -
trunk/Source/WTF/wtf/text/WTFString.cpp
r128908 r129165 451 451 } 452 452 453 String String::number(double number, unsigned flags, unsigned precision)453 String String::number(double number, unsigned precision, TrailingZerosTruncatingPolicy trailingZerosTruncatingPolicy) 454 454 { 455 455 NumberToStringBuffer buffer; 456 457 // Mimic String::format("%.[precision]g", ...), but use dtoas rounding facilities. 458 if (flags & ShouldRoundSignificantFigures) 459 return String(numberToFixedPrecisionString(number, precision, buffer, flags & ShouldTruncateTrailingZeros)); 460 461 // Mimic String::format("%.[precision]f", ...), but use dtoas rounding facilities. 462 return String(numberToFixedWidthString(number, precision, buffer)); 456 return String(numberToFixedPrecisionString(number, precision, buffer, trailingZerosTruncatingPolicy == TruncateTrailingZeros)); 463 457 } 464 458 … … 467 461 NumberToStringBuffer buffer; 468 462 return String(numberToString(number, buffer)); 463 } 464 465 String String::numberToStringFixedWidth(double number, unsigned decimalPlaces) 466 { 467 NumberToStringBuffer buffer; 468 return String(numberToFixedWidthString(number, decimalPlaces, buffer)); 469 469 } 470 470 -
trunk/Source/WTF/wtf/text/WTFString.h
r128609 r129165 98 98 class ASCIILiteral; 99 99 100 enum FloatConversionFlags { 101 ShouldRoundSignificantFigures = 1 << 0, 102 ShouldRoundDecimalPlaces = 1 << 1, 103 ShouldTruncateTrailingZeros = 1 << 2 100 enum TrailingZerosTruncatingPolicy { 101 KeepTrailingZeros, 102 TruncateTrailingZeros 104 103 }; 105 104 … … 234 233 WTF_EXPORT_STRING_API static String number(unsigned long long); 235 234 236 WTF_EXPORT_STRING_API static String number(double, unsigned = ShouldRoundSignificantFigures | ShouldTruncateTrailingZeros, unsigned precision = 6);235 WTF_EXPORT_STRING_API static String number(double, unsigned precision = 6, TrailingZerosTruncatingPolicy = TruncateTrailingZeros); 237 236 238 237 // Number to String conversion following the ECMAScript definition. 239 238 WTF_EXPORT_STRING_API static String numberToStringECMAScript(double); 239 WTF_EXPORT_STRING_API static String numberToStringFixedWidth(double, unsigned decimalPlaces); 240 240 241 241 // Find a single character or string, also with match function & latin1 forms. … … 661 661 662 662 using WTF::CString; 663 using WTF::KeepTrailingZeros; 663 664 using WTF::String; 664 665 using WTF::emptyString; … … 684 685 using WTF::isSpaceOrNewline; 685 686 using WTF::reverseFind; 686 using WTF::ShouldRoundDecimalPlaces;687 687 using WTF::ASCIILiteral; 688 688 -
trunk/Source/WebCore/ChangeLog
r129164 r129165 1 2012-09-20 Patrick Gansterer <paroga@webkit.org> 2 3 Add String::numberToFixedPrecisionString() 4 https://bugs.webkit.org/show_bug.cgi?id=96330 5 6 Reviewed by Benjamin Poulain. 7 8 * platform/text/TextStream.cpp: 9 (WebCore::TextStream::operator<<): Use the new function instead of String::number() with flags. 10 1 11 2012-09-20 Adam Klein <adamk@chromium.org> 2 12 -
trunk/Source/WebCore/platform/text/TextStream.cpp
r128564 r129165 88 88 TextStream& TextStream::operator<<(float f) 89 89 { 90 m_text.append(String::number (f, ShouldRoundDecimalPlaces, 2));90 m_text.append(String::numberToStringFixedWidth(f, 2)); 91 91 return *this; 92 92 } … … 94 94 TextStream& TextStream::operator<<(double d) 95 95 { 96 m_text.append(String::number (d, ShouldRoundDecimalPlaces, 2));96 m_text.append(String::numberToStringFixedWidth(d, 2)); 97 97 return *this; 98 98 } -
trunk/Source/WebKit2/ChangeLog
r129140 r129165 1 2012-09-20 Patrick Gansterer <paroga@webkit.org> 2 3 Add String::numberToStringFixedWidth() 4 https://bugs.webkit.org/show_bug.cgi?id=96330 5 6 Reviewed by Benjamin Poulain. 7 8 * win/WebKit2.def: 9 * win/WebKit2CFLite.def: 10 1 11 2012-09-17 Jon Lee <jonlee@apple.com> 2 12 -
trunk/Source/WebKit2/win/WebKit2.def
r128963 r129165 200 200 ?number@String@WTF@@SA?AV12@H@Z 201 201 ?number@String@WTF@@SA?AV12@I@Z 202 ?number@String@WTF@@SA?AV12@NI I@Z202 ?number@String@WTF@@SA?AV12@NIW4TrailingZerosTruncatingPolicy@2@@Z 203 203 ?overrideUserPreferredLanguages@WebCore@@YAXABV?$Vector@VString@WTF@@$0A@@WTF@@@Z 204 204 ?numberOfScopedHTMLStyleChildren@Node@WebCore@@QBEIXZ -
trunk/Source/WebKit2/win/WebKit2CFLite.def
r128963 r129165 193 193 ?number@String@WTF@@SA?AV12@H@Z 194 194 ?number@String@WTF@@SA?AV12@I@Z 195 ?number@String@WTF@@SA?AV12@NI I@Z195 ?number@String@WTF@@SA?AV12@NIW4TrailingZerosTruncatingPolicy@2@@Z 196 196 ?overrideUserPreferredLanguages@WebCore@@YAXABV?$Vector@VString@WTF@@$0A@@WTF@@@Z 197 197 ?numberOfScopedHTMLStyleChildren@Node@WebCore@@QBEIXZ
Note: See TracChangeset
for help on using the changeset viewer.