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