| 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 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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) |
| 337 { | 337 { |
| 338 return value && value->unit == CSSParserValue::Operator && value->iValue ==
','; | 338 ASSERT(value); |
| 339 return value->unit == CSSParserValue::Operator && value->iValue == ','; |
| 339 } | 340 } |
| 340 | 341 |
| 341 static bool consumeComma(CSSParserValueList* valueList) | 342 static bool consumeComma(CSSParserValueList* valueList) |
| 342 { | 343 { |
| 343 if (!isComma(valueList->current())) | 344 CSSParserValue* value = valueList->current(); |
| 345 if (!value || !isComma(value)) |
| 344 return false; | 346 return false; |
| 345 valueList->next(); | 347 valueList->next(); |
| 346 return true; | 348 return true; |
| 347 } | 349 } |
| 348 | 350 |
| 349 static inline bool isForwardSlashOperator(CSSParserValue* value) | 351 static inline bool isForwardSlashOperator(CSSParserValue* value) |
| 350 { | 352 { |
| 351 ASSERT(value); | 353 ASSERT(value); |
| 352 return value->unit == CSSParserValue::Operator && value->iValue == '/'; | 354 return value->unit == CSSParserValue::Operator && value->iValue == '/'; |
| 353 } | 355 } |
| (...skipping 1244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1598 #endif | 1600 #endif |
| 1599 RefPtrWillBeRawPtr<CSSValue> clipValue = nullptr; | 1601 RefPtrWillBeRawPtr<CSSValue> clipValue = nullptr; |
| 1600 RefPtrWillBeRawPtr<CSSValue> positionYValue = nullptr; | 1602 RefPtrWillBeRawPtr<CSSValue> positionYValue = nullptr; |
| 1601 RefPtrWillBeRawPtr<CSSValue> repeatYValue = nullptr; | 1603 RefPtrWillBeRawPtr<CSSValue> repeatYValue = nullptr; |
| 1602 bool foundClip = false; | 1604 bool foundClip = false; |
| 1603 int i; | 1605 int i; |
| 1604 bool foundPositionCSSProperty = false; | 1606 bool foundPositionCSSProperty = false; |
| 1605 | 1607 |
| 1606 while (m_valueList->current()) { | 1608 while (m_valueList->current()) { |
| 1607 CSSParserValue* val = m_valueList->current(); | 1609 CSSParserValue* val = m_valueList->current(); |
| 1608 if (val->unit == CSSParserValue::Operator && val->iValue == ',') { | 1610 if (isComma(val)) { |
| 1609 // We hit the end. Fill in all remaining values with the initial va
lue. | 1611 // We hit the end. Fill in all remaining values with the initial va
lue. |
| 1610 m_valueList->next(); | 1612 m_valueList->next(); |
| 1611 for (i = 0; i < numProperties; ++i) { | 1613 for (i = 0; i < numProperties; ++i) { |
| 1612 if (properties[i] == CSSPropertyBackgroundColor && parsedPropert
y[i]) | 1614 if (properties[i] == CSSPropertyBackgroundColor && parsedPropert
y[i]) |
| 1613 // Color is not allowed except as the last item in a list fo
r backgrounds. | 1615 // Color is not allowed except as the last item in a list fo
r backgrounds. |
| 1614 // Reject the entire property. | 1616 // Reject the entire property. |
| 1615 return false; | 1617 return false; |
| 1616 | 1618 |
| 1617 if (!parsedProperty[i] && properties[i] != CSSPropertyBackground
Color) { | 1619 if (!parsedProperty[i] && properties[i] != CSSPropertyBackground
Color) { |
| 1618 addFillValue(values[i], cssValuePool().createImplicitInitial
Value()); | 1620 addFillValue(values[i], cssValuePool().createImplicitInitial
Value()); |
| (...skipping 907 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2526 inline bool CSSPropertyParser::isPotentialPositionValue(CSSParserValue* value) | 2528 inline bool CSSPropertyParser::isPotentialPositionValue(CSSParserValue* value) |
| 2527 { | 2529 { |
| 2528 return isFillPositionKeyword(value->id) || validUnit(value, FPercent | FLeng
th, ReleaseParsedCalcValue); | 2530 return isFillPositionKeyword(value->id) || validUnit(value, FPercent | FLeng
th, ReleaseParsedCalcValue); |
| 2529 } | 2531 } |
| 2530 | 2532 |
| 2531 void CSSPropertyParser::parseFillPosition(CSSParserValueList* valueList, RefPtrW
illBeRawPtr<CSSValue>& value1, RefPtrWillBeRawPtr<CSSValue>& value2, Units unitl
ess) | 2533 void CSSPropertyParser::parseFillPosition(CSSParserValueList* valueList, RefPtrW
illBeRawPtr<CSSValue>& value1, RefPtrWillBeRawPtr<CSSValue>& value2, Units unitl
ess) |
| 2532 { | 2534 { |
| 2533 unsigned numberOfValues = 0; | 2535 unsigned numberOfValues = 0; |
| 2534 for (unsigned i = valueList->currentIndex(); i < valueList->size(); ++i, ++n
umberOfValues) { | 2536 for (unsigned i = valueList->currentIndex(); i < valueList->size(); ++i, ++n
umberOfValues) { |
| 2535 CSSParserValue* current = valueList->valueAt(i); | 2537 CSSParserValue* current = valueList->valueAt(i); |
| 2536 if (isComma(current) || !current || isForwardSlashOperator(current) || !
isPotentialPositionValue(current)) | 2538 if (!current || isComma(current) || isForwardSlashOperator(current) || !
isPotentialPositionValue(current)) |
| 2537 break; | 2539 break; |
| 2538 } | 2540 } |
| 2539 | 2541 |
| 2540 if (numberOfValues > 4) | 2542 if (numberOfValues > 4) |
| 2541 return; | 2543 return; |
| 2542 | 2544 |
| 2543 // If we are parsing two values, we can safely call the CSS 2.1 parsing func
tion and return. | 2545 // If we are parsing two values, we can safely call the CSS 2.1 parsing func
tion and return. |
| 2544 if (numberOfValues <= 2) { | 2546 if (numberOfValues <= 2) { |
| 2545 parse2ValuesFillPosition(valueList, value1, value2, unitless); | 2547 parse2ValuesFillPosition(valueList, value1, value2, unitless); |
| 2546 return; | 2548 return; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2600 value1 = parseFillPositionComponent(valueList, cumulativeFlags, value1Flag,
ResolveValuesAsPercent, unitless); | 2602 value1 = parseFillPositionComponent(valueList, cumulativeFlags, value1Flag,
ResolveValuesAsPercent, unitless); |
| 2601 if (!value1) | 2603 if (!value1) |
| 2602 return; | 2604 return; |
| 2603 | 2605 |
| 2604 // It only takes one value for background-position to be correctly parsed if
it was specified in a shorthand (since we | 2606 // It only takes one value for background-position to be correctly parsed if
it was specified in a shorthand (since we |
| 2605 // can assume that any other values belong to the rest of the shorthand). I
f we're not parsing a shorthand, though, the | 2607 // can assume that any other values belong to the rest of the shorthand). I
f we're not parsing a shorthand, though, the |
| 2606 // value was explicitly specified for our property. | 2608 // value was explicitly specified for our property. |
| 2607 CSSParserValue* value = valueList->next(); | 2609 CSSParserValue* value = valueList->next(); |
| 2608 | 2610 |
| 2609 // First check for the comma. If so, we are finished parsing this value or
value pair. | 2611 // First check for the comma. If so, we are finished parsing this value or
value pair. |
| 2610 if (isComma(value)) | 2612 if (value && isComma(value)) |
| 2611 value = 0; | 2613 value = 0; |
| 2612 | 2614 |
| 2613 if (value) { | 2615 if (value) { |
| 2614 value2 = parseFillPositionComponent(valueList, cumulativeFlags, value2Fl
ag, ResolveValuesAsPercent, unitless); | 2616 value2 = parseFillPositionComponent(valueList, cumulativeFlags, value2Fl
ag, ResolveValuesAsPercent, unitless); |
| 2615 if (value2) | 2617 if (value2) |
| 2616 valueList->next(); | 2618 valueList->next(); |
| 2617 else { | 2619 else { |
| 2618 if (!inShorthand()) { | 2620 if (!inShorthand()) { |
| 2619 value1.clear(); | 2621 value1.clear(); |
| 2620 return; | 2622 return; |
| (...skipping 1983 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4604 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseFontFamily() | 4606 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseFontFamily() |
| 4605 { | 4607 { |
| 4606 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createCommaSeparated()
; | 4608 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createCommaSeparated()
; |
| 4607 CSSParserValue* value = m_valueList->current(); | 4609 CSSParserValue* value = m_valueList->current(); |
| 4608 | 4610 |
| 4609 FontFamilyValueBuilder familyBuilder(list.get()); | 4611 FontFamilyValueBuilder familyBuilder(list.get()); |
| 4610 bool inFamily = false; | 4612 bool inFamily = false; |
| 4611 | 4613 |
| 4612 while (value) { | 4614 while (value) { |
| 4613 CSSParserValue* nextValue = m_valueList->next(); | 4615 CSSParserValue* nextValue = m_valueList->next(); |
| 4614 bool nextValBreaksFont = !nextValue || | 4616 bool nextValBreaksFont = !nextValue || isComma(nextValue); |
| 4615 (nextValue->unit == CSSParserValue::Operator &&
nextValue->iValue == ','); | |
| 4616 bool nextValIsFontName = nextValue && | 4617 bool nextValIsFontName = nextValue && |
| 4617 ((nextValue->id >= CSSValueSerif && nextValue->id <= CSSValueWebkitB
ody) || | 4618 ((nextValue->id >= CSSValueSerif && nextValue->id <= CSSValueWebkitB
ody) || |
| 4618 (nextValue->unit == CSSPrimitiveValue::CSS_STRING || nextValue->unit
== CSSPrimitiveValue::CSS_IDENT)); | 4619 (nextValue->unit == CSSPrimitiveValue::CSS_STRING || nextValue->unit
== CSSPrimitiveValue::CSS_IDENT)); |
| 4619 | 4620 |
| 4620 if (isCSSWideKeyword(*value) && !inFamily) { | 4621 if (isCSSWideKeyword(*value) && !inFamily) { |
| 4621 if (nextValBreaksFont) | 4622 if (nextValBreaksFont) |
| 4622 value = m_valueList->next(); | 4623 value = m_valueList->next(); |
| 4623 else if (nextValIsFontName) | 4624 else if (nextValIsFontName) |
| 4624 value = nextValue; | 4625 value = nextValue; |
| 4625 continue; | 4626 continue; |
| (...skipping 3536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8162 bool validPrimitive = true; | 8163 bool validPrimitive = true; |
| 8163 while (value) { | 8164 while (value) { |
| 8164 validPrimitive = validUnit(value, FLength | FPercent | FNonNeg, SVGAttri
buteMode); | 8165 validPrimitive = validUnit(value, FLength | FPercent | FNonNeg, SVGAttri
buteMode); |
| 8165 if (!validPrimitive) | 8166 if (!validPrimitive) |
| 8166 break; | 8167 break; |
| 8167 if (value->id) | 8168 if (value->id) |
| 8168 ret->append(CSSPrimitiveValue::createIdentifier(value->id)); | 8169 ret->append(CSSPrimitiveValue::createIdentifier(value->id)); |
| 8169 else if (value->unit >= CSSPrimitiveValue::CSS_NUMBER && value->unit <=
CSSPrimitiveValue::CSS_KHZ) | 8170 else if (value->unit >= CSSPrimitiveValue::CSS_NUMBER && value->unit <=
CSSPrimitiveValue::CSS_KHZ) |
| 8170 ret->append(CSSPrimitiveValue::create(value->fValue, (CSSPrimitiveVa
lue::UnitType) value->unit)); | 8171 ret->append(CSSPrimitiveValue::create(value->fValue, (CSSPrimitiveVa
lue::UnitType) value->unit)); |
| 8171 value = m_valueList->next(); | 8172 value = m_valueList->next(); |
| 8172 if (value && value->unit == CSSParserValue::Operator && value->iValue ==
',') | 8173 bool commaConsumed = consumeComma(m_valueList); |
| 8173 value = m_valueList->next(); | 8174 value = m_valueList->current(); |
| 8175 if (commaConsumed && !value) |
| 8176 return nullptr; |
| 8174 } | 8177 } |
| 8175 if (!validPrimitive) | 8178 if (!validPrimitive) |
| 8176 return nullptr; | 8179 return nullptr; |
| 8177 return ret.release(); | 8180 return ret.release(); |
| 8178 } | 8181 } |
| 8179 | 8182 |
| 8180 // normal | [ fill || stroke || markers ] | 8183 // normal | [ fill || stroke || markers ] |
| 8181 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parsePaintOrder() const | 8184 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parsePaintOrder() const |
| 8182 { | 8185 { |
| 8183 if (m_valueList->size() > 3) | 8186 if (m_valueList->size() > 3) |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8403 } else if (!validUnit(a, unit, HTMLStandardMode)) { | 8406 } else if (!validUnit(a, unit, HTMLStandardMode)) { |
| 8404 return nullptr; | 8407 return nullptr; |
| 8405 } | 8408 } |
| 8406 | 8409 |
| 8407 // Add the value to the current transform operation. | 8410 // Add the value to the current transform operation. |
| 8408 transformValue->append(createPrimitiveNumericValue(a)); | 8411 transformValue->append(createPrimitiveNumericValue(a)); |
| 8409 | 8412 |
| 8410 a = args->next(); | 8413 a = args->next(); |
| 8411 if (!a) | 8414 if (!a) |
| 8412 break; | 8415 break; |
| 8413 if (a->unit != CSSParserValue::Operator || a->iValue != ',') | 8416 if (!isComma(a)) |
| 8414 return nullptr; | 8417 return nullptr; |
| 8415 a = args->next(); | 8418 a = args->next(); |
| 8416 | 8419 |
| 8417 argNumber++; | 8420 argNumber++; |
| 8418 } | 8421 } |
| 8419 | 8422 |
| 8420 return transformValue.release(); | 8423 return transformValue.release(); |
| 8421 } | 8424 } |
| 8422 | 8425 |
| 8423 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseMotionPath() | 8426 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseMotionPath() |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8468 } | 8471 } |
| 8469 } | 8472 } |
| 8470 | 8473 |
| 8471 if (!list->length()) | 8474 if (!list->length()) |
| 8472 return nullptr; | 8475 return nullptr; |
| 8473 | 8476 |
| 8474 return list.release(); | 8477 return list.release(); |
| 8475 } | 8478 } |
| 8476 | 8479 |
| 8477 } // namespace blink | 8480 } // namespace blink |
| OLD | NEW |