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 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 case CalcOther: | 250 case CalcOther: |
251 break; | 251 break; |
252 } | 252 } |
253 if (!b || releaseCalc == ReleaseParsedCalcValue) | 253 if (!b || releaseCalc == ReleaseParsedCalcValue) |
254 m_parsedCalculation.release(); | 254 m_parsedCalculation.release(); |
255 return b; | 255 return b; |
256 } | 256 } |
257 | 257 |
258 inline bool CSSPropertyParser::shouldAcceptUnitLessValues(CSSParserValue* value,
Units unitflags, CSSParserMode cssParserMode) | 258 inline bool CSSPropertyParser::shouldAcceptUnitLessValues(CSSParserValue* value,
Units unitflags, CSSParserMode cssParserMode) |
259 { | 259 { |
260 // Quirks mode and presentation attributes accept unit less values. | 260 // Quirks mode for certain properties and presentation attributes accept uni
t-less values for certain units. |
261 return (unitflags & (FLength | FAngle | FTime)) && (!value->fValue || isUnit
LessLengthParsingEnabledForMode(cssParserMode)); | 261 return (unitflags & (FLength | FAngle | FTime)) |
| 262 && (!value->fValue // 0 can always be unitless. |
| 263 || isUnitLessLengthParsingEnabledForMode(cssParserMode) // HTML and
SVG attribute values can always be unitless. |
| 264 || (cssParserMode == HTMLQuirksMode && (unitflags & FUnitlessQuirk))
); |
262 } | 265 } |
263 | 266 |
264 bool CSSPropertyParser::validUnit(CSSParserValue* value, Units unitflags, CSSPar
serMode cssParserMode, ReleaseParsedCalcValueCondition releaseCalc) | 267 bool CSSPropertyParser::validUnit(CSSParserValue* value, Units unitflags, CSSPar
serMode cssParserMode, ReleaseParsedCalcValueCondition releaseCalc) |
265 { | 268 { |
266 if (isCalculation(value)) | 269 if (isCalculation(value)) |
267 return validCalculationUnit(value, unitflags, releaseCalc); | 270 return validCalculationUnit(value, unitflags, releaseCalc); |
268 | 271 |
269 bool b = false; | 272 bool b = false; |
270 switch (value->unit) { | 273 switch (value->unit) { |
271 case CSSPrimitiveValue::CSS_NUMBER: | 274 case CSSPrimitiveValue::CSS_NUMBER: |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 || id == CSSValueRepeatingRadialGradient | 387 || id == CSSValueRepeatingRadialGradient |
385 || id == CSSValueWebkitLinearGradient | 388 || id == CSSValueWebkitLinearGradient |
386 || id == CSSValueWebkitRadialGradient | 389 || id == CSSValueWebkitRadialGradient |
387 || id == CSSValueWebkitRepeatingLinearGradient | 390 || id == CSSValueWebkitRepeatingLinearGradient |
388 || id == CSSValueWebkitRepeatingRadialGradient | 391 || id == CSSValueWebkitRepeatingRadialGradient |
389 || id == CSSValueWebkitGradient | 392 || id == CSSValueWebkitGradient |
390 || id == CSSValueWebkitCanvas | 393 || id == CSSValueWebkitCanvas |
391 || id == CSSValueWebkitCrossFade; | 394 || id == CSSValueWebkitCrossFade; |
392 } | 395 } |
393 | 396 |
394 bool CSSPropertyParser::validWidthOrHeight(CSSParserValue* value) | 397 bool CSSPropertyParser::validWidthOrHeight(CSSParserValue* value, Units unitless
) |
395 { | 398 { |
396 int id = value->id; | 399 int id = value->id; |
397 if (id == CSSValueIntrinsic || id == CSSValueMinIntrinsic || id == CSSValueW
ebkitMinContent || id == CSSValueWebkitMaxContent || id == CSSValueWebkitFillAva
ilable || id == CSSValueWebkitFitContent) | 400 if (id == CSSValueIntrinsic || id == CSSValueMinIntrinsic || id == CSSValueW
ebkitMinContent || id == CSSValueWebkitMaxContent || id == CSSValueWebkitFillAva
ilable || id == CSSValueWebkitFitContent) |
398 return true; | 401 return true; |
399 return !id && validUnit(value, FLength | FPercent | FNonNeg); | 402 return !id && validUnit(value, FLength | FPercent | FNonNeg | unitless); |
400 } | 403 } |
401 | 404 |
402 inline PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::parseValidPr
imitive(CSSValueID identifier, CSSParserValue* value) | 405 inline PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::parseValidPr
imitive(CSSValueID identifier, CSSParserValue* value) |
403 { | 406 { |
404 if (identifier) | 407 if (identifier) |
405 return cssValuePool().createIdentifierValue(identifier); | 408 return cssValuePool().createIdentifierValue(identifier); |
406 if (value->unit == CSSPrimitiveValue::CSS_STRING) | 409 if (value->unit == CSSPrimitiveValue::CSS_STRING) |
407 return createPrimitiveStringValue(value); | 410 return createPrimitiveStringValue(value); |
408 if (value->unit >= CSSPrimitiveValue::CSS_NUMBER && value->unit <= CSSPrimit
iveValue::CSS_KHZ) | 411 if (value->unit >= CSSPrimitiveValue::CSS_NUMBER && value->unit <= CSSPrimit
iveValue::CSS_KHZ) |
409 return createPrimitiveNumericValue(value); | 412 return createPrimitiveNumericValue(value); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
486 if (CSSParserFastPaths::isKeywordPropertyID(propId)) { | 489 if (CSSParserFastPaths::isKeywordPropertyID(propId)) { |
487 if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(propId, id)) | 490 if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(propId, id)) |
488 return false; | 491 return false; |
489 if (m_valueList->next() && !inShorthand()) | 492 if (m_valueList->next() && !inShorthand()) |
490 return false; | 493 return false; |
491 addProperty(propId, cssValuePool().createIdentifierValue(id), important)
; | 494 addProperty(propId, cssValuePool().createIdentifierValue(id), important)
; |
492 return true; | 495 return true; |
493 } | 496 } |
494 | 497 |
495 bool validPrimitive = false; | 498 bool validPrimitive = false; |
| 499 Units unitless = FUnknown; |
496 RefPtrWillBeRawPtr<CSSValue> parsedValue = nullptr; | 500 RefPtrWillBeRawPtr<CSSValue> parsedValue = nullptr; |
497 | 501 |
498 switch (propId) { | 502 switch (propId) { |
499 case CSSPropertySize: // <length>{1,2} | auto | [ <page-size
> || [ portrait | landscape] ] | 503 case CSSPropertySize: // <length>{1,2} | auto | [ <page-size
> || [ portrait | landscape] ] |
500 return parseSize(propId, important); | 504 return parseSize(propId, important); |
501 | 505 |
502 case CSSPropertyQuotes: // [<string> <string>]+ | none | 506 case CSSPropertyQuotes: // [<string> <string>]+ | none |
503 if (id == CSSValueNone) | 507 if (id == CSSValueNone) |
504 validPrimitive = true; | 508 validPrimitive = true; |
505 else | 509 else |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
565 else if (num == 2) { | 569 else if (num == 2) { |
566 ShorthandScope scope(this, CSSPropertyBorderSpacing); | 570 ShorthandScope scope(this, CSSPropertyBorderSpacing); |
567 if (!parseValue(CSSPropertyWebkitBorderHorizontalSpacing, important)
|| !parseValue(CSSPropertyWebkitBorderVerticalSpacing, important)) | 571 if (!parseValue(CSSPropertyWebkitBorderHorizontalSpacing, important)
|| !parseValue(CSSPropertyWebkitBorderVerticalSpacing, important)) |
568 return false; | 572 return false; |
569 return true; | 573 return true; |
570 } | 574 } |
571 return false; | 575 return false; |
572 } | 576 } |
573 case CSSPropertyWebkitBorderHorizontalSpacing: | 577 case CSSPropertyWebkitBorderHorizontalSpacing: |
574 case CSSPropertyWebkitBorderVerticalSpacing: | 578 case CSSPropertyWebkitBorderVerticalSpacing: |
575 validPrimitive = validUnit(value, FLength | FNonNeg); | 579 unitless = FLength | FNonNeg; |
| 580 if (inShorthand() && m_currentShorthand == CSSPropertyBorderSpacing) |
| 581 unitless = unitless | FUnitlessQuirk; |
| 582 validPrimitive = validUnit(value, unitless); |
576 break; | 583 break; |
577 case CSSPropertyOutlineColor: // <color> | invert | inherit | 584 case CSSPropertyOutlineColor: // <color> | invert | inherit |
578 // Outline color has "invert" as additional keyword. | 585 // Outline color has "invert" as additional keyword. |
579 // Also, we want to allow the special focus color even in HTML Standard
parsing mode. | 586 // Also, we want to allow the special focus color even in HTML Standard
parsing mode. |
580 if (id == CSSValueInvert || id == CSSValueWebkitFocusRingColor) { | 587 if (id == CSSValueInvert || id == CSSValueWebkitFocusRingColor) { |
581 validPrimitive = true; | 588 validPrimitive = true; |
582 break; | 589 break; |
583 } | 590 } |
584 /* nobreak */ | 591 /* nobreak */ |
585 case CSSPropertyBackgroundColor: // <color> | inherit | 592 case CSSPropertyBackgroundColor: // <color> | inherit |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
777 else | 784 else |
778 return false; | 785 return false; |
779 } else if (value->unit == CSSParserValue::Function && value->function->i
d == CSSValueWebkitImageSet) { | 786 } else if (value->unit == CSSParserValue::Function && value->function->i
d == CSSValueWebkitImageSet) { |
780 parsedValue = parseImageSet(m_valueList); | 787 parsedValue = parseImageSet(m_valueList); |
781 if (!parsedValue) | 788 if (!parsedValue) |
782 return false; | 789 return false; |
783 m_valueList->next(); | 790 m_valueList->next(); |
784 } | 791 } |
785 break; | 792 break; |
786 | 793 |
787 case CSSPropertyWebkitTextStrokeWidth: | |
788 case CSSPropertyOutlineWidth: // <border-width> | inherit | |
789 case CSSPropertyBorderTopWidth: //// <border-width> | inherit | 794 case CSSPropertyBorderTopWidth: //// <border-width> | inherit |
790 case CSSPropertyBorderRightWidth: // Which is defined as | 795 case CSSPropertyBorderRightWidth: // Which is defined as |
791 case CSSPropertyBorderBottomWidth: // thin | medium | thick | <length> | 796 case CSSPropertyBorderBottomWidth: // thin | medium | thick | <length> |
792 case CSSPropertyBorderLeftWidth: | 797 case CSSPropertyBorderLeftWidth: |
| 798 if (!inShorthand() || m_currentShorthand == CSSPropertyBorderWidth) |
| 799 unitless = FUnitlessQuirk; |
| 800 // fall through |
| 801 case CSSPropertyWebkitTextStrokeWidth: |
| 802 case CSSPropertyOutlineWidth: // <border-width> | inherit |
793 case CSSPropertyWebkitBorderStartWidth: | 803 case CSSPropertyWebkitBorderStartWidth: |
794 case CSSPropertyWebkitBorderEndWidth: | 804 case CSSPropertyWebkitBorderEndWidth: |
795 case CSSPropertyWebkitBorderBeforeWidth: | 805 case CSSPropertyWebkitBorderBeforeWidth: |
796 case CSSPropertyWebkitBorderAfterWidth: | 806 case CSSPropertyWebkitBorderAfterWidth: |
797 case CSSPropertyWebkitColumnRuleWidth: | 807 case CSSPropertyWebkitColumnRuleWidth: |
798 if (id == CSSValueThin || id == CSSValueMedium || id == CSSValueThick) | 808 if (id == CSSValueThin || id == CSSValueMedium || id == CSSValueThick) |
799 validPrimitive = true; | 809 validPrimitive = true; |
800 else | 810 else |
801 validPrimitive = validUnit(value, FLength | FNonNeg); | 811 validPrimitive = validUnit(value, FLength | FNonNeg | unitless); |
802 break; | 812 break; |
803 | 813 |
804 case CSSPropertyLetterSpacing: // normal | <length> | inherit | 814 case CSSPropertyLetterSpacing: // normal | <length> | inherit |
805 case CSSPropertyWordSpacing: // normal | <length> | inherit | 815 case CSSPropertyWordSpacing: // normal | <length> | inherit |
806 if (id == CSSValueNormal) | 816 if (id == CSSValueNormal) |
807 validPrimitive = true; | 817 validPrimitive = true; |
808 else | 818 else |
809 validPrimitive = validUnit(value, FLength); | 819 validPrimitive = validUnit(value, FLength | FUnitlessQuirk); |
810 break; | 820 break; |
811 | 821 |
812 case CSSPropertyTextIndent: | 822 case CSSPropertyTextIndent: |
813 parsedValue = parseTextIndent(); | 823 parsedValue = parseTextIndent(); |
814 break; | 824 break; |
815 | 825 |
816 case CSSPropertyPaddingTop: //// <padding-width> | inherit | 826 case CSSPropertyPaddingTop: //// <padding-width> | inherit |
817 case CSSPropertyPaddingRight: // Which is defined as | 827 case CSSPropertyPaddingRight: // Which is defined as |
818 case CSSPropertyPaddingBottom: // <length> | <percentage> | 828 case CSSPropertyPaddingBottom: // <length> | <percentage> |
819 case CSSPropertyPaddingLeft: //// | 829 case CSSPropertyPaddingLeft: //// |
| 830 unitless = FUnitlessQuirk; |
| 831 // fall through |
820 case CSSPropertyWebkitPaddingStart: | 832 case CSSPropertyWebkitPaddingStart: |
821 case CSSPropertyWebkitPaddingEnd: | 833 case CSSPropertyWebkitPaddingEnd: |
822 case CSSPropertyWebkitPaddingBefore: | 834 case CSSPropertyWebkitPaddingBefore: |
823 case CSSPropertyWebkitPaddingAfter: | 835 case CSSPropertyWebkitPaddingAfter: |
824 validPrimitive = (!id && validUnit(value, FLength | FPercent | FNonNeg))
; | 836 validPrimitive = (!id && validUnit(value, FLength | FPercent | FNonNeg |
unitless)); |
825 break; | 837 break; |
826 | 838 |
827 case CSSPropertyMaxWidth: | 839 case CSSPropertyMaxWidth: |
| 840 case CSSPropertyMaxHeight: |
| 841 unitless = FUnitlessQuirk; |
| 842 // fall through |
828 case CSSPropertyWebkitMaxLogicalWidth: | 843 case CSSPropertyWebkitMaxLogicalWidth: |
829 case CSSPropertyMaxHeight: | |
830 case CSSPropertyWebkitMaxLogicalHeight: | 844 case CSSPropertyWebkitMaxLogicalHeight: |
831 validPrimitive = (id == CSSValueNone || validWidthOrHeight(value)); | 845 validPrimitive = (id == CSSValueNone || validWidthOrHeight(value, unitle
ss)); |
832 break; | 846 break; |
833 | 847 |
834 case CSSPropertyMinWidth: | 848 case CSSPropertyMinWidth: |
| 849 case CSSPropertyMinHeight: |
| 850 unitless = FUnitlessQuirk; |
| 851 // fall through |
835 case CSSPropertyWebkitMinLogicalWidth: | 852 case CSSPropertyWebkitMinLogicalWidth: |
836 case CSSPropertyMinHeight: | |
837 case CSSPropertyWebkitMinLogicalHeight: | 853 case CSSPropertyWebkitMinLogicalHeight: |
838 validPrimitive = validWidthOrHeight(value); | 854 validPrimitive = validWidthOrHeight(value, unitless); |
839 break; | 855 break; |
840 | 856 |
841 case CSSPropertyWidth: | 857 case CSSPropertyWidth: |
| 858 case CSSPropertyHeight: |
| 859 unitless = FUnitlessQuirk; |
| 860 // fall through |
842 case CSSPropertyWebkitLogicalWidth: | 861 case CSSPropertyWebkitLogicalWidth: |
843 case CSSPropertyHeight: | |
844 case CSSPropertyWebkitLogicalHeight: | 862 case CSSPropertyWebkitLogicalHeight: |
845 validPrimitive = (id == CSSValueAuto || validWidthOrHeight(value)); | 863 validPrimitive = (id == CSSValueAuto || validWidthOrHeight(value, unitle
ss)); |
846 break; | 864 break; |
847 | 865 |
848 case CSSPropertyFontSize: | 866 case CSSPropertyFontSize: |
849 return parseFontSize(important); | 867 return parseFontSize(important); |
850 | 868 |
851 case CSSPropertyFontVariant: // normal | small-caps | inherit | 869 case CSSPropertyFontVariant: // normal | small-caps | inherit |
852 return parseFontVariant(important); | 870 return parseFontVariant(important); |
853 | 871 |
854 case CSSPropertyVerticalAlign: | 872 case CSSPropertyVerticalAlign: |
855 // baseline | sub | super | top | text-top | middle | bottom | text-bott
om | | 873 // baseline | sub | super | top | text-top | middle | bottom | text-bott
om | |
856 // <percentage> | <length> | inherit | 874 // <percentage> | <length> | inherit |
857 | 875 |
858 if (id >= CSSValueBaseline && id <= CSSValueWebkitBaselineMiddle) | 876 if (id >= CSSValueBaseline && id <= CSSValueWebkitBaselineMiddle) |
859 validPrimitive = true; | 877 validPrimitive = true; |
860 else | 878 else |
861 validPrimitive = (!id && validUnit(value, FLength | FPercent)); | 879 validPrimitive = (!id && validUnit(value, FLength | FPercent | FUnit
lessQuirk)); |
862 break; | 880 break; |
863 | 881 |
864 case CSSPropertyBottom: // <length> | <percentage> | auto | in
herit | 882 case CSSPropertyBottom: // <length> | <percentage> | auto | in
herit |
865 case CSSPropertyLeft: // <length> | <percentage> | auto | in
herit | 883 case CSSPropertyLeft: // <length> | <percentage> | auto | in
herit |
866 case CSSPropertyRight: // <length> | <percentage> | auto | in
herit | 884 case CSSPropertyRight: // <length> | <percentage> | auto | in
herit |
867 case CSSPropertyTop: // <length> | <percentage> | auto | in
herit | 885 case CSSPropertyTop: // <length> | <percentage> | auto | in
herit |
868 case CSSPropertyMarginTop: //// <margin-width> | inherit | 886 case CSSPropertyMarginTop: //// <margin-width> | inherit |
869 case CSSPropertyMarginRight: // Which is defined as | 887 case CSSPropertyMarginRight: // Which is defined as |
870 case CSSPropertyMarginBottom: // <length> | <percentage> | auto | i
nherit | 888 case CSSPropertyMarginBottom: // <length> | <percentage> | auto | i
nherit |
871 case CSSPropertyMarginLeft: //// | 889 case CSSPropertyMarginLeft: //// |
| 890 unitless = FUnitlessQuirk; |
| 891 // fall through |
872 case CSSPropertyWebkitMarginStart: | 892 case CSSPropertyWebkitMarginStart: |
873 case CSSPropertyWebkitMarginEnd: | 893 case CSSPropertyWebkitMarginEnd: |
874 case CSSPropertyWebkitMarginBefore: | 894 case CSSPropertyWebkitMarginBefore: |
875 case CSSPropertyWebkitMarginAfter: | 895 case CSSPropertyWebkitMarginAfter: |
876 if (id == CSSValueAuto) | 896 if (id == CSSValueAuto) |
877 validPrimitive = true; | 897 validPrimitive = true; |
878 else | 898 else |
879 validPrimitive = (!id && validUnit(value, FLength | FPercent)); | 899 validPrimitive = (!id && validUnit(value, FLength | FPercent | unitl
ess)); |
880 break; | 900 break; |
881 | 901 |
882 case CSSPropertyOrphans: // <integer> | inherit | auto (We've added support
for auto for backwards compatibility) | 902 case CSSPropertyOrphans: // <integer> | inherit | auto (We've added support
for auto for backwards compatibility) |
883 case CSSPropertyWidows: // <integer> | inherit | auto (Ditto) | 903 case CSSPropertyWidows: // <integer> | inherit | auto (Ditto) |
884 if (id == CSSValueAuto) | 904 if (id == CSSValueAuto) |
885 validPrimitive = true; | 905 validPrimitive = true; |
886 else | 906 else |
887 validPrimitive = (!id && validUnit(value, FPositiveInteger)); | 907 validPrimitive = (!id && validUnit(value, FPositiveInteger)); |
888 break; | 908 break; |
889 | 909 |
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1314 // End of CSS3 properties | 1334 // End of CSS3 properties |
1315 | 1335 |
1316 // Apple specific properties. These will never be standardized and are pure
ly to | 1336 // Apple specific properties. These will never be standardized and are pure
ly to |
1317 // support custom WebKit-based Apple applications. | 1337 // support custom WebKit-based Apple applications. |
1318 case CSSPropertyWebkitLineClamp: | 1338 case CSSPropertyWebkitLineClamp: |
1319 // When specifying number of lines, don't allow 0 as a valid value | 1339 // When specifying number of lines, don't allow 0 as a valid value |
1320 // When specifying either type of unit, require non-negative integers | 1340 // When specifying either type of unit, require non-negative integers |
1321 validPrimitive = (!id && (value->unit == CSSPrimitiveValue::CSS_PERCENTA
GE || value->fValue) && validUnit(value, FInteger | FPercent | FNonNeg)); | 1341 validPrimitive = (!id && (value->unit == CSSPrimitiveValue::CSS_PERCENTA
GE || value->fValue) && validUnit(value, FInteger | FPercent | FNonNeg)); |
1322 break; | 1342 break; |
1323 | 1343 |
1324 case CSSPropertyWebkitFontSizeDelta: // <length> | 1344 case CSSPropertyWebkitFontSizeDelta: // <length> |
1325 validPrimitive = validUnit(value, FLength); | 1345 validPrimitive = validUnit(value, FLength | FUnitlessQuirk); |
1326 break; | 1346 break; |
1327 | 1347 |
1328 case CSSPropertyWebkitHighlight: | 1348 case CSSPropertyWebkitHighlight: |
1329 if (id == CSSValueNone || value->unit == CSSPrimitiveValue::CSS_STRING) | 1349 if (id == CSSValueNone || value->unit == CSSPrimitiveValue::CSS_STRING) |
1330 validPrimitive = true; | 1350 validPrimitive = true; |
1331 break; | 1351 break; |
1332 | 1352 |
1333 case CSSPropertyWebkitHyphenateCharacter: | 1353 case CSSPropertyWebkitHyphenateCharacter: |
1334 if (id == CSSValueAuto || value->unit == CSSPrimitiveValue::CSS_STRING) | 1354 if (id == CSSValueAuto || value->unit == CSSPrimitiveValue::CSS_STRING) |
1335 validPrimitive = true; | 1355 validPrimitive = true; |
(...skipping 970 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2306 percent = 100; | 2326 percent = 100; |
2307 else if (id == CSSValueCenter) | 2327 else if (id == CSSValueCenter) |
2308 percent = 50; | 2328 percent = 50; |
2309 return cssValuePool().createValue(percent, CSSPrimitiveValue::CSS_PERCEN
TAGE); | 2329 return cssValuePool().createValue(percent, CSSPrimitiveValue::CSS_PERCEN
TAGE); |
2310 } | 2330 } |
2311 if (validUnit(valueList->current(), FPercent | FLength)) | 2331 if (validUnit(valueList->current(), FPercent | FLength)) |
2312 return createPrimitiveNumericValue(valueList->current()); | 2332 return createPrimitiveNumericValue(valueList->current()); |
2313 return nullptr; | 2333 return nullptr; |
2314 } | 2334 } |
2315 | 2335 |
2316 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::parseFillPositionCo
mponent(CSSParserValueList* valueList, unsigned& cumulativeFlags, FillPositionFl
ag& individualFlag, FillPositionParsingMode parsingMode) | 2336 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::parseFillPositionCo
mponent(CSSParserValueList* valueList, unsigned& cumulativeFlags, FillPositionFl
ag& individualFlag, FillPositionParsingMode parsingMode, Units unitless) |
2317 { | 2337 { |
2318 CSSValueID id = valueList->current()->id; | 2338 CSSValueID id = valueList->current()->id; |
2319 if (id == CSSValueLeft || id == CSSValueTop || id == CSSValueRight || id ==
CSSValueBottom || id == CSSValueCenter) { | 2339 if (id == CSSValueLeft || id == CSSValueTop || id == CSSValueRight || id ==
CSSValueBottom || id == CSSValueCenter) { |
2320 int percent = 0; | 2340 int percent = 0; |
2321 if (id == CSSValueLeft || id == CSSValueRight) { | 2341 if (id == CSSValueLeft || id == CSSValueRight) { |
2322 if (cumulativeFlags & XFillPosition) | 2342 if (cumulativeFlags & XFillPosition) |
2323 return nullptr; | 2343 return nullptr; |
2324 cumulativeFlags |= XFillPosition; | 2344 cumulativeFlags |= XFillPosition; |
2325 individualFlag = XFillPosition; | 2345 individualFlag = XFillPosition; |
2326 if (id == CSSValueRight) | 2346 if (id == CSSValueRight) |
(...skipping 11 matching lines...) Expand all Loading... |
2338 percent = 50; | 2358 percent = 50; |
2339 cumulativeFlags |= AmbiguousFillPosition; | 2359 cumulativeFlags |= AmbiguousFillPosition; |
2340 individualFlag = AmbiguousFillPosition; | 2360 individualFlag = AmbiguousFillPosition; |
2341 } | 2361 } |
2342 | 2362 |
2343 if (parsingMode == ResolveValuesAsKeyword) | 2363 if (parsingMode == ResolveValuesAsKeyword) |
2344 return cssValuePool().createIdentifierValue(id); | 2364 return cssValuePool().createIdentifierValue(id); |
2345 | 2365 |
2346 return cssValuePool().createValue(percent, CSSPrimitiveValue::CSS_PERCEN
TAGE); | 2366 return cssValuePool().createValue(percent, CSSPrimitiveValue::CSS_PERCEN
TAGE); |
2347 } | 2367 } |
2348 if (validUnit(valueList->current(), FPercent | FLength)) { | 2368 if (validUnit(valueList->current(), FPercent | FLength | unitless)) { |
2349 if (!cumulativeFlags) { | 2369 if (!cumulativeFlags) { |
2350 cumulativeFlags |= XFillPosition; | 2370 cumulativeFlags |= XFillPosition; |
2351 individualFlag = XFillPosition; | 2371 individualFlag = XFillPosition; |
2352 } else if (cumulativeFlags & (XFillPosition | AmbiguousFillPosition)) { | 2372 } else if (cumulativeFlags & (XFillPosition | AmbiguousFillPosition)) { |
2353 cumulativeFlags |= YFillPosition; | 2373 cumulativeFlags |= YFillPosition; |
2354 individualFlag = YFillPosition; | 2374 individualFlag = YFillPosition; |
2355 } else { | 2375 } else { |
2356 if (m_parsedCalculation) | 2376 if (m_parsedCalculation) |
2357 m_parsedCalculation.release(); | 2377 m_parsedCalculation.release(); |
2358 return nullptr; | 2378 return nullptr; |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2515 ASSERT(ident1 == CSSValueLeft || ident1 == CSSValueRight); | 2535 ASSERT(ident1 == CSSValueLeft || ident1 == CSSValueRight); |
2516 ASSERT(ident2 == CSSValueBottom || ident2 == CSSValueTop); | 2536 ASSERT(ident2 == CSSValueBottom || ident2 == CSSValueTop); |
2517 #endif | 2537 #endif |
2518 } | 2538 } |
2519 | 2539 |
2520 inline bool CSSPropertyParser::isPotentialPositionValue(CSSParserValue* value) | 2540 inline bool CSSPropertyParser::isPotentialPositionValue(CSSParserValue* value) |
2521 { | 2541 { |
2522 return isFillPositionKeyword(value->id) || validUnit(value, FPercent | FLeng
th, ReleaseParsedCalcValue); | 2542 return isFillPositionKeyword(value->id) || validUnit(value, FPercent | FLeng
th, ReleaseParsedCalcValue); |
2523 } | 2543 } |
2524 | 2544 |
2525 void CSSPropertyParser::parseFillPosition(CSSParserValueList* valueList, RefPtrW
illBeRawPtr<CSSValue>& value1, RefPtrWillBeRawPtr<CSSValue>& value2) | 2545 void CSSPropertyParser::parseFillPosition(CSSParserValueList* valueList, RefPtrW
illBeRawPtr<CSSValue>& value1, RefPtrWillBeRawPtr<CSSValue>& value2, Units unitl
ess) |
2526 { | 2546 { |
2527 unsigned numberOfValues = 0; | 2547 unsigned numberOfValues = 0; |
2528 for (unsigned i = valueList->currentIndex(); i < valueList->size(); ++i, ++n
umberOfValues) { | 2548 for (unsigned i = valueList->currentIndex(); i < valueList->size(); ++i, ++n
umberOfValues) { |
2529 CSSParserValue* current = valueList->valueAt(i); | 2549 CSSParserValue* current = valueList->valueAt(i); |
2530 if (isComma(current) || !current || isForwardSlashOperator(current) || !
isPotentialPositionValue(current)) | 2550 if (isComma(current) || !current || isForwardSlashOperator(current) || !
isPotentialPositionValue(current)) |
2531 break; | 2551 break; |
2532 } | 2552 } |
2533 | 2553 |
2534 if (numberOfValues > 4) | 2554 if (numberOfValues > 4) |
2535 return; | 2555 return; |
2536 | 2556 |
2537 // If we are parsing two values, we can safely call the CSS 2.1 parsing func
tion and return. | 2557 // If we are parsing two values, we can safely call the CSS 2.1 parsing func
tion and return. |
2538 if (numberOfValues <= 2) { | 2558 if (numberOfValues <= 2) { |
2539 parse2ValuesFillPosition(valueList, value1, value2); | 2559 parse2ValuesFillPosition(valueList, value1, value2, unitless); |
2540 return; | 2560 return; |
2541 } | 2561 } |
2542 | 2562 |
2543 ASSERT(numberOfValues > 2 && numberOfValues <= 4); | 2563 ASSERT(numberOfValues > 2 && numberOfValues <= 4); |
2544 | 2564 |
2545 CSSParserValue* value = valueList->current(); | 2565 CSSParserValue* value = valueList->current(); |
2546 | 2566 |
2547 // <position> requires the first value to be a background keyword. | 2567 // <position> requires the first value to be a background keyword. |
2548 if (!isFillPositionKeyword(value->id)) | 2568 if (!isFillPositionKeyword(value->id)) |
2549 return; | 2569 return; |
(...skipping 28 matching lines...) Expand all Loading... |
2578 // Per CSS3 syntax, <position> can't have 'center' as its second keyword as
we have more arguments to follow. | 2598 // Per CSS3 syntax, <position> can't have 'center' as its second keyword as
we have more arguments to follow. |
2579 if (parsedValue2->getValueID() == CSSValueCenter) | 2599 if (parsedValue2->getValueID() == CSSValueCenter) |
2580 return; | 2600 return; |
2581 | 2601 |
2582 if (numberOfValues == 3) | 2602 if (numberOfValues == 3) |
2583 parse3ValuesFillPosition(valueList, value1, value2, parsedValue1.release
(), parsedValue2.release()); | 2603 parse3ValuesFillPosition(valueList, value1, value2, parsedValue1.release
(), parsedValue2.release()); |
2584 else | 2604 else |
2585 parse4ValuesFillPosition(valueList, value1, value2, parsedValue1.release
(), parsedValue2.release()); | 2605 parse4ValuesFillPosition(valueList, value1, value2, parsedValue1.release
(), parsedValue2.release()); |
2586 } | 2606 } |
2587 | 2607 |
2588 void CSSPropertyParser::parse2ValuesFillPosition(CSSParserValueList* valueList,
RefPtrWillBeRawPtr<CSSValue>& value1, RefPtrWillBeRawPtr<CSSValue>& value2) | 2608 void CSSPropertyParser::parse2ValuesFillPosition(CSSParserValueList* valueList,
RefPtrWillBeRawPtr<CSSValue>& value1, RefPtrWillBeRawPtr<CSSValue>& value2, Unit
s unitless) |
2589 { | 2609 { |
2590 // Parse the first value. We're just making sure that it is one of the vali
d keywords or a percentage/length. | 2610 // Parse the first value. We're just making sure that it is one of the vali
d keywords or a percentage/length. |
2591 unsigned cumulativeFlags = 0; | 2611 unsigned cumulativeFlags = 0; |
2592 FillPositionFlag value1Flag = InvalidFillPosition; | 2612 FillPositionFlag value1Flag = InvalidFillPosition; |
2593 FillPositionFlag value2Flag = InvalidFillPosition; | 2613 FillPositionFlag value2Flag = InvalidFillPosition; |
2594 value1 = parseFillPositionComponent(valueList, cumulativeFlags, value1Flag); | 2614 value1 = parseFillPositionComponent(valueList, cumulativeFlags, value1Flag,
ResolveValuesAsPercent, unitless); |
2595 if (!value1) | 2615 if (!value1) |
2596 return; | 2616 return; |
2597 | 2617 |
2598 // It only takes one value for background-position to be correctly parsed if
it was specified in a shorthand (since we | 2618 // It only takes one value for background-position to be correctly parsed if
it was specified in a shorthand (since we |
2599 // can assume that any other values belong to the rest of the shorthand). I
f we're not parsing a shorthand, though, the | 2619 // can assume that any other values belong to the rest of the shorthand). I
f we're not parsing a shorthand, though, the |
2600 // value was explicitly specified for our property. | 2620 // value was explicitly specified for our property. |
2601 CSSParserValue* value = valueList->next(); | 2621 CSSParserValue* value = valueList->next(); |
2602 | 2622 |
2603 // First check for the comma. If so, we are finished parsing this value or
value pair. | 2623 // First check for the comma. If so, we are finished parsing this value or
value pair. |
2604 if (isComma(value)) | 2624 if (isComma(value)) |
2605 value = 0; | 2625 value = 0; |
2606 | 2626 |
2607 if (value) { | 2627 if (value) { |
2608 value2 = parseFillPositionComponent(valueList, cumulativeFlags, value2Fl
ag); | 2628 value2 = parseFillPositionComponent(valueList, cumulativeFlags, value2Fl
ag, ResolveValuesAsPercent, unitless); |
2609 if (value2) | 2629 if (value2) |
2610 valueList->next(); | 2630 valueList->next(); |
2611 else { | 2631 else { |
2612 if (!inShorthand()) { | 2632 if (!inShorthand()) { |
2613 value1.clear(); | 2633 value1.clear(); |
2614 return; | 2634 return; |
2615 } | 2635 } |
2616 } | 2636 } |
2617 } | 2637 } |
2618 | 2638 |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2739 propId1 = CSSPropertyBackgroundRepeatX; | 2759 propId1 = CSSPropertyBackgroundRepeatX; |
2740 propId2 = CSSPropertyBackgroundRepeatY; | 2760 propId2 = CSSPropertyBackgroundRepeatY; |
2741 } else if (propId == CSSPropertyWebkitMaskRepeat) { | 2761 } else if (propId == CSSPropertyWebkitMaskRepeat) { |
2742 propId1 = CSSPropertyWebkitMaskRepeatX; | 2762 propId1 = CSSPropertyWebkitMaskRepeatX; |
2743 propId2 = CSSPropertyWebkitMaskRepeatY; | 2763 propId2 = CSSPropertyWebkitMaskRepeatY; |
2744 } | 2764 } |
2745 | 2765 |
2746 for (CSSParserValue* val = m_valueList->current(); val; val = m_valueList->c
urrent()) { | 2766 for (CSSParserValue* val = m_valueList->current(); val; val = m_valueList->c
urrent()) { |
2747 RefPtrWillBeRawPtr<CSSValue> currValue = nullptr; | 2767 RefPtrWillBeRawPtr<CSSValue> currValue = nullptr; |
2748 RefPtrWillBeRawPtr<CSSValue> currValue2 = nullptr; | 2768 RefPtrWillBeRawPtr<CSSValue> currValue2 = nullptr; |
2749 | 2769 Units unitless = FUnknown; |
2750 if (allowComma) { | 2770 if (allowComma) { |
2751 if (!isComma(val)) | 2771 if (!isComma(val)) |
2752 return false; | 2772 return false; |
2753 m_valueList->next(); | 2773 m_valueList->next(); |
2754 allowComma = false; | 2774 allowComma = false; |
2755 } else { | 2775 } else { |
2756 allowComma = true; | 2776 allowComma = true; |
2757 switch (propId) { | 2777 switch (propId) { |
2758 case CSSPropertyBackgroundColor: | 2778 case CSSPropertyBackgroundColor: |
2759 currValue = parseBackgroundColor(); | 2779 currValue = parseBackgroundColor(); |
(...skipping 29 matching lines...) Expand all Loading... |
2789 if (parseBackgroundClip(val, currValue)) | 2809 if (parseBackgroundClip(val, currValue)) |
2790 m_valueList->next(); | 2810 m_valueList->next(); |
2791 break; | 2811 break; |
2792 case CSSPropertyBackgroundOrigin: | 2812 case CSSPropertyBackgroundOrigin: |
2793 if (val->id == CSSValueBorderBox || val->id == CSSValuePaddi
ngBox || val->id == CSSValueContentBox) { | 2813 if (val->id == CSSValueBorderBox || val->id == CSSValuePaddi
ngBox || val->id == CSSValueContentBox) { |
2794 currValue = cssValuePool().createIdentifierValue(val->id
); | 2814 currValue = cssValuePool().createIdentifierValue(val->id
); |
2795 m_valueList->next(); | 2815 m_valueList->next(); |
2796 } | 2816 } |
2797 break; | 2817 break; |
2798 case CSSPropertyBackgroundPosition: | 2818 case CSSPropertyBackgroundPosition: |
| 2819 if (!inShorthand()) |
| 2820 unitless = FUnitlessQuirk; |
| 2821 // fall-through |
2799 case CSSPropertyWebkitMaskPosition: | 2822 case CSSPropertyWebkitMaskPosition: |
2800 parseFillPosition(m_valueList, currValue, currValue2); | 2823 parseFillPosition(m_valueList, currValue, currValue2, unitle
ss); |
2801 // parseFillPosition advances the m_valueList pointer. | 2824 // parseFillPosition advances the m_valueList pointer. |
2802 break; | 2825 break; |
2803 case CSSPropertyBackgroundPositionX: | 2826 case CSSPropertyBackgroundPositionX: |
2804 case CSSPropertyWebkitMaskPositionX: { | 2827 case CSSPropertyWebkitMaskPositionX: { |
2805 currValue = parseFillPositionX(m_valueList); | 2828 currValue = parseFillPositionX(m_valueList); |
2806 if (currValue) | 2829 if (currValue) |
2807 m_valueList->next(); | 2830 m_valueList->next(); |
2808 break; | 2831 break; |
2809 } | 2832 } |
2810 case CSSPropertyBackgroundPositionY: | 2833 case CSSPropertyBackgroundPositionY: |
(...skipping 1084 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3895 if (value->function->id != CSSValueRect || !args) | 3918 if (value->function->id != CSSValueRect || !args) |
3896 return false; | 3919 return false; |
3897 | 3920 |
3898 // rect(t, r, b, l) || rect(t r b l) | 3921 // rect(t, r, b, l) || rect(t r b l) |
3899 if (args->size() != 4 && args->size() != 7) | 3922 if (args->size() != 4 && args->size() != 7) |
3900 return false; | 3923 return false; |
3901 RefPtrWillBeRawPtr<Rect> rect = Rect::create(); | 3924 RefPtrWillBeRawPtr<Rect> rect = Rect::create(); |
3902 int i = 0; | 3925 int i = 0; |
3903 CSSParserValue* a = args->current(); | 3926 CSSParserValue* a = args->current(); |
3904 while (a) { | 3927 while (a) { |
3905 if (a->id != CSSValueAuto && !validUnit(a, FLength)) | 3928 if (a->id != CSSValueAuto && !validUnit(a, FLength | FUnitlessQuirk)) |
3906 return false; | 3929 return false; |
3907 RefPtrWillBeRawPtr<CSSPrimitiveValue> length = a->id == CSSValueAuto ? | 3930 RefPtrWillBeRawPtr<CSSPrimitiveValue> length = a->id == CSSValueAuto ? |
3908 cssValuePool().createIdentifierValue(CSSValueAuto) : | 3931 cssValuePool().createIdentifierValue(CSSValueAuto) : |
3909 createPrimitiveNumericValue(a); | 3932 createPrimitiveNumericValue(a); |
3910 if (i == 0) | 3933 if (i == 0) |
3911 rect->setTop(length); | 3934 rect->setTop(length); |
3912 else if (i == 1) | 3935 else if (i == 1) |
3913 rect->setRight(length); | 3936 rect->setRight(length); |
3914 else if (i == 2) | 3937 else if (i == 2) |
3915 rect->setBottom(length); | 3938 rect->setBottom(length); |
(...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4691 | 4714 |
4692 bool CSSPropertyParser::parseFontSize(bool important) | 4715 bool CSSPropertyParser::parseFontSize(bool important) |
4693 { | 4716 { |
4694 CSSParserValue* value = m_valueList->current(); | 4717 CSSParserValue* value = m_valueList->current(); |
4695 CSSValueID id = value->id; | 4718 CSSValueID id = value->id; |
4696 bool validPrimitive = false; | 4719 bool validPrimitive = false; |
4697 // <absolute-size> | <relative-size> | <length> | <percentage> | inherit | 4720 // <absolute-size> | <relative-size> | <length> | <percentage> | inherit |
4698 if (id >= CSSValueXxSmall && id <= CSSValueLarger) | 4721 if (id >= CSSValueXxSmall && id <= CSSValueLarger) |
4699 validPrimitive = true; | 4722 validPrimitive = true; |
4700 else | 4723 else |
4701 validPrimitive = validUnit(value, FLength | FPercent | FNonNeg); | 4724 validPrimitive = validUnit(value, FLength | FPercent | FNonNeg | (inShor
thand() ? FUnknown : FUnitlessQuirk)); |
4702 if (validPrimitive && (!m_valueList->next() || inShorthand())) | 4725 if (validPrimitive && (!m_valueList->next() || inShorthand())) |
4703 addProperty(CSSPropertyFontSize, parseValidPrimitive(id, value), importa
nt); | 4726 addProperty(CSSPropertyFontSize, parseValidPrimitive(id, value), importa
nt); |
4704 return validPrimitive; | 4727 return validPrimitive; |
4705 } | 4728 } |
4706 | 4729 |
4707 bool CSSPropertyParser::parseFontVariant(bool important) | 4730 bool CSSPropertyParser::parseFontVariant(bool important) |
4708 { | 4731 { |
4709 RefPtrWillBeRawPtr<CSSValueList> values = nullptr; | 4732 RefPtrWillBeRawPtr<CSSValueList> values = nullptr; |
4710 if (m_valueList->size() > 1) | 4733 if (m_valueList->size() > 1) |
4711 values = CSSValueList::createCommaSeparated(); | 4734 values = CSSValueList::createCommaSeparated(); |
(...skipping 2890 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7602 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseTextIndent() | 7625 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseTextIndent() |
7603 { | 7626 { |
7604 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated()
; | 7627 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated()
; |
7605 | 7628 |
7606 bool hasLengthOrPercentage = false; | 7629 bool hasLengthOrPercentage = false; |
7607 bool hasEachLine = false; | 7630 bool hasEachLine = false; |
7608 bool hasHanging = false; | 7631 bool hasHanging = false; |
7609 | 7632 |
7610 for (CSSParserValue* value = m_valueList->current(); value; value = m_valueL
ist->next()) { | 7633 for (CSSParserValue* value = m_valueList->current(); value; value = m_valueL
ist->next()) { |
7611 // <length> | <percentage> | inherit when RuntimeEnabledFeatures::css3Te
xtEnabled() returns false | 7634 // <length> | <percentage> | inherit when RuntimeEnabledFeatures::css3Te
xtEnabled() returns false |
7612 if (!hasLengthOrPercentage && validUnit(value, FLength | FPercent)) { | 7635 if (!hasLengthOrPercentage && validUnit(value, FLength | FPercent | FUni
tlessQuirk)) { |
7613 list->append(createPrimitiveNumericValue(value)); | 7636 list->append(createPrimitiveNumericValue(value)); |
7614 hasLengthOrPercentage = true; | 7637 hasLengthOrPercentage = true; |
7615 continue; | 7638 continue; |
7616 } | 7639 } |
7617 | 7640 |
7618 // [ <length> | <percentage> ] && hanging? && each-line? | inherit | 7641 // [ <length> | <percentage> ] && hanging? && each-line? | inherit |
7619 // when RuntimeEnabledFeatures::css3TextEnabled() returns true | 7642 // when RuntimeEnabledFeatures::css3TextEnabled() returns true |
7620 if (RuntimeEnabledFeatures::css3TextEnabled()) { | 7643 if (RuntimeEnabledFeatures::css3TextEnabled()) { |
7621 if (!hasEachLine && value->id == CSSValueEachLine) { | 7644 if (!hasEachLine && value->id == CSSValueEachLine) { |
7622 list->append(cssValuePool().createIdentifierValue(CSSValueEachLi
ne)); | 7645 list->append(cssValuePool().createIdentifierValue(CSSValueEachLi
ne)); |
(...skipping 947 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8570 } | 8593 } |
8571 } | 8594 } |
8572 | 8595 |
8573 if (!list->length()) | 8596 if (!list->length()) |
8574 return nullptr; | 8597 return nullptr; |
8575 | 8598 |
8576 return list.release(); | 8599 return list.release(); |
8577 } | 8600 } |
8578 | 8601 |
8579 } // namespace blink | 8602 } // namespace blink |
OLD | NEW |