OLD | NEW |
1 /* | 1 /* |
2 * CSS Media Query | 2 * CSS Media Query |
3 * | 3 * |
4 * Copyright (C) 2006 Kimmo Kinnunen <kimmo.t.kinnunen@nokia.com>. | 4 * Copyright (C) 2006 Kimmo Kinnunen <kimmo.t.kinnunen@nokia.com>. |
5 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). | 5 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
6 * Copyright (C) 2013 Apple Inc. All rights reserved. | 6 * Copyright (C) 2013 Apple Inc. All rights reserved. |
7 * | 7 * |
8 * Redistribution and use in source and binary forms, with or without | 8 * Redistribution and use in source and binary forms, with or without |
9 * modification, are permitted provided that the following conditions | 9 * modification, are permitted provided that the following conditions |
10 * are met: | 10 * are met: |
(...skipping 16 matching lines...) Expand all Loading... |
27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
28 */ | 28 */ |
29 | 29 |
30 #include "config.h" | 30 #include "config.h" |
31 #include "core/css/MediaQueryExp.h" | 31 #include "core/css/MediaQueryExp.h" |
32 | 32 |
33 #include "core/css/CSSAspectRatioValue.h" | 33 #include "core/css/CSSAspectRatioValue.h" |
34 #include "core/css/CSSParserValues.h" | 34 #include "core/css/CSSParserValues.h" |
35 #include "core/css/CSSPrimitiveValue.h" | 35 #include "core/css/CSSPrimitiveValue.h" |
36 #include "core/html/parser/HTMLParserIdioms.h" | 36 #include "core/html/parser/HTMLParserIdioms.h" |
37 #include "wtf/DecimalNumber.h" | 37 #include "platform/Decimal.h" |
38 #include "wtf/text/StringBuffer.h" | 38 #include "wtf/text/StringBuffer.h" |
39 #include "wtf/text/StringBuilder.h" | 39 #include "wtf/text/StringBuilder.h" |
40 | 40 |
41 namespace WebCore { | 41 namespace WebCore { |
42 | 42 |
43 using namespace MediaFeatureNames; | 43 using namespace MediaFeatureNames; |
44 | 44 |
45 static inline bool featureWithCSSValueID(const String& mediaFeature, const CSSPa
rserValue* value) | 45 static inline bool featureWithCSSValueID(const String& mediaFeature, const CSSPa
rserValue* value) |
46 { | 46 { |
47 if (!value->id) | 47 if (!value->id) |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 result.append(m_mediaFeature.lower()); | 291 result.append(m_mediaFeature.lower()); |
292 if (m_expValue.isValid()) { | 292 if (m_expValue.isValid()) { |
293 result.append(": "); | 293 result.append(": "); |
294 result.append(m_expValue.cssText()); | 294 result.append(m_expValue.cssText()); |
295 } | 295 } |
296 result.append(")"); | 296 result.append(")"); |
297 | 297 |
298 return result.toString(); | 298 return result.toString(); |
299 } | 299 } |
300 | 300 |
301 static String printNumber(double number) | 301 static inline String printNumber(double number) |
302 { | 302 { |
303 DecimalNumber decimal(number); | 303 return Decimal::fromDouble(number).toString(); |
304 StringBuffer<LChar> buffer(decimal.bufferLengthForStringDecimal()); | |
305 decimal.toStringDecimal(buffer.characters(), buffer.length()); | |
306 return String::adopt(buffer); | |
307 } | 304 } |
308 | 305 |
309 String MediaQueryExpValue::cssText() const | 306 String MediaQueryExpValue::cssText() const |
310 { | 307 { |
311 StringBuilder output; | 308 StringBuilder output; |
312 if (isValue) { | 309 if (isValue) { |
313 output.append(printNumber(value)); | 310 output.append(printNumber(value)); |
314 output.append(CSSPrimitiveValue::unitTypeToString(unit)); | 311 output.append(CSSPrimitiveValue::unitTypeToString(unit)); |
315 } else if (isRatio) { | 312 } else if (isRatio) { |
316 output.append(printNumber(numerator)); | 313 output.append(printNumber(numerator)); |
317 output.append("/"); | 314 output.append("/"); |
318 output.append(printNumber(denominator)); | 315 output.append(printNumber(denominator)); |
319 } else if (isID) { | 316 } else if (isID) { |
320 output.append(getValueName(id)); | 317 output.append(getValueName(id)); |
321 } | 318 } |
322 | 319 |
323 return output.toString(); | 320 return output.toString(); |
324 } | 321 } |
325 | 322 |
326 } // namespace | 323 } // namespace |
OLD | NEW |