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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 if (mediaFeature == MediaFeatureNames::pointerMediaFeature) | 70 if (mediaFeature == MediaFeatureNames::pointerMediaFeature) |
71 return ident == CSSValueNone || ident == CSSValueCoarse || ident == CSSV
alueFine; | 71 return ident == CSSValueNone || ident == CSSValueCoarse || ident == CSSV
alueFine; |
72 | 72 |
73 if (mediaFeature == MediaFeatureNames::scanMediaFeature) | 73 if (mediaFeature == MediaFeatureNames::scanMediaFeature) |
74 return ident == CSSValueInterlace || ident == CSSValueProgressive; | 74 return ident == CSSValueInterlace || ident == CSSValueProgressive; |
75 | 75 |
76 ASSERT_NOT_REACHED(); | 76 ASSERT_NOT_REACHED(); |
77 return false; | 77 return false; |
78 } | 78 } |
79 | 79 |
80 static inline bool featureWithValidPositiveLenghtOrNumber(const AtomicString& me
diaFeature, const CSSParserValue* value) | 80 static inline bool featureWithValidPositiveLength(const AtomicString& mediaFeatu
re, const CSSParserValue* value) |
81 { | 81 { |
82 if (!(((value->unit >= CSSPrimitiveValue::CSS_EMS && value->unit <= CSSPrimi
tiveValue::CSS_PC) || value->unit == CSSPrimitiveValue::CSS_REMS) || value->unit
== CSSPrimitiveValue::CSS_NUMBER) || value->fValue < 0) | 82 if (!(((value->unit >= CSSPrimitiveValue::CSS_EMS && value->unit <= CSSPrimi
tiveValue::CSS_PC) || value->unit == CSSPrimitiveValue::CSS_REMS) || (value->uni
t == CSSPrimitiveValue::CSS_NUMBER && !(value->fValue))) || value->fValue < 0) |
83 return false; | 83 return false; |
84 | 84 |
85 return mediaFeature == MediaFeatureNames::heightMediaFeature | 85 return mediaFeature == MediaFeatureNames::heightMediaFeature |
86 || mediaFeature == MediaFeatureNames::maxHeightMediaFeature | 86 || mediaFeature == MediaFeatureNames::maxHeightMediaFeature |
87 || mediaFeature == MediaFeatureNames::minHeightMediaFeature | 87 || mediaFeature == MediaFeatureNames::minHeightMediaFeature |
88 || mediaFeature == MediaFeatureNames::widthMediaFeature | 88 || mediaFeature == MediaFeatureNames::widthMediaFeature |
89 || mediaFeature == MediaFeatureNames::maxWidthMediaFeature | 89 || mediaFeature == MediaFeatureNames::maxWidthMediaFeature |
90 || mediaFeature == MediaFeatureNames::minWidthMediaFeature | 90 || mediaFeature == MediaFeatureNames::minWidthMediaFeature |
91 || mediaFeature == MediaFeatureNames::deviceHeightMediaFeature | 91 || mediaFeature == MediaFeatureNames::deviceHeightMediaFeature |
92 || mediaFeature == MediaFeatureNames::maxDeviceHeightMediaFeature | 92 || mediaFeature == MediaFeatureNames::maxDeviceHeightMediaFeature |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 CSSParserValue* value = valueList->current(); | 218 CSSParserValue* value = valueList->current(); |
219 | 219 |
220 if (featureWithCSSValueID(mediaFeature, value)) { | 220 if (featureWithCSSValueID(mediaFeature, value)) { |
221 // Media features that use CSSValueIDs. | 221 // Media features that use CSSValueIDs. |
222 cssValue = CSSPrimitiveValue::createIdentifier(value->id); | 222 cssValue = CSSPrimitiveValue::createIdentifier(value->id); |
223 if (!featureWithValidIdent(mediaFeature, toCSSPrimitiveValue(css
Value.get())->getValueID())) | 223 if (!featureWithValidIdent(mediaFeature, toCSSPrimitiveValue(css
Value.get())->getValueID())) |
224 cssValue.clear(); | 224 cssValue.clear(); |
225 } else if (featureWithValidDensity(mediaFeature, value)) { | 225 } else if (featureWithValidDensity(mediaFeature, value)) { |
226 // Media features that must have non-negative <density>, ie. dpp
x, dpi or dpcm. | 226 // Media features that must have non-negative <density>, ie. dpp
x, dpi or dpcm. |
227 cssValue = CSSPrimitiveValue::create(value->fValue, (CSSPrimitiv
eValue::UnitTypes) value->unit); | 227 cssValue = CSSPrimitiveValue::create(value->fValue, (CSSPrimitiv
eValue::UnitTypes) value->unit); |
228 } else if (featureWithValidPositiveLenghtOrNumber(mediaFeature, valu
e)) { | 228 } else if (featureWithValidPositiveLength(mediaFeature, value)) { |
229 // Media features that must have non-negative <lenght> or number
value. | 229 // Media features that must have non-negative <lenght> or number
value. |
230 cssValue = CSSPrimitiveValue::create(value->fValue, (CSSPrimitiv
eValue::UnitTypes) value->unit); | 230 cssValue = CSSPrimitiveValue::create(value->fValue, (CSSPrimitiv
eValue::UnitTypes) value->unit); |
231 } else if (featureWithPositiveInteger(mediaFeature, value)) { | 231 } else if (featureWithPositiveInteger(mediaFeature, value)) { |
232 // Media features that must have non-negative integer value. | 232 // Media features that must have non-negative integer value. |
233 cssValue = CSSPrimitiveValue::create(value->fValue, CSSPrimitive
Value::CSS_NUMBER); | 233 cssValue = CSSPrimitiveValue::create(value->fValue, CSSPrimitive
Value::CSS_NUMBER); |
234 } else if (featureWithPositiveNumber(mediaFeature, value)) { | 234 } else if (featureWithPositiveNumber(mediaFeature, value)) { |
235 // Media features that must have non-negative number value. | 235 // Media features that must have non-negative number value. |
236 cssValue = CSSPrimitiveValue::create(value->fValue, CSSPrimitive
Value::CSS_NUMBER); | 236 cssValue = CSSPrimitiveValue::create(value->fValue, CSSPrimitive
Value::CSS_NUMBER); |
237 } else if (featureWithZeroOrOne(mediaFeature, value)) { | 237 } else if (featureWithZeroOrOne(mediaFeature, value)) { |
238 // Media features that must have (0|1) value. | 238 // Media features that must have (0|1) value. |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 if (m_value) { | 289 if (m_value) { |
290 result.append(": "); | 290 result.append(": "); |
291 result.append(m_value->cssText()); | 291 result.append(m_value->cssText()); |
292 } | 292 } |
293 result.append(")"); | 293 result.append(")"); |
294 | 294 |
295 return result.toString(); | 295 return result.toString(); |
296 } | 296 } |
297 | 297 |
298 } // namespace | 298 } // namespace |
OLD | NEW |