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

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: Fix ch as well 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 return ((unit >= CSSPrimitiveValue::CSS_EMS && unit <= CSSPrimitiveValue::CS S_PC)
73 || unit == CSSPrimitiveValue::CSS_REMS || unit == CSSPrimitiveValue::CSS _CHS);
alancutter (OOO until 2018) 2014/07/29 03:25:15 A switch would be more explicit and readable here.
74 }
75
70 static inline bool featureWithValidPositiveLength(const String& mediaFeature, co nst CSSParserValue* value) 76 static inline bool featureWithValidPositiveLength(const String& mediaFeature, co nst CSSParserValue* value)
71 { 77 {
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) 78 if (!(positiveLengthUnit(value->unit) || (value->unit == CSSPrimitiveValue:: CSS_NUMBER && !(value->fValue))) || value->fValue < 0)
alancutter (OOO until 2018) 2014/07/29 03:25:15 It's within the style guide to make comparisons wi
73 return false; 79 return false;
74 80
75 81
76 return mediaFeature == heightMediaFeature 82 return mediaFeature == heightMediaFeature
77 || mediaFeature == maxHeightMediaFeature 83 || mediaFeature == maxHeightMediaFeature
78 || mediaFeature == minHeightMediaFeature 84 || mediaFeature == minHeightMediaFeature
79 || mediaFeature == widthMediaFeature 85 || mediaFeature == widthMediaFeature
80 || mediaFeature == maxWidthMediaFeature 86 || mediaFeature == maxWidthMediaFeature
81 || mediaFeature == minWidthMediaFeature 87 || mediaFeature == minWidthMediaFeature
82 || mediaFeature == deviceHeightMediaFeature 88 || mediaFeature == deviceHeightMediaFeature
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 output.append("/"); 320 output.append("/");
315 output.append(printNumber(denominator)); 321 output.append(printNumber(denominator));
316 } else if (isID) { 322 } else if (isID) {
317 output.append(getValueName(id)); 323 output.append(getValueName(id));
318 } 324 }
319 325
320 return output.toString(); 326 return output.toString();
321 } 327 }
322 328
323 } // namespace 329 } // 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