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) 2004, 2005, 2006, 2008, 2009, 2010 Apple Inc. All rights reserv
ed. | 3 * Copyright (C) 2004, 2005, 2006, 2008, 2009, 2010 Apple Inc. All rights reserv
ed. |
4 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> | 4 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> |
5 * Copyright (C) 2009 - 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserve
d. | 5 * Copyright (C) 2009 - 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserve
d. |
6 * | 6 * |
7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 class CSSBasicShapeInset; | 49 class CSSBasicShapeInset; |
50 class CSSGridLineNamesValue; | 50 class CSSGridLineNamesValue; |
51 class StylePropertyShorthand; | 51 class StylePropertyShorthand; |
52 | 52 |
53 // Inputs: PropertyID, isImportant bool, CSSParserValueList. | 53 // Inputs: PropertyID, isImportant bool, CSSParserValueList. |
54 // Outputs: Vector of CSSProperties | 54 // Outputs: Vector of CSSProperties |
55 | 55 |
56 class CSSPropertyParser { | 56 class CSSPropertyParser { |
57 STACK_ALLOCATED(); | 57 STACK_ALLOCATED(); |
58 public: | 58 public: |
| 59 |
| 60 enum Units { |
| 61 FUnknown = 0x0000, |
| 62 FInteger = 0x0001, |
| 63 FNumber = 0x0002, // Real Numbers |
| 64 FPercent = 0x0004, |
| 65 FLength = 0x0008, |
| 66 FAngle = 0x0010, |
| 67 FTime = 0x0020, |
| 68 FFrequency = 0x0040, |
| 69 FPositiveInteger = 0x0080, |
| 70 FRelative = 0x0100, |
| 71 FResolution = 0x0200, |
| 72 FNonNeg = 0x0400, |
| 73 FUnitlessQuirk = 0x0800 |
| 74 }; |
| 75 |
59 static bool parseValue(CSSPropertyID, bool important, | 76 static bool parseValue(CSSPropertyID, bool important, |
60 CSSParserValueList*, const CSSParserContext&, bool inViewport, | 77 CSSParserValueList*, const CSSParserContext&, bool inViewport, |
61 WillBeHeapVector<CSSProperty, 256>&, CSSRuleSourceData::Type); | 78 WillBeHeapVector<CSSProperty, 256>&, CSSRuleSourceData::Type); |
62 | 79 |
63 // FIXME: This should probably move to CSSParserFastPaths | 80 // FIXME: This should probably move to CSSParserFastPaths |
64 template<typename StringType> | 81 template<typename StringType> |
65 static bool fastParseColor(RGBA32&, const StringType&, bool strict); | 82 static bool fastParseColor(RGBA32&, const StringType&, bool strict); |
66 | 83 |
67 static bool isSystemColor(int id); | 84 static bool isSystemColor(int id); |
68 | 85 |
(...skipping 25 matching lines...) Expand all Loading... |
94 PassRefPtrWillBeRawPtr<CSSValue> parseQuotes(); | 111 PassRefPtrWillBeRawPtr<CSSValue> parseQuotes(); |
95 | 112 |
96 PassRefPtrWillBeRawPtr<CSSValue> parseAttr(CSSParserValueList* args); | 113 PassRefPtrWillBeRawPtr<CSSValue> parseAttr(CSSParserValueList* args); |
97 | 114 |
98 PassRefPtrWillBeRawPtr<CSSValue> parseBackgroundColor(); | 115 PassRefPtrWillBeRawPtr<CSSValue> parseBackgroundColor(); |
99 | 116 |
100 bool parseFillImage(CSSParserValueList*, RefPtrWillBeRawPtr<CSSValue>&); | 117 bool parseFillImage(CSSParserValueList*, RefPtrWillBeRawPtr<CSSValue>&); |
101 | 118 |
102 enum FillPositionFlag { InvalidFillPosition = 0, AmbiguousFillPosition = 1,
XFillPosition = 2, YFillPosition = 4 }; | 119 enum FillPositionFlag { InvalidFillPosition = 0, AmbiguousFillPosition = 1,
XFillPosition = 2, YFillPosition = 4 }; |
103 enum FillPositionParsingMode { ResolveValuesAsPercent = 0, ResolveValuesAsKe
yword = 1 }; | 120 enum FillPositionParsingMode { ResolveValuesAsPercent = 0, ResolveValuesAsKe
yword = 1 }; |
104 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> parseFillPositionComponent(CSSPars
erValueList*, unsigned& cumulativeFlags, FillPositionFlag& individualFlag, FillP
ositionParsingMode = ResolveValuesAsPercent); | 121 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> parseFillPositionComponent(CSSPars
erValueList*, unsigned& cumulativeFlags, FillPositionFlag& individualFlag, FillP
ositionParsingMode = ResolveValuesAsPercent, Units = FUnknown); |
105 PassRefPtrWillBeRawPtr<CSSValue> parseFillPositionX(CSSParserValueList*); | 122 PassRefPtrWillBeRawPtr<CSSValue> parseFillPositionX(CSSParserValueList*); |
106 PassRefPtrWillBeRawPtr<CSSValue> parseFillPositionY(CSSParserValueList*); | 123 PassRefPtrWillBeRawPtr<CSSValue> parseFillPositionY(CSSParserValueList*); |
107 void parse2ValuesFillPosition(CSSParserValueList*, RefPtrWillBeRawPtr<CSSVal
ue>&, RefPtrWillBeRawPtr<CSSValue>&); | 124 void parse2ValuesFillPosition(CSSParserValueList*, RefPtrWillBeRawPtr<CSSVal
ue>&, RefPtrWillBeRawPtr<CSSValue>&, Units = FUnknown); |
108 bool isPotentialPositionValue(CSSParserValue*); | 125 bool isPotentialPositionValue(CSSParserValue*); |
109 void parseFillPosition(CSSParserValueList*, RefPtrWillBeRawPtr<CSSValue>&, R
efPtrWillBeRawPtr<CSSValue>&); | 126 void parseFillPosition(CSSParserValueList*, RefPtrWillBeRawPtr<CSSValue>&, R
efPtrWillBeRawPtr<CSSValue>&, Units = FUnknown); |
110 void parse3ValuesFillPosition(CSSParserValueList*, RefPtrWillBeRawPtr<CSSVal
ue>&, RefPtrWillBeRawPtr<CSSValue>&, PassRefPtrWillBeRawPtr<CSSPrimitiveValue>,
PassRefPtrWillBeRawPtr<CSSPrimitiveValue>); | 127 void parse3ValuesFillPosition(CSSParserValueList*, RefPtrWillBeRawPtr<CSSVal
ue>&, RefPtrWillBeRawPtr<CSSValue>&, PassRefPtrWillBeRawPtr<CSSPrimitiveValue>,
PassRefPtrWillBeRawPtr<CSSPrimitiveValue>); |
111 void parse4ValuesFillPosition(CSSParserValueList*, RefPtrWillBeRawPtr<CSSVal
ue>&, RefPtrWillBeRawPtr<CSSValue>&, PassRefPtrWillBeRawPtr<CSSPrimitiveValue>,
PassRefPtrWillBeRawPtr<CSSPrimitiveValue>); | 128 void parse4ValuesFillPosition(CSSParserValueList*, RefPtrWillBeRawPtr<CSSVal
ue>&, RefPtrWillBeRawPtr<CSSValue>&, PassRefPtrWillBeRawPtr<CSSPrimitiveValue>,
PassRefPtrWillBeRawPtr<CSSPrimitiveValue>); |
112 | 129 |
113 void parseFillRepeat(RefPtrWillBeRawPtr<CSSValue>&, RefPtrWillBeRawPtr<CSSVa
lue>&); | 130 void parseFillRepeat(RefPtrWillBeRawPtr<CSSValue>&, RefPtrWillBeRawPtr<CSSVa
lue>&); |
114 PassRefPtrWillBeRawPtr<CSSValue> parseFillSize(CSSPropertyID, bool &allowCom
ma); | 131 PassRefPtrWillBeRawPtr<CSSValue> parseFillSize(CSSPropertyID, bool &allowCom
ma); |
115 | 132 |
116 bool parseFillProperty(CSSPropertyID propId, CSSPropertyID& propId1, CSSProp
ertyID& propId2, RefPtrWillBeRawPtr<CSSValue>&, RefPtrWillBeRawPtr<CSSValue>&); | 133 bool parseFillProperty(CSSPropertyID propId, CSSPropertyID& propId1, CSSProp
ertyID& propId2, RefPtrWillBeRawPtr<CSSValue>&, RefPtrWillBeRawPtr<CSSValue>&); |
117 bool parseFillShorthand(CSSPropertyID, const CSSPropertyID* properties, int
numProperties, bool important); | 134 bool parseFillShorthand(CSSPropertyID, const CSSPropertyID* properties, int
numProperties, bool important); |
118 | 135 |
119 void addFillValue(RefPtrWillBeRawPtr<CSSValue>& lval, PassRefPtrWillBeRawPtr
<CSSValue> rval); | 136 void addFillValue(RefPtrWillBeRawPtr<CSSValue>& lval, PassRefPtrWillBeRawPtr
<CSSValue> rval); |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 | 273 |
257 bool parseFontVariantLigatures(bool important); | 274 bool parseFontVariantLigatures(bool important); |
258 | 275 |
259 bool parseGeneratedImage(CSSParserValueList*, RefPtrWillBeRawPtr<CSSValue>&)
; | 276 bool parseGeneratedImage(CSSParserValueList*, RefPtrWillBeRawPtr<CSSValue>&)
; |
260 | 277 |
261 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> createPrimitiveNumericValue(CSSPar
serValue*); | 278 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> createPrimitiveNumericValue(CSSPar
serValue*); |
262 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> createPrimitiveStringValue(CSSPars
erValue*); | 279 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> createPrimitiveStringValue(CSSPars
erValue*); |
263 | 280 |
264 PassRefPtrWillBeRawPtr<CSSValue> createCSSImageValueWithReferrer(const Strin
g& rawValue, const KURL&); | 281 PassRefPtrWillBeRawPtr<CSSValue> createCSSImageValueWithReferrer(const Strin
g& rawValue, const KURL&); |
265 | 282 |
266 bool validWidthOrHeight(CSSParserValue*); | |
267 | |
268 PassRefPtrWillBeRawPtr<CSSBasicShape> parseInsetRoundedCorners(PassRefPtrWil
lBeRawPtr<CSSBasicShapeInset>, CSSParserValueList*); | 283 PassRefPtrWillBeRawPtr<CSSBasicShape> parseInsetRoundedCorners(PassRefPtrWil
lBeRawPtr<CSSBasicShapeInset>, CSSParserValueList*); |
269 | 284 |
270 enum SizeParameterType { | 285 enum SizeParameterType { |
271 None, | 286 None, |
272 Auto, | 287 Auto, |
273 Length, | 288 Length, |
274 PageSize, | 289 PageSize, |
275 Orientation, | 290 Orientation, |
276 }; | 291 }; |
277 | 292 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 | 332 |
318 private: | 333 private: |
319 CSSPropertyParser* m_parser; | 334 CSSPropertyParser* m_parser; |
320 }; | 335 }; |
321 | 336 |
322 enum ReleaseParsedCalcValueCondition { | 337 enum ReleaseParsedCalcValueCondition { |
323 ReleaseParsedCalcValue, | 338 ReleaseParsedCalcValue, |
324 DoNotReleaseParsedCalcValue | 339 DoNotReleaseParsedCalcValue |
325 }; | 340 }; |
326 | 341 |
327 enum Units { | |
328 FUnknown = 0x0000, | |
329 FInteger = 0x0001, | |
330 FNumber = 0x0002, // Real Numbers | |
331 FPercent = 0x0004, | |
332 FLength = 0x0008, | |
333 FAngle = 0x0010, | |
334 FTime = 0x0020, | |
335 FFrequency = 0x0040, | |
336 FPositiveInteger = 0x0080, | |
337 FRelative = 0x0100, | |
338 FResolution = 0x0200, | |
339 FNonNeg = 0x0400 | |
340 }; | |
341 | |
342 friend inline Units operator|(Units a, Units b) | 342 friend inline Units operator|(Units a, Units b) |
343 { | 343 { |
344 return static_cast<Units>(static_cast<unsigned>(a) | static_cast<unsigne
d>(b)); | 344 return static_cast<Units>(static_cast<unsigned>(a) | static_cast<unsigne
d>(b)); |
345 } | 345 } |
346 | 346 |
| 347 bool validWidthOrHeight(CSSParserValue*, Units); |
| 348 |
347 bool validCalculationUnit(CSSParserValue*, Units, ReleaseParsedCalcValueCond
ition releaseCalc = DoNotReleaseParsedCalcValue); | 349 bool validCalculationUnit(CSSParserValue*, Units, ReleaseParsedCalcValueCond
ition releaseCalc = DoNotReleaseParsedCalcValue); |
348 | 350 |
349 bool shouldAcceptUnitLessValues(CSSParserValue*, Units, CSSParserMode); | 351 bool shouldAcceptUnitLessValues(CSSParserValue*, Units, CSSParserMode); |
350 | 352 |
351 inline bool validUnit(CSSParserValue* value, Units unitflags, ReleaseParsedC
alcValueCondition releaseCalc = DoNotReleaseParsedCalcValue) { return validUnit(
value, unitflags, m_context.mode(), releaseCalc); } | 353 inline bool validUnit(CSSParserValue* value, Units unitflags, ReleaseParsedC
alcValueCondition releaseCalc = DoNotReleaseParsedCalcValue) { return validUnit(
value, unitflags, m_context.mode(), releaseCalc); } |
352 bool validUnit(CSSParserValue*, Units, CSSParserMode, ReleaseParsedCalcValue
Condition releaseCalc = DoNotReleaseParsedCalcValue); | 354 bool validUnit(CSSParserValue*, Units, CSSParserMode, ReleaseParsedCalcValue
Condition releaseCalc = DoNotReleaseParsedCalcValue); |
353 | 355 |
354 bool parseBorderImageQuad(Units, RefPtrWillBeRawPtr<CSSPrimitiveValue>&); | 356 bool parseBorderImageQuad(Units, RefPtrWillBeRawPtr<CSSPrimitiveValue>&); |
355 int colorIntFromValue(CSSParserValue*); | 357 int colorIntFromValue(CSSParserValue*); |
356 bool isCalculation(CSSParserValue*); | 358 bool isCalculation(CSSParserValue*); |
(...skipping 25 matching lines...) Expand all Loading... |
382 friend PassRefPtrWillBeRawPtr<CSSPrimitiveValue> parseGradientColorOrKeyword
(CSSPropertyParser*, CSSParserValue*); | 384 friend PassRefPtrWillBeRawPtr<CSSPrimitiveValue> parseGradientColorOrKeyword
(CSSPropertyParser*, CSSParserValue*); |
383 }; | 385 }; |
384 | 386 |
385 CSSPropertyID cssPropertyID(const CSSParserString&); | 387 CSSPropertyID cssPropertyID(const CSSParserString&); |
386 CSSPropertyID cssPropertyID(const String&); | 388 CSSPropertyID cssPropertyID(const String&); |
387 CSSValueID cssValueKeywordID(const CSSParserString&); | 389 CSSValueID cssValueKeywordID(const CSSParserString&); |
388 | 390 |
389 } // namespace blink | 391 } // namespace blink |
390 | 392 |
391 #endif // CSSPropertyParser_h | 393 #endif // CSSPropertyParser_h |
OLD | NEW |