Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(134)

Side by Side Diff: Source/core/css/CSSPrimitiveValue.cpp

Issue 1120133004: Serialize <number> to round to at most 6 decimals (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: V7 Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 14 matching lines...) Expand all
25 #include "core/css/CSSCalculationValue.h" 25 #include "core/css/CSSCalculationValue.h"
26 #include "core/css/CSSHelper.h" 26 #include "core/css/CSSHelper.h"
27 #include "core/css/CSSMarkup.h" 27 #include "core/css/CSSMarkup.h"
28 #include "core/css/CSSToLengthConversionData.h" 28 #include "core/css/CSSToLengthConversionData.h"
29 #include "core/css/Counter.h" 29 #include "core/css/Counter.h"
30 #include "core/css/Pair.h" 30 #include "core/css/Pair.h"
31 #include "core/css/Rect.h" 31 #include "core/css/Rect.h"
32 #include "core/css/StyleSheetContents.h" 32 #include "core/css/StyleSheetContents.h"
33 #include "core/dom/Node.h" 33 #include "core/dom/Node.h"
34 #include "core/style/ComputedStyle.h" 34 #include "core/style/ComputedStyle.h"
35 #include "platform/Decimal.h"
36 #include "platform/LayoutUnit.h" 35 #include "platform/LayoutUnit.h"
37 #include "platform/fonts/FontMetrics.h" 36 #include "platform/fonts/FontMetrics.h"
38 #include "wtf/StdLibExtras.h" 37 #include "wtf/StdLibExtras.h"
39 #include "wtf/ThreadSpecific.h" 38 #include "wtf/ThreadSpecific.h"
40 #include "wtf/Threading.h" 39 #include "wtf/Threading.h"
41 #include "wtf/text/StringBuffer.h" 40 #include "wtf/text/StringBuffer.h"
42 #include "wtf/text/StringBuilder.h" 41 #include "wtf/text/StringBuilder.h"
43 42
44 using namespace WTF; 43 using namespace WTF;
45 44
(...skipping 777 matching lines...) Expand 10 before | Expand all | Expand 10 after
823 return propertyName(m_value.propertyID); 822 return propertyName(m_value.propertyID);
824 default: 823 default:
825 break; 824 break;
826 } 825 }
827 826
828 return String(); 827 return String();
829 } 828 }
830 829
831 static String formatNumber(double number, const char* suffix, unsigned suffixLen gth) 830 static String formatNumber(double number, const char* suffix, unsigned suffixLen gth)
832 { 831 {
833 Decimal decimal = Decimal::fromDouble(number); 832 String result = String::format("%.6g", number);
834 String result = decimal.toString();
835 result.append(suffix, suffixLength); 833 result.append(suffix, suffixLength);
836 return result; 834 return result;
837 } 835 }
838 836
839 template <unsigned characterCount> 837 template <unsigned characterCount>
840 ALWAYS_INLINE static String formatNumber(double number, const char (&characters) [characterCount]) 838 ALWAYS_INLINE static String formatNumber(double number, const char (&characters) [characterCount])
841 { 839 {
842 return formatNumber(number, characters, characterCount - 1); 840 return formatNumber(number, characters, characterCount - 1);
843 } 841 }
844 842
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
1139 visitor->trace(m_value.shape); 1137 visitor->trace(m_value.shape);
1140 break; 1138 break;
1141 default: 1139 default:
1142 break; 1140 break;
1143 } 1141 }
1144 #endif 1142 #endif
1145 CSSValue::traceAfterDispatch(visitor); 1143 CSSValue::traceAfterDispatch(visitor);
1146 } 1144 }
1147 1145
1148 } // namespace blink 1146 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698