| OLD | NEW |
| 1 /* | 1 /* |
| 2 * CSS Media Query Evaluator | 2 * CSS Media Query Evaluator |
| 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) 2013 Apple Inc. All rights reserved. | 5 * Copyright (C) 2013 Apple Inc. All rights reserved. |
| 6 * Copyright (C) 2013 Intel Corporation. All rights reserved. | 6 * Copyright (C) 2013 Intel Corporation. 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 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 | 307 |
| 308 if (value.unit == CSSPrimitiveValue::UnitType::Number) | 308 if (value.unit == CSSPrimitiveValue::UnitType::Number) |
| 309 return compareValue(actualResolution, clampTo<float>(value.value), op); | 309 return compareValue(actualResolution, clampTo<float>(value.value), op); |
| 310 | 310 |
| 311 if (!CSSPrimitiveValue::isResolution(value.unit)) | 311 if (!CSSPrimitiveValue::isResolution(value.unit)) |
| 312 return false; | 312 return false; |
| 313 | 313 |
| 314 double canonicalFactor = CSSPrimitiveValue::conversionToCanonicalUnitsScaleF
actor(value.unit); | 314 double canonicalFactor = CSSPrimitiveValue::conversionToCanonicalUnitsScaleF
actor(value.unit); |
| 315 double dppxFactor = CSSPrimitiveValue::conversionToCanonicalUnitsScaleFactor
(CSSPrimitiveValue::UnitType::DotsPerPixel); | 315 double dppxFactor = CSSPrimitiveValue::conversionToCanonicalUnitsScaleFactor
(CSSPrimitiveValue::UnitType::DotsPerPixel); |
| 316 float valueInDppx = clampTo<float>(value.value * (canonicalFactor / dppxFact
or)); | 316 float valueInDppx = clampTo<float>(value.value * (canonicalFactor / dppxFact
or)); |
| 317 if (CSSPrimitiveValue::isDotsPerCentimeter(value.unit)) { | 317 if (value.unit == CSSPrimitiveValue::UnitType::DotsPerCentimeter) { |
| 318 // To match DPCM to DPPX values, we limit to 2 decimal points. | 318 // To match DPCM to DPPX values, we limit to 2 decimal points. |
| 319 // The http://dev.w3.org/csswg/css3-values/#absolute-lengths recommends | 319 // The http://dev.w3.org/csswg/css3-values/#absolute-lengths recommends |
| 320 // "that the pixel unit refer to the whole number of device pixels that
best | 320 // "that the pixel unit refer to the whole number of device pixels that
best |
| 321 // approximates the reference pixel". With that in mind, allowing 2 deci
mal | 321 // approximates the reference pixel". With that in mind, allowing 2 deci
mal |
| 322 // point precision seems appropriate. | 322 // point precision seems appropriate. |
| 323 return compareValue( | 323 return compareValue( |
| 324 floorf(0.5 + 100 * actualResolution) / 100, | 324 floorf(0.5 + 100 * actualResolution) / 100, |
| 325 floorf(0.5 + 100 * valueInDppx) / 100, op); | 325 floorf(0.5 + 100 * valueInDppx) / 100, op); |
| 326 } | 326 } |
| 327 | 327 |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 659 // Call the media feature evaluation function. Assume no prefix and let | 659 // Call the media feature evaluation function. Assume no prefix and let |
| 660 // trampoline functions override the prefix if prefix is used. | 660 // trampoline functions override the prefix if prefix is used. |
| 661 EvalFunc func = gFunctionMap->get(expr->mediaFeature().impl()); | 661 EvalFunc func = gFunctionMap->get(expr->mediaFeature().impl()); |
| 662 if (func) | 662 if (func) |
| 663 return func(expr->expValue(), NoPrefix, *m_mediaValues); | 663 return func(expr->expValue(), NoPrefix, *m_mediaValues); |
| 664 | 664 |
| 665 return false; | 665 return false; |
| 666 } | 666 } |
| 667 | 667 |
| 668 } // namespace | 668 } // namespace |
| OLD | NEW |