Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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_CUSTOM_IDENT || value->unit == CSSPrimitiveValue::CSS_IDENT); |
|
Timothy Loh
2015/03/03 23:20:15
I guess this check should stay as CSS_STRING || CS
| |
| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 378 int id = value->id; | 378 int id = value->id; |
| 379 if (id == CSSValueIntrinsic || id == CSSValueMinIntrinsic || id == CSSValueW ebkitMinContent || id == CSSValueWebkitMaxContent || id == CSSValueWebkitFillAva ilable || id == CSSValueWebkitFitContent) | 379 if (id == CSSValueIntrinsic || id == CSSValueMinIntrinsic || id == CSSValueW ebkitMinContent || id == CSSValueWebkitMaxContent || id == CSSValueWebkitFillAva ilable || id == CSSValueWebkitFitContent) |
| 380 return true; | 380 return true; |
| 381 return !id && validUnit(value, FLength | FPercent | FNonNeg | unitless); | 381 return !id && validUnit(value, FLength | FPercent | FNonNeg | unitless); |
| 382 } | 382 } |
| 383 | 383 |
| 384 inline PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::parseValidPr imitive(CSSValueID identifier, CSSParserValue* value) | 384 inline PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::parseValidPr imitive(CSSValueID identifier, CSSParserValue* value) |
| 385 { | 385 { |
| 386 if (identifier) | 386 if (identifier) |
| 387 return cssValuePool().createIdentifierValue(identifier); | 387 return cssValuePool().createIdentifierValue(identifier); |
| 388 if (value->unit == CSSPrimitiveValue::CSS_STRING) | 388 if (value->unit == CSSPrimitiveValue::CSS_CUSTOM_IDENT) |
| 389 return createPrimitiveStringValue(value); | 389 return createPrimitiveStringValue(value); |
| 390 if (value->unit >= CSSPrimitiveValue::CSS_NUMBER && value->unit <= CSSPrimit iveValue::CSS_KHZ) | 390 if (value->unit >= CSSPrimitiveValue::CSS_NUMBER && value->unit <= CSSPrimit iveValue::CSS_KHZ) |
| 391 return createPrimitiveNumericValue(value); | 391 return createPrimitiveNumericValue(value); |
| 392 if (value->unit >= CSSPrimitiveValue::CSS_TURN && value->unit <= CSSPrimitiv eValue::CSS_CHS) | 392 if (value->unit >= CSSPrimitiveValue::CSS_TURN && value->unit <= CSSPrimitiv eValue::CSS_CHS) |
| 393 return createPrimitiveNumericValue(value); | 393 return createPrimitiveNumericValue(value); |
| 394 if (value->unit >= CSSPrimitiveValue::CSS_VW && value->unit <= CSSPrimitiveV alue::CSS_VMAX) | 394 if (value->unit >= CSSPrimitiveValue::CSS_VW && value->unit <= CSSPrimitiveV alue::CSS_VMAX) |
| 395 return createPrimitiveNumericValue(value); | 395 return createPrimitiveNumericValue(value); |
| 396 if (value->unit >= CSSPrimitiveValue::CSS_DPPX && value->unit <= CSSPrimitiv eValue::CSS_DPCM) | 396 if (value->unit >= CSSPrimitiveValue::CSS_DPPX && value->unit <= CSSPrimitiv eValue::CSS_DPCM) |
| 397 return createPrimitiveNumericValue(value); | 397 return createPrimitiveNumericValue(value); |
| 398 if (value->unit >= CSSParserValue::Q_EMS) | 398 if (value->unit >= CSSParserValue::Q_EMS) |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 516 else | 516 else |
| 517 overflowXValue = m_parsedProperties.last().value(); | 517 overflowXValue = m_parsedProperties.last().value(); |
| 518 addProperty(CSSPropertyOverflowX, overflowXValue.release(), important); | 518 addProperty(CSSPropertyOverflowX, overflowXValue.release(), important); |
| 519 return true; | 519 return true; |
| 520 } | 520 } |
| 521 | 521 |
| 522 case CSSPropertyTextAlign: | 522 case CSSPropertyTextAlign: |
| 523 // left | right | center | justify | -webkit-left | -webkit-right | -web kit-center | -webkit-match-parent | 523 // left | right | center | justify | -webkit-left | -webkit-right | -web kit-center | -webkit-match-parent |
| 524 // | start | end | <string> | inherit | -webkit-auto (converted to start ) | 524 // | start | end | <string> | inherit | -webkit-auto (converted to start ) |
| 525 if ((id >= CSSValueWebkitAuto && id <= CSSValueWebkitMatchParent) || id == CSSValueStart || id == CSSValueEnd | 525 if ((id >= CSSValueWebkitAuto && id <= CSSValueWebkitMatchParent) || id == CSSValueStart || id == CSSValueEnd |
| 526 || value->unit == CSSPrimitiveValue::CSS_STRING) | 526 || value->unit == CSSPrimitiveValue::CSS_CUSTOM_IDENT) |
| 527 validPrimitive = true; | 527 validPrimitive = true; |
| 528 break; | 528 break; |
| 529 | 529 |
| 530 case CSSPropertyFontWeight: { // normal | bold | bolder | lighter | 100 | 2 00 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | inherit | 530 case CSSPropertyFontWeight: { // normal | bold | bolder | lighter | 100 | 2 00 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | inherit |
| 531 if (m_valueList->size() != 1) | 531 if (m_valueList->size() != 1) |
| 532 return false; | 532 return false; |
| 533 return parseFontWeight(important); | 533 return parseFontWeight(important); |
| 534 } | 534 } |
| 535 | 535 |
| 536 case CSSPropertyBorderSpacing: { | 536 case CSSPropertyBorderSpacing: { |
| (...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1322 // When specifying number of lines, don't allow 0 as a valid value | 1322 // When specifying number of lines, don't allow 0 as a valid value |
| 1323 // When specifying either type of unit, require non-negative integers | 1323 // When specifying either type of unit, require non-negative integers |
| 1324 validPrimitive = (!id && (value->unit == CSSPrimitiveValue::CSS_PERCENTA GE || value->fValue) && validUnit(value, FInteger | FPercent | FNonNeg)); | 1324 validPrimitive = (!id && (value->unit == CSSPrimitiveValue::CSS_PERCENTA GE || value->fValue) && validUnit(value, FInteger | FPercent | FNonNeg)); |
| 1325 break; | 1325 break; |
| 1326 | 1326 |
| 1327 case CSSPropertyWebkitFontSizeDelta: // <length> | 1327 case CSSPropertyWebkitFontSizeDelta: // <length> |
| 1328 validPrimitive = validUnit(value, FLength | FUnitlessQuirk); | 1328 validPrimitive = validUnit(value, FLength | FUnitlessQuirk); |
| 1329 break; | 1329 break; |
| 1330 | 1330 |
| 1331 case CSSPropertyWebkitHighlight: | 1331 case CSSPropertyWebkitHighlight: |
| 1332 if (id == CSSValueNone || value->unit == CSSPrimitiveValue::CSS_STRING) | 1332 if (id == CSSValueNone || value->unit == CSSPrimitiveValue::CSS_CUSTOM_I DENT) |
| 1333 validPrimitive = true; | 1333 validPrimitive = true; |
| 1334 break; | 1334 break; |
| 1335 | 1335 |
| 1336 case CSSPropertyWebkitHyphenateCharacter: | 1336 case CSSPropertyWebkitHyphenateCharacter: |
| 1337 if (id == CSSValueAuto || value->unit == CSSPrimitiveValue::CSS_STRING) | 1337 if (id == CSSValueAuto || value->unit == CSSPrimitiveValue::CSS_CUSTOM_I DENT) |
| 1338 validPrimitive = true; | 1338 validPrimitive = true; |
| 1339 break; | 1339 break; |
| 1340 | 1340 |
| 1341 case CSSPropertyWebkitLocale: | 1341 case CSSPropertyWebkitLocale: |
| 1342 if (id == CSSValueAuto || value->unit == CSSPrimitiveValue::CSS_STRING) | 1342 if (id == CSSValueAuto || value->unit == CSSPrimitiveValue::CSS_CUSTOM_I DENT) |
| 1343 validPrimitive = true; | 1343 validPrimitive = true; |
| 1344 break; | 1344 break; |
| 1345 | 1345 |
| 1346 // End Apple-specific properties | 1346 // End Apple-specific properties |
| 1347 | 1347 |
| 1348 case CSSPropertyWebkitAppRegion: | 1348 case CSSPropertyWebkitAppRegion: |
| 1349 if (id >= CSSValueDrag && id <= CSSValueNoDrag) | 1349 if (id >= CSSValueDrag && id <= CSSValueNoDrag) |
| 1350 validPrimitive = true; | 1350 validPrimitive = true; |
| 1351 break; | 1351 break; |
| 1352 | 1352 |
| (...skipping 795 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2148 return None; | 2148 return None; |
| 2149 } | 2149 } |
| 2150 } | 2150 } |
| 2151 | 2151 |
| 2152 // [ <string> <string> ]+ | none, but none is handled in parseValue | 2152 // [ <string> <string> ]+ | none, but none is handled in parseValue |
| 2153 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseQuotes() | 2153 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseQuotes() |
| 2154 { | 2154 { |
| 2155 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createCommaSeparated (); | 2155 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createCommaSeparated (); |
| 2156 while (CSSParserValue* val = m_valueList->current()) { | 2156 while (CSSParserValue* val = m_valueList->current()) { |
| 2157 RefPtrWillBeRawPtr<CSSValue> parsedValue = nullptr; | 2157 RefPtrWillBeRawPtr<CSSValue> parsedValue = nullptr; |
| 2158 if (val->unit != CSSPrimitiveValue::CSS_STRING) | 2158 if (val->unit != CSSPrimitiveValue::CSS_CUSTOM_IDENT) |
| 2159 return nullptr; | 2159 return nullptr; |
| 2160 parsedValue = CSSPrimitiveValue::create(val->string, CSSPrimitiveValue:: CSS_STRING); | 2160 parsedValue = CSSPrimitiveValue::create(val->string, CSSPrimitiveValue:: CSS_CUSTOM_IDENT); |
|
Timothy Loh
2015/03/03 23:20:15
CSS_STRING
| |
| 2161 values->append(parsedValue.release()); | 2161 values->append(parsedValue.release()); |
| 2162 m_valueList->next(); | 2162 m_valueList->next(); |
| 2163 } | 2163 } |
| 2164 if (values->length() && values->length() % 2 == 0) | 2164 if (values->length() && values->length() % 2 == 0) |
| 2165 return values.release(); | 2165 return values.release(); |
| 2166 return nullptr; | 2166 return nullptr; |
| 2167 } | 2167 } |
| 2168 | 2168 |
| 2169 // [ <string> | <uri> | <counter> | attr(X) | open-quote | close-quote | no-open -quote | no-close-quote ]+ | inherit | 2169 // [ <string> | <uri> | <counter> | attr(X) | open-quote | close-quote | no-open -quote | no-close-quote ]+ | inherit |
| 2170 // in CSS 2.1 this got somewhat reduced: | 2170 // in CSS 2.1 this got somewhat reduced: |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2209 case CSSValueOpenQuote: | 2209 case CSSValueOpenQuote: |
| 2210 case CSSValueCloseQuote: | 2210 case CSSValueCloseQuote: |
| 2211 case CSSValueNoOpenQuote: | 2211 case CSSValueNoOpenQuote: |
| 2212 case CSSValueNoCloseQuote: | 2212 case CSSValueNoCloseQuote: |
| 2213 case CSSValueNone: | 2213 case CSSValueNone: |
| 2214 case CSSValueNormal: | 2214 case CSSValueNormal: |
| 2215 parsedValue = cssValuePool().createIdentifierValue(val->id); | 2215 parsedValue = cssValuePool().createIdentifierValue(val->id); |
| 2216 default: | 2216 default: |
| 2217 break; | 2217 break; |
| 2218 } | 2218 } |
| 2219 } else if (val->unit == CSSPrimitiveValue::CSS_STRING) { | 2219 } else if (val->unit == CSSPrimitiveValue::CSS_CUSTOM_IDENT) { |
| 2220 parsedValue = createPrimitiveStringValue(val); | 2220 parsedValue = createPrimitiveStringValue(val, CSSPrimitiveValue::CSS _STRING); |
| 2221 } | 2221 } |
| 2222 if (!parsedValue) | 2222 if (!parsedValue) |
| 2223 break; | 2223 break; |
| 2224 values->append(parsedValue.release()); | 2224 values->append(parsedValue.release()); |
| 2225 m_valueList->next(); | 2225 m_valueList->next(); |
| 2226 } | 2226 } |
| 2227 | 2227 |
| 2228 if (values->length()) { | 2228 if (values->length()) { |
| 2229 addProperty(propId, values.release(), important); | 2229 addProperty(propId, values.release(), important); |
| 2230 m_valueList->next(); | 2230 m_valueList->next(); |
| (...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2956 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAnimationName(bool allo wQuotedName) | 2956 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAnimationName(bool allo wQuotedName) |
| 2957 { | 2957 { |
| 2958 CSSParserValue* value = m_valueList->current(); | 2958 CSSParserValue* value = m_valueList->current(); |
| 2959 | 2959 |
| 2960 if (value->id == CSSValueNone) | 2960 if (value->id == CSSValueNone) |
| 2961 return cssValuePool().createIdentifierValue(CSSValueNone); | 2961 return cssValuePool().createIdentifierValue(CSSValueNone); |
| 2962 | 2962 |
| 2963 if (value->unit == CSSPrimitiveValue::CSS_IDENT) | 2963 if (value->unit == CSSPrimitiveValue::CSS_IDENT) |
| 2964 return createPrimitiveStringValue(value); | 2964 return createPrimitiveStringValue(value); |
| 2965 | 2965 |
| 2966 if (allowQuotedName && value->unit == CSSPrimitiveValue::CSS_STRING) { | 2966 if (allowQuotedName && value->unit == CSSPrimitiveValue::CSS_CUSTOM_IDENT) { |
| 2967 // Legacy support for strings in prefixed animations | 2967 // Legacy support for strings in prefixed animations |
| 2968 if (m_context.useCounter()) | 2968 if (m_context.useCounter()) |
| 2969 m_context.useCounter()->count(UseCounter::QuotedAnimationName); | 2969 m_context.useCounter()->count(UseCounter::QuotedAnimationName); |
| 2970 if (equalIgnoringCase(value->string, "none")) | 2970 if (equalIgnoringCase(value->string, "none")) |
| 2971 return cssValuePool().createIdentifierValue(CSSValueNone); | 2971 return cssValuePool().createIdentifierValue(CSSValueNone); |
| 2972 return createPrimitiveStringValue(value); | 2972 return createPrimitiveStringValue(value); |
| 2973 } | 2973 } |
| 2974 | 2974 |
| 2975 return nullptr; | 2975 return nullptr; |
| 2976 } | 2976 } |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3252 // If we didn't parse anything, this is not a valid grid position. | 3252 // If we didn't parse anything, this is not a valid grid position. |
| 3253 if (!hasSeenSpanKeyword && !gridLineName && !numericValue) | 3253 if (!hasSeenSpanKeyword && !gridLineName && !numericValue) |
| 3254 return nullptr; | 3254 return nullptr; |
| 3255 | 3255 |
| 3256 // Negative numbers are not allowed for span (but are for <integer>). | 3256 // Negative numbers are not allowed for span (but are for <integer>). |
| 3257 if (hasSeenSpanKeyword && numericValue && numericValue->getIntValue() < 0) | 3257 if (hasSeenSpanKeyword && numericValue && numericValue->getIntValue() < 0) |
| 3258 return nullptr; | 3258 return nullptr; |
| 3259 | 3259 |
| 3260 // For the <custom-ident> case. | 3260 // For the <custom-ident> case. |
| 3261 if (gridLineName && !numericValue && !hasSeenSpanKeyword) | 3261 if (gridLineName && !numericValue && !hasSeenSpanKeyword) |
| 3262 return cssValuePool().createValue(gridLineName->getStringValue(), CSSPri mitiveValue::CSS_STRING); | 3262 return cssValuePool().createValue(gridLineName->getStringValue(), CSSPri mitiveValue::CSS_CUSTOM_IDENT); |
| 3263 | 3263 |
| 3264 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createSpaceSeparated (); | 3264 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createSpaceSeparated (); |
| 3265 if (hasSeenSpanKeyword) | 3265 if (hasSeenSpanKeyword) |
| 3266 values->append(cssValuePool().createIdentifierValue(CSSValueSpan)); | 3266 values->append(cssValuePool().createIdentifierValue(CSSValueSpan)); |
| 3267 if (numericValue) | 3267 if (numericValue) |
| 3268 values->append(numericValue.release()); | 3268 values->append(numericValue.release()); |
| 3269 if (gridLineName) | 3269 if (gridLineName) |
| 3270 values->append(gridLineName.release()); | 3270 values->append(gridLineName.release()); |
| 3271 ASSERT(values->length()); | 3271 ASSERT(values->length()); |
| 3272 return values.release(); | 3272 return values.release(); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3330 } else { | 3330 } else { |
| 3331 maybeParseGridLineNames(*m_valueList, *templateRows); | 3331 maybeParseGridLineNames(*m_valueList, *templateRows); |
| 3332 } | 3332 } |
| 3333 | 3333 |
| 3334 // Handle a template-area's row. | 3334 // Handle a template-area's row. |
| 3335 if (!parseGridTemplateAreasRow(gridAreaMap, rowCount, columnCount)) | 3335 if (!parseGridTemplateAreasRow(gridAreaMap, rowCount, columnCount)) |
| 3336 return false; | 3336 return false; |
| 3337 ++rowCount; | 3337 ++rowCount; |
| 3338 | 3338 |
| 3339 // Handle template-rows's track-size. | 3339 // Handle template-rows's track-size. |
| 3340 if (m_valueList->current() && m_valueList->current()->unit != CSSParserV alue::ValueList && m_valueList->current()->unit != CSSPrimitiveValue::CSS_STRING ) { | 3340 if (m_valueList->current() && m_valueList->current()->unit != CSSParserV alue::ValueList && m_valueList->current()->unit != CSSPrimitiveValue::CSS_CUSTOM _IDENT) { |
| 3341 RefPtrWillBeRawPtr<CSSValue> value = parseGridTrackSize(*m_valueList ); | 3341 RefPtrWillBeRawPtr<CSSValue> value = parseGridTrackSize(*m_valueList ); |
| 3342 if (!value) | 3342 if (!value) |
| 3343 return false; | 3343 return false; |
| 3344 templateRows->append(value); | 3344 templateRows->append(value); |
| 3345 } else { | 3345 } else { |
| 3346 templateRows->append(cssValuePool().createIdentifierValue(CSSValueAu to)); | 3346 templateRows->append(cssValuePool().createIdentifierValue(CSSValueAu to)); |
| 3347 } | 3347 } |
| 3348 | 3348 |
| 3349 // This will handle the trailing/leading <custom-ident>* in the grammar. | 3349 // This will handle the trailing/leading <custom-ident>* in the grammar. |
| 3350 const CSSParserValue* current = m_valueList->current(); | 3350 const CSSParserValue* current = m_valueList->current(); |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3707 | 3707 |
| 3708 if (!validUnit(currentValue, FNonNeg | FLength | FPercent)) | 3708 if (!validUnit(currentValue, FNonNeg | FLength | FPercent)) |
| 3709 return nullptr; | 3709 return nullptr; |
| 3710 | 3710 |
| 3711 return createPrimitiveNumericValue(currentValue); | 3711 return createPrimitiveNumericValue(currentValue); |
| 3712 } | 3712 } |
| 3713 | 3713 |
| 3714 bool CSSPropertyParser::parseGridTemplateAreasRow(NamedGridAreaMap& gridAreaMap, const size_t rowCount, size_t& columnCount) | 3714 bool CSSPropertyParser::parseGridTemplateAreasRow(NamedGridAreaMap& gridAreaMap, const size_t rowCount, size_t& columnCount) |
| 3715 { | 3715 { |
| 3716 CSSParserValue* currentValue = m_valueList->current(); | 3716 CSSParserValue* currentValue = m_valueList->current(); |
| 3717 if (!currentValue || currentValue->unit != CSSPrimitiveValue::CSS_STRING) | 3717 if (!currentValue || currentValue->unit != CSSPrimitiveValue::CSS_CUSTOM_IDE NT) |
| 3718 return false; | 3718 return false; |
| 3719 | 3719 |
| 3720 String gridRowNames = currentValue->string; | 3720 String gridRowNames = currentValue->string; |
| 3721 if (gridRowNames.isEmpty() || gridRowNames.containsOnlyWhitespace()) | 3721 if (gridRowNames.isEmpty() || gridRowNames.containsOnlyWhitespace()) |
| 3722 return false; | 3722 return false; |
| 3723 | 3723 |
| 3724 Vector<String> columnNames; | 3724 Vector<String> columnNames; |
| 3725 gridRowNames.split(' ', columnNames); | 3725 gridRowNames.split(' ', columnNames); |
| 3726 | 3726 |
| 3727 if (!columnCount) { | 3727 if (!columnCount) { |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3840 if (!counters && numArgs != 1 && numArgs != 3) | 3840 if (!counters && numArgs != 1 && numArgs != 3) |
| 3841 return nullptr; | 3841 return nullptr; |
| 3842 | 3842 |
| 3843 CSSParserValue* i = args->current(); | 3843 CSSParserValue* i = args->current(); |
| 3844 if (i->unit != CSSPrimitiveValue::CSS_IDENT) | 3844 if (i->unit != CSSPrimitiveValue::CSS_IDENT) |
| 3845 return nullptr; | 3845 return nullptr; |
| 3846 RefPtrWillBeRawPtr<CSSPrimitiveValue> identifier = createPrimitiveStringValu e(i); | 3846 RefPtrWillBeRawPtr<CSSPrimitiveValue> identifier = createPrimitiveStringValu e(i); |
| 3847 | 3847 |
| 3848 RefPtrWillBeRawPtr<CSSPrimitiveValue> separator = nullptr; | 3848 RefPtrWillBeRawPtr<CSSPrimitiveValue> separator = nullptr; |
| 3849 if (!counters) | 3849 if (!counters) |
| 3850 separator = cssValuePool().createValue(String(), CSSPrimitiveValue::CSS_ STRING); | 3850 separator = cssValuePool().createValue(String(), CSSPrimitiveValue::CSS_ CUSTOM_IDENT); |
| 3851 else { | 3851 else { |
| 3852 args->next(); | 3852 args->next(); |
| 3853 if (!consumeComma(args)) | 3853 if (!consumeComma(args)) |
| 3854 return nullptr; | 3854 return nullptr; |
| 3855 | 3855 |
| 3856 i = args->current(); | 3856 i = args->current(); |
| 3857 if (i->unit != CSSPrimitiveValue::CSS_STRING) | 3857 if (i->unit != CSSPrimitiveValue::CSS_CUSTOM_IDENT) |
| 3858 return nullptr; | 3858 return nullptr; |
| 3859 | 3859 |
| 3860 separator = createPrimitiveStringValue(i); | 3860 separator = createPrimitiveStringValue(i); |
| 3861 } | 3861 } |
| 3862 | 3862 |
| 3863 RefPtrWillBeRawPtr<CSSPrimitiveValue> listStyle = nullptr; | 3863 RefPtrWillBeRawPtr<CSSPrimitiveValue> listStyle = nullptr; |
| 3864 i = args->next(); | 3864 i = args->next(); |
| 3865 if (!i) // Make the list style default decimal | 3865 if (!i) // Make the list style default decimal |
| 3866 listStyle = cssValuePool().createIdentifierValue(CSSValueDecimal); | 3866 listStyle = cssValuePool().createIdentifierValue(CSSValueDecimal); |
| 3867 else { | 3867 else { |
| (...skipping 741 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4609 CSSParserValue* value = m_valueList->current(); | 4609 CSSParserValue* value = m_valueList->current(); |
| 4610 | 4610 |
| 4611 FontFamilyValueBuilder familyBuilder(list.get()); | 4611 FontFamilyValueBuilder familyBuilder(list.get()); |
| 4612 bool inFamily = false; | 4612 bool inFamily = false; |
| 4613 | 4613 |
| 4614 while (value) { | 4614 while (value) { |
| 4615 CSSParserValue* nextValue = m_valueList->next(); | 4615 CSSParserValue* nextValue = m_valueList->next(); |
| 4616 bool nextValBreaksFont = !nextValue || isComma(nextValue); | 4616 bool nextValBreaksFont = !nextValue || isComma(nextValue); |
| 4617 bool nextValIsFontName = nextValue && | 4617 bool nextValIsFontName = nextValue && |
| 4618 ((nextValue->id >= CSSValueSerif && nextValue->id <= CSSValueWebkitB ody) || | 4618 ((nextValue->id >= CSSValueSerif && nextValue->id <= CSSValueWebkitB ody) || |
| 4619 (nextValue->unit == CSSPrimitiveValue::CSS_STRING || nextValue->unit == CSSPrimitiveValue::CSS_IDENT)); | 4619 (nextValue->unit == CSSPrimitiveValue::CSS_CUSTOM_IDENT || nextValue ->unit == CSSPrimitiveValue::CSS_IDENT)); |
| 4620 | 4620 |
| 4621 if (isCSSWideKeyword(*value) && !inFamily) { | 4621 if (isCSSWideKeyword(*value) && !inFamily) { |
| 4622 if (nextValBreaksFont) | 4622 if (nextValBreaksFont) |
| 4623 value = m_valueList->next(); | 4623 value = m_valueList->next(); |
| 4624 else if (nextValIsFontName) | 4624 else if (nextValIsFontName) |
| 4625 value = nextValue; | 4625 value = nextValue; |
| 4626 continue; | 4626 continue; |
| 4627 } | 4627 } |
| 4628 | 4628 |
| 4629 if (value->id >= CSSValueSerif && value->id <= CSSValueWebkitBody) { | 4629 if (value->id >= CSSValueSerif && value->id <= CSSValueWebkitBody) { |
| 4630 if (inFamily) | 4630 if (inFamily) |
| 4631 familyBuilder.add(value->string); | 4631 familyBuilder.add(value->string); |
| 4632 else if (nextValBreaksFont || !nextValIsFontName) | 4632 else if (nextValBreaksFont || !nextValIsFontName) |
| 4633 list->append(cssValuePool().createIdentifierValue(value->id)); | 4633 list->append(cssValuePool().createIdentifierValue(value->id)); |
| 4634 else { | 4634 else { |
| 4635 familyBuilder.commit(); | 4635 familyBuilder.commit(); |
| 4636 familyBuilder.add(value->string); | 4636 familyBuilder.add(value->string); |
| 4637 inFamily = true; | 4637 inFamily = true; |
| 4638 } | 4638 } |
| 4639 } else if (value->unit == CSSPrimitiveValue::CSS_STRING) { | 4639 } else if (value->unit == CSSPrimitiveValue::CSS_CUSTOM_IDENT) { |
| 4640 // Strings never share in a family name. | 4640 // Strings never share in a family name. |
| 4641 inFamily = false; | 4641 inFamily = false; |
| 4642 familyBuilder.commit(); | 4642 familyBuilder.commit(); |
| 4643 list->append(cssValuePool().createFontFamilyValue(value->string)); | 4643 list->append(cssValuePool().createFontFamilyValue(value->string)); |
| 4644 } else if (value->unit == CSSPrimitiveValue::CSS_IDENT) { | 4644 } else if (value->unit == CSSPrimitiveValue::CSS_IDENT) { |
| 4645 if (inFamily) | 4645 if (inFamily) |
| 4646 familyBuilder.add(value->string); | 4646 familyBuilder.add(value->string); |
| 4647 else if (nextValBreaksFont || !nextValIsFontName) | 4647 else if (nextValBreaksFont || !nextValIsFontName) |
| 4648 list->append(cssValuePool().createFontFamilyValue(value->string) ); | 4648 list->append(cssValuePool().createFontFamilyValue(value->string) ); |
| 4649 else { | 4649 else { |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4784 | 4784 |
| 4785 CSSParserValue* value = m_valueList->next(); | 4785 CSSParserValue* value = m_valueList->next(); |
| 4786 if (!value || value->unit != CSSParserValue::Function || value->function->id != CSSValueFormat) { | 4786 if (!value || value->unit != CSSParserValue::Function || value->function->id != CSSValueFormat) { |
| 4787 valueList->append(uriValue.release()); | 4787 valueList->append(uriValue.release()); |
| 4788 return true; | 4788 return true; |
| 4789 } | 4789 } |
| 4790 | 4790 |
| 4791 // FIXME: http://www.w3.org/TR/2011/WD-css3-fonts-20111004/ says that format () contains a comma-separated list of strings, | 4791 // FIXME: http://www.w3.org/TR/2011/WD-css3-fonts-20111004/ says that format () contains a comma-separated list of strings, |
| 4792 // but CSSFontFaceSrcValue stores only one format. Allowing one format for n ow. | 4792 // but CSSFontFaceSrcValue stores only one format. Allowing one format for n ow. |
| 4793 CSSParserValueList* args = value->function->args.get(); | 4793 CSSParserValueList* args = value->function->args.get(); |
| 4794 if (!args || args->size() != 1 || (args->current()->unit != CSSPrimitiveValu e::CSS_STRING && args->current()->unit != CSSPrimitiveValue::CSS_IDENT)) | 4794 if (!args || args->size() != 1 || (args->current()->unit != CSSPrimitiveValu e::CSS_CUSTOM_IDENT && args->current()->unit != CSSPrimitiveValue::CSS_IDENT)) |
| 4795 return false; | 4795 return false; |
| 4796 uriValue->setFormat(args->current()->string); | 4796 uriValue->setFormat(args->current()->string); |
| 4797 valueList->append(uriValue.release()); | 4797 valueList->append(uriValue.release()); |
| 4798 m_valueList->next(); | 4798 m_valueList->next(); |
| 4799 return true; | 4799 return true; |
| 4800 } | 4800 } |
| 4801 | 4801 |
| 4802 bool CSSPropertyParser::parseFontFaceSrcLocal(CSSValueList* valueList) | 4802 bool CSSPropertyParser::parseFontFaceSrcLocal(CSSValueList* valueList) |
| 4803 { | 4803 { |
| 4804 CSSParserValueList* args = m_valueList->current()->function->args.get(); | 4804 CSSParserValueList* args = m_valueList->current()->function->args.get(); |
| 4805 if (!args || !args->size()) | 4805 if (!args || !args->size()) |
| 4806 return false; | 4806 return false; |
| 4807 m_valueList->next(); | 4807 m_valueList->next(); |
| 4808 | 4808 |
| 4809 ContentSecurityPolicyDisposition shouldCheckContentSecurityPolicy = m_contex t.shouldCheckContentSecurityPolicy(); | 4809 ContentSecurityPolicyDisposition shouldCheckContentSecurityPolicy = m_contex t.shouldCheckContentSecurityPolicy(); |
| 4810 if (args->size() == 1 && args->current()->unit == CSSPrimitiveValue::CSS_STR ING) | 4810 if (args->size() == 1 && args->current()->unit == CSSPrimitiveValue::CSS_CUS TOM_IDENT) |
| 4811 valueList->append(CSSFontFaceSrcValue::createLocal(args->current()->stri ng, shouldCheckContentSecurityPolicy)); | 4811 valueList->append(CSSFontFaceSrcValue::createLocal(args->current()->stri ng, shouldCheckContentSecurityPolicy)); |
| 4812 else if (args->current()->unit == CSSPrimitiveValue::CSS_IDENT) { | 4812 else if (args->current()->unit == CSSPrimitiveValue::CSS_IDENT) { |
| 4813 StringBuilder builder; | 4813 StringBuilder builder; |
| 4814 for (CSSParserValue* localValue = args->current(); localValue; localValu e = args->next()) { | 4814 for (CSSParserValue* localValue = args->current(); localValue; localValu e = args->next()) { |
| 4815 if (localValue->unit != CSSPrimitiveValue::CSS_IDENT) | 4815 if (localValue->unit != CSSPrimitiveValue::CSS_IDENT) |
| 4816 return false; | 4816 return false; |
| 4817 if (!builder.isEmpty()) | 4817 if (!builder.isEmpty()) |
| 4818 builder.append(' '); | 4818 builder.append(' '); |
| 4819 builder.append(localValue->string); | 4819 builder.append(localValue->string); |
| 4820 } | 4820 } |
| (...skipping 2657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7478 | 7478 |
| 7479 return false; | 7479 return false; |
| 7480 } | 7480 } |
| 7481 | 7481 |
| 7482 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseTextEmphasisStyle() | 7482 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseTextEmphasisStyle() |
| 7483 { | 7483 { |
| 7484 RefPtrWillBeRawPtr<CSSPrimitiveValue> fill = nullptr; | 7484 RefPtrWillBeRawPtr<CSSPrimitiveValue> fill = nullptr; |
| 7485 RefPtrWillBeRawPtr<CSSPrimitiveValue> shape = nullptr; | 7485 RefPtrWillBeRawPtr<CSSPrimitiveValue> shape = nullptr; |
| 7486 | 7486 |
| 7487 for (CSSParserValue* value = m_valueList->current(); value; value = m_valueL ist->next()) { | 7487 for (CSSParserValue* value = m_valueList->current(); value; value = m_valueL ist->next()) { |
| 7488 if (value->unit == CSSPrimitiveValue::CSS_STRING) { | 7488 if (value->unit == CSSPrimitiveValue::CSS_CUSTOM_IDENT) { |
| 7489 if (fill || shape) | 7489 if (fill || shape) |
| 7490 return nullptr; | 7490 return nullptr; |
| 7491 m_valueList->next(); | 7491 m_valueList->next(); |
| 7492 return createPrimitiveStringValue(value); | 7492 return createPrimitiveStringValue(value); |
| 7493 } | 7493 } |
| 7494 | 7494 |
| 7495 if (value->id == CSSValueNone) { | 7495 if (value->id == CSSValueNone) { |
| 7496 if (fill || shape) | 7496 if (fill || shape) |
| 7497 return nullptr; | 7497 return nullptr; |
| 7498 m_valueList->next(); | 7498 m_valueList->next(); |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7595 return CSSLineBoxContainValue::create(lineBoxContain); | 7595 return CSSLineBoxContainValue::create(lineBoxContain); |
| 7596 } | 7596 } |
| 7597 | 7597 |
| 7598 bool CSSPropertyParser::parseFontFeatureTag(CSSValueList* settings) | 7598 bool CSSPropertyParser::parseFontFeatureTag(CSSValueList* settings) |
| 7599 { | 7599 { |
| 7600 // Feature tag name consists of 4-letter characters. | 7600 // Feature tag name consists of 4-letter characters. |
| 7601 static const unsigned tagNameLength = 4; | 7601 static const unsigned tagNameLength = 4; |
| 7602 | 7602 |
| 7603 CSSParserValue* value = m_valueList->current(); | 7603 CSSParserValue* value = m_valueList->current(); |
| 7604 // Feature tag name comes first | 7604 // Feature tag name comes first |
| 7605 if (value->unit != CSSPrimitiveValue::CSS_STRING) | 7605 if (value->unit != CSSPrimitiveValue::CSS_CUSTOM_IDENT) |
| 7606 return false; | 7606 return false; |
| 7607 if (value->string.length() != tagNameLength) | 7607 if (value->string.length() != tagNameLength) |
| 7608 return false; | 7608 return false; |
| 7609 for (unsigned i = 0; i < tagNameLength; ++i) { | 7609 for (unsigned i = 0; i < tagNameLength; ++i) { |
| 7610 // Limits the range of characters to 0x20-0x7E, following the tag name r ules defiend in the OpenType specification. | 7610 // Limits the range of characters to 0x20-0x7E, following the tag name r ules defiend in the OpenType specification. |
| 7611 UChar character = value->string[i]; | 7611 UChar character = value->string[i]; |
| 7612 if (character < 0x20 || character > 0x7E) | 7612 if (character < 0x20 || character > 0x7E) |
| 7613 return false; | 7613 return false; |
| 7614 } | 7614 } |
| 7615 | 7615 |
| (...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8130 default: | 8130 default: |
| 8131 // If you crash here, it's because you added a css property and are not handling it | 8131 // If you crash here, it's because you added a css property and are not handling it |
| 8132 // in either this switch statement or the one in CSSPropertyParser::pars eValue | 8132 // in either this switch statement or the one in CSSPropertyParser::pars eValue |
| 8133 ASSERT_WITH_MESSAGE(0, "unimplemented propertyID: %d", propId); | 8133 ASSERT_WITH_MESSAGE(0, "unimplemented propertyID: %d", propId); |
| 8134 return false; | 8134 return false; |
| 8135 } | 8135 } |
| 8136 | 8136 |
| 8137 if (validPrimitive) { | 8137 if (validPrimitive) { |
| 8138 if (id) | 8138 if (id) |
| 8139 parsedValue = CSSPrimitiveValue::createIdentifier(id); | 8139 parsedValue = CSSPrimitiveValue::createIdentifier(id); |
| 8140 else if (value->unit == CSSPrimitiveValue::CSS_STRING) | 8140 else if (value->unit == CSSPrimitiveValue::CSS_CUSTOM_IDENT) |
| 8141 parsedValue = CSSPrimitiveValue::create(value->string, (CSSPrimitive Value::UnitType) value->unit); | 8141 parsedValue = CSSPrimitiveValue::create(value->string, (CSSPrimitive Value::UnitType) value->unit); |
| 8142 else if (value->unit >= CSSPrimitiveValue::CSS_NUMBER && value->unit <= CSSPrimitiveValue::CSS_KHZ) | 8142 else if (value->unit >= CSSPrimitiveValue::CSS_NUMBER && value->unit <= CSSPrimitiveValue::CSS_KHZ) |
| 8143 parsedValue = CSSPrimitiveValue::create(value->fValue, (CSSPrimitive Value::UnitType) value->unit); | 8143 parsedValue = CSSPrimitiveValue::create(value->fValue, (CSSPrimitive Value::UnitType) value->unit); |
| 8144 else if (value->unit >= CSSParserValue::Q_EMS) | 8144 else if (value->unit >= CSSParserValue::Q_EMS) |
| 8145 parsedValue = CSSPrimitiveValue::createAllowingMarginQuirk(value->fV alue, CSSPrimitiveValue::CSS_EMS); | 8145 parsedValue = CSSPrimitiveValue::createAllowingMarginQuirk(value->fV alue, CSSPrimitiveValue::CSS_EMS); |
| 8146 if (isCalculation(value)) { | 8146 if (isCalculation(value)) { |
| 8147 // FIXME calc() http://webkit.org/b/16662 : actually create a CSSPri mitiveValue here, ie | 8147 // FIXME calc() http://webkit.org/b/16662 : actually create a CSSPri mitiveValue here, ie |
| 8148 // parsedValue = CSSPrimitiveValue::create(m_parsedCalculation.relea se()); | 8148 // parsedValue = CSSPrimitiveValue::create(m_parsedCalculation.relea se()); |
| 8149 m_parsedCalculation.release(); | 8149 m_parsedCalculation.release(); |
| 8150 parsedValue = nullptr; | 8150 parsedValue = nullptr; |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8436 // FIXME: Add support for <url>, <basic-shape>, <geometry-box>. | 8436 // FIXME: Add support for <url>, <basic-shape>, <geometry-box>. |
| 8437 if (value->unit != CSSParserValue::Function || value->function->id != CSSVal uePath) | 8437 if (value->unit != CSSParserValue::Function || value->function->id != CSSVal uePath) |
| 8438 return nullptr; | 8438 return nullptr; |
| 8439 | 8439 |
| 8440 // FIXME: Add support for <fill-rule>. | 8440 // FIXME: Add support for <fill-rule>. |
| 8441 CSSParserValueList* functionArgs = value->function->args.get(); | 8441 CSSParserValueList* functionArgs = value->function->args.get(); |
| 8442 if (!functionArgs || functionArgs->size() != 1 || !functionArgs->current()) | 8442 if (!functionArgs || functionArgs->size() != 1 || !functionArgs->current()) |
| 8443 return nullptr; | 8443 return nullptr; |
| 8444 | 8444 |
| 8445 CSSParserValue* arg = functionArgs->current(); | 8445 CSSParserValue* arg = functionArgs->current(); |
| 8446 if (arg->unit != CSSPrimitiveValue::CSS_STRING) | 8446 if (arg->unit != CSSPrimitiveValue::CSS_CUSTOM_IDENT) |
| 8447 return nullptr; | 8447 return nullptr; |
| 8448 | 8448 |
| 8449 String pathString = arg->string; | 8449 String pathString = arg->string; |
| 8450 Path path; | 8450 Path path; |
| 8451 if (!buildPathFromString(pathString, path)) | 8451 if (!buildPathFromString(pathString, path)) |
| 8452 return nullptr; | 8452 return nullptr; |
| 8453 | 8453 |
| 8454 m_valueList->next(); | 8454 m_valueList->next(); |
| 8455 return CSSPathValue::create(pathString); | 8455 return CSSPathValue::create(pathString); |
| 8456 } | 8456 } |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 8473 } | 8473 } |
| 8474 } | 8474 } |
| 8475 | 8475 |
| 8476 if (!list->length()) | 8476 if (!list->length()) |
| 8477 return nullptr; | 8477 return nullptr; |
| 8478 | 8478 |
| 8479 return list.release(); | 8479 return list.release(); |
| 8480 } | 8480 } |
| 8481 | 8481 |
| 8482 } // namespace blink | 8482 } // namespace blink |
| OLD | NEW |