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 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 valueList->next(); | 281 valueList->next(); |
282 return true; | 282 return true; |
283 } | 283 } |
284 | 284 |
285 static inline bool isForwardSlashOperator(CSSParserValue* value) | 285 static inline bool isForwardSlashOperator(CSSParserValue* value) |
286 { | 286 { |
287 ASSERT(value); | 287 ASSERT(value); |
288 return value->m_unit == CSSParserValue::Operator && value->iValue == '/'; | 288 return value->m_unit == CSSParserValue::Operator && value->iValue == '/'; |
289 } | 289 } |
290 | 290 |
291 static bool isGeneratedImageValue(CSSParserValue* val) | 291 static bool isGeneratedImageValue(CSSValueID id) |
292 { | 292 { |
293 if (val->m_unit != CSSParserValue::Function) | 293 return id == CSSValueLinearGradient || id == CSSValueRadialGradient |
294 return false; | 294 || id == CSSValueRepeatingLinearGradient || id == CSSValueRepeatingRadia
lGradient |
295 | 295 || id == CSSValueWebkitLinearGradient || id == CSSValueWebkitRadialGradi
ent |
296 CSSValueID id = val->function->id; | 296 || id == CSSValueWebkitRepeatingLinearGradient || id == CSSValueWebkitRe
peatingRadialGradient |
297 return id == CSSValueLinearGradient | 297 || id == CSSValueWebkitGradient || id == CSSValueWebkitCrossFade; |
298 || id == CSSValueRadialGradient | |
299 || id == CSSValueRepeatingLinearGradient | |
300 || id == CSSValueRepeatingRadialGradient | |
301 || id == CSSValueWebkitLinearGradient | |
302 || id == CSSValueWebkitRadialGradient | |
303 || id == CSSValueWebkitRepeatingLinearGradient | |
304 || id == CSSValueWebkitRepeatingRadialGradient | |
305 || id == CSSValueWebkitGradient | |
306 || id == CSSValueWebkitCrossFade; | |
307 } | 298 } |
308 | 299 |
309 inline PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::parseValidPr
imitive(CSSValueID identifier, CSSParserValue* value) | 300 inline PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::parseValidPr
imitive(CSSValueID identifier, CSSParserValue* value) |
310 { | 301 { |
311 if (identifier) | 302 if (identifier) |
312 return cssValuePool().createIdentifierValue(identifier); | 303 return cssValuePool().createIdentifierValue(identifier); |
313 if (value->unit() >= CSSPrimitiveValue::UnitType::Number && value->unit() <=
CSSPrimitiveValue::UnitType::Kilohertz) | 304 if (value->unit() >= CSSPrimitiveValue::UnitType::Number && value->unit() <=
CSSPrimitiveValue::UnitType::Kilohertz) |
314 return createPrimitiveNumericValue(value); | 305 return createPrimitiveNumericValue(value); |
315 if (value->unit() >= CSSPrimitiveValue::UnitType::Turns && value->unit() <=
CSSPrimitiveValue::UnitType::Chs) | 306 if (value->unit() >= CSSPrimitiveValue::UnitType::Turns && value->unit() <=
CSSPrimitiveValue::UnitType::Chs) |
316 return createPrimitiveNumericValue(value); | 307 return createPrimitiveNumericValue(value); |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
515 addProperty(propId2, val2.release(), important); | 506 addProperty(propId2, val2.release(), important); |
516 } | 507 } |
517 result = true; | 508 result = true; |
518 } | 509 } |
519 m_implicitShorthand = false; | 510 m_implicitShorthand = false; |
520 return result; | 511 return result; |
521 } | 512 } |
522 case CSSPropertyListStyleImage: // <uri> | none | inherit | 513 case CSSPropertyListStyleImage: // <uri> | none | inherit |
523 case CSSPropertyBorderImageSource: | 514 case CSSPropertyBorderImageSource: |
524 case CSSPropertyWebkitMaskBoxImageSource: | 515 case CSSPropertyWebkitMaskBoxImageSource: |
525 if (id == CSSValueNone) { | 516 if (parseFillImage(m_valueList, parsedValue)) |
526 parsedValue = cssValuePool().createIdentifierValue(CSSValueNone); | |
527 m_valueList->next(); | 517 m_valueList->next(); |
528 } else if (value->m_unit == CSSParserValue::URI) { | |
529 parsedValue = createCSSImageValueWithReferrer(value->string, complet
eURL(value->string)); | |
530 m_valueList->next(); | |
531 } else if (isGeneratedImageValue(value)) { | |
532 if (parseGeneratedImage(m_valueList, parsedValue)) | |
533 m_valueList->next(); | |
534 else | |
535 return false; | |
536 } else if (value->m_unit == CSSParserValue::Function && value->function-
>id == CSSValueWebkitImageSet) { | |
537 parsedValue = parseImageSet(m_valueList); | |
538 if (!parsedValue) | |
539 return false; | |
540 m_valueList->next(); | |
541 } | |
542 break; | 518 break; |
543 | 519 |
544 case CSSPropertyBorderTopWidth: //// <border-width> | inherit | 520 case CSSPropertyBorderTopWidth: //// <border-width> | inherit |
545 case CSSPropertyBorderRightWidth: // Which is defined as | 521 case CSSPropertyBorderRightWidth: // Which is defined as |
546 case CSSPropertyBorderBottomWidth: // thin | medium | thick | <length> | 522 case CSSPropertyBorderBottomWidth: // thin | medium | thick | <length> |
547 case CSSPropertyBorderLeftWidth: | 523 case CSSPropertyBorderLeftWidth: |
548 if (!inShorthand() || m_currentShorthand == CSSPropertyBorderWidth) | 524 if (!inShorthand() || m_currentShorthand == CSSPropertyBorderWidth) |
549 unitless = FUnitlessQuirk; | 525 unitless = FUnitlessQuirk; |
550 if (id == CSSValueThin || id == CSSValueMedium || id == CSSValueThick) | 526 if (id == CSSValueThin || id == CSSValueMedium || id == CSSValueThick) |
551 validPrimitive = true; | 527 validPrimitive = true; |
(...skipping 889 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1441 if (!args) | 1417 if (!args) |
1442 return nullptr; | 1418 return nullptr; |
1443 if (val->function->id == CSSValueAttr) { | 1419 if (val->function->id == CSSValueAttr) { |
1444 parsedValue = parseAttr(args); | 1420 parsedValue = parseAttr(args); |
1445 } else if (val->function->id == CSSValueCounter) { | 1421 } else if (val->function->id == CSSValueCounter) { |
1446 parsedValue = parseCounterContent(args, false); | 1422 parsedValue = parseCounterContent(args, false); |
1447 } else if (val->function->id == CSSValueCounters) { | 1423 } else if (val->function->id == CSSValueCounters) { |
1448 parsedValue = parseCounterContent(args, true); | 1424 parsedValue = parseCounterContent(args, true); |
1449 } else if (val->function->id == CSSValueWebkitImageSet) { | 1425 } else if (val->function->id == CSSValueWebkitImageSet) { |
1450 parsedValue = parseImageSet(m_valueList); | 1426 parsedValue = parseImageSet(m_valueList); |
1451 } else if (isGeneratedImageValue(val)) { | 1427 } else if (isGeneratedImageValue(val->function->id)) { |
1452 if (!parseGeneratedImage(m_valueList, parsedValue)) | 1428 if (!parseGeneratedImage(m_valueList, parsedValue)) |
1453 return nullptr; | 1429 return nullptr; |
1454 } | 1430 } |
1455 } else if (val->m_unit == CSSParserValue::Identifier) { | 1431 } else if (val->m_unit == CSSParserValue::Identifier) { |
1456 switch (val->id) { | 1432 switch (val->id) { |
1457 case CSSValueOpenQuote: | 1433 case CSSValueOpenQuote: |
1458 case CSSValueCloseQuote: | 1434 case CSSValueCloseQuote: |
1459 case CSSValueNoOpenQuote: | 1435 case CSSValueNoOpenQuote: |
1460 case CSSValueNoCloseQuote: | 1436 case CSSValueNoCloseQuote: |
1461 case CSSValueNone: | 1437 case CSSValueNone: |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1550 { | 1526 { |
1551 if (valueList->current()->id == CSSValueNone) { | 1527 if (valueList->current()->id == CSSValueNone) { |
1552 value = cssValuePool().createIdentifierValue(CSSValueNone); | 1528 value = cssValuePool().createIdentifierValue(CSSValueNone); |
1553 return true; | 1529 return true; |
1554 } | 1530 } |
1555 if (valueList->current()->m_unit == CSSParserValue::URI) { | 1531 if (valueList->current()->m_unit == CSSParserValue::URI) { |
1556 value = createCSSImageValueWithReferrer(valueList->current()->string, co
mpleteURL(valueList->current()->string)); | 1532 value = createCSSImageValueWithReferrer(valueList->current()->string, co
mpleteURL(valueList->current()->string)); |
1557 return true; | 1533 return true; |
1558 } | 1534 } |
1559 | 1535 |
1560 if (isGeneratedImageValue(valueList->current())) | 1536 if (valueList->current()->m_unit == CSSParserValue::Function) { |
1561 return parseGeneratedImage(valueList, value); | 1537 if (isGeneratedImageValue(valueList->current()->function->id)) |
| 1538 return parseGeneratedImage(valueList, value); |
1562 | 1539 |
1563 if (valueList->current()->m_unit == CSSParserValue::Function && valueList->c
urrent()->function->id == CSSValueWebkitImageSet) { | 1540 if (valueList->current()->function->id == CSSValueWebkitImageSet) { |
1564 value = parseImageSet(m_valueList); | 1541 value = parseImageSet(m_valueList); |
1565 if (value) | 1542 if (value) |
1566 return true; | 1543 return true; |
| 1544 } |
1567 } | 1545 } |
1568 | 1546 |
1569 return false; | 1547 return false; |
1570 } | 1548 } |
1571 | 1549 |
1572 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseFillPositionX(CSSParser
ValueList* valueList) | 1550 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseFillPositionX(CSSParser
ValueList* valueList) |
1573 { | 1551 { |
1574 int id = valueList->current()->id; | 1552 int id = valueList->current()->id; |
1575 if (id == CSSValueLeft || id == CSSValueRight || id == CSSValueCenter) { | 1553 if (id == CSSValueLeft || id == CSSValueRight || id == CSSValueCenter) { |
1576 int percent = 0; | 1554 int percent = 0; |
(...skipping 2311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3888 CSSPropertyParser::ShorthandScope scope(this, propId); | 3866 CSSPropertyParser::ShorthandScope scope(this, propId); |
3889 while (CSSParserValue* val = m_valueList->current()) { | 3867 while (CSSParserValue* val = m_valueList->current()) { |
3890 context.setCanAdvance(false); | 3868 context.setCanAdvance(false); |
3891 | 3869 |
3892 if (!context.canAdvance() && context.allowForwardSlashOperator() && isFo
rwardSlashOperator(val)) | 3870 if (!context.canAdvance() && context.allowForwardSlashOperator() && isFo
rwardSlashOperator(val)) |
3893 context.commitForwardSlashOperator(); | 3871 context.commitForwardSlashOperator(); |
3894 | 3872 |
3895 if (!context.canAdvance() && context.allowImage()) { | 3873 if (!context.canAdvance() && context.allowImage()) { |
3896 if (val->m_unit == CSSParserValue::URI) { | 3874 if (val->m_unit == CSSParserValue::URI) { |
3897 context.commitImage(createCSSImageValueWithReferrer(val->string,
m_context.completeURL(val->string))); | 3875 context.commitImage(createCSSImageValueWithReferrer(val->string,
m_context.completeURL(val->string))); |
3898 } else if (isGeneratedImageValue(val)) { | 3876 } else if (val->m_unit == CSSParserValue::Function) { |
3899 RefPtrWillBeRawPtr<CSSValue> value = nullptr; | 3877 if (isGeneratedImageValue(val->function->id)) { |
3900 if (parseGeneratedImage(m_valueList, value)) | 3878 RefPtrWillBeRawPtr<CSSValue> value = nullptr; |
3901 context.commitImage(value.release()); | 3879 if (parseGeneratedImage(m_valueList, value)) |
3902 else | 3880 context.commitImage(value.release()); |
3903 return false; | 3881 else |
3904 } else if (val->m_unit == CSSParserValue::Function && val->function-
>id == CSSValueWebkitImageSet) { | 3882 return false; |
3905 RefPtrWillBeRawPtr<CSSValue> value = parseImageSet(m_valueList); | 3883 } else if (val->function->id == CSSValueWebkitImageSet) { |
3906 if (value) | 3884 RefPtrWillBeRawPtr<CSSValue> value = parseImageSet(m_valueLi
st); |
3907 context.commitImage(value.release()); | 3885 if (value) |
3908 else | 3886 context.commitImage(value.release()); |
3909 return false; | 3887 else |
| 3888 return false; |
| 3889 } |
3910 } else if (val->id == CSSValueNone) | 3890 } else if (val->id == CSSValueNone) |
3911 context.commitImage(cssValuePool().createIdentifierValue(CSSValu
eNone)); | 3891 context.commitImage(cssValuePool().createIdentifierValue(CSSValu
eNone)); |
3912 } | 3892 } |
3913 | 3893 |
3914 if (!context.canAdvance() && context.allowImageSlice()) { | 3894 if (!context.canAdvance() && context.allowImageSlice()) { |
3915 RefPtrWillBeRawPtr<CSSBorderImageSliceValue> imageSlice = nullptr; | 3895 RefPtrWillBeRawPtr<CSSBorderImageSliceValue> imageSlice = nullptr; |
3916 if (parseBorderImageSlice(propId, imageSlice)) | 3896 if (parseBorderImageSlice(propId, imageSlice)) |
3917 context.commitImageSlice(imageSlice.release()); | 3897 context.commitImageSlice(imageSlice.release()); |
3918 } | 3898 } |
3919 | 3899 |
(...skipping 1344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5264 | 5244 |
5265 return string.is8Bit() ? cssValueKeywordID(string.characters8(), length) : c
ssValueKeywordID(string.characters16(), length); | 5245 return string.is8Bit() ? cssValueKeywordID(string.characters8(), length) : c
ssValueKeywordID(string.characters16(), length); |
5266 } | 5246 } |
5267 | 5247 |
5268 bool CSSPropertyParser::isSystemColor(CSSValueID id) | 5248 bool CSSPropertyParser::isSystemColor(CSSValueID id) |
5269 { | 5249 { |
5270 return (id >= CSSValueActiveborder && id <= CSSValueWindowtext) || id == CSS
ValueMenu; | 5250 return (id >= CSSValueActiveborder && id <= CSSValueWindowtext) || id == CSS
ValueMenu; |
5271 } | 5251 } |
5272 | 5252 |
5273 } // namespace blink | 5253 } // namespace blink |
OLD | NEW |