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

Side by Side Diff: Source/core/css/resolver/CSSToStyleMap.cpp

Issue 108653006: Assert that convertToLength succeeds instead of returning Length(Undefined) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebased Created 7 years 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) 3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com)
4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) 4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com)
5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All r ights reserved. 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All r ights reserved.
6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> 6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> 7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org>
8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. 9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved.
10 * Copyright (C) Research In Motion Limited 2011. All rights reserved. 10 * Copyright (C) Research In Motion Limited 2011. All rights reserved.
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 Length secondLength; 204 Length secondLength;
205 205
206 if (Pair* pair = primitiveValue->getPairValue()) { 206 if (Pair* pair = primitiveValue->getPairValue()) {
207 firstLength = pair->first()->convertToLength<AnyConversion>(cssToLengthC onversionData()); 207 firstLength = pair->first()->convertToLength<AnyConversion>(cssToLengthC onversionData());
208 secondLength = pair->second()->convertToLength<AnyConversion>(cssToLengt hConversionData()); 208 secondLength = pair->second()->convertToLength<AnyConversion>(cssToLengt hConversionData());
209 } else { 209 } else {
210 firstLength = primitiveValue->convertToLength<AnyConversion>(cssToLength ConversionData()); 210 firstLength = primitiveValue->convertToLength<AnyConversion>(cssToLength ConversionData());
211 secondLength = Length(); 211 secondLength = Length();
212 } 212 }
213 213
214 if (firstLength.isUndefined() || secondLength.isUndefined())
215 return;
216
217 b.setWidth(firstLength); 214 b.setWidth(firstLength);
218 b.setHeight(secondLength); 215 b.setHeight(secondLength);
219 layer->setSizeLength(b); 216 layer->setSizeLength(b);
220 } 217 }
221 218
222 void CSSToStyleMap::mapFillXPosition(CSSPropertyID propertyID, FillLayer* layer, CSSValue* value) const 219 void CSSToStyleMap::mapFillXPosition(CSSPropertyID propertyID, FillLayer* layer, CSSValue* value) const
223 { 220 {
224 if (!value->isPrimitiveValue()) 221 if (!value->isPrimitiveValue())
225 return; 222 return;
226 223
227 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 224 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
228 Pair* pair = primitiveValue->getPairValue(); 225 Pair* pair = primitiveValue->getPairValue();
229 if (pair) { 226 if (pair) {
230 ASSERT_UNUSED(propertyID, propertyID == CSSPropertyBackgroundPositionX | | propertyID == CSSPropertyWebkitMaskPositionX); 227 ASSERT_UNUSED(propertyID, propertyID == CSSPropertyBackgroundPositionX | | propertyID == CSSPropertyWebkitMaskPositionX);
231 primitiveValue = pair->second(); 228 primitiveValue = pair->second();
232 } 229 }
233 230
234 Length length = primitiveValue->convertToLength<FixedConversion | PercentCon version>(cssToLengthConversionData()); 231 Length length = primitiveValue->convertToLength<FixedConversion | PercentCon version>(cssToLengthConversionData());
235 ASSERT(!length.isUndefined());
236 232
237 layer->setXPosition(length); 233 layer->setXPosition(length);
238 if (pair) 234 if (pair)
239 layer->setBackgroundXOrigin(*(pair->first())); 235 layer->setBackgroundXOrigin(*(pair->first()));
240 } 236 }
241 237
242 void CSSToStyleMap::mapFillYPosition(CSSPropertyID propertyID, FillLayer* layer, CSSValue* value) const 238 void CSSToStyleMap::mapFillYPosition(CSSPropertyID propertyID, FillLayer* layer, CSSValue* value) const
243 { 239 {
244 if (!value->isPrimitiveValue()) 240 if (!value->isPrimitiveValue())
245 return; 241 return;
246 242
247 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 243 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
248 Pair* pair = primitiveValue->getPairValue(); 244 Pair* pair = primitiveValue->getPairValue();
249 if (pair) { 245 if (pair) {
250 ASSERT_UNUSED(propertyID, propertyID == CSSPropertyBackgroundPositionY | | propertyID == CSSPropertyWebkitMaskPositionY); 246 ASSERT_UNUSED(propertyID, propertyID == CSSPropertyBackgroundPositionY | | propertyID == CSSPropertyWebkitMaskPositionY);
251 primitiveValue = pair->second(); 247 primitiveValue = pair->second();
252 } 248 }
253 249
254 Length length = primitiveValue->convertToLength<FixedConversion | PercentCon version>(cssToLengthConversionData()); 250 Length length = primitiveValue->convertToLength<FixedConversion | PercentCon version>(cssToLengthConversionData());
255 ASSERT(!length.isUndefined());
256 251
257 layer->setYPosition(length); 252 layer->setYPosition(length);
258 if (pair) 253 if (pair)
259 layer->setBackgroundYOrigin(*(pair->first())); 254 layer->setBackgroundYOrigin(*(pair->first()));
260 } 255 }
261 256
262 void CSSToStyleMap::mapFillMaskSourceType(CSSPropertyID, FillLayer* layer, CSSVa lue* value) 257 void CSSToStyleMap::mapFillMaskSourceType(CSSPropertyID, FillLayer* layer, CSSVa lue* value)
263 { 258 {
264 EMaskSourceType type = FillLayer::initialFillMaskSourceType(layer->type()); 259 EMaskSourceType type = FillLayer::initialFillMaskSourceType(layer->type());
265 if (value->isInitialValue()) { 260 if (value->isInitialValue()) {
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
651 verticalRule = SpaceImageRule; 646 verticalRule = SpaceImageRule;
652 break; 647 break;
653 default: // CSSValueRepeat 648 default: // CSSValueRepeat
654 verticalRule = RepeatImageRule; 649 verticalRule = RepeatImageRule;
655 break; 650 break;
656 } 651 }
657 image.setVerticalRule(verticalRule); 652 image.setVerticalRule(verticalRule);
658 } 653 }
659 654
660 }; 655 };
OLDNEW
« no previous file with comments | « Source/core/css/CSSPrimitiveValueMappings.h ('k') | Source/core/css/resolver/FilterOperationResolver.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698