Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(28)

Side by Side Diff: Source/core/css/MediaQueryExp.cpp

Issue 186603002: Length MQs invalidate non zero numbers (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fixed build issue Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/core/core.gypi ('k') | Source/core/css/MediaQuerySetTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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
OLDNEW
« no previous file with comments | « Source/core/core.gypi ('k') | Source/core/css/MediaQuerySetTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698