| 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 17 matching lines...) Expand all Loading... |
| 28 #include "core/css/parser/CSSPropertyParser.h" | 28 #include "core/css/parser/CSSPropertyParser.h" |
| 29 | 29 |
| 30 #include "core/StylePropertyShorthand.h" | 30 #include "core/StylePropertyShorthand.h" |
| 31 #include "core/css/CSSBasicShapes.h" | 31 #include "core/css/CSSBasicShapes.h" |
| 32 #include "core/css/CSSBorderImage.h" | 32 #include "core/css/CSSBorderImage.h" |
| 33 #include "core/css/CSSCanvasValue.h" | 33 #include "core/css/CSSCanvasValue.h" |
| 34 #include "core/css/CSSContentDistributionValue.h" | 34 #include "core/css/CSSContentDistributionValue.h" |
| 35 #include "core/css/CSSCounterValue.h" | 35 #include "core/css/CSSCounterValue.h" |
| 36 #include "core/css/CSSCrossfadeValue.h" | 36 #include "core/css/CSSCrossfadeValue.h" |
| 37 #include "core/css/CSSCursorImageValue.h" | 37 #include "core/css/CSSCursorImageValue.h" |
| 38 #include "core/css/CSSFontFaceSrcValue.h" | |
| 39 #include "core/css/CSSFontFeatureValue.h" | |
| 40 #include "core/css/CSSFunctionValue.h" | 38 #include "core/css/CSSFunctionValue.h" |
| 41 #include "core/css/CSSGridLineNamesValue.h" | 39 #include "core/css/CSSGridLineNamesValue.h" |
| 42 #include "core/css/CSSImageSetValue.h" | 40 #include "core/css/CSSImageSetValue.h" |
| 43 #include "core/css/CSSImageValue.h" | 41 #include "core/css/CSSImageValue.h" |
| 44 #include "core/css/CSSPathValue.h" | 42 #include "core/css/CSSPathValue.h" |
| 45 #include "core/css/CSSPrimitiveValueMappings.h" | 43 #include "core/css/CSSPrimitiveValueMappings.h" |
| 46 #include "core/css/CSSProperty.h" | 44 #include "core/css/CSSProperty.h" |
| 47 #include "core/css/CSSPropertyMetadata.h" | 45 #include "core/css/CSSPropertyMetadata.h" |
| 48 #include "core/css/CSSQuadValue.h" | 46 #include "core/css/CSSQuadValue.h" |
| 49 #include "core/css/CSSReflectValue.h" | 47 #include "core/css/CSSReflectValue.h" |
| 50 #include "core/css/CSSSVGDocumentValue.h" | 48 #include "core/css/CSSSVGDocumentValue.h" |
| 51 #include "core/css/CSSShadowValue.h" | 49 #include "core/css/CSSShadowValue.h" |
| 52 #include "core/css/CSSTimingFunctionValue.h" | 50 #include "core/css/CSSTimingFunctionValue.h" |
| 53 #include "core/css/CSSUnicodeRangeValue.h" | |
| 54 #include "core/css/CSSValuePair.h" | 51 #include "core/css/CSSValuePair.h" |
| 55 #include "core/css/CSSValuePool.h" | 52 #include "core/css/CSSValuePool.h" |
| 56 #include "core/css/HashTools.h" | 53 #include "core/css/HashTools.h" |
| 57 #include "core/css/parser/CSSParserFastPaths.h" | 54 #include "core/css/parser/CSSParserFastPaths.h" |
| 58 #include "core/css/parser/CSSParserValues.h" | 55 #include "core/css/parser/CSSParserValues.h" |
| 59 #include "core/frame/UseCounter.h" | 56 #include "core/frame/UseCounter.h" |
| 60 #include "core/layout/LayoutTheme.h" | 57 #include "core/layout/LayoutTheme.h" |
| 61 #include "core/style/GridCoordinate.h" | 58 #include "core/style/GridCoordinate.h" |
| 62 #include "core/svg/SVGPathUtilities.h" | 59 #include "core/svg/SVGPathUtilities.h" |
| 63 #include "platform/RuntimeEnabledFeatures.h" | 60 #include "platform/RuntimeEnabledFeatures.h" |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 | 459 |
| 463 case CSSPropertyTextAlign: | 460 case CSSPropertyTextAlign: |
| 464 // left | right | center | justify | -webkit-left | -webkit-right | -web
kit-center | -webkit-match-parent | 461 // left | right | center | justify | -webkit-left | -webkit-right | -web
kit-center | -webkit-match-parent |
| 465 // | start | end | <string> | inherit | -webkit-auto (converted to start
) | 462 // | start | end | <string> | inherit | -webkit-auto (converted to start
) |
| 466 // FIXME: <string> not supported right now | 463 // FIXME: <string> not supported right now |
| 467 if ((id >= CSSValueWebkitAuto && id <= CSSValueWebkitMatchParent) || id
== CSSValueStart || id == CSSValueEnd) { | 464 if ((id >= CSSValueWebkitAuto && id <= CSSValueWebkitMatchParent) || id
== CSSValueStart || id == CSSValueEnd) { |
| 468 validPrimitive = true; | 465 validPrimitive = true; |
| 469 } | 466 } |
| 470 break; | 467 break; |
| 471 | 468 |
| 472 case CSSPropertyFontWeight: // normal | bold | bolder | lighter | 100 | 200
| 300 | 400 | 500 | 600 | 700 | 800 | 900 | inherit | |
| 473 return parseFontWeight(important) && !m_valueList->next(); | |
| 474 | |
| 475 case CSSPropertyBorderSpacing: { | 469 case CSSPropertyBorderSpacing: { |
| 476 ShorthandScope scope(this, CSSPropertyBorderSpacing); | 470 ShorthandScope scope(this, CSSPropertyBorderSpacing); |
| 477 if (!parseValue(CSSPropertyWebkitBorderHorizontalSpacing, important)) | 471 if (!parseValue(CSSPropertyWebkitBorderHorizontalSpacing, important)) |
| 478 return false; | 472 return false; |
| 479 if (!m_valueList->current()) { | 473 if (!m_valueList->current()) { |
| 480 CSSValue* value = m_parsedProperties.last().value(); | 474 CSSValue* value = m_parsedProperties.last().value(); |
| 481 addProperty(CSSPropertyWebkitBorderVerticalSpacing, value, important
); | 475 addProperty(CSSPropertyWebkitBorderVerticalSpacing, value, important
); |
| 482 return true; | 476 return true; |
| 483 } | 477 } |
| 484 if (!parseValue(CSSPropertyWebkitBorderVerticalSpacing, important)) | 478 if (!parseValue(CSSPropertyWebkitBorderVerticalSpacing, important)) |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 740 case CSSPropertyWebkitMinLogicalWidth: | 734 case CSSPropertyWebkitMinLogicalWidth: |
| 741 case CSSPropertyWebkitMinLogicalHeight: | 735 case CSSPropertyWebkitMinLogicalHeight: |
| 742 case CSSPropertyWebkitLogicalWidth: | 736 case CSSPropertyWebkitLogicalWidth: |
| 743 case CSSPropertyWebkitLogicalHeight: | 737 case CSSPropertyWebkitLogicalHeight: |
| 744 validPrimitive = (id == CSSValueAuto || validWidthOrHeight(value, unitle
ss)); | 738 validPrimitive = (id == CSSValueAuto || validWidthOrHeight(value, unitle
ss)); |
| 745 break; | 739 break; |
| 746 | 740 |
| 747 case CSSPropertyFontSize: | 741 case CSSPropertyFontSize: |
| 748 return parseFontSize(important); | 742 return parseFontSize(important); |
| 749 | 743 |
| 750 case CSSPropertyFontVariant: // normal | small-caps | inherit | |
| 751 return parseFontVariant(important); | |
| 752 | |
| 753 case CSSPropertyVerticalAlign: | 744 case CSSPropertyVerticalAlign: |
| 754 // baseline | sub | super | top | text-top | middle | bottom | text-bott
om | | 745 // baseline | sub | super | top | text-top | middle | bottom | text-bott
om | |
| 755 // <percentage> | <length> | inherit | 746 // <percentage> | <length> | inherit |
| 756 | 747 |
| 757 if (id >= CSSValueBaseline && id <= CSSValueWebkitBaselineMiddle) | 748 if (id >= CSSValueBaseline && id <= CSSValueWebkitBaselineMiddle) |
| 758 validPrimitive = true; | 749 validPrimitive = true; |
| 759 else | 750 else |
| 760 validPrimitive = validUnit(value, FLength | FPercent | FUnitlessQuir
k); | 751 validPrimitive = validUnit(value, FLength | FPercent | FUnitlessQuir
k); |
| 761 break; | 752 break; |
| 762 | 753 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 805 validPrimitive = true; | 796 validPrimitive = true; |
| 806 else | 797 else |
| 807 parsedValue = parseCounter(1); | 798 parsedValue = parseCounter(1); |
| 808 break; | 799 break; |
| 809 case CSSPropertyCounterReset: | 800 case CSSPropertyCounterReset: |
| 810 if (id == CSSValueNone) | 801 if (id == CSSValueNone) |
| 811 validPrimitive = true; | 802 validPrimitive = true; |
| 812 else | 803 else |
| 813 parsedValue = parseCounter(0); | 804 parsedValue = parseCounter(0); |
| 814 break; | 805 break; |
| 815 case CSSPropertyFontFamily: | |
| 816 // [[ <family-name> | <generic-family> ],]* [<family-name> | <generic-fa
mily>] | inherit | |
| 817 { | |
| 818 parsedValue = parseFontFamily(); | |
| 819 break; | |
| 820 } | |
| 821 | 806 |
| 822 case CSSPropertyTextDecoration: | 807 case CSSPropertyTextDecoration: |
| 823 // Fall through 'text-decoration-line' parsing if CSS 3 Text Decoration | 808 // Fall through 'text-decoration-line' parsing if CSS 3 Text Decoration |
| 824 // is disabled to match CSS 2.1 rules for parsing 'text-decoration'. | 809 // is disabled to match CSS 2.1 rules for parsing 'text-decoration'. |
| 825 if (RuntimeEnabledFeatures::css3TextDecorationsEnabled()) { | 810 if (RuntimeEnabledFeatures::css3TextDecorationsEnabled()) { |
| 826 // [ <text-decoration-line> || <text-decoration-style> || <text-deco
ration-color> ] | inherit | 811 // [ <text-decoration-line> || <text-decoration-style> || <text-deco
ration-color> ] | inherit |
| 827 return parseShorthand(CSSPropertyTextDecoration, textDecorationShort
hand(), important); | 812 return parseShorthand(CSSPropertyTextDecoration, textDecorationShort
hand(), important); |
| 828 } | 813 } |
| 829 case CSSPropertyWebkitTextDecorationsInEffect: | 814 case CSSPropertyWebkitTextDecorationsInEffect: |
| 830 case CSSPropertyTextDecorationLine: | 815 case CSSPropertyTextDecorationLine: |
| (...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1369 case CSSPropertyWebkitTextEmphasisStyle: | 1354 case CSSPropertyWebkitTextEmphasisStyle: |
| 1370 parsedValue = parseTextEmphasisStyle(); | 1355 parsedValue = parseTextEmphasisStyle(); |
| 1371 break; | 1356 break; |
| 1372 | 1357 |
| 1373 case CSSPropertyWebkitTextOrientation: | 1358 case CSSPropertyWebkitTextOrientation: |
| 1374 // FIXME: For now just support sideways, sideways-right, upright and ver
tical-right. | 1359 // FIXME: For now just support sideways, sideways-right, upright and ver
tical-right. |
| 1375 if (id == CSSValueSideways || id == CSSValueSidewaysRight || id == CSSVa
lueVerticalRight || id == CSSValueUpright) | 1360 if (id == CSSValueSideways || id == CSSValueSidewaysRight || id == CSSVa
lueVerticalRight || id == CSSValueUpright) |
| 1376 validPrimitive = true; | 1361 validPrimitive = true; |
| 1377 break; | 1362 break; |
| 1378 | 1363 |
| 1379 case CSSPropertyWebkitFontFeatureSettings: | |
| 1380 if (id == CSSValueNormal) | |
| 1381 validPrimitive = true; | |
| 1382 else | |
| 1383 parsedValue = parseFontFeatureSettings(); | |
| 1384 break; | |
| 1385 | |
| 1386 case CSSPropertyWebkitClipPath: | 1364 case CSSPropertyWebkitClipPath: |
| 1387 if (id == CSSValueNone) { | 1365 if (id == CSSValueNone) { |
| 1388 validPrimitive = true; | 1366 validPrimitive = true; |
| 1389 } else if (value->m_unit == CSSParserValue::Function) { | 1367 } else if (value->m_unit == CSSParserValue::Function) { |
| 1390 parsedValue = parseBasicShape(); | 1368 parsedValue = parseBasicShape(); |
| 1391 } else if (value->unit() == CSSPrimitiveValue::UnitType::URI) { | 1369 } else if (value->unit() == CSSPrimitiveValue::UnitType::URI) { |
| 1392 parsedValue = CSSPrimitiveValue::create(value->string, CSSPrimitiveV
alue::UnitType::URI); | 1370 parsedValue = CSSPrimitiveValue::create(value->string, CSSPrimitiveV
alue::UnitType::URI); |
| 1393 addProperty(propId, parsedValue.release(), important); | 1371 addProperty(propId, parsedValue.release(), important); |
| 1394 return true; | 1372 return true; |
| 1395 } | 1373 } |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1435 break; | 1413 break; |
| 1436 | 1414 |
| 1437 // These were not accepted by the new path above so we should return false. | 1415 // These were not accepted by the new path above so we should return false. |
| 1438 case CSSPropertyWebkitMarginCollapse: | 1416 case CSSPropertyWebkitMarginCollapse: |
| 1439 case CSSPropertyWillChange: | 1417 case CSSPropertyWillChange: |
| 1440 case CSSPropertyPage: | 1418 case CSSPropertyPage: |
| 1441 case CSSPropertyOverflow: | 1419 case CSSPropertyOverflow: |
| 1442 case CSSPropertyQuotes: | 1420 case CSSPropertyQuotes: |
| 1443 case CSSPropertyWebkitHighlight: | 1421 case CSSPropertyWebkitHighlight: |
| 1444 case CSSPropertyFontVariantLigatures: | 1422 case CSSPropertyFontVariantLigatures: |
| 1423 case CSSPropertyWebkitFontFeatureSettings: |
| 1424 case CSSPropertyFontVariant: |
| 1425 case CSSPropertyFontFamily: |
| 1426 case CSSPropertyFontWeight: |
| 1445 validPrimitive = false; | 1427 validPrimitive = false; |
| 1446 break; | 1428 break; |
| 1447 | 1429 |
| 1448 case CSSPropertyScrollSnapPointsX: | 1430 case CSSPropertyScrollSnapPointsX: |
| 1449 case CSSPropertyScrollSnapPointsY: | 1431 case CSSPropertyScrollSnapPointsY: |
| 1450 parsedValue = parseScrollSnapPoints(); | 1432 parsedValue = parseScrollSnapPoints(); |
| 1451 break; | 1433 break; |
| 1452 case CSSPropertyScrollSnapCoordinate: | 1434 case CSSPropertyScrollSnapCoordinate: |
| 1453 parsedValue = parseScrollSnapCoordinate(); | 1435 parsedValue = parseScrollSnapCoordinate(); |
| 1454 break; | 1436 break; |
| (...skipping 3210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4665 // <absolute-size> | <relative-size> | <length> | <percentage> | inherit | 4647 // <absolute-size> | <relative-size> | <length> | <percentage> | inherit |
| 4666 if (id >= CSSValueXxSmall && id <= CSSValueLarger) | 4648 if (id >= CSSValueXxSmall && id <= CSSValueLarger) |
| 4667 validPrimitive = true; | 4649 validPrimitive = true; |
| 4668 else | 4650 else |
| 4669 validPrimitive = validUnit(value, FLength | FPercent | FNonNeg | (inShor
thand() ? FUnknown : FUnitlessQuirk)); | 4651 validPrimitive = validUnit(value, FLength | FPercent | FNonNeg | (inShor
thand() ? FUnknown : FUnitlessQuirk)); |
| 4670 if (validPrimitive && (!m_valueList->next() || inShorthand())) | 4652 if (validPrimitive && (!m_valueList->next() || inShorthand())) |
| 4671 addProperty(CSSPropertyFontSize, parseValidPrimitive(id, value), importa
nt); | 4653 addProperty(CSSPropertyFontSize, parseValidPrimitive(id, value), importa
nt); |
| 4672 return validPrimitive; | 4654 return validPrimitive; |
| 4673 } | 4655 } |
| 4674 | 4656 |
| 4675 bool CSSPropertyParser::parseFontVariant(bool important) | |
| 4676 { | |
| 4677 RefPtrWillBeRawPtr<CSSValueList> values = nullptr; | |
| 4678 if (m_valueList->size() > 1) | |
| 4679 values = CSSValueList::createCommaSeparated(); | |
| 4680 bool expectComma = false; | |
| 4681 for (CSSParserValue* val = m_valueList->current(); val; val = m_valueList->c
urrent()) { | |
| 4682 RefPtrWillBeRawPtr<CSSPrimitiveValue> parsedValue = nullptr; | |
| 4683 if (!expectComma) { | |
| 4684 expectComma = true; | |
| 4685 if (val->id == CSSValueNormal || val->id == CSSValueSmallCaps) | |
| 4686 parsedValue = cssValuePool().createIdentifierValue(val->id); | |
| 4687 else if (val->id == CSSValueAll && !values) { | |
| 4688 // FIXME: CSSPropertyParser::parseFontVariant() implements | |
| 4689 // the old css3 draft: | |
| 4690 // http://www.w3.org/TR/2002/WD-css3-webfonts-20020802/#font-var
iant | |
| 4691 // 'all' is only allowed in @font-face and with no other values.
Make a value list to | |
| 4692 // indicate that we are in the @font-face case. | |
| 4693 values = CSSValueList::createCommaSeparated(); | |
| 4694 parsedValue = cssValuePool().createIdentifierValue(val->id); | |
| 4695 } | |
| 4696 } else if (consumeComma(m_valueList)) { | |
| 4697 expectComma = false; | |
| 4698 continue; | |
| 4699 } | |
| 4700 | |
| 4701 if (!parsedValue) | |
| 4702 return false; | |
| 4703 | |
| 4704 m_valueList->next(); | |
| 4705 | |
| 4706 if (values) | |
| 4707 values->append(parsedValue.release()); | |
| 4708 else { | |
| 4709 addProperty(CSSPropertyFontVariant, parsedValue.release(), important
); | |
| 4710 return true; | |
| 4711 } | |
| 4712 } | |
| 4713 | |
| 4714 if (values && values->length()) { | |
| 4715 if (m_ruleType != StyleRule::FontFace) | |
| 4716 return false; | |
| 4717 addProperty(CSSPropertyFontVariant, values.release(), important); | |
| 4718 return true; | |
| 4719 } | |
| 4720 | |
| 4721 return false; | |
| 4722 } | |
| 4723 | |
| 4724 bool CSSPropertyParser::parseFontWeight(bool important) | 4657 bool CSSPropertyParser::parseFontWeight(bool important) |
| 4725 { | 4658 { |
| 4726 CSSParserValue* value = m_valueList->current(); | 4659 CSSParserValue* value = m_valueList->current(); |
| 4727 if (value->id >= CSSValueNormal && value->id <= CSSValueLighter) { | 4660 if (value->id >= CSSValueNormal && value->id <= CSSValueLighter) { |
| 4728 addProperty(CSSPropertyFontWeight, cssValuePool().createIdentifierValue(
value->id), important); | 4661 addProperty(CSSPropertyFontWeight, cssValuePool().createIdentifierValue(
value->id), important); |
| 4729 return true; | 4662 return true; |
| 4730 } | 4663 } |
| 4731 if (value->unit() == CSSPrimitiveValue::UnitType::Number) { | 4664 if (value->unit() == CSSPrimitiveValue::UnitType::Number) { |
| 4732 int weight = static_cast<int>(value->fValue); | 4665 int weight = static_cast<int>(value->fValue); |
| 4733 if (!(weight % 100) && weight >= 100 && weight <= 900) { | 4666 if (!(weight % 100) && weight >= 100 && weight <= 900) { |
| 4734 addProperty(CSSPropertyFontWeight, cssValuePool().createIdentifierVa
lue(static_cast<CSSValueID>(CSSValue100 + weight / 100 - 1)), important); | 4667 addProperty(CSSPropertyFontWeight, cssValuePool().createIdentifierVa
lue(static_cast<CSSValueID>(CSSValue100 + weight / 100 - 1)), important); |
| 4735 return true; | 4668 return true; |
| 4736 } | 4669 } |
| 4737 } | 4670 } |
| 4738 return false; | 4671 return false; |
| 4739 } | 4672 } |
| 4740 | 4673 |
| 4741 bool CSSPropertyParser::parseFontFaceSrcURI(CSSValueList* valueList) | |
| 4742 { | |
| 4743 RefPtrWillBeRawPtr<CSSFontFaceSrcValue> uriValue(CSSFontFaceSrcValue::create
(completeURL(m_valueList->current()->string), m_context.shouldCheckContentSecuri
tyPolicy())); | |
| 4744 uriValue->setReferrer(m_context.referrer()); | |
| 4745 | |
| 4746 CSSParserValue* value = m_valueList->next(); | |
| 4747 if (!value || value->m_unit != CSSParserValue::Function || value->function->
id != CSSValueFormat) { | |
| 4748 valueList->append(uriValue.release()); | |
| 4749 return true; | |
| 4750 } | |
| 4751 | |
| 4752 // FIXME: http://www.w3.org/TR/2011/WD-css3-fonts-20111004/ says that format
() contains a comma-separated list of strings, | |
| 4753 // but CSSFontFaceSrcValue stores only one format. Allowing one format for n
ow. | |
| 4754 CSSParserValueList* args = value->function->args.get(); | |
| 4755 if (!args || args->size() != 1 || (args->current()->unit() != CSSPrimitiveVa
lue::UnitType::String && args->current()->m_unit != CSSParserValue::Identifier)) | |
| 4756 return false; | |
| 4757 uriValue->setFormat(args->current()->string); | |
| 4758 valueList->append(uriValue.release()); | |
| 4759 m_valueList->next(); | |
| 4760 return true; | |
| 4761 } | |
| 4762 | |
| 4763 bool CSSPropertyParser::parseFontFaceSrcLocal(CSSValueList* valueList) | |
| 4764 { | |
| 4765 CSSParserValueList* args = m_valueList->current()->function->args.get(); | |
| 4766 if (!args || !args->size()) | |
| 4767 return false; | |
| 4768 m_valueList->next(); | |
| 4769 | |
| 4770 ContentSecurityPolicyDisposition shouldCheckContentSecurityPolicy = m_contex
t.shouldCheckContentSecurityPolicy(); | |
| 4771 if (args->size() == 1 && args->current()->unit() == CSSPrimitiveValue::UnitT
ype::String) { | |
| 4772 valueList->append(CSSFontFaceSrcValue::createLocal(args->current()->stri
ng, shouldCheckContentSecurityPolicy)); | |
| 4773 } else if (args->current()->m_unit == CSSParserValue::Identifier) { | |
| 4774 StringBuilder builder; | |
| 4775 for (CSSParserValue* localValue = args->current(); localValue; localValu
e = args->next()) { | |
| 4776 if (localValue->m_unit != CSSParserValue::Identifier) | |
| 4777 return false; | |
| 4778 if (!builder.isEmpty()) | |
| 4779 builder.append(' '); | |
| 4780 builder.append(localValue->string); | |
| 4781 } | |
| 4782 valueList->append(CSSFontFaceSrcValue::createLocal(builder.toString(), s
houldCheckContentSecurityPolicy)); | |
| 4783 } else | |
| 4784 return false; | |
| 4785 | |
| 4786 return true; | |
| 4787 } | |
| 4788 | |
| 4789 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseFontFaceSrc() | |
| 4790 { | |
| 4791 RefPtrWillBeRawPtr<CSSValueList> values(CSSValueList::createCommaSeparated()
); | |
| 4792 | |
| 4793 while (true) { | |
| 4794 CSSParserValue* value = m_valueList->current(); | |
| 4795 if (!value) | |
| 4796 return nullptr; | |
| 4797 if (value->unit() == CSSPrimitiveValue::UnitType::URI) { | |
| 4798 if (!parseFontFaceSrcURI(values.get())) | |
| 4799 return nullptr; | |
| 4800 } else if (value->m_unit == CSSParserValue::Function && value->function-
>id == CSSValueLocal) { | |
| 4801 if (!parseFontFaceSrcLocal(values.get())) | |
| 4802 return nullptr; | |
| 4803 } else { | |
| 4804 return nullptr; | |
| 4805 } | |
| 4806 | |
| 4807 if (!m_valueList->current()) | |
| 4808 return values.release(); | |
| 4809 if (!consumeComma(m_valueList)) | |
| 4810 return nullptr; | |
| 4811 } | |
| 4812 } | |
| 4813 | |
| 4814 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseFontFaceUnicodeRang
e() | |
| 4815 { | |
| 4816 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createCommaSeparated
(); | |
| 4817 | |
| 4818 do { | |
| 4819 CSSParserValue* current = m_valueList->current(); | |
| 4820 if (!current || current->m_unit != CSSParserValue::UnicodeRange) | |
| 4821 return nullptr; | |
| 4822 | |
| 4823 UChar32 start = current->m_unicodeRange.start; | |
| 4824 UChar32 end = current->m_unicodeRange.end; | |
| 4825 if (start > end) | |
| 4826 return nullptr; | |
| 4827 values->append(CSSUnicodeRangeValue::create(start, end)); | |
| 4828 m_valueList->next(); | |
| 4829 } while (consumeComma(m_valueList)); | |
| 4830 | |
| 4831 return values.release(); | |
| 4832 } | |
| 4833 | |
| 4834 inline int CSSPropertyParser::colorIntFromValue(CSSParserValue* v) | 4674 inline int CSSPropertyParser::colorIntFromValue(CSSParserValue* v) |
| 4835 { | 4675 { |
| 4836 bool isPercent; | 4676 bool isPercent; |
| 4837 double value; | 4677 double value; |
| 4838 | 4678 |
| 4839 if (m_parsedCalculation) { | 4679 if (m_parsedCalculation) { |
| 4840 isPercent = m_parsedCalculation->category() == CalcPercent; | 4680 isPercent = m_parsedCalculation->category() == CalcPercent; |
| 4841 value = m_parsedCalculation->doubleValue(); | 4681 value = m_parsedCalculation->doubleValue(); |
| 4842 m_parsedCalculation.release(); | 4682 m_parsedCalculation.release(); |
| 4843 } else { | 4683 } else { |
| (...skipping 2116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6960 } | 6800 } |
| 6961 return nullptr; | 6801 return nullptr; |
| 6962 } | 6802 } |
| 6963 | 6803 |
| 6964 if (!hasLengthOrPercentage) | 6804 if (!hasLengthOrPercentage) |
| 6965 return nullptr; | 6805 return nullptr; |
| 6966 | 6806 |
| 6967 return list.release(); | 6807 return list.release(); |
| 6968 } | 6808 } |
| 6969 | 6809 |
| 6970 bool CSSPropertyParser::parseFontFeatureTag(CSSValueList* settings) | |
| 6971 { | |
| 6972 // Feature tag name consists of 4-letter characters. | |
| 6973 static const unsigned tagNameLength = 4; | |
| 6974 | |
| 6975 CSSParserValue* value = m_valueList->current(); | |
| 6976 // Feature tag name comes first | |
| 6977 if (value->unit() != CSSPrimitiveValue::UnitType::String) | |
| 6978 return false; | |
| 6979 if (value->string.length() != tagNameLength) | |
| 6980 return false; | |
| 6981 for (unsigned i = 0; i < tagNameLength; ++i) { | |
| 6982 // Limits the range of characters to 0x20-0x7E, following the tag name r
ules defiend in the OpenType specification. | |
| 6983 UChar character = value->string[i]; | |
| 6984 if (character < 0x20 || character > 0x7E) | |
| 6985 return false; | |
| 6986 } | |
| 6987 | |
| 6988 AtomicString tag = value->string; | |
| 6989 int tagValue = 1; | |
| 6990 // Feature tag values could follow: <integer> | on | off | |
| 6991 value = m_valueList->next(); | |
| 6992 if (value) { | |
| 6993 if (value->unit() == CSSPrimitiveValue::UnitType::Number && value->isInt
&& value->fValue >= 0) { | |
| 6994 tagValue = clampTo<int>(value->fValue); | |
| 6995 if (tagValue < 0) | |
| 6996 return false; | |
| 6997 m_valueList->next(); | |
| 6998 } else if (value->id == CSSValueOn || value->id == CSSValueOff) { | |
| 6999 tagValue = value->id == CSSValueOn; | |
| 7000 m_valueList->next(); | |
| 7001 } | |
| 7002 } | |
| 7003 settings->append(CSSFontFeatureValue::create(tag, tagValue)); | |
| 7004 return true; | |
| 7005 } | |
| 7006 | |
| 7007 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseFontFeatureSettings() | |
| 7008 { | |
| 7009 RefPtrWillBeRawPtr<CSSValueList> settings = CSSValueList::createCommaSeparat
ed(); | |
| 7010 while (true) { | |
| 7011 if (!m_valueList->current() || !parseFontFeatureTag(settings.get())) | |
| 7012 return nullptr; | |
| 7013 if (!m_valueList->current()) | |
| 7014 break; | |
| 7015 if (!consumeComma(m_valueList)) | |
| 7016 return nullptr; | |
| 7017 } | |
| 7018 return settings.release(); | |
| 7019 } | |
| 7020 | |
| 7021 bool CSSPropertyParser::parseCalculation(CSSParserValue* value, ValueRange range
) | 6810 bool CSSPropertyParser::parseCalculation(CSSParserValue* value, ValueRange range
) |
| 7022 { | 6811 { |
| 7023 ASSERT(isCalculation(value)); | 6812 ASSERT(isCalculation(value)); |
| 7024 | 6813 |
| 7025 CSSParserTokenRange args = value->calcFunction->args; | 6814 CSSParserTokenRange args = value->calcFunction->args; |
| 7026 | 6815 |
| 7027 ASSERT(!m_parsedCalculation); | 6816 ASSERT(!m_parsedCalculation); |
| 7028 m_parsedCalculation = CSSCalcValue::create(args, range); | 6817 m_parsedCalculation = CSSCalcValue::create(args, range); |
| 7029 | 6818 |
| 7030 if (!m_parsedCalculation) | 6819 if (!m_parsedCalculation) |
| 7031 return false; | 6820 return false; |
| 7032 | 6821 |
| 7033 return true; | 6822 return true; |
| 7034 } | 6823 } |
| 7035 | 6824 |
| 7036 bool CSSPropertyParser::parseFontFaceDescriptor(CSSPropertyID propId) | |
| 7037 { | |
| 7038 CSSParserValue* value = m_valueList->current(); | |
| 7039 ASSERT(value); | |
| 7040 CSSValueID id = value->id; | |
| 7041 RefPtrWillBeRawPtr<CSSValue> parsedValue = nullptr; | |
| 7042 | |
| 7043 switch (propId) { | |
| 7044 case CSSPropertyFontFamily: | |
| 7045 // <family-name> | |
| 7046 // TODO(rwlbuis): check there is only one family-name | |
| 7047 parsedValue = parseFontFamily(); | |
| 7048 break; | |
| 7049 case CSSPropertySrc: // This is a list of urls or local references. | |
| 7050 parsedValue = parseFontFaceSrc(); | |
| 7051 break; | |
| 7052 case CSSPropertyUnicodeRange: | |
| 7053 parsedValue = parseFontFaceUnicodeRange(); | |
| 7054 break; | |
| 7055 case CSSPropertyFontWeight: // normal | bold | 100 | 200 | 300 | 400 | 500 |
600 | 700 | 800 | 900 | |
| 7056 return parseFontWeight(false) && !m_valueList->next(); | |
| 7057 case CSSPropertyFontStretch: | |
| 7058 case CSSPropertyFontStyle: | |
| 7059 if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(propId, id)) | |
| 7060 return false; | |
| 7061 addProperty(propId, cssValuePool().createIdentifierValue(id), false); | |
| 7062 return true; | |
| 7063 case CSSPropertyFontVariant: // normal | small-caps | inherit | |
| 7064 return parseFontVariant(false); | |
| 7065 case CSSPropertyWebkitFontFeatureSettings: | |
| 7066 if (id == CSSValueNormal) { | |
| 7067 parsedValue = cssValuePool().createIdentifierValue(CSSValueNormal); | |
| 7068 m_valueList->next(); | |
| 7069 } else { | |
| 7070 parsedValue = parseFontFeatureSettings(); | |
| 7071 } | |
| 7072 break; | |
| 7073 default: | |
| 7074 break; | |
| 7075 } | |
| 7076 | |
| 7077 if (!parsedValue || m_valueList->current()) | |
| 7078 return false; | |
| 7079 | |
| 7080 addProperty(propId, parsedValue.release(), false); | |
| 7081 return true; | |
| 7082 } | |
| 7083 | |
| 7084 bool CSSPropertyParser::parseViewportProperty(CSSPropertyID propId, bool importa
nt) | 6825 bool CSSPropertyParser::parseViewportProperty(CSSPropertyID propId, bool importa
nt) |
| 7085 { | 6826 { |
| 7086 ASSERT(RuntimeEnabledFeatures::cssViewportEnabled() || isUASheetBehavior(m_c
ontext.mode())); | 6827 ASSERT(RuntimeEnabledFeatures::cssViewportEnabled() || isUASheetBehavior(m_c
ontext.mode())); |
| 7087 | 6828 |
| 7088 CSSParserValue* value = m_valueList->current(); | 6829 CSSParserValue* value = m_valueList->current(); |
| 7089 if (!value) | 6830 if (!value) |
| 7090 return false; | 6831 return false; |
| 7091 | 6832 |
| 7092 CSSValueID id = value->id; | 6833 CSSValueID id = value->id; |
| 7093 bool validPrimitive = false; | 6834 bool validPrimitive = false; |
| (...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7734 } | 7475 } |
| 7735 } | 7476 } |
| 7736 | 7477 |
| 7737 if (!list->length()) | 7478 if (!list->length()) |
| 7738 return nullptr; | 7479 return nullptr; |
| 7739 | 7480 |
| 7740 return list.release(); | 7481 return list.release(); |
| 7741 } | 7482 } |
| 7742 | 7483 |
| 7743 } // namespace blink | 7484 } // namespace blink |
| OLD | NEW |