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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 b = (unitflags & FFrequency); | 163 b = (unitflags & FFrequency); |
164 break; | 164 break; |
165 case CalcOther: | 165 case CalcOther: |
166 break; | 166 break; |
167 } | 167 } |
168 if (!b || releaseCalc == ReleaseParsedCalcValue) | 168 if (!b || releaseCalc == ReleaseParsedCalcValue) |
169 m_parsedCalculation.release(); | 169 m_parsedCalculation.release(); |
170 return b; | 170 return b; |
171 } | 171 } |
172 | 172 |
173 inline bool CSSPropertyParser::shouldAcceptUnitLessValues(CSSParserValue* value,
Units unitflags, CSSParserMode cssParserMode) | |
174 { | |
175 // Quirks mode for certain properties and presentation attributes accept uni
t-less values for certain units. | |
176 return (unitflags & (FLength | FAngle)) | |
177 && (!value->fValue // 0 can always be unitless. | |
178 || isUnitLessLengthParsingEnabledForMode(cssParserMode) // HTML and
SVG attribute values can always be unitless. | |
179 || (cssParserMode == HTMLQuirksMode && (unitflags & FUnitlessQuirk))
); | |
180 } | |
181 | |
182 inline bool isCalculation(CSSParserValue* value) | 173 inline bool isCalculation(CSSParserValue* value) |
183 { | 174 { |
184 return value->m_unit == CSSParserValue::CalcFunction; | 175 return value->m_unit == CSSParserValue::CalcFunction; |
185 } | 176 } |
186 | 177 |
187 bool CSSPropertyParser::validUnit(CSSParserValue* value, Units unitflags, CSSPar
serMode cssParserMode, ReleaseParsedCalcValueCondition releaseCalc) | 178 bool CSSPropertyParser::validUnit(CSSParserValue* value, Units unitflags, CSSPar
serMode cssParserMode, ReleaseParsedCalcValueCondition releaseCalc) |
188 { | 179 { |
189 if (isCalculation(value)) | 180 if (isCalculation(value)) |
190 return validCalculationUnit(value, unitflags, releaseCalc); | 181 return validCalculationUnit(value, unitflags, releaseCalc); |
191 | 182 |
192 if (unitflags & FNonNeg && value->fValue < 0) | 183 if (unitflags & FNonNeg && value->fValue < 0) |
193 return false; | 184 return false; |
194 switch (value->unit()) { | 185 switch (value->unit()) { |
195 case CSSPrimitiveValue::UnitType::Number: | 186 case CSSPrimitiveValue::UnitType::Number: |
196 if (unitflags & FNumber) | 187 if (unitflags & FNumber) |
197 return true; | 188 return true; |
198 if (shouldAcceptUnitLessValues(value, unitflags, cssParserMode)) { | 189 if (shouldAcceptUnitLessValues(value->fValue, unitflags, cssParserMode))
{ |
199 value->setUnit((unitflags & FLength) ? CSSPrimitiveValue::UnitType::
Pixels : CSSPrimitiveValue::UnitType::Degrees); | 190 value->setUnit((unitflags & FLength) ? CSSPrimitiveValue::UnitType::
Pixels : CSSPrimitiveValue::UnitType::Degrees); |
200 return true; | 191 return true; |
201 } | 192 } |
202 if ((unitflags & FInteger) && value->isInt) | 193 if ((unitflags & FInteger) && value->isInt) |
203 return true; | 194 return true; |
204 if ((unitflags & FPositiveInteger) && value->isInt && value->fValue > 0) | 195 if ((unitflags & FPositiveInteger) && value->isInt && value->fValue > 0) |
205 return true; | 196 return true; |
206 return false; | 197 return false; |
207 case CSSPrimitiveValue::UnitType::Percentage: | 198 case CSSPrimitiveValue::UnitType::Percentage: |
208 return unitflags & FPercent; | 199 return unitflags & FPercent; |
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
684 case CSSPropertyWebkitBorderEndWidth: | 675 case CSSPropertyWebkitBorderEndWidth: |
685 case CSSPropertyWebkitBorderBeforeWidth: | 676 case CSSPropertyWebkitBorderBeforeWidth: |
686 case CSSPropertyWebkitBorderAfterWidth: | 677 case CSSPropertyWebkitBorderAfterWidth: |
687 case CSSPropertyWebkitColumnRuleWidth: | 678 case CSSPropertyWebkitColumnRuleWidth: |
688 if (id == CSSValueThin || id == CSSValueMedium || id == CSSValueThick) | 679 if (id == CSSValueThin || id == CSSValueMedium || id == CSSValueThick) |
689 validPrimitive = true; | 680 validPrimitive = true; |
690 else | 681 else |
691 validPrimitive = validUnit(value, FLength | FNonNeg | unitless); | 682 validPrimitive = validUnit(value, FLength | FNonNeg | unitless); |
692 break; | 683 break; |
693 | 684 |
694 case CSSPropertyLetterSpacing: // normal | <length> | inherit | |
695 case CSSPropertyWordSpacing: // normal | <length> | inherit | |
696 if (id == CSSValueNormal) | |
697 validPrimitive = true; | |
698 else | |
699 validPrimitive = validUnit(value, FLength | FUnitlessQuirk); | |
700 break; | |
701 | |
702 case CSSPropertyTextIndent: | 685 case CSSPropertyTextIndent: |
703 parsedValue = parseTextIndent(); | 686 parsedValue = parseTextIndent(); |
704 break; | 687 break; |
705 | 688 |
706 case CSSPropertyPaddingTop: //// <padding-width> | inherit | 689 case CSSPropertyPaddingTop: //// <padding-width> | inherit |
707 case CSSPropertyPaddingRight: // Which is defined as | 690 case CSSPropertyPaddingRight: // Which is defined as |
708 case CSSPropertyPaddingBottom: // <length> | <percentage> | 691 case CSSPropertyPaddingBottom: // <length> | <percentage> |
709 case CSSPropertyPaddingLeft: //// | 692 case CSSPropertyPaddingLeft: //// |
710 unitless = FUnitlessQuirk; | 693 unitless = FUnitlessQuirk; |
711 // fall through | 694 // fall through |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
905 return false; | 888 return false; |
906 parsedValue2 = createPrimitiveNumericValue(value); | 889 parsedValue2 = createPrimitiveNumericValue(value); |
907 } else | 890 } else |
908 parsedValue2 = parsedValue1; | 891 parsedValue2 = parsedValue1; |
909 | 892 |
910 if (m_valueList->next()) | 893 if (m_valueList->next()) |
911 return false; | 894 return false; |
912 addProperty(propId, CSSValuePair::create(parsedValue1.release(), parsedV
alue2.release(), CSSValuePair::DropIdenticalValues), important); | 895 addProperty(propId, CSSValuePair::create(parsedValue1.release(), parsedV
alue2.release(), CSSValuePair::DropIdenticalValues), important); |
913 return true; | 896 return true; |
914 } | 897 } |
915 case CSSPropertyTabSize: | |
916 // May be specified as a unit-less non-negative integer or length indica
ting number of space characters. | |
917 validPrimitive = validUnit(value, FInteger | FLength | FNonNeg); | |
918 break; | |
919 case CSSPropertyBorderRadius: | 898 case CSSPropertyBorderRadius: |
920 case CSSPropertyAliasWebkitBorderRadius: | 899 case CSSPropertyAliasWebkitBorderRadius: |
921 return parseBorderRadius(unresolvedProperty, important); | 900 return parseBorderRadius(unresolvedProperty, important); |
922 case CSSPropertyOutlineOffset: | 901 case CSSPropertyOutlineOffset: |
923 validPrimitive = validUnit(value, FLength); | 902 validPrimitive = validUnit(value, FLength); |
924 break; | 903 break; |
925 case CSSPropertyTextShadow: // CSS2 property, dropped in CSS2.1, back in CSS
3, so treat as CSS3 | 904 case CSSPropertyTextShadow: // CSS2 property, dropped in CSS2.1, back in CSS
3, so treat as CSS3 |
926 case CSSPropertyBoxShadow: | 905 case CSSPropertyBoxShadow: |
927 if (id == CSSValueNone) | 906 if (id == CSSValueNone) |
928 validPrimitive = true; | 907 validPrimitive = true; |
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1417 case CSSPropertyWillChange: | 1396 case CSSPropertyWillChange: |
1418 case CSSPropertyPage: | 1397 case CSSPropertyPage: |
1419 case CSSPropertyOverflow: | 1398 case CSSPropertyOverflow: |
1420 case CSSPropertyQuotes: | 1399 case CSSPropertyQuotes: |
1421 case CSSPropertyWebkitHighlight: | 1400 case CSSPropertyWebkitHighlight: |
1422 case CSSPropertyFontVariantLigatures: | 1401 case CSSPropertyFontVariantLigatures: |
1423 case CSSPropertyWebkitFontFeatureSettings: | 1402 case CSSPropertyWebkitFontFeatureSettings: |
1424 case CSSPropertyFontVariant: | 1403 case CSSPropertyFontVariant: |
1425 case CSSPropertyFontFamily: | 1404 case CSSPropertyFontFamily: |
1426 case CSSPropertyFontWeight: | 1405 case CSSPropertyFontWeight: |
| 1406 case CSSPropertyLetterSpacing: |
| 1407 case CSSPropertyWordSpacing: |
| 1408 case CSSPropertyTabSize: |
1427 validPrimitive = false; | 1409 validPrimitive = false; |
1428 break; | 1410 break; |
1429 | 1411 |
1430 case CSSPropertyScrollSnapPointsX: | 1412 case CSSPropertyScrollSnapPointsX: |
1431 case CSSPropertyScrollSnapPointsY: | 1413 case CSSPropertyScrollSnapPointsY: |
1432 parsedValue = parseScrollSnapPoints(); | 1414 parsedValue = parseScrollSnapPoints(); |
1433 break; | 1415 break; |
1434 case CSSPropertyScrollSnapCoordinate: | 1416 case CSSPropertyScrollSnapCoordinate: |
1435 parsedValue = parseScrollSnapCoordinate(); | 1417 parsedValue = parseScrollSnapCoordinate(); |
1436 break; | 1418 break; |
(...skipping 6038 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7475 } | 7457 } |
7476 } | 7458 } |
7477 | 7459 |
7478 if (!list->length()) | 7460 if (!list->length()) |
7479 return nullptr; | 7461 return nullptr; |
7480 | 7462 |
7481 return list.release(); | 7463 return list.release(); |
7482 } | 7464 } |
7483 | 7465 |
7484 } // namespace blink | 7466 } // namespace blink |
OLD | NEW |