OLD | NEW |
1 /* | 1 /* |
2 * (C) 1999-2003 Lars Knoll (knoll@kde.org) | 2 * (C) 1999-2003 Lars Knoll (knoll@kde.org) |
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2012 Apple Inc. All rights reserv
ed. | 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2012 Apple Inc. All rights reserv
ed. |
4 * | 4 * |
5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
9 * | 9 * |
10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
(...skipping 17 matching lines...) Expand all Loading... |
28 #include "core/css/CSSMarkup.h" | 28 #include "core/css/CSSMarkup.h" |
29 #include "core/css/CSSToLengthConversionData.h" | 29 #include "core/css/CSSToLengthConversionData.h" |
30 #include "core/css/Counter.h" | 30 #include "core/css/Counter.h" |
31 #include "core/css/Pair.h" | 31 #include "core/css/Pair.h" |
32 #include "core/css/RGBColor.h" | 32 #include "core/css/RGBColor.h" |
33 #include "core/css/Rect.h" | 33 #include "core/css/Rect.h" |
34 #include "core/css/StyleSheetContents.h" | 34 #include "core/css/StyleSheetContents.h" |
35 #include "core/dom/ExceptionCode.h" | 35 #include "core/dom/ExceptionCode.h" |
36 #include "core/dom/Node.h" | 36 #include "core/dom/Node.h" |
37 #include "core/rendering/style/RenderStyle.h" | 37 #include "core/rendering/style/RenderStyle.h" |
| 38 #include "platform/Decimal.h" |
38 #include "platform/LayoutUnit.h" | 39 #include "platform/LayoutUnit.h" |
39 #include "wtf/DecimalNumber.h" | |
40 #include "wtf/StdLibExtras.h" | 40 #include "wtf/StdLibExtras.h" |
41 #include "wtf/text/StringBuffer.h" | 41 #include "wtf/text/StringBuffer.h" |
42 #include "wtf/text/StringBuilder.h" | 42 #include "wtf/text/StringBuilder.h" |
43 | 43 |
44 using namespace WTF; | 44 using namespace WTF; |
45 | 45 |
46 namespace WebCore { | 46 namespace WebCore { |
47 | 47 |
48 // Max/min values for CSS, needs to slightly smaller/larger than the true max/mi
n values to allow for rounding without overflowing. | 48 // Max/min values for CSS, needs to slightly smaller/larger than the true max/mi
n values to allow for rounding without overflowing. |
49 // Subtract two (rather than one) to allow for values to be converted to float a
nd back without exceeding the LayoutUnit::max. | 49 // Subtract two (rather than one) to allow for values to be converted to float a
nd back without exceeding the LayoutUnit::max. |
(...skipping 983 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1033 if (m_primitiveUnitType != CSS_PAIR) { | 1033 if (m_primitiveUnitType != CSS_PAIR) { |
1034 exceptionState.throwDOMException(InvalidAccessError, "This object is not
a pair value."); | 1034 exceptionState.throwDOMException(InvalidAccessError, "This object is not
a pair value."); |
1035 return 0; | 1035 return 0; |
1036 } | 1036 } |
1037 | 1037 |
1038 return m_value.pair; | 1038 return m_value.pair; |
1039 } | 1039 } |
1040 | 1040 |
1041 static String formatNumber(double number, const char* suffix, unsigned suffixLen
gth) | 1041 static String formatNumber(double number, const char* suffix, unsigned suffixLen
gth) |
1042 { | 1042 { |
1043 DecimalNumber decimal(number); | 1043 Decimal decimal = Decimal::fromDouble(number); |
1044 | 1044 String result = decimal.toString(); |
1045 StringBuffer<LChar> buffer(decimal.bufferLengthForStringDecimal() + suffixLe
ngth); | 1045 result.append(suffix, suffixLength); |
1046 unsigned length = decimal.toStringDecimal(buffer.characters(), buffer.length
()); | 1046 return result; |
1047 ASSERT(length + suffixLength == buffer.length()); | |
1048 | |
1049 for (unsigned i = 0; i < suffixLength; ++i) | |
1050 buffer[length + i] = static_cast<LChar>(suffix[i]); | |
1051 | |
1052 return String::adopt(buffer); | |
1053 } | 1047 } |
1054 | 1048 |
1055 template <unsigned characterCount> | 1049 template <unsigned characterCount> |
1056 ALWAYS_INLINE static String formatNumber(double number, const char (&characters)
[characterCount]) | 1050 ALWAYS_INLINE static String formatNumber(double number, const char (&characters)
[characterCount]) |
1057 { | 1051 { |
1058 return formatNumber(number, characters, characterCount - 1); | 1052 return formatNumber(number, characters, characterCount - 1); |
1059 } | 1053 } |
1060 | 1054 |
1061 static String formatNumber(double number, const char* characters) | 1055 static String formatNumber(double number, const char* characters) |
1062 { | 1056 { |
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1464 case CSS_SHAPE: | 1458 case CSS_SHAPE: |
1465 visitor->trace(m_value.shape); | 1459 visitor->trace(m_value.shape); |
1466 break; | 1460 break; |
1467 default: | 1461 default: |
1468 break; | 1462 break; |
1469 } | 1463 } |
1470 CSSValue::traceAfterDispatch(visitor); | 1464 CSSValue::traceAfterDispatch(visitor); |
1471 } | 1465 } |
1472 | 1466 |
1473 } // namespace WebCore | 1467 } // namespace WebCore |
OLD | NEW |