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

Side by Side Diff: Source/core/css/parser/CSSPropertyParser.cpp

Issue 973623002: Fix serialization of content property to always quote (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix final test Created 5 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2003 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 2003 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) 3 * Copyright (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com)
4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. 4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved.
5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> 5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com>
6 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> 6 * Copyright (C) 2008 Eric Seidel <eric@webkit.org>
7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) 7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/)
8 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. 8 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved.
9 * Copyright (C) 2012 Intel Corporation. All rights reserved. 9 * Copyright (C) 2012 Intel Corporation. All rights reserved.
10 * 10 *
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 return CSSPrimitiveValue::create(m_parsedCalculation.release()); 313 return CSSPrimitiveValue::create(m_parsedCalculation.release());
314 } 314 }
315 315
316 ASSERT((value->unit >= CSSPrimitiveValue::CSS_NUMBER && value->unit <= CSSPr imitiveValue::CSS_KHZ) 316 ASSERT((value->unit >= CSSPrimitiveValue::CSS_NUMBER && value->unit <= CSSPr imitiveValue::CSS_KHZ)
317 || (value->unit >= CSSPrimitiveValue::CSS_TURN && value->unit <= CSSPrim itiveValue::CSS_CHS) 317 || (value->unit >= CSSPrimitiveValue::CSS_TURN && value->unit <= CSSPrim itiveValue::CSS_CHS)
318 || (value->unit >= CSSPrimitiveValue::CSS_VW && value->unit <= CSSPrimit iveValue::CSS_VMAX) 318 || (value->unit >= CSSPrimitiveValue::CSS_VW && value->unit <= CSSPrimit iveValue::CSS_VMAX)
319 || (value->unit >= CSSPrimitiveValue::CSS_DPPX && value->unit <= CSSPrim itiveValue::CSS_DPCM)); 319 || (value->unit >= CSSPrimitiveValue::CSS_DPPX && value->unit <= CSSPrim itiveValue::CSS_DPCM));
320 return cssValuePool().createValue(value->fValue, static_cast<CSSPrimitiveVal ue::UnitType>(value->unit)); 320 return cssValuePool().createValue(value->fValue, static_cast<CSSPrimitiveVal ue::UnitType>(value->unit));
321 } 321 }
322 322
323 inline PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::createPrimit iveStringValue(CSSParserValue* value) 323 inline PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::createPrimit iveStringValue(CSSParserValue* value, CSSPrimitiveValue::UnitType type)
324 { 324 {
325 ASSERT(value->unit == CSSPrimitiveValue::CSS_STRING || value->unit == CSSPri mitiveValue::CSS_IDENT); 325 ASSERT(value->unit == CSSPrimitiveValue::CSS_STRING || value->unit == CSSPri mitiveValue::CSS_IDENT);
326 return cssValuePool().createValue(value->string, CSSPrimitiveValue::CSS_STRI NG); 326 return cssValuePool().createValue(value->string, type);
327 } 327 }
328 328
329 inline PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::createCSSImageValueWi thReferrer(const String& rawValue, const KURL& url) 329 inline PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::createCSSImageValueWi thReferrer(const String& rawValue, const KURL& url)
330 { 330 {
331 RefPtrWillBeRawPtr<CSSValue> imageValue = CSSImageValue::create(rawValue, ur l); 331 RefPtrWillBeRawPtr<CSSValue> imageValue = CSSImageValue::create(rawValue, ur l);
332 toCSSImageValue(imageValue.get())->setReferrer(m_context.referrer()); 332 toCSSImageValue(imageValue.get())->setReferrer(m_context.referrer());
333 return imageValue; 333 return imageValue;
334 } 334 }
335 335
336 static inline bool isComma(CSSParserValue* value) 336 static inline bool isComma(CSSParserValue* value)
(...skipping 1877 matching lines...) Expand 10 before | Expand all | Expand 10 after
2214 case CSSValueCloseQuote: 2214 case CSSValueCloseQuote:
2215 case CSSValueNoOpenQuote: 2215 case CSSValueNoOpenQuote:
2216 case CSSValueNoCloseQuote: 2216 case CSSValueNoCloseQuote:
2217 case CSSValueNone: 2217 case CSSValueNone:
2218 case CSSValueNormal: 2218 case CSSValueNormal:
2219 parsedValue = cssValuePool().createIdentifierValue(val->id); 2219 parsedValue = cssValuePool().createIdentifierValue(val->id);
2220 default: 2220 default:
2221 break; 2221 break;
2222 } 2222 }
2223 } else if (val->unit == CSSPrimitiveValue::CSS_STRING) { 2223 } else if (val->unit == CSSPrimitiveValue::CSS_STRING) {
2224 parsedValue = createPrimitiveStringValue(val); 2224 parsedValue = createPrimitiveStringValue(val, CSSPrimitiveValue::CSS _STRING);
2225 } 2225 }
2226 if (!parsedValue) 2226 if (!parsedValue)
2227 break; 2227 break;
2228 values->append(parsedValue.release()); 2228 values->append(parsedValue.release());
2229 m_valueList->next(); 2229 m_valueList->next();
2230 } 2230 }
2231 2231
2232 if (values->length()) { 2232 if (values->length()) {
2233 addProperty(propId, values.release(), important); 2233 addProperty(propId, values.release(), important);
2234 m_valueList->next(); 2234 m_valueList->next();
(...skipping 1021 matching lines...) Expand 10 before | Expand all | Expand 10 after
3256 // If we didn't parse anything, this is not a valid grid position. 3256 // If we didn't parse anything, this is not a valid grid position.
3257 if (!hasSeenSpanKeyword && !gridLineName && !numericValue) 3257 if (!hasSeenSpanKeyword && !gridLineName && !numericValue)
3258 return nullptr; 3258 return nullptr;
3259 3259
3260 // Negative numbers are not allowed for span (but are for <integer>). 3260 // Negative numbers are not allowed for span (but are for <integer>).
3261 if (hasSeenSpanKeyword && numericValue && numericValue->getIntValue() < 0) 3261 if (hasSeenSpanKeyword && numericValue && numericValue->getIntValue() < 0)
3262 return nullptr; 3262 return nullptr;
3263 3263
3264 // For the <custom-ident> case. 3264 // For the <custom-ident> case.
3265 if (gridLineName && !numericValue && !hasSeenSpanKeyword) 3265 if (gridLineName && !numericValue && !hasSeenSpanKeyword)
3266 return cssValuePool().createValue(gridLineName->getStringValue(), CSSPri mitiveValue::CSS_STRING); 3266 return cssValuePool().createValue(gridLineName->getStringValue(), CSSPri mitiveValue::CSS_CUSTOM_IDENT);
3267 3267
3268 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createSpaceSeparated (); 3268 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createSpaceSeparated ();
3269 if (hasSeenSpanKeyword) 3269 if (hasSeenSpanKeyword)
3270 values->append(cssValuePool().createIdentifierValue(CSSValueSpan)); 3270 values->append(cssValuePool().createIdentifierValue(CSSValueSpan));
3271 if (numericValue) 3271 if (numericValue)
3272 values->append(numericValue.release()); 3272 values->append(numericValue.release());
3273 if (gridLineName) 3273 if (gridLineName)
3274 values->append(gridLineName.release()); 3274 values->append(gridLineName.release());
3275 ASSERT(values->length()); 3275 ASSERT(values->length());
3276 return values.release(); 3276 return values.release();
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after
3844 if (!counters && numArgs != 1 && numArgs != 3) 3844 if (!counters && numArgs != 1 && numArgs != 3)
3845 return nullptr; 3845 return nullptr;
3846 3846
3847 CSSParserValue* i = args->current(); 3847 CSSParserValue* i = args->current();
3848 if (i->unit != CSSPrimitiveValue::CSS_IDENT) 3848 if (i->unit != CSSPrimitiveValue::CSS_IDENT)
3849 return nullptr; 3849 return nullptr;
3850 RefPtrWillBeRawPtr<CSSPrimitiveValue> identifier = createPrimitiveStringValu e(i); 3850 RefPtrWillBeRawPtr<CSSPrimitiveValue> identifier = createPrimitiveStringValu e(i);
3851 3851
3852 RefPtrWillBeRawPtr<CSSPrimitiveValue> separator = nullptr; 3852 RefPtrWillBeRawPtr<CSSPrimitiveValue> separator = nullptr;
3853 if (!counters) 3853 if (!counters)
3854 separator = cssValuePool().createValue(String(), CSSPrimitiveValue::CSS_ STRING); 3854 separator = cssValuePool().createValue(String(), CSSPrimitiveValue::CSS_ CUSTOM_IDENT);
3855 else { 3855 else {
3856 args->next(); 3856 args->next();
3857 if (!consumeComma(args)) 3857 if (!consumeComma(args))
3858 return nullptr; 3858 return nullptr;
3859 3859
3860 i = args->current(); 3860 i = args->current();
3861 if (i->unit != CSSPrimitiveValue::CSS_STRING) 3861 if (i->unit != CSSPrimitiveValue::CSS_STRING)
3862 return nullptr; 3862 return nullptr;
3863 3863
3864 separator = createPrimitiveStringValue(i); 3864 separator = createPrimitiveStringValue(i);
(...skipping 4612 matching lines...) Expand 10 before | Expand all | Expand 10 after
8477 } 8477 }
8478 } 8478 }
8479 8479
8480 if (!list->length()) 8480 if (!list->length())
8481 return nullptr; 8481 return nullptr;
8482 8482
8483 return list.release(); 8483 return list.release();
8484 } 8484 }
8485 8485
8486 } // namespace blink 8486 } // namespace blink
OLDNEW
« Source/core/css/LayoutStyleCSSValueMapping.cpp ('K') | « Source/core/css/parser/CSSPropertyParser.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698