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 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 | 207 |
208 MediaQueryExp::MediaQueryExp(const String& mediaFeature, PassRefPtrWillBeRawPtr<
CSSValue> value) | 208 MediaQueryExp::MediaQueryExp(const String& mediaFeature, PassRefPtrWillBeRawPtr<
CSSValue> value) |
209 : m_mediaFeature(mediaFeature) | 209 : m_mediaFeature(mediaFeature) |
210 , m_value(value) | 210 , m_value(value) |
211 { | 211 { |
212 } | 212 } |
213 | 213 |
214 // FIXME - create should not return a null. | 214 // FIXME - create should not return a null. |
215 PassOwnPtrWillBeRawPtr<MediaQueryExp> MediaQueryExp::create(const String& mediaF
eature, CSSParserValueList* valueList) | 215 PassOwnPtrWillBeRawPtr<MediaQueryExp> MediaQueryExp::create(const String& mediaF
eature, CSSParserValueList* valueList) |
216 { | 216 { |
| 217 ASSERT(!mediaFeature.isNull()); |
| 218 |
217 RefPtrWillBeRawPtr<CSSValue> cssValue; | 219 RefPtrWillBeRawPtr<CSSValue> cssValue; |
218 bool isValid = false; | 220 bool isValid = false; |
219 String lowerMediaFeature = attemptStaticStringCreation(mediaFeature.lower())
; | 221 String lowerMediaFeature = attemptStaticStringCreation(mediaFeature.lower())
; |
220 | 222 |
221 // Create value for media query expression that must have 1 or more values. | 223 // Create value for media query expression that must have 1 or more values. |
222 if (valueList && valueList->size() > 0) { | 224 if (valueList && valueList->size() > 0) { |
223 if (valueList->size() == 1) { | 225 if (valueList->size() == 1) { |
224 CSSParserValue* value = valueList->current(); | 226 CSSParserValue* value = valueList->current(); |
| 227 ASSERT(value); |
225 | 228 |
226 if (featureWithCSSValueID(lowerMediaFeature, value)) { | 229 if (featureWithCSSValueID(lowerMediaFeature, value)) { |
227 // Media features that use CSSValueIDs. | 230 // Media features that use CSSValueIDs. |
228 cssValue = CSSPrimitiveValue::createIdentifier(value->id); | 231 cssValue = CSSPrimitiveValue::createIdentifier(value->id); |
229 if (!featureWithValidIdent(lowerMediaFeature, toCSSPrimitiveValu
e(cssValue.get())->getValueID())) | 232 if (!featureWithValidIdent(lowerMediaFeature, toCSSPrimitiveValu
e(cssValue.get())->getValueID())) |
230 cssValue.clear(); | 233 cssValue.clear(); |
231 } else if (featureWithValidDensity(lowerMediaFeature, value)) { | 234 } else if (featureWithValidDensity(lowerMediaFeature, value)) { |
232 // Media features that must have non-negative <density>, ie. dpp
x, dpi or dpcm. | 235 // Media features that must have non-negative <density>, ie. dpp
x, dpi or dpcm. |
233 cssValue = CSSPrimitiveValue::create(value->fValue, (CSSPrimitiv
eValue::UnitTypes) value->unit); | 236 cssValue = CSSPrimitiveValue::create(value->fValue, (CSSPrimitiv
eValue::UnitTypes) value->unit); |
234 } else if (featureWithValidPositiveLength(lowerMediaFeature, value))
{ | 237 } else if (featureWithValidPositiveLength(lowerMediaFeature, value))
{ |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 if (m_value) { | 298 if (m_value) { |
296 result.append(": "); | 299 result.append(": "); |
297 result.append(m_value->cssText()); | 300 result.append(m_value->cssText()); |
298 } | 301 } |
299 result.append(")"); | 302 result.append(")"); |
300 | 303 |
301 return result.toString(); | 304 return result.toString(); |
302 } | 305 } |
303 | 306 |
304 } // namespace | 307 } // namespace |
OLD | NEW |