| 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) |
| 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) |
| 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 3240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4415 if (!isComma(v)) | 4417 if (!isComma(v)) |
| 4416 return false; | 4418 return false; |
| 4417 args->next(); | 4419 args->next(); |
| 4418 return true; | 4420 return true; |
| 4419 } | 4421 } |
| 4420 | 4422 |
| 4421 PassRefPtr<CSSValue> BisonCSSParser::parseAnimationTimingFunction() | 4423 PassRefPtr<CSSValue> BisonCSSParser::parseAnimationTimingFunction() |
| 4422 { | 4424 { |
| 4423 CSSParserValue* value = m_valueList->current(); | 4425 CSSParserValue* value = m_valueList->current(); |
| 4424 if (value->id == CSSValueEase || value->id == CSSValueLinear || value->id ==
CSSValueEaseIn || value->id == CSSValueEaseOut | 4426 if (value->id == CSSValueEase || value->id == CSSValueLinear || value->id ==
CSSValueEaseIn || value->id == CSSValueEaseOut |
| 4425 || value->id == CSSValueEaseInOut || value->id == CSSValueStepStart || v
alue->id == CSSValueStepEnd) | 4427 || value->id == CSSValueEaseInOut || value->id == CSSValueStepStart || v
alue->id == CSSValueStepEnd |
| 4428 || (value->id == CSSValueStepMiddle && m_parseStepMiddleTimingFunction)) |
| 4426 return cssValuePool().createIdentifierValue(value->id); | 4429 return cssValuePool().createIdentifierValue(value->id); |
| 4427 | 4430 |
| 4428 // We must be a function. | 4431 // We must be a function. |
| 4429 if (value->unit != CSSParserValue::Function) | 4432 if (value->unit != CSSParserValue::Function) |
| 4430 return 0; | 4433 return 0; |
| 4431 | 4434 |
| 4432 CSSParserValueList* args = value->function->args.get(); | 4435 CSSParserValueList* args = value->function->args.get(); |
| 4433 | 4436 |
| 4434 if (equalIgnoringCase(value->function->name, "steps(")) { | 4437 if (equalIgnoringCase(value->function->name, "steps(")) { |
| 4435 // For steps, 1 or 2 params must be specified (comma-separated) | 4438 // For steps, 1 or 2 params must be specified (comma-separated) |
| 4436 if (!args || (args->size() != 1 && args->size() != 3)) | 4439 if (!args || (args->size() != 1 && args->size() != 3)) |
| 4437 return 0; | 4440 return 0; |
| 4438 | 4441 |
| 4439 // There are two values. | 4442 // There are two values. |
| 4440 int numSteps; | 4443 int numSteps; |
| 4441 bool stepAtStart = false; | 4444 StepsTimingFunction::StepAtPosition stepAtPosition = StepsTimingFunction
::StepAtEnd; |
| 4442 | 4445 |
| 4443 CSSParserValue* v = args->current(); | 4446 CSSParserValue* v = args->current(); |
| 4444 if (!validUnit(v, FInteger)) | 4447 if (!validUnit(v, FInteger)) |
| 4445 return 0; | 4448 return 0; |
| 4446 numSteps = clampToInteger(v->fValue); | 4449 numSteps = clampToInteger(v->fValue); |
| 4447 if (numSteps < 1) | 4450 if (numSteps < 1) |
| 4448 return 0; | 4451 return 0; |
| 4449 v = args->next(); | 4452 v = args->next(); |
| 4450 | 4453 |
| 4451 if (v) { | 4454 if (v) { |
| 4452 // There is a comma so we need to parse the second value | 4455 // There is a comma so we need to parse the second value |
| 4453 if (!isComma(v)) | 4456 if (!isComma(v)) |
| 4454 return 0; | 4457 return 0; |
| 4455 v = args->next(); | 4458 v = args->next(); |
| 4456 if (v->id != CSSValueStart && v->id != CSSValueEnd) | 4459 if (!m_parseStepMiddleTimingFunction && v->id == CSSValueMiddle) |
| 4457 return 0; | 4460 return 0; |
| 4458 stepAtStart = v->id == CSSValueStart; | 4461 if (v->id != CSSValueStart && v->id != CSSValueEnd && v->id != CSSVa
lueMiddle) |
| 4462 return 0; |
| 4463 if (v->id == CSSValueStart) { |
| 4464 stepAtPosition = StepsTimingFunction::StepAtStart; |
| 4465 } else if (v->id == CSSValueMiddle) { |
| 4466 stepAtPosition = StepsTimingFunction::StepAtMiddle; |
| 4467 } |
| 4459 } | 4468 } |
| 4460 | 4469 |
| 4461 return CSSStepsTimingFunctionValue::create(numSteps, stepAtStart); | 4470 return CSSStepsTimingFunctionValue::create(numSteps, stepAtPosition); |
| 4462 } | 4471 } |
| 4463 | 4472 |
| 4464 if (equalIgnoringCase(value->function->name, "cubic-bezier(")) { | 4473 if (equalIgnoringCase(value->function->name, "cubic-bezier(")) { |
| 4465 // For cubic bezier, 4 values must be specified. | 4474 // For cubic bezier, 4 values must be specified. |
| 4466 if (!args || args->size() != 7) | 4475 if (!args || args->size() != 7) |
| 4467 return 0; | 4476 return 0; |
| 4468 | 4477 |
| 4469 // There are two points specified. The x values must be between 0 and 1
but the y values can exceed this range. | 4478 // There are two points specified. The x values must be between 0 and 1
but the y values can exceed this range. |
| 4470 double x1, y1, x2, y2; | 4479 double x1, y1, x2, y2; |
| 4471 | 4480 |
| (...skipping 5822 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10294 { | 10303 { |
| 10295 // The tokenizer checks for the construct of an+b. | 10304 // The tokenizer checks for the construct of an+b. |
| 10296 // However, since the {ident} rule precedes the {nth} rule, some of those | 10305 // However, since the {ident} rule precedes the {nth} rule, some of those |
| 10297 // tokens are identified as string literal. Furthermore we need to accept | 10306 // tokens are identified as string literal. Furthermore we need to accept |
| 10298 // "odd" and "even" which does not match to an+b. | 10307 // "odd" and "even" which does not match to an+b. |
| 10299 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even") | 10308 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even") |
| 10300 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n"); | 10309 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n"); |
| 10301 } | 10310 } |
| 10302 | 10311 |
| 10303 } | 10312 } |
| OLD | NEW |