| 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 17 matching lines...) Expand all Loading... |
| 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 "platform/Decimal.h" | 37 #include "platform/Decimal.h" |
| 38 #include "platform/RuntimeEnabledFeatures.h" |
| 38 #include "wtf/text/StringBuffer.h" | 39 #include "wtf/text/StringBuffer.h" |
| 39 #include "wtf/text/StringBuilder.h" | 40 #include "wtf/text/StringBuilder.h" |
| 40 | 41 |
| 41 namespace blink { | 42 namespace blink { |
| 42 | 43 |
| 43 using namespace MediaFeatureNames; | 44 using namespace MediaFeatureNames; |
| 44 | 45 |
| 45 static inline bool featureWithCSSValueID(const String& mediaFeature, const CSSPa
rserValue* value) | 46 static inline bool featureWithCSSValueID(const String& mediaFeature, const CSSPa
rserValue* value) |
| 46 { | 47 { |
| 47 if (!value->id) | 48 if (!value->id) |
| 48 return false; | 49 return false; |
| 49 | 50 |
| 50 return mediaFeature == orientationMediaFeature | 51 return mediaFeature == orientationMediaFeature |
| 51 || mediaFeature == pointerMediaFeature | 52 || mediaFeature == pointerMediaFeature |
| 53 || (mediaFeature == hoverMediaFeature && RuntimeEnabledFeatures::hoverMe
diaQueryKeywordsEnabled()) |
| 52 || mediaFeature == scanMediaFeature; | 54 || mediaFeature == scanMediaFeature; |
| 53 } | 55 } |
| 54 | 56 |
| 55 static inline bool featureWithValidIdent(const String& mediaFeature, CSSValueID
ident) | 57 static inline bool featureWithValidIdent(const String& mediaFeature, CSSValueID
ident) |
| 56 { | 58 { |
| 57 if (mediaFeature == orientationMediaFeature) | 59 if (mediaFeature == orientationMediaFeature) |
| 58 return ident == CSSValuePortrait || ident == CSSValueLandscape; | 60 return ident == CSSValuePortrait || ident == CSSValueLandscape; |
| 59 | 61 |
| 60 if (mediaFeature == pointerMediaFeature) | 62 if (mediaFeature == pointerMediaFeature) |
| 61 return ident == CSSValueNone || ident == CSSValueCoarse || ident == CSSV
alueFine; | 63 return ident == CSSValueNone || ident == CSSValueCoarse || ident == CSSV
alueFine; |
| 62 | 64 |
| 65 if (mediaFeature == hoverMediaFeature && RuntimeEnabledFeatures::hoverMediaQ
ueryKeywordsEnabled()) |
| 66 return ident == CSSValueNone || ident == CSSValueOnDemand || ident == CS
SValueHover; |
| 67 |
| 63 if (mediaFeature == scanMediaFeature) | 68 if (mediaFeature == scanMediaFeature) |
| 64 return ident == CSSValueInterlace || ident == CSSValueProgressive; | 69 return ident == CSSValueInterlace || ident == CSSValueProgressive; |
| 65 | 70 |
| 66 ASSERT_NOT_REACHED(); | 71 ASSERT_NOT_REACHED(); |
| 67 return false; | 72 return false; |
| 68 } | 73 } |
| 69 | 74 |
| 70 static bool positiveLengthUnit(const int unit) | 75 static bool positiveLengthUnit(const int unit) |
| 71 { | 76 { |
| 72 switch (unit) { | 77 switch (unit) { |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 || mediaFeature == maxDevicePixelRatioMediaFeature | 146 || mediaFeature == maxDevicePixelRatioMediaFeature |
| 142 || mediaFeature == minDevicePixelRatioMediaFeature; | 147 || mediaFeature == minDevicePixelRatioMediaFeature; |
| 143 } | 148 } |
| 144 | 149 |
| 145 static inline bool featureWithZeroOrOne(const String& mediaFeature, const CSSPar
serValue* value) | 150 static inline bool featureWithZeroOrOne(const String& mediaFeature, const CSSPar
serValue* value) |
| 146 { | 151 { |
| 147 if (!value->isInt || !(value->fValue == 1 || !value->fValue)) | 152 if (!value->isInt || !(value->fValue == 1 || !value->fValue)) |
| 148 return false; | 153 return false; |
| 149 | 154 |
| 150 return mediaFeature == gridMediaFeature | 155 return mediaFeature == gridMediaFeature |
| 151 || mediaFeature == hoverMediaFeature; | 156 || (mediaFeature == hoverMediaFeature && !RuntimeEnabledFeatures::hoverM
ediaQueryKeywordsEnabled()); |
| 152 } | 157 } |
| 153 | 158 |
| 154 static inline bool featureWithAspectRatio(const String& mediaFeature) | 159 static inline bool featureWithAspectRatio(const String& mediaFeature) |
| 155 { | 160 { |
| 156 return mediaFeature == aspectRatioMediaFeature | 161 return mediaFeature == aspectRatioMediaFeature |
| 157 || mediaFeature == deviceAspectRatioMediaFeature | 162 || mediaFeature == deviceAspectRatioMediaFeature |
| 158 || mediaFeature == minAspectRatioMediaFeature | 163 || mediaFeature == minAspectRatioMediaFeature |
| 159 || mediaFeature == maxAspectRatioMediaFeature | 164 || mediaFeature == maxAspectRatioMediaFeature |
| 160 || mediaFeature == minDeviceAspectRatioMediaFeature | 165 || mediaFeature == minDeviceAspectRatioMediaFeature |
| 161 || mediaFeature == maxDeviceAspectRatioMediaFeature; | 166 || mediaFeature == maxDeviceAspectRatioMediaFeature; |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 output.append("/"); | 337 output.append("/"); |
| 333 output.append(printNumber(denominator)); | 338 output.append(printNumber(denominator)); |
| 334 } else if (isID) { | 339 } else if (isID) { |
| 335 output.append(getValueName(id)); | 340 output.append(getValueName(id)); |
| 336 } | 341 } |
| 337 | 342 |
| 338 return output.toString(); | 343 return output.toString(); |
| 339 } | 344 } |
| 340 | 345 |
| 341 } // namespace | 346 } // namespace |
| OLD | NEW |