| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 { | 44 { |
| 45 if (!value->id) | 45 if (!value->id) |
| 46 return false; | 46 return false; |
| 47 | 47 |
| 48 return mediaFeature == MediaFeatureNames::orientationMediaFeature | 48 return mediaFeature == MediaFeatureNames::orientationMediaFeature |
| 49 || mediaFeature == MediaFeatureNames::viewModeMediaFeature | 49 || mediaFeature == MediaFeatureNames::viewModeMediaFeature |
| 50 || mediaFeature == MediaFeatureNames::pointerMediaFeature | 50 || mediaFeature == MediaFeatureNames::pointerMediaFeature |
| 51 || mediaFeature == MediaFeatureNames::scanMediaFeature; | 51 || mediaFeature == MediaFeatureNames::scanMediaFeature; |
| 52 } | 52 } |
| 53 | 53 |
| 54 static inline bool featureWithValidIdent(const AtomicString& mediaFeature, int i
dent) | 54 static inline bool featureWithValidIdent(const AtomicString& mediaFeature, CSSVa
lueID ident) |
| 55 { | 55 { |
| 56 if (mediaFeature == MediaFeatureNames::orientationMediaFeature) | 56 if (mediaFeature == MediaFeatureNames::orientationMediaFeature) |
| 57 return ident == CSSValuePortrait || ident == CSSValueLandscape; | 57 return ident == CSSValuePortrait || ident == CSSValueLandscape; |
| 58 | 58 |
| 59 if (mediaFeature == MediaFeatureNames::viewModeMediaFeature) { | 59 if (mediaFeature == MediaFeatureNames::viewModeMediaFeature) { |
| 60 switch (ident) { | 60 switch (ident) { |
| 61 case CSSValueWindowed: | 61 case CSSValueWindowed: |
| 62 case CSSValueFloating: | 62 case CSSValueFloating: |
| 63 case CSSValueFullscreen: | 63 case CSSValueFullscreen: |
| 64 case CSSValueMaximized: | 64 case CSSValueMaximized: |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 , m_isValid(false) | 203 , m_isValid(false) |
| 204 { | 204 { |
| 205 // Initialize media query expression that must have 1 or more values. | 205 // Initialize media query expression that must have 1 or more values. |
| 206 if (valueList) { | 206 if (valueList) { |
| 207 if (valueList->size() == 1) { | 207 if (valueList->size() == 1) { |
| 208 CSSParserValue* value = valueList->current(); | 208 CSSParserValue* value = valueList->current(); |
| 209 | 209 |
| 210 // Media features that use CSSValueIDs. | 210 // Media features that use CSSValueIDs. |
| 211 if (featureWithCSSValueID(mediaFeature, value)) { | 211 if (featureWithCSSValueID(mediaFeature, value)) { |
| 212 m_value = CSSPrimitiveValue::createIdentifier(value->id); | 212 m_value = CSSPrimitiveValue::createIdentifier(value->id); |
| 213 if (!featureWithValidIdent(mediaFeature, toCSSPrimitiveValue(m_v
alue.get())->getIdent())) | 213 if (!featureWithValidIdent(mediaFeature, toCSSPrimitiveValue(m_v
alue.get())->getValueID())) |
| 214 m_value.clear(); | 214 m_value.clear(); |
| 215 } | 215 } |
| 216 | 216 |
| 217 // Media features that must have non-negative <density>, ie. dppx, d
pi or dpcm. | 217 // Media features that must have non-negative <density>, ie. dppx, d
pi or dpcm. |
| 218 else if (featureWithValidDensity(mediaFeature, value)) | 218 else if (featureWithValidDensity(mediaFeature, value)) |
| 219 m_value = CSSPrimitiveValue::create(value->fValue, (CSSPrimitive
Value::UnitTypes) value->unit); | 219 m_value = CSSPrimitiveValue::create(value->fValue, (CSSPrimitive
Value::UnitTypes) value->unit); |
| 220 | 220 |
| 221 // Media features that must have non-negative <lenght> or number val
ue. | 221 // Media features that must have non-negative <lenght> or number val
ue. |
| 222 else if (featureWithValidPositiveLenghtOrNumber(mediaFeature, value)
) | 222 else if (featureWithValidPositiveLenghtOrNumber(mediaFeature, value)
) |
| 223 m_value = CSSPrimitiveValue::create(value->fValue, (CSSPrimitive
Value::UnitTypes) value->unit); | 223 m_value = CSSPrimitiveValue::create(value->fValue, (CSSPrimitive
Value::UnitTypes) value->unit); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 } | 292 } |
| 293 | 293 |
| 294 void MediaQueryExp::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const | 294 void MediaQueryExp::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const |
| 295 { | 295 { |
| 296 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS); | 296 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS); |
| 297 info.addMember(m_mediaFeature, "mediaFeature"); | 297 info.addMember(m_mediaFeature, "mediaFeature"); |
| 298 info.addMember(m_value, "value"); | 298 info.addMember(m_value, "value"); |
| 299 } | 299 } |
| 300 | 300 |
| 301 } // namespace | 301 } // namespace |
| OLD | NEW |