Diff
Modified: trunk/Source/WTF/ChangeLog (129164 => 129165)
--- trunk/Source/WTF/ChangeLog 2012-09-20 20:47:41 UTC (rev 129164)
+++ trunk/Source/WTF/ChangeLog 2012-09-20 21:03:56 UTC (rev 129165)
@@ -1,3 +1,18 @@
+2012-09-20 Patrick Gansterer <[email protected]>
+
+ Add String::numberToStringFixedWidth()
+ https://bugs.webkit.org/show_bug.cgi?id=96330
+
+ Reviewed by Benjamin Poulain.
+
+ Add this new function as replacement for the ShouldRoundDecimalPlaces flag of String::number()
+ and remove the now unnecessary branch in String::number() for the old flags.
+
+ * wtf/text/WTFString.cpp:
+ (WTF::String::number):
+ (WTF::String::numberToStringFixedWidth):
+ * wtf/text/WTFString.h:
+
2012-09-19 Geoffrey Garen <[email protected]>
OSR exit sometimes neglects to create the arguments object
Modified: trunk/Source/WTF/wtf/text/WTFString.cpp (129164 => 129165)
--- trunk/Source/WTF/wtf/text/WTFString.cpp 2012-09-20 20:47:41 UTC (rev 129164)
+++ trunk/Source/WTF/wtf/text/WTFString.cpp 2012-09-20 21:03:56 UTC (rev 129165)
@@ -450,16 +450,10 @@
return numberToStringUnsigned<String>(number);
}
-String String::number(double number, unsigned flags, unsigned precision)
+String String::number(double number, unsigned precision, TrailingZerosTruncatingPolicy trailingZerosTruncatingPolicy)
{
NumberToStringBuffer buffer;
-
- // Mimic String::format("%.[precision]g", ...), but use dtoas rounding facilities.
- if (flags & ShouldRoundSignificantFigures)
- return String(numberToFixedPrecisionString(number, precision, buffer, flags & ShouldTruncateTrailingZeros));
-
- // Mimic String::format("%.[precision]f", ...), but use dtoas rounding facilities.
- return String(numberToFixedWidthString(number, precision, buffer));
+ return String(numberToFixedPrecisionString(number, precision, buffer, trailingZerosTruncatingPolicy == TruncateTrailingZeros));
}
String String::numberToStringECMAScript(double number)
@@ -468,6 +462,12 @@
return String(numberToString(number, buffer));
}
+String String::numberToStringFixedWidth(double number, unsigned decimalPlaces)
+{
+ NumberToStringBuffer buffer;
+ return String(numberToFixedWidthString(number, decimalPlaces, buffer));
+}
+
int String::toIntStrict(bool* ok, int base) const
{
if (!m_impl) {
Modified: trunk/Source/WTF/wtf/text/WTFString.h (129164 => 129165)
--- trunk/Source/WTF/wtf/text/WTFString.h 2012-09-20 20:47:41 UTC (rev 129164)
+++ trunk/Source/WTF/wtf/text/WTFString.h 2012-09-20 21:03:56 UTC (rev 129165)
@@ -97,10 +97,9 @@
class ASCIILiteral;
-enum FloatConversionFlags {
- ShouldRoundSignificantFigures = 1 << 0,
- ShouldRoundDecimalPlaces = 1 << 1,
- ShouldTruncateTrailingZeros = 1 << 2
+enum TrailingZerosTruncatingPolicy {
+ KeepTrailingZeros,
+ TruncateTrailingZeros
};
template<bool isSpecialCharacter(UChar), typename CharacterType>
@@ -233,10 +232,11 @@
WTF_EXPORT_STRING_API static String number(long long);
WTF_EXPORT_STRING_API static String number(unsigned long long);
- WTF_EXPORT_STRING_API static String number(double, unsigned = ShouldRoundSignificantFigures | ShouldTruncateTrailingZeros, unsigned precision = 6);
+ WTF_EXPORT_STRING_API static String number(double, unsigned precision = 6, TrailingZerosTruncatingPolicy = TruncateTrailingZeros);
// Number to String conversion following the ECMAScript definition.
WTF_EXPORT_STRING_API static String numberToStringECMAScript(double);
+ WTF_EXPORT_STRING_API static String numberToStringFixedWidth(double, unsigned decimalPlaces);
// Find a single character or string, also with match function & latin1 forms.
size_t find(UChar c, unsigned start = 0) const
@@ -660,6 +660,7 @@
}
using WTF::CString;
+using WTF::KeepTrailingZeros;
using WTF::String;
using WTF::emptyString;
using WTF::append;
@@ -683,7 +684,6 @@
using WTF::isAllSpecialCharacters;
using WTF::isSpaceOrNewline;
using WTF::reverseFind;
-using WTF::ShouldRoundDecimalPlaces;
using WTF::ASCIILiteral;
#include <wtf/text/AtomicString.h>
Modified: trunk/Source/WebCore/ChangeLog (129164 => 129165)
--- trunk/Source/WebCore/ChangeLog 2012-09-20 20:47:41 UTC (rev 129164)
+++ trunk/Source/WebCore/ChangeLog 2012-09-20 21:03:56 UTC (rev 129165)
@@ -1,3 +1,13 @@
+2012-09-20 Patrick Gansterer <[email protected]>
+
+ Add String::numberToFixedPrecisionString()
+ https://bugs.webkit.org/show_bug.cgi?id=96330
+
+ Reviewed by Benjamin Poulain.
+
+ * platform/text/TextStream.cpp:
+ (WebCore::TextStream::operator<<): Use the new function instead of String::number() with flags.
+
2012-09-20 Adam Klein <[email protected]>
Rename ContainerNode::parserAddChild "parserAppendChild" for consistency
Modified: trunk/Source/WebCore/platform/text/TextStream.cpp (129164 => 129165)
--- trunk/Source/WebCore/platform/text/TextStream.cpp 2012-09-20 20:47:41 UTC (rev 129164)
+++ trunk/Source/WebCore/platform/text/TextStream.cpp 2012-09-20 21:03:56 UTC (rev 129165)
@@ -87,13 +87,13 @@
TextStream& TextStream::operator<<(float f)
{
- m_text.append(String::number(f, ShouldRoundDecimalPlaces, 2));
+ m_text.append(String::numberToStringFixedWidth(f, 2));
return *this;
}
TextStream& TextStream::operator<<(double d)
{
- m_text.append(String::number(d, ShouldRoundDecimalPlaces, 2));
+ m_text.append(String::numberToStringFixedWidth(d, 2));
return *this;
}
Modified: trunk/Source/WebKit2/ChangeLog (129164 => 129165)
--- trunk/Source/WebKit2/ChangeLog 2012-09-20 20:47:41 UTC (rev 129164)
+++ trunk/Source/WebKit2/ChangeLog 2012-09-20 21:03:56 UTC (rev 129165)
@@ -1,3 +1,13 @@
+2012-09-20 Patrick Gansterer <[email protected]>
+
+ Add String::numberToStringFixedWidth()
+ https://bugs.webkit.org/show_bug.cgi?id=96330
+
+ Reviewed by Benjamin Poulain.
+
+ * win/WebKit2.def:
+ * win/WebKit2CFLite.def:
+
2012-09-17 Jon Lee <[email protected]>
Safari 6 notifications' onclick handlers can't call window.open()
Modified: trunk/Source/WebKit2/win/WebKit2.def (129164 => 129165)
--- trunk/Source/WebKit2/win/WebKit2.def 2012-09-20 20:47:41 UTC (rev 129164)
+++ trunk/Source/WebKit2/win/WebKit2.def 2012-09-20 21:03:56 UTC (rev 129165)
@@ -199,7 +199,7 @@
?number@String@WTF@@SA?AV12@_K@Z
?number@String@WTF@@SA?AV12@H@Z
?number@String@WTF@@SA?AV12@I@Z
- ?number@String@WTF@@SA?AV12@NII@Z
+ ?number@String@WTF@@SA?AV12@NIW4TrailingZerosTruncatingPolicy@2@@Z
?overrideUserPreferredLanguages@WebCore@@YAXABV?$Vector@VString@WTF@@$0A@@WTF@@@Z
?numberOfScopedHTMLStyleChildren@Node@WebCore@@QBEIXZ
?page@Document@WebCore@@QBEPAVPage@2@XZ
Modified: trunk/Source/WebKit2/win/WebKit2CFLite.def (129164 => 129165)
--- trunk/Source/WebKit2/win/WebKit2CFLite.def 2012-09-20 20:47:41 UTC (rev 129164)
+++ trunk/Source/WebKit2/win/WebKit2CFLite.def 2012-09-20 21:03:56 UTC (rev 129165)
@@ -192,7 +192,7 @@
?number@String@WTF@@SA?AV12@_K@Z
?number@String@WTF@@SA?AV12@H@Z
?number@String@WTF@@SA?AV12@I@Z
- ?number@String@WTF@@SA?AV12@NII@Z
+ ?number@String@WTF@@SA?AV12@NIW4TrailingZerosTruncatingPolicy@2@@Z
?overrideUserPreferredLanguages@WebCore@@YAXABV?$Vector@VString@WTF@@$0A@@WTF@@@Z
?numberOfScopedHTMLStyleChildren@Node@WebCore@@QBEIXZ
?page@Document@WebCore@@QBEPAVPage@2@XZ