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

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

Issue 427683002: Bug fix - rem & ch in MQs/sizes treated as unknown units (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Nits Created 6 years, 4 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/css/CSSPrimitiveValue.cpp ('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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 if (mediaFeature == pointerMediaFeature) 60 if (mediaFeature == pointerMediaFeature)
61 return ident == CSSValueNone || ident == CSSValueCoarse || ident == CSSV alueFine; 61 return ident == CSSValueNone || ident == CSSValueCoarse || ident == CSSV alueFine;
62 62
63 if (mediaFeature == scanMediaFeature) 63 if (mediaFeature == scanMediaFeature)
64 return ident == CSSValueInterlace || ident == CSSValueProgressive; 64 return ident == CSSValueInterlace || ident == CSSValueProgressive;
65 65
66 ASSERT_NOT_REACHED(); 66 ASSERT_NOT_REACHED();
67 return false; 67 return false;
68 } 68 }
69 69
70 static bool positiveLengthUnit(const int unit)
71 {
72 switch (unit) {
73 case CSSPrimitiveValue::CSS_EMS:
74 case CSSPrimitiveValue::CSS_EXS:
75 case CSSPrimitiveValue::CSS_PX:
76 case CSSPrimitiveValue::CSS_CM:
77 case CSSPrimitiveValue::CSS_MM:
78 case CSSPrimitiveValue::CSS_IN:
79 case CSSPrimitiveValue::CSS_PT:
80 case CSSPrimitiveValue::CSS_PC:
81 case CSSPrimitiveValue::CSS_REMS:
82 case CSSPrimitiveValue::CSS_CHS:
83 return true;
84 }
85 return false;
86 }
87
70 static inline bool featureWithValidPositiveLength(const String& mediaFeature, co nst CSSParserValue* value) 88 static inline bool featureWithValidPositiveLength(const String& mediaFeature, co nst CSSParserValue* value)
71 { 89 {
72 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) 90 if (!(positiveLengthUnit(value->unit) || (value->unit == CSSPrimitiveValue:: CSS_NUMBER && value->fValue == 0)) || value->fValue < 0)
73 return false; 91 return false;
74 92
75 93
76 return mediaFeature == heightMediaFeature 94 return mediaFeature == heightMediaFeature
77 || mediaFeature == maxHeightMediaFeature 95 || mediaFeature == maxHeightMediaFeature
78 || mediaFeature == minHeightMediaFeature 96 || mediaFeature == minHeightMediaFeature
79 || mediaFeature == widthMediaFeature 97 || mediaFeature == widthMediaFeature
80 || mediaFeature == maxWidthMediaFeature 98 || mediaFeature == maxWidthMediaFeature
81 || mediaFeature == minWidthMediaFeature 99 || mediaFeature == minWidthMediaFeature
82 || mediaFeature == deviceHeightMediaFeature 100 || mediaFeature == deviceHeightMediaFeature
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 output.append("/"); 332 output.append("/");
315 output.append(printNumber(denominator)); 333 output.append(printNumber(denominator));
316 } else if (isID) { 334 } else if (isID) {
317 output.append(getValueName(id)); 335 output.append(getValueName(id));
318 } 336 }
319 337
320 return output.toString(); 338 return output.toString();
321 } 339 }
322 340
323 } // namespace 341 } // namespace
OLDNEW
« no previous file with comments | « Source/core/css/CSSPrimitiveValue.cpp ('k') | Source/core/css/MediaQuerySetTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698