Chromium Code Reviews| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 45 struct CSSParserValue; | 45 struct CSSParserValue; |
| 46 class CSSParserValueList; | 46 class CSSParserValueList; |
| 47 class CSSPrimitiveValue; | 47 class CSSPrimitiveValue; |
| 48 class CSSProperty; | 48 class CSSProperty; |
| 49 class CSSQuadValue; | 49 class CSSQuadValue; |
| 50 class CSSShadowValue; | 50 class CSSShadowValue; |
| 51 class CSSValue; | 51 class CSSValue; |
| 52 class CSSValueList; | 52 class CSSValueList; |
| 53 class StylePropertyShorthand; | 53 class StylePropertyShorthand; |
| 54 | 54 |
| 55 enum class UnitlessQuirk { | |
| 56 Allow, | |
| 57 Forbid | |
| 58 }; | |
| 59 | |
| 55 // Inputs: PropertyID, isImportant bool, CSSParserValueList. | 60 // Inputs: PropertyID, isImportant bool, CSSParserValueList. |
| 56 // Outputs: Vector of CSSProperties | 61 // Outputs: Vector of CSSProperties |
| 57 | 62 |
| 58 class CSSPropertyParser { | 63 class CSSPropertyParser { |
| 59 STACK_ALLOCATED(); | 64 STACK_ALLOCATED(); |
| 60 public: | 65 public: |
| 61 | 66 |
| 62 enum Units { | 67 enum Units { |
| 63 FUnknown = 0x0000, | 68 FUnknown = 0x0000, |
| 64 FInteger = 0x0001, | 69 FInteger = 0x0001, |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 333 | 338 |
| 334 friend inline Units operator|(Units a, Units b) | 339 friend inline Units operator|(Units a, Units b) |
| 335 { | 340 { |
| 336 return static_cast<Units>(static_cast<unsigned>(a) | static_cast<unsigne d>(b)); | 341 return static_cast<Units>(static_cast<unsigned>(a) | static_cast<unsigne d>(b)); |
| 337 } | 342 } |
| 338 | 343 |
| 339 bool validWidthOrHeight(CSSParserValue*, Units); | 344 bool validWidthOrHeight(CSSParserValue*, Units); |
| 340 | 345 |
| 341 bool validCalculationUnit(CSSParserValue*, Units, ReleaseParsedCalcValueCond ition releaseCalc = DoNotReleaseParsedCalcValue); | 346 bool validCalculationUnit(CSSParserValue*, Units, ReleaseParsedCalcValueCond ition releaseCalc = DoNotReleaseParsedCalcValue); |
| 342 | 347 |
| 343 bool shouldAcceptUnitLessValues(CSSParserValue*, Units, CSSParserMode); | |
| 344 | |
| 345 inline bool validUnit(CSSParserValue* value, Units unitflags, ReleaseParsedC alcValueCondition releaseCalc = DoNotReleaseParsedCalcValue) { return validUnit( value, unitflags, m_context.mode(), releaseCalc); } | 348 inline bool validUnit(CSSParserValue* value, Units unitflags, ReleaseParsedC alcValueCondition releaseCalc = DoNotReleaseParsedCalcValue) { return validUnit( value, unitflags, m_context.mode(), releaseCalc); } |
| 346 bool validUnit(CSSParserValue*, Units, CSSParserMode, ReleaseParsedCalcValue Condition releaseCalc = DoNotReleaseParsedCalcValue); | 349 bool validUnit(CSSParserValue*, Units, CSSParserMode, ReleaseParsedCalcValue Condition releaseCalc = DoNotReleaseParsedCalcValue); |
| 347 | 350 |
| 348 bool parseBorderImageQuad(Units, RefPtrWillBeRawPtr<CSSQuadValue>&); | 351 bool parseBorderImageQuad(Units, RefPtrWillBeRawPtr<CSSQuadValue>&); |
| 349 int colorIntFromValue(CSSParserValue*); | 352 int colorIntFromValue(CSSParserValue*); |
| 350 | 353 |
| 351 bool buildBorderImageParseContext(CSSPropertyID, BorderImageParseContext&); | 354 bool buildBorderImageParseContext(CSSPropertyID, BorderImageParseContext&); |
| 352 | 355 |
| 353 bool parseDeprecatedGradientColorStop(CSSParserValue*, CSSGradientColorStop& ); | 356 bool parseDeprecatedGradientColorStop(CSSParserValue*, CSSGradientColorStop& ); |
| 354 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> parseDeprecatedGradientStopColor(c onst CSSParserValue*); | 357 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> parseDeprecatedGradientStopColor(c onst CSSParserValue*); |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 370 WillBeHeapVector<CSSProperty, 256>& m_parsedProperties; | 373 WillBeHeapVector<CSSProperty, 256>& m_parsedProperties; |
| 371 StyleRule::Type m_ruleType; | 374 StyleRule::Type m_ruleType; |
| 372 | 375 |
| 373 // Locals during parsing: | 376 // Locals during parsing: |
| 374 int m_inParseShorthand; | 377 int m_inParseShorthand; |
| 375 CSSPropertyID m_currentShorthand; | 378 CSSPropertyID m_currentShorthand; |
| 376 bool m_implicitShorthand; | 379 bool m_implicitShorthand; |
| 377 RefPtrWillBeMember<CSSCalcValue> m_parsedCalculation; | 380 RefPtrWillBeMember<CSSCalcValue> m_parsedCalculation; |
| 378 }; | 381 }; |
| 379 | 382 |
| 383 inline bool shouldAcceptUnitLessValues(double fValue, CSSPropertyParser::Units u nitflags, CSSParserMode cssParserMode) | |
|
alancutter (OOO until 2018)
2015/09/27 23:13:38
This should move back into LegacyCSSPropertyParser
| |
| 384 { | |
| 385 // Quirks mode for certain properties and presentation attributes accept uni t-less values for certain units. | |
| 386 return (unitflags & (CSSPropertyParser::FLength | CSSPropertyParser::FAngle) ) | |
| 387 && (!fValue // 0 can always be unitless. | |
| 388 || isUnitLessLengthParsingEnabledForMode(cssParserMode) // HTML and SVG attribute values can always be unitless. | |
| 389 || (cssParserMode == HTMLQuirksMode && (unitflags & CSSPropertyParse r::FUnitlessQuirk))); | |
| 390 } | |
| 391 | |
| 380 CSSPropertyID unresolvedCSSPropertyID(const CSSParserString&); | 392 CSSPropertyID unresolvedCSSPropertyID(const CSSParserString&); |
| 381 CSSValueID cssValueKeywordID(const CSSParserString&); | 393 CSSValueID cssValueKeywordID(const CSSParserString&); |
| 382 | 394 |
| 383 } // namespace blink | 395 } // namespace blink |
| 384 | 396 |
| 385 #endif // CSSPropertyParser_h | 397 #endif // CSSPropertyParser_h |
| OLD | NEW |