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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
192 , m_supportsCondition(false) | 192 , m_supportsCondition(false) |
193 , m_selectorListForParseSelector(0) | 193 , m_selectorListForParseSelector(0) |
194 , m_numParsedPropertiesBeforeMarginBox(INVALID_NUM_PARSED_PROPERTIES) | 194 , m_numParsedPropertiesBeforeMarginBox(INVALID_NUM_PARSED_PROPERTIES) |
195 , m_inParseShorthand(0) | 195 , m_inParseShorthand(0) |
196 , m_currentShorthand(CSSPropertyInvalid) | 196 , m_currentShorthand(CSSPropertyInvalid) |
197 , m_implicitShorthand(false) | 197 , m_implicitShorthand(false) |
198 , m_hasFontFaceOnlyValues(false) | 198 , m_hasFontFaceOnlyValues(false) |
199 , m_hadSyntacticallyValidCSSRule(false) | 199 , m_hadSyntacticallyValidCSSRule(false) |
200 , m_logErrors(false) | 200 , m_logErrors(false) |
201 , m_ignoreErrors(false) | 201 , m_ignoreErrors(false) |
202 , m_parseStepMiddleTimingFunction(false) | |
eseidel
2014/02/05 01:41:18
This can't be right. We really need to disintangl
| |
202 , m_defaultNamespace(starAtom) | 203 , m_defaultNamespace(starAtom) |
203 , m_observer(0) | 204 , m_observer(0) |
204 , m_source(0) | 205 , m_source(0) |
205 , m_ruleHeaderType(CSSRuleSourceData::UNKNOWN_RULE) | 206 , m_ruleHeaderType(CSSRuleSourceData::UNKNOWN_RULE) |
206 , m_allowImportRules(true) | 207 , m_allowImportRules(true) |
207 , m_allowNamespaceDeclarations(true) | 208 , m_allowNamespaceDeclarations(true) |
208 , m_inViewport(false) | 209 , m_inViewport(false) |
209 , m_useCounter(counter) | 210 , m_useCounter(counter) |
210 , m_tokenizer(*this) | 211 , m_tokenizer(*this) |
211 { | 212 { |
(...skipping 895 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1107 if (!parseValue(dummyStyle.get(), CSSPropertyFontFamily, string, false, HTML QuirksMode, 0)) | 1108 if (!parseValue(dummyStyle.get(), CSSPropertyFontFamily, string, false, HTML QuirksMode, 0)) |
1108 return 0; | 1109 return 0; |
1109 | 1110 |
1110 RefPtr<CSSValue> fontFamily = dummyStyle->getPropertyCSSValue(CSSPropertyFon tFamily); | 1111 RefPtr<CSSValue> fontFamily = dummyStyle->getPropertyCSSValue(CSSPropertyFon tFamily); |
1111 if (!fontFamily->isValueList()) | 1112 if (!fontFamily->isValueList()) |
1112 return 0; | 1113 return 0; |
1113 | 1114 |
1114 return toCSSValueList(dummyStyle->getPropertyCSSValue(CSSPropertyFontFamily) .get()); | 1115 return toCSSValueList(dummyStyle->getPropertyCSSValue(CSSPropertyFontFamily) .get()); |
1115 } | 1116 } |
1116 | 1117 |
1117 PassRefPtr<CSSValue> BisonCSSParser::parseAnimationTimingFunctionValue(const Str ing& string) | 1118 PassRefPtr<CSSValue> BisonCSSParser::parseAnimationTimingFunctionValue(const Str ing& string, bool parseStepMiddleTimingFunction) |
1118 { | 1119 { |
1119 if (string.isEmpty()) | 1120 if (string.isEmpty()) |
1120 return 0; | 1121 return 0; |
1121 RefPtr<MutableStylePropertySet> style = MutableStylePropertySet::create(); | 1122 RefPtr<MutableStylePropertySet> style = MutableStylePropertySet::create(); |
1122 if (!parseValue(style.get(), CSSPropertyAnimationTimingFunction, string, fal se, HTMLStandardMode, 0)) | 1123 if (!parseValue(style.get(), CSSPropertyAnimationTimingFunction, string, fal se, HTMLStandardMode, 0, parseStepMiddleTimingFunction)) |
1123 return 0; | 1124 return 0; |
1124 | 1125 |
1125 return style->getPropertyCSSValue(CSSPropertyAnimationTimingFunction); | 1126 return style->getPropertyCSSValue(CSSPropertyAnimationTimingFunction); |
1126 } | 1127 } |
1127 | 1128 |
1128 bool BisonCSSParser::parseValue(MutableStylePropertySet* declaration, CSSPropert yID propertyID, const String& string, bool important, const Document& document) | 1129 bool BisonCSSParser::parseValue(MutableStylePropertySet* declaration, CSSPropert yID propertyID, const String& string, bool important, const Document& document) |
1129 { | 1130 { |
1130 ASSERT(!string.isEmpty()); | 1131 ASSERT(!string.isEmpty()); |
1131 | 1132 |
1132 CSSParserContext context(document); | 1133 CSSParserContext context(document); |
1133 | 1134 |
1134 if (parseSimpleLengthValue(declaration, propertyID, string, important, conte xt.mode())) | 1135 if (parseSimpleLengthValue(declaration, propertyID, string, important, conte xt.mode())) |
1135 return true; | 1136 return true; |
1136 if (parseColorValue(declaration, propertyID, string, important, context.mode ())) | 1137 if (parseColorValue(declaration, propertyID, string, important, context.mode ())) |
1137 return true; | 1138 return true; |
1138 if (parseKeywordValue(declaration, propertyID, string, important, context)) | 1139 if (parseKeywordValue(declaration, propertyID, string, important, context)) |
1139 return true; | 1140 return true; |
1140 | 1141 |
1141 BisonCSSParser parser(context, UseCounter::getFrom(&document)); | 1142 BisonCSSParser parser(context, UseCounter::getFrom(&document)); |
1142 return parser.parseValue(declaration, propertyID, string, important, static_ cast<StyleSheetContents*>(0)); | 1143 return parser.parseValue(declaration, propertyID, string, important, static_ cast<StyleSheetContents*>(0)); |
1143 } | 1144 } |
1144 | 1145 |
1145 bool BisonCSSParser::parseValue(MutableStylePropertySet* declaration, CSSPropert yID propertyID, const String& string, bool important, CSSParserMode cssParserMod e, StyleSheetContents* contextStyleSheet) | 1146 bool BisonCSSParser::parseValue(MutableStylePropertySet* declaration, CSSPropert yID propertyID, const String& string, bool important, CSSParserMode cssParserMod e, StyleSheetContents* contextStyleSheet, bool parseStepMiddleTimingFunction) |
Timothy Loh
2014/02/03 01:49:49
Why not just inline the relevant parts of this fun
rjwright
2014/02/03 02:47:14
I could do that. Although nothing else calls the p
alancutter (OOO until 2018)
2014/02/04 02:11:15
Should we add a FIXME to make step middle part of
| |
1146 { | 1147 { |
1147 ASSERT(!string.isEmpty()); | 1148 ASSERT(!string.isEmpty()); |
1148 if (parseSimpleLengthValue(declaration, propertyID, string, important, cssPa rserMode)) | 1149 if (parseSimpleLengthValue(declaration, propertyID, string, important, cssPa rserMode)) |
1149 return true; | 1150 return true; |
1150 if (parseColorValue(declaration, propertyID, string, important, cssParserMod e)) | 1151 if (parseColorValue(declaration, propertyID, string, important, cssParserMod e)) |
1151 return true; | 1152 return true; |
1152 | 1153 |
1153 CSSParserContext context(cssParserMode); | 1154 CSSParserContext context(cssParserMode); |
1154 if (contextStyleSheet) { | 1155 if (contextStyleSheet) { |
1155 context = contextStyleSheet->parserContext(); | 1156 context = contextStyleSheet->parserContext(); |
1156 context.setMode(cssParserMode); | 1157 context.setMode(cssParserMode); |
1157 } | 1158 } |
1158 | 1159 |
1159 if (parseKeywordValue(declaration, propertyID, string, important, context)) | 1160 if (parseKeywordValue(declaration, propertyID, string, important, context)) |
1160 return true; | 1161 return true; |
1161 if (parseTranslateTransform(declaration, propertyID, string, important)) | 1162 if (parseTranslateTransform(declaration, propertyID, string, important)) |
1162 return true; | 1163 return true; |
1163 | 1164 |
1164 BisonCSSParser parser(context); | 1165 BisonCSSParser parser(context); |
1166 parser.m_parseStepMiddleTimingFunction = parseStepMiddleTimingFunction; | |
1165 return parser.parseValue(declaration, propertyID, string, important, context StyleSheet); | 1167 return parser.parseValue(declaration, propertyID, string, important, context StyleSheet); |
1166 } | 1168 } |
1167 | 1169 |
1168 bool BisonCSSParser::parseValue(MutableStylePropertySet* declaration, CSSPropert yID propertyID, const String& string, bool important, StyleSheetContents* contex tStyleSheet) | 1170 bool BisonCSSParser::parseValue(MutableStylePropertySet* declaration, CSSPropert yID propertyID, const String& string, bool important, StyleSheetContents* contex tStyleSheet) |
1169 { | 1171 { |
1170 // FIXME: Check RuntimeCSSEnabled::isPropertyEnabled or isValueEnabledForPro perty. | 1172 // FIXME: Check RuntimeCSSEnabled::isPropertyEnabled or isValueEnabledForPro perty. |
1171 | 1173 |
1172 if (m_useCounter) | 1174 if (m_useCounter) |
1173 m_useCounter->count(m_context, propertyID); | 1175 m_useCounter->count(m_context, propertyID); |
1174 | 1176 |
(...skipping 3231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4406 if (!isComma(v)) | 4408 if (!isComma(v)) |
4407 return false; | 4409 return false; |
4408 args->next(); | 4410 args->next(); |
4409 return true; | 4411 return true; |
4410 } | 4412 } |
4411 | 4413 |
4412 PassRefPtr<CSSValue> BisonCSSParser::parseAnimationTimingFunction() | 4414 PassRefPtr<CSSValue> BisonCSSParser::parseAnimationTimingFunction() |
4413 { | 4415 { |
4414 CSSParserValue* value = m_valueList->current(); | 4416 CSSParserValue* value = m_valueList->current(); |
4415 if (value->id == CSSValueEase || value->id == CSSValueLinear || value->id == CSSValueEaseIn || value->id == CSSValueEaseOut | 4417 if (value->id == CSSValueEase || value->id == CSSValueLinear || value->id == CSSValueEaseIn || value->id == CSSValueEaseOut |
4416 || value->id == CSSValueEaseInOut || value->id == CSSValueStepStart || v alue->id == CSSValueStepEnd) | 4418 || value->id == CSSValueEaseInOut || value->id == CSSValueStepStart || v alue->id == CSSValueStepEnd |
4419 || (value->id == CSSValueStepMiddle && m_parseStepMiddleTimingFunction)) | |
4417 return cssValuePool().createIdentifierValue(value->id); | 4420 return cssValuePool().createIdentifierValue(value->id); |
4418 | 4421 |
4419 // We must be a function. | 4422 // We must be a function. |
4420 if (value->unit != CSSParserValue::Function) | 4423 if (value->unit != CSSParserValue::Function) |
4421 return 0; | 4424 return 0; |
4422 | 4425 |
4423 CSSParserValueList* args = value->function->args.get(); | 4426 CSSParserValueList* args = value->function->args.get(); |
4424 | 4427 |
4425 if (equalIgnoringCase(value->function->name, "steps(")) { | 4428 if (equalIgnoringCase(value->function->name, "steps(")) { |
4426 // For steps, 1 or 2 params must be specified (comma-separated) | 4429 // For steps, 1 or 2 params must be specified (comma-separated) |
4427 if (!args || (args->size() != 1 && args->size() != 3)) | 4430 if (!args || (args->size() != 1 && args->size() != 3)) |
4428 return 0; | 4431 return 0; |
4429 | 4432 |
4430 // There are two values. | 4433 // There are two values. |
4431 int numSteps; | 4434 int numSteps; |
4432 bool stepAtStart = false; | 4435 StepsTimingFunction::StepAtPosition stepAtPosition = StepsTimingFunction ::StepAtEnd; |
4433 | 4436 |
4434 CSSParserValue* v = args->current(); | 4437 CSSParserValue* v = args->current(); |
4435 if (!validUnit(v, FInteger)) | 4438 if (!validUnit(v, FInteger)) |
4436 return 0; | 4439 return 0; |
4437 numSteps = clampToInteger(v->fValue); | 4440 numSteps = clampToInteger(v->fValue); |
4438 if (numSteps < 1) | 4441 if (numSteps < 1) |
4439 return 0; | 4442 return 0; |
4440 v = args->next(); | 4443 v = args->next(); |
4441 | 4444 |
4442 if (v) { | 4445 if (v) { |
4443 // There is a comma so we need to parse the second value | 4446 // There is a comma so we need to parse the second value |
4444 if (!isComma(v)) | 4447 if (!isComma(v)) |
4445 return 0; | 4448 return 0; |
4446 v = args->next(); | 4449 v = args->next(); |
4447 if (v->id != CSSValueStart && v->id != CSSValueEnd) | 4450 if (!m_parseStepMiddleTimingFunction && v->id == CSSValueMiddle) |
4448 return 0; | 4451 return 0; |
4449 stepAtStart = v->id == CSSValueStart; | 4452 if (v->id != CSSValueStart && v->id != CSSValueEnd && v->id != CSSVa lueMiddle) |
4453 return 0; | |
4454 if (v->id == CSSValueStart) { | |
4455 stepAtPosition = StepsTimingFunction::StepAtStart; | |
4456 } else if (v->id == CSSValueMiddle) { | |
4457 stepAtPosition = StepsTimingFunction::StepAtMiddle; | |
4458 } | |
alancutter (OOO until 2018)
2014/02/04 01:19:12
The above 8 lines might be cleaner as a switch on
rjwright
2014/02/17 07:16:53
Done.
| |
4450 } | 4459 } |
4451 | 4460 |
4452 return CSSStepsTimingFunctionValue::create(numSteps, stepAtStart); | 4461 return CSSStepsTimingFunctionValue::create(numSteps, stepAtPosition); |
4453 } | 4462 } |
4454 | 4463 |
4455 if (equalIgnoringCase(value->function->name, "cubic-bezier(")) { | 4464 if (equalIgnoringCase(value->function->name, "cubic-bezier(")) { |
4456 // For cubic bezier, 4 values must be specified. | 4465 // For cubic bezier, 4 values must be specified. |
4457 if (!args || args->size() != 7) | 4466 if (!args || args->size() != 7) |
4458 return 0; | 4467 return 0; |
4459 | 4468 |
4460 // There are two points specified. The x values must be between 0 and 1 but the y values can exceed this range. | 4469 // There are two points specified. The x values must be between 0 and 1 but the y values can exceed this range. |
4461 double x1, y1, x2, y2; | 4470 double x1, y1, x2, y2; |
4462 | 4471 |
(...skipping 5822 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
10285 { | 10294 { |
10286 // The tokenizer checks for the construct of an+b. | 10295 // The tokenizer checks for the construct of an+b. |
10287 // However, since the {ident} rule precedes the {nth} rule, some of those | 10296 // However, since the {ident} rule precedes the {nth} rule, some of those |
10288 // tokens are identified as string literal. Furthermore we need to accept | 10297 // tokens are identified as string literal. Furthermore we need to accept |
10289 // "odd" and "even" which does not match to an+b. | 10298 // "odd" and "even" which does not match to an+b. |
10290 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even") | 10299 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even") |
10291 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n"); | 10300 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n"); |
10292 } | 10301 } |
10293 | 10302 |
10294 } | 10303 } |
OLD | NEW |