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

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

Issue 204333005: Fix an MQ parsing related crash (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Added a test 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/css/CSSParserValuesTest.cpp ('k') | no next file » | 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 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 207
208 MediaQueryExp::MediaQueryExp(const String& mediaFeature, PassRefPtrWillBeRawPtr< CSSValue> value) 208 MediaQueryExp::MediaQueryExp(const String& mediaFeature, PassRefPtrWillBeRawPtr< CSSValue> value)
209 : m_mediaFeature(mediaFeature) 209 : m_mediaFeature(mediaFeature)
210 , m_value(value) 210 , m_value(value)
211 { 211 {
212 } 212 }
213 213
214 // FIXME - create should not return a null. 214 // FIXME - create should not return a null.
215 PassOwnPtrWillBeRawPtr<MediaQueryExp> MediaQueryExp::create(const String& mediaF eature, CSSParserValueList* valueList) 215 PassOwnPtrWillBeRawPtr<MediaQueryExp> MediaQueryExp::create(const String& mediaF eature, CSSParserValueList* valueList)
216 { 216 {
217 ASSERT(!mediaFeature.isNull());
218
217 RefPtrWillBeRawPtr<CSSValue> cssValue; 219 RefPtrWillBeRawPtr<CSSValue> cssValue;
218 bool isValid = false; 220 bool isValid = false;
219 String lowerMediaFeature = attemptStaticStringCreation(mediaFeature.lower()) ; 221 String lowerMediaFeature = attemptStaticStringCreation(mediaFeature.lower()) ;
220 222
221 // Create value for media query expression that must have 1 or more values. 223 // Create value for media query expression that must have 1 or more values.
222 if (valueList && valueList->size() > 0) { 224 if (valueList && valueList->size() > 0) {
223 if (valueList->size() == 1) { 225 if (valueList->size() == 1) {
224 CSSParserValue* value = valueList->current(); 226 CSSParserValue* value = valueList->current();
227 ASSERT(value);
225 228
226 if (featureWithCSSValueID(lowerMediaFeature, value)) { 229 if (featureWithCSSValueID(lowerMediaFeature, value)) {
227 // Media features that use CSSValueIDs. 230 // Media features that use CSSValueIDs.
228 cssValue = CSSPrimitiveValue::createIdentifier(value->id); 231 cssValue = CSSPrimitiveValue::createIdentifier(value->id);
229 if (!featureWithValidIdent(lowerMediaFeature, toCSSPrimitiveValu e(cssValue.get())->getValueID())) 232 if (!featureWithValidIdent(lowerMediaFeature, toCSSPrimitiveValu e(cssValue.get())->getValueID()))
230 cssValue.clear(); 233 cssValue.clear();
231 } else if (featureWithValidDensity(lowerMediaFeature, value)) { 234 } else if (featureWithValidDensity(lowerMediaFeature, value)) {
232 // Media features that must have non-negative <density>, ie. dpp x, dpi or dpcm. 235 // Media features that must have non-negative <density>, ie. dpp x, dpi or dpcm.
233 cssValue = CSSPrimitiveValue::create(value->fValue, (CSSPrimitiv eValue::UnitTypes) value->unit); 236 cssValue = CSSPrimitiveValue::create(value->fValue, (CSSPrimitiv eValue::UnitTypes) value->unit);
234 } else if (featureWithValidPositiveLength(lowerMediaFeature, value)) { 237 } else if (featureWithValidPositiveLength(lowerMediaFeature, value)) {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 if (m_value) { 298 if (m_value) {
296 result.append(": "); 299 result.append(": ");
297 result.append(m_value->cssText()); 300 result.append(m_value->cssText());
298 } 301 }
299 result.append(")"); 302 result.append(")");
300 303
301 return result.toString(); 304 return result.toString();
302 } 305 }
303 306
304 } // namespace 307 } // namespace
OLDNEW
« no previous file with comments | « Source/core/css/CSSParserValuesTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698