Chromium Code Reviews| Index: Source/core/css/parser/CSSParserToken.cpp |
| diff --git a/Source/core/css/parser/CSSParserToken.cpp b/Source/core/css/parser/CSSParserToken.cpp |
| index a57271e903bb090ae0768b908b793643fbfbb031..9ae3f1bb5ae98ecccf127037ba3778b8b3f111ef 100644 |
| --- a/Source/core/css/parser/CSSParserToken.cpp |
| +++ b/Source/core/css/parser/CSSParserToken.cpp |
| @@ -71,39 +71,32 @@ void CSSParserToken::convertToPercentage() |
| // FIXME - This doesn't cover all possible Token types, but it's enough for current testing. |
| String CSSParserToken::textForUnitTests() const |
| { |
| - char buffer[std::numeric_limits<float>::digits]; |
| if (!m_value.isNull()) |
| return m_value; |
| if (m_type == LeftParenthesisToken) |
| - return String("("); |
| + return "("; |
| if (m_type == RightParenthesisToken) |
| - return String(")"); |
| + return ")"; |
| if (m_type == ColonToken) |
| - return String(":"); |
| + return ":"; |
| if (m_type == WhitespaceToken) |
| - return String(" "); |
| + return " "; |
| + if (m_delimiter) |
| + return String("'") + m_delimiter + '\''; |
| - if (m_delimiter) { |
| - sprintf(buffer, "'%c'", m_delimiter); |
| - return String(buffer, strlen(buffer)); |
| - } |
| if (m_numericValue) { |
| - static const unsigned maxUnitBufferLength = 6; |
| - char unitBuffer[maxUnitBufferLength] = {0}; |
| + String unit; |
| if (m_unit == CSSPrimitiveValue::CSS_PERCENTAGE) |
| - sprintf(unitBuffer, "%s", "%"); |
| + unit = "%"; |
| else if (m_unit == CSSPrimitiveValue::CSS_PX) |
| - sprintf(unitBuffer, "%s", "px"); |
| + unit = "px"; |
| else if (m_unit == CSSPrimitiveValue::CSS_EMS) |
| - sprintf(unitBuffer, "%s", "em"); |
| + unit = "em"; |
| else if (m_unit != CSSPrimitiveValue::CSS_NUMBER) |
| - sprintf(unitBuffer, "%s", "other"); |
| + unit = "other"; |
| if (m_numericValueType == IntegerValueType) |
| - sprintf(buffer, "%d%s", static_cast<int>(m_numericValue), unitBuffer); |
| - else |
| - sprintf(buffer, "%f%s", m_numericValue, unitBuffer); |
| - |
| - return String(buffer, strlen(buffer)); |
| + return String::number(static_cast<int>(m_numericValue)) + unit; |
| + return String::number(m_numericValue, 6, KeepTrailingZeros) + unit; |
|
Yoav Weiss
2014/10/20 08:04:43
If I understand correctly the intention here is to
Timothy Loh
2014/10/20 08:16:38
Would it be clearer with "const int significantDig
Yoav Weiss
2014/10/20 08:38:24
Maybe replace this line with 'return String::numbe
Timothy Loh
2014/10/20 10:52:32
Done.
|
| } |
| return String(); |
| } |