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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
83 CSSPropertyParser::CSSPropertyParser(CSSParserValueList* valueList, | 83 CSSPropertyParser::CSSPropertyParser(CSSParserValueList* valueList, |
84 const CSSParserContext& context, WillBeHeapVector<CSSProperty, 256>& parsedP roperties, | 84 const CSSParserContext& context, WillBeHeapVector<CSSProperty, 256>& parsedP roperties, |
85 StyleRule::Type ruleType) | 85 StyleRule::Type ruleType) |
86 : m_valueList(valueList) | 86 : m_valueList(valueList) |
87 , m_context(context) | 87 , m_context(context) |
88 , m_parsedProperties(parsedProperties) | 88 , m_parsedProperties(parsedProperties) |
89 , m_ruleType(ruleType) | 89 , m_ruleType(ruleType) |
90 , m_inParseShorthand(0) | 90 , m_inParseShorthand(0) |
91 , m_currentShorthand(CSSPropertyInvalid) | 91 , m_currentShorthand(CSSPropertyInvalid) |
92 , m_implicitShorthand(false) | 92 , m_implicitShorthand(false) |
93 , m_usesRems(false) | |
93 { | 94 { |
94 } | 95 } |
95 | 96 |
96 bool CSSPropertyParser::parseValue(CSSPropertyID unresolvedProperty, bool import ant, | 97 bool CSSPropertyParser::parseValue(CSSPropertyID unresolvedProperty, bool import ant, |
97 CSSParserValueList* valueList, const CSSParserContext& context, | 98 CSSParserValueList* valueList, const CSSParserContext& context, |
98 WillBeHeapVector<CSSProperty, 256>& parsedProperties, StyleRule::Type ruleTy pe) | 99 WillBeHeapVector<CSSProperty, 256>& parsedProperties, StyleRule::Type ruleTy pe, bool &usesRems) |
99 { | 100 { |
100 int parsedPropertiesSize = parsedProperties.size(); | 101 int parsedPropertiesSize = parsedProperties.size(); |
101 | 102 |
102 CSSPropertyParser parser(valueList, context, parsedProperties, ruleType); | 103 CSSPropertyParser parser(valueList, context, parsedProperties, ruleType); |
103 CSSPropertyID resolvedProperty = resolveCSSPropertyID(unresolvedProperty); | 104 CSSPropertyID resolvedProperty = resolveCSSPropertyID(unresolvedProperty); |
104 bool parseSuccess; | 105 bool parseSuccess; |
105 | 106 |
106 if (ruleType == StyleRule::Viewport) { | 107 if (ruleType == StyleRule::Viewport) { |
107 parseSuccess = (RuntimeEnabledFeatures::cssViewportEnabled() || isUAShee tBehavior(context.mode())) | 108 parseSuccess = (RuntimeEnabledFeatures::cssViewportEnabled() || isUAShee tBehavior(context.mode())) |
108 && parser.parseViewportProperty(resolvedProperty, important); | 109 && parser.parseViewportProperty(resolvedProperty, important); |
109 } else if (ruleType == StyleRule::FontFace) { | 110 } else if (ruleType == StyleRule::FontFace) { |
110 parseSuccess = parser.parseFontFaceDescriptor(resolvedProperty); | 111 parseSuccess = parser.parseFontFaceDescriptor(resolvedProperty); |
111 } else { | 112 } else { |
112 parseSuccess = parser.parseValue(unresolvedProperty, important); | 113 parseSuccess = parser.parseValue(unresolvedProperty, important); |
113 } | 114 } |
114 | 115 |
115 // This doesn't count UA style sheets | 116 // This doesn't count UA style sheets |
116 if (parseSuccess && context.useCounter()) | 117 if (parseSuccess && context.useCounter()) |
117 context.useCounter()->count(context, unresolvedProperty); | 118 context.useCounter()->count(context, unresolvedProperty); |
118 | 119 |
119 if (!parseSuccess) | 120 if (!parseSuccess) |
120 parser.rollbackLastProperties(parsedProperties.size() - parsedProperties Size); | 121 parser.rollbackLastProperties(parsedProperties.size() - parsedProperties Size); |
122 else | |
123 usesRems = parser.m_usesRems; | |
121 | 124 |
122 return parseSuccess; | 125 return parseSuccess; |
123 } | 126 } |
124 | 127 |
125 void CSSPropertyParser::addProperty(CSSPropertyID propId, PassRefPtrWillBeRawPtr <CSSValue> value, bool important, bool implicit) | 128 void CSSPropertyParser::addProperty(CSSPropertyID propId, PassRefPtrWillBeRawPtr <CSSValue> value, bool important, bool implicit) |
126 { | 129 { |
127 ASSERT(!isPropertyAlias(propId)); | 130 ASSERT(!isPropertyAlias(propId)); |
128 | 131 |
129 int shorthandIndex = 0; | 132 int shorthandIndex = 0; |
130 bool setFromShorthand = false; | 133 bool setFromShorthand = false; |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
375 } | 378 } |
376 return validUnit(value, FLength | FPercent | FNonNeg | unitless); | 379 return validUnit(value, FLength | FPercent | FNonNeg | unitless); |
377 } | 380 } |
378 | 381 |
379 inline PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::parseValidPr imitive(CSSValueID identifier, CSSParserValue* value) | 382 inline PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::parseValidPr imitive(CSSValueID identifier, CSSParserValue* value) |
380 { | 383 { |
381 if (identifier) | 384 if (identifier) |
382 return cssValuePool().createIdentifierValue(identifier); | 385 return cssValuePool().createIdentifierValue(identifier); |
383 if (value->unit >= CSSPrimitiveValue::CSS_NUMBER && value->unit <= CSSPrimit iveValue::CSS_KHZ) | 386 if (value->unit >= CSSPrimitiveValue::CSS_NUMBER && value->unit <= CSSPrimit iveValue::CSS_KHZ) |
384 return createPrimitiveNumericValue(value); | 387 return createPrimitiveNumericValue(value); |
388 if (value->unit == CSSPrimitiveValue::CSS_REMS) { | |
Timothy Loh
2015/06/17 01:35:18
Probably better in createPrimitiveNumericValue, I
| |
389 m_usesRems = true; | |
390 return createPrimitiveNumericValue(value); | |
391 } | |
385 if (value->unit >= CSSPrimitiveValue::CSS_TURN && value->unit <= CSSPrimitiv eValue::CSS_CHS) | 392 if (value->unit >= CSSPrimitiveValue::CSS_TURN && value->unit <= CSSPrimitiv eValue::CSS_CHS) |
386 return createPrimitiveNumericValue(value); | 393 return createPrimitiveNumericValue(value); |
387 if (value->unit >= CSSPrimitiveValue::CSS_VW && value->unit <= CSSPrimitiveV alue::CSS_VMAX) | 394 if (value->unit >= CSSPrimitiveValue::CSS_VW && value->unit <= CSSPrimitiveV alue::CSS_VMAX) |
388 return createPrimitiveNumericValue(value); | 395 return createPrimitiveNumericValue(value); |
389 if (value->unit >= CSSPrimitiveValue::CSS_DPPX && value->unit <= CSSPrimitiv eValue::CSS_DPCM) | 396 if (value->unit >= CSSPrimitiveValue::CSS_DPPX && value->unit <= CSSPrimitiv eValue::CSS_DPCM) |
390 return createPrimitiveNumericValue(value); | 397 return createPrimitiveNumericValue(value); |
391 if (value->unit == CSSPrimitiveValue::CSS_QEM) | 398 if (value->unit == CSSPrimitiveValue::CSS_QEM) |
392 return CSSPrimitiveValue::createAllowingMarginQuirk(value->fValue, CSSPr imitiveValue::CSS_EMS); | 399 return CSSPrimitiveValue::createAllowingMarginQuirk(value->fValue, CSSPr imitiveValue::CSS_EMS); |
393 if (isCalculation(value)) | 400 if (isCalculation(value)) |
394 return CSSPrimitiveValue::create(m_parsedCalculation.release()); | 401 return CSSPrimitiveValue::create(m_parsedCalculation.release()); |
(...skipping 7784 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8179 } | 8186 } |
8180 } | 8187 } |
8181 | 8188 |
8182 if (!list->length()) | 8189 if (!list->length()) |
8183 return nullptr; | 8190 return nullptr; |
8184 | 8191 |
8185 return list.release(); | 8192 return list.release(); |
8186 } | 8193 } |
8187 | 8194 |
8188 } // namespace blink | 8195 } // namespace blink |
OLD | NEW |