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 * |
11 * This library is free software; you can redistribute it and/or | 11 * This library is free software; you can redistribute it and/or |
12 * modify it under the terms of the GNU Library General Public | 12 * modify it under the terms of the GNU Library General Public |
13 * License as published by the Free Software Foundation; either | 13 * License as published by the Free Software Foundation; either |
14 * version 2 of the License, or (at your option) any later version. | 14 * version 2 of the License, or (at your option) any later version. |
15 * | 15 * |
16 * This library is distributed in the hope that it will be useful, | 16 * This library is distributed in the hope that it will be useful, |
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
19 * Library General Public License for more details. | 19 * Library General Public License for more details. |
20 * | 20 * |
21 * You should have received a copy of the GNU Library General Public License | 21 * You should have received a copy of the GNU Library General Public License |
22 * along with this library; see the file COPYING.LIB. If not, write to | 22 * along with this library; see the file COPYING.LIB. If not, write to |
23 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 23 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
24 * Boston, MA 02110-1301, USA. | 24 * Boston, MA 02110-1301, USA. |
25 */ | 25 */ |
26 | 26 |
27 #include "config.h" | 27 #include "config.h" |
28 #include "core/css/CSSParser.h" | 28 #include "core/css/parser/BisonCSSParser.h" |
29 | 29 |
30 #include "CSSValueKeywords.h" | 30 #include "CSSValueKeywords.h" |
31 #include "RuntimeEnabledFeatures.h" | 31 #include "RuntimeEnabledFeatures.h" |
32 #include "StylePropertyShorthand.h" | 32 #include "StylePropertyShorthand.h" |
33 #include "core/css/CSSArrayFunctionValue.h" | 33 #include "core/css/CSSArrayFunctionValue.h" |
34 #include "core/css/CSSAspectRatioValue.h" | 34 #include "core/css/CSSAspectRatioValue.h" |
35 #include "core/css/CSSBasicShapes.h" | 35 #include "core/css/CSSBasicShapes.h" |
36 #include "core/css/CSSBorderImage.h" | 36 #include "core/css/CSSBorderImage.h" |
37 #include "core/css/CSSCanvasValue.h" | 37 #include "core/css/CSSCanvasValue.h" |
38 #include "core/css/CSSCrossfadeValue.h" | 38 #include "core/css/CSSCrossfadeValue.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 #include "wtf/text/StringImpl.h" | 92 #include "wtf/text/StringImpl.h" |
93 #include "wtf/text/TextEncoding.h" | 93 #include "wtf/text/TextEncoding.h" |
94 #include <limits.h> | 94 #include <limits.h> |
95 | 95 |
96 #define YYDEBUG 0 | 96 #define YYDEBUG 0 |
97 | 97 |
98 #if YYDEBUG > 0 | 98 #if YYDEBUG > 0 |
99 extern int cssyydebug; | 99 extern int cssyydebug; |
100 #endif | 100 #endif |
101 | 101 |
102 extern int cssyyparse(WebCore::CSSParser*); | 102 extern int cssyyparse(WebCore::BisonCSSParser*); |
103 | 103 |
104 using namespace std; | 104 using namespace std; |
105 using namespace WTF; | 105 using namespace WTF; |
106 | 106 |
107 namespace WebCore { | 107 namespace WebCore { |
108 | 108 |
109 static const unsigned INVALID_NUM_PARSED_PROPERTIES = UINT_MAX; | 109 static const unsigned INVALID_NUM_PARSED_PROPERTIES = UINT_MAX; |
110 static const double MAX_SCALE = 1000000; | 110 static const double MAX_SCALE = 1000000; |
111 | 111 |
112 template <unsigned N> | 112 template <unsigned N> |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 { | 179 { |
180 m_hasSeenAnimationPropertyKeyword = true; | 180 m_hasSeenAnimationPropertyKeyword = true; |
181 } | 181 } |
182 | 182 |
183 private: | 183 private: |
184 bool m_animationPropertyKeywordAllowed; | 184 bool m_animationPropertyKeywordAllowed; |
185 bool m_firstAnimationCommitted; | 185 bool m_firstAnimationCommitted; |
186 bool m_hasSeenAnimationPropertyKeyword; | 186 bool m_hasSeenAnimationPropertyKeyword; |
187 }; | 187 }; |
188 | 188 |
189 CSSParser::CSSParser(const CSSParserContext& context, UseCounter* counter) | 189 BisonCSSParser::BisonCSSParser(const CSSParserContext& context, UseCounter* coun
ter) |
190 : m_context(context) | 190 : m_context(context) |
191 , m_important(false) | 191 , m_important(false) |
192 , m_id(CSSPropertyInvalid) | 192 , m_id(CSSPropertyInvalid) |
193 , m_styleSheet(0) | 193 , m_styleSheet(0) |
194 , m_supportsCondition(false) | 194 , m_supportsCondition(false) |
195 , m_selectorListForParseSelector(0) | 195 , m_selectorListForParseSelector(0) |
196 , m_numParsedPropertiesBeforeMarginBox(INVALID_NUM_PARSED_PROPERTIES) | 196 , m_numParsedPropertiesBeforeMarginBox(INVALID_NUM_PARSED_PROPERTIES) |
197 , m_inParseShorthand(0) | 197 , m_inParseShorthand(0) |
198 , m_currentShorthand(CSSPropertyInvalid) | 198 , m_currentShorthand(CSSPropertyInvalid) |
199 , m_implicitShorthand(false) | 199 , m_implicitShorthand(false) |
(...skipping 11 matching lines...) Expand all Loading... |
211 , m_inViewport(false) | 211 , m_inViewport(false) |
212 , m_useCounter(counter) | 212 , m_useCounter(counter) |
213 , m_tokenizer(*this) | 213 , m_tokenizer(*this) |
214 { | 214 { |
215 #if YYDEBUG > 0 | 215 #if YYDEBUG > 0 |
216 cssyydebug = 1; | 216 cssyydebug = 1; |
217 #endif | 217 #endif |
218 CSSPropertySourceData::init(); | 218 CSSPropertySourceData::init(); |
219 } | 219 } |
220 | 220 |
221 CSSParser::~CSSParser() | 221 BisonCSSParser::~BisonCSSParser() |
222 { | 222 { |
223 clearProperties(); | 223 clearProperties(); |
224 | 224 |
225 deleteAllValues(m_floatingSelectors); | 225 deleteAllValues(m_floatingSelectors); |
226 deleteAllValues(m_floatingSelectorVectors); | 226 deleteAllValues(m_floatingSelectorVectors); |
227 deleteAllValues(m_floatingValueLists); | 227 deleteAllValues(m_floatingValueLists); |
228 deleteAllValues(m_floatingFunctions); | 228 deleteAllValues(m_floatingFunctions); |
229 } | 229 } |
230 | 230 |
231 void CSSParser::setupParser(const char* prefix, unsigned prefixLength, const Str
ing& string, const char* suffix, unsigned suffixLength) | 231 void BisonCSSParser::setupParser(const char* prefix, unsigned prefixLength, cons
t String& string, const char* suffix, unsigned suffixLength) |
232 { | 232 { |
233 m_tokenizer.setupTokenizer(prefix, prefixLength, string, suffix, suffixLengt
h); | 233 m_tokenizer.setupTokenizer(prefix, prefixLength, string, suffix, suffixLengt
h); |
234 m_ruleHasHeader = true; | 234 m_ruleHasHeader = true; |
235 } | 235 } |
236 | 236 |
237 void CSSParser::parseSheet(StyleSheetContents* sheet, const String& string, cons
t TextPosition& startPosition, CSSParserObserver* observer, bool logErrors) | 237 void BisonCSSParser::parseSheet(StyleSheetContents* sheet, const String& string,
const TextPosition& startPosition, CSSParserObserver* observer, bool logErrors) |
238 { | 238 { |
239 setStyleSheet(sheet); | 239 setStyleSheet(sheet); |
240 m_defaultNamespace = starAtom; // Reset the default namespace. | 240 m_defaultNamespace = starAtom; // Reset the default namespace. |
241 TemporaryChange<CSSParserObserver*> scopedObsever(m_observer, observer); | 241 TemporaryChange<CSSParserObserver*> scopedObsever(m_observer, observer); |
242 m_logErrors = logErrors && sheet->singleOwnerDocument() && !sheet->baseURL()
.isEmpty() && sheet->singleOwnerDocument()->frameHost(); | 242 m_logErrors = logErrors && sheet->singleOwnerDocument() && !sheet->baseURL()
.isEmpty() && sheet->singleOwnerDocument()->frameHost(); |
243 m_ignoreErrors = false; | 243 m_ignoreErrors = false; |
244 m_tokenizer.m_lineNumber = 0; | 244 m_tokenizer.m_lineNumber = 0; |
245 m_startPosition = startPosition; | 245 m_startPosition = startPosition; |
246 m_source = &string; | 246 m_source = &string; |
247 m_tokenizer.m_internal = false; | 247 m_tokenizer.m_internal = false; |
248 setupParser("", string, ""); | 248 setupParser("", string, ""); |
249 cssyyparse(this); | 249 cssyyparse(this); |
250 sheet->shrinkToFit(); | 250 sheet->shrinkToFit(); |
251 m_source = 0; | 251 m_source = 0; |
252 m_rule = 0; | 252 m_rule = 0; |
253 m_lineEndings.clear(); | 253 m_lineEndings.clear(); |
254 m_ignoreErrors = false; | 254 m_ignoreErrors = false; |
255 m_logErrors = false; | 255 m_logErrors = false; |
256 m_tokenizer.m_internal = true; | 256 m_tokenizer.m_internal = true; |
257 } | 257 } |
258 | 258 |
259 PassRefPtr<StyleRuleBase> CSSParser::parseRule(StyleSheetContents* sheet, const
String& string) | 259 PassRefPtr<StyleRuleBase> BisonCSSParser::parseRule(StyleSheetContents* sheet, c
onst String& string) |
260 { | 260 { |
261 setStyleSheet(sheet); | 261 setStyleSheet(sheet); |
262 m_allowNamespaceDeclarations = false; | 262 m_allowNamespaceDeclarations = false; |
263 setupParser("@-internal-rule ", string, ""); | 263 setupParser("@-internal-rule ", string, ""); |
264 cssyyparse(this); | 264 cssyyparse(this); |
265 return m_rule.release(); | 265 return m_rule.release(); |
266 } | 266 } |
267 | 267 |
268 PassRefPtr<StyleKeyframe> CSSParser::parseKeyframeRule(StyleSheetContents* sheet
, const String& string) | 268 PassRefPtr<StyleKeyframe> BisonCSSParser::parseKeyframeRule(StyleSheetContents*
sheet, const String& string) |
269 { | 269 { |
270 setStyleSheet(sheet); | 270 setStyleSheet(sheet); |
271 setupParser("@-internal-keyframe-rule ", string, ""); | 271 setupParser("@-internal-keyframe-rule ", string, ""); |
272 cssyyparse(this); | 272 cssyyparse(this); |
273 return m_keyframe.release(); | 273 return m_keyframe.release(); |
274 } | 274 } |
275 | 275 |
276 PassOwnPtr<Vector<double> > CSSParser::parseKeyframeKeyList(const String& string
) | 276 PassOwnPtr<Vector<double> > BisonCSSParser::parseKeyframeKeyList(const String& s
tring) |
277 { | 277 { |
278 setupParser("@-internal-keyframe-key-list ", string, ""); | 278 setupParser("@-internal-keyframe-key-list ", string, ""); |
279 cssyyparse(this); | 279 cssyyparse(this); |
280 ASSERT(m_valueList); | 280 ASSERT(m_valueList); |
281 return StyleKeyframe::createKeyList(m_valueList.get()); | 281 return StyleKeyframe::createKeyList(m_valueList.get()); |
282 } | 282 } |
283 | 283 |
284 bool CSSParser::parseSupportsCondition(const String& string) | 284 bool BisonCSSParser::parseSupportsCondition(const String& string) |
285 { | 285 { |
286 m_supportsCondition = false; | 286 m_supportsCondition = false; |
287 setupParser("@-internal-supports-condition ", string, ""); | 287 setupParser("@-internal-supports-condition ", string, ""); |
288 cssyyparse(this); | 288 cssyyparse(this); |
289 return m_supportsCondition; | 289 return m_supportsCondition; |
290 } | 290 } |
291 | 291 |
292 static inline bool isColorPropertyID(CSSPropertyID propertyId) | 292 static inline bool isColorPropertyID(CSSPropertyID propertyId) |
293 { | 293 { |
294 switch (propertyId) { | 294 switch (propertyId) { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 || (quirksMode && valueID >= CSSValueWebkitFocusRingColor && valueID < C
SSValueWebkitText)) { | 336 || (quirksMode && valueID >= CSSValueWebkitFocusRingColor && valueID < C
SSValueWebkitText)) { |
337 validPrimitive = true; | 337 validPrimitive = true; |
338 } | 338 } |
339 | 339 |
340 if (validPrimitive) { | 340 if (validPrimitive) { |
341 RefPtr<CSSValue> value = cssValuePool().createIdentifierValue(valueID); | 341 RefPtr<CSSValue> value = cssValuePool().createIdentifierValue(valueID); |
342 declaration->addParsedProperty(CSSProperty(propertyId, value.release(),
important)); | 342 declaration->addParsedProperty(CSSProperty(propertyId, value.release(),
important)); |
343 return true; | 343 return true; |
344 } | 344 } |
345 RGBA32 color; | 345 RGBA32 color; |
346 if (!CSSParser::fastParseColor(color, string, !quirksMode && string[0] != '#
')) | 346 if (!BisonCSSParser::fastParseColor(color, string, !quirksMode && string[0]
!= '#')) |
347 return false; | 347 return false; |
348 RefPtr<CSSValue> value = cssValuePool().createColorValue(color); | 348 RefPtr<CSSValue> value = cssValuePool().createColorValue(color); |
349 declaration->addParsedProperty(CSSProperty(propertyId, value.release(), impo
rtant)); | 349 declaration->addParsedProperty(CSSProperty(propertyId, value.release(), impo
rtant)); |
350 return true; | 350 return true; |
351 } | 351 } |
352 | 352 |
353 static inline bool isSimpleLengthPropertyID(CSSPropertyID propertyId, bool& acce
ptsNegativeNumbers) | 353 static inline bool isSimpleLengthPropertyID(CSSPropertyID propertyId, bool& acce
ptsNegativeNumbers) |
354 { | 354 { |
355 switch (propertyId) { | 355 switch (propertyId) { |
356 case CSSPropertyFontSize: | 356 case CSSPropertyFontSize: |
(...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
947 static bool parseKeywordValue(MutableStylePropertySet* declaration, CSSPropertyI
D propertyId, const String& string, bool important, const CSSParserContext& pars
erContext) | 947 static bool parseKeywordValue(MutableStylePropertySet* declaration, CSSPropertyI
D propertyId, const String& string, bool important, const CSSParserContext& pars
erContext) |
948 { | 948 { |
949 ASSERT(!string.isEmpty()); | 949 ASSERT(!string.isEmpty()); |
950 | 950 |
951 if (!isKeywordPropertyID(propertyId)) { | 951 if (!isKeywordPropertyID(propertyId)) { |
952 // All properties accept the values of "initial" and "inherit". | 952 // All properties accept the values of "initial" and "inherit". |
953 String lowerCaseString = string.lower(); | 953 String lowerCaseString = string.lower(); |
954 if (lowerCaseString != "initial" && lowerCaseString != "inherit") | 954 if (lowerCaseString != "initial" && lowerCaseString != "inherit") |
955 return false; | 955 return false; |
956 | 956 |
957 // Parse initial/inherit shorthands using the CSSParser. | 957 // Parse initial/inherit shorthands using the BisonCSSParser. |
958 if (shorthandForProperty(propertyId).length()) | 958 if (shorthandForProperty(propertyId).length()) |
959 return false; | 959 return false; |
960 } | 960 } |
961 | 961 |
962 CSSParserString cssString; | 962 CSSParserString cssString; |
963 cssString.init(string); | 963 cssString.init(string); |
964 CSSValueID valueID = cssValueKeywordID(cssString); | 964 CSSValueID valueID = cssValueKeywordID(cssString); |
965 | 965 |
966 if (!valueID) | 966 if (!valueID) |
967 return false; | 967 return false; |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1086 const UChar* pos = string.characters16(); | 1086 const UChar* pos = string.characters16(); |
1087 const UChar* end = pos + string.length(); | 1087 const UChar* end = pos + string.length(); |
1088 transformList = parseTranslateTransformList(pos, end); | 1088 transformList = parseTranslateTransformList(pos, end); |
1089 if (!transformList) | 1089 if (!transformList) |
1090 return false; | 1090 return false; |
1091 } | 1091 } |
1092 properties->addParsedProperty(CSSProperty(CSSPropertyWebkitTransform, transf
ormList.release(), important)); | 1092 properties->addParsedProperty(CSSProperty(CSSPropertyWebkitTransform, transf
ormList.release(), important)); |
1093 return true; | 1093 return true; |
1094 } | 1094 } |
1095 | 1095 |
1096 PassRefPtr<CSSValueList> CSSParser::parseFontFaceValue(const AtomicString& strin
g) | 1096 PassRefPtr<CSSValueList> BisonCSSParser::parseFontFaceValue(const AtomicString&
string) |
1097 { | 1097 { |
1098 if (string.isEmpty()) | 1098 if (string.isEmpty()) |
1099 return 0; | 1099 return 0; |
1100 RefPtr<MutableStylePropertySet> dummyStyle = MutableStylePropertySet::create
(); | 1100 RefPtr<MutableStylePropertySet> dummyStyle = MutableStylePropertySet::create
(); |
1101 if (!parseValue(dummyStyle.get(), CSSPropertyFontFamily, string, false, HTML
QuirksMode, 0)) | 1101 if (!parseValue(dummyStyle.get(), CSSPropertyFontFamily, string, false, HTML
QuirksMode, 0)) |
1102 return 0; | 1102 return 0; |
1103 | 1103 |
1104 RefPtr<CSSValue> fontFamily = dummyStyle->getPropertyCSSValue(CSSPropertyFon
tFamily); | 1104 RefPtr<CSSValue> fontFamily = dummyStyle->getPropertyCSSValue(CSSPropertyFon
tFamily); |
1105 if (!fontFamily->isValueList()) | 1105 if (!fontFamily->isValueList()) |
1106 return 0; | 1106 return 0; |
1107 | 1107 |
1108 return toCSSValueList(dummyStyle->getPropertyCSSValue(CSSPropertyFontFamily)
.get()); | 1108 return toCSSValueList(dummyStyle->getPropertyCSSValue(CSSPropertyFontFamily)
.get()); |
1109 } | 1109 } |
1110 | 1110 |
1111 bool CSSParser::parseValue(MutableStylePropertySet* declaration, CSSPropertyID p
ropertyID, const String& string, bool important, const Document& document) | 1111 bool BisonCSSParser::parseValue(MutableStylePropertySet* declaration, CSSPropert
yID propertyID, const String& string, bool important, const Document& document) |
1112 { | 1112 { |
1113 ASSERT(!string.isEmpty()); | 1113 ASSERT(!string.isEmpty()); |
1114 | 1114 |
1115 CSSParserContext context(document); | 1115 CSSParserContext context(document); |
1116 | 1116 |
1117 if (parseSimpleLengthValue(declaration, propertyID, string, important, conte
xt.mode())) | 1117 if (parseSimpleLengthValue(declaration, propertyID, string, important, conte
xt.mode())) |
1118 return true; | 1118 return true; |
1119 if (parseColorValue(declaration, propertyID, string, important, context.mode
())) | 1119 if (parseColorValue(declaration, propertyID, string, important, context.mode
())) |
1120 return true; | 1120 return true; |
1121 if (parseKeywordValue(declaration, propertyID, string, important, context)) | 1121 if (parseKeywordValue(declaration, propertyID, string, important, context)) |
1122 return true; | 1122 return true; |
1123 | 1123 |
1124 CSSParser parser(context, UseCounter::getFrom(&document)); | 1124 BisonCSSParser parser(context, UseCounter::getFrom(&document)); |
1125 return parser.parseValue(declaration, propertyID, string, important, static_
cast<StyleSheetContents*>(0)); | 1125 return parser.parseValue(declaration, propertyID, string, important, static_
cast<StyleSheetContents*>(0)); |
1126 } | 1126 } |
1127 | 1127 |
1128 bool CSSParser::parseValue(MutableStylePropertySet* declaration, CSSPropertyID p
ropertyID, const String& string, bool important, CSSParserMode cssParserMode, St
yleSheetContents* contextStyleSheet) | 1128 bool BisonCSSParser::parseValue(MutableStylePropertySet* declaration, CSSPropert
yID propertyID, const String& string, bool important, CSSParserMode cssParserMod
e, StyleSheetContents* contextStyleSheet) |
1129 { | 1129 { |
1130 ASSERT(!string.isEmpty()); | 1130 ASSERT(!string.isEmpty()); |
1131 if (parseSimpleLengthValue(declaration, propertyID, string, important, cssPa
rserMode)) | 1131 if (parseSimpleLengthValue(declaration, propertyID, string, important, cssPa
rserMode)) |
1132 return true; | 1132 return true; |
1133 if (parseColorValue(declaration, propertyID, string, important, cssParserMod
e)) | 1133 if (parseColorValue(declaration, propertyID, string, important, cssParserMod
e)) |
1134 return true; | 1134 return true; |
1135 | 1135 |
1136 CSSParserContext context(cssParserMode); | 1136 CSSParserContext context(cssParserMode); |
1137 if (contextStyleSheet) { | 1137 if (contextStyleSheet) { |
1138 context = contextStyleSheet->parserContext(); | 1138 context = contextStyleSheet->parserContext(); |
1139 context.setMode(cssParserMode); | 1139 context.setMode(cssParserMode); |
1140 } | 1140 } |
1141 | 1141 |
1142 if (parseKeywordValue(declaration, propertyID, string, important, context)) | 1142 if (parseKeywordValue(declaration, propertyID, string, important, context)) |
1143 return true; | 1143 return true; |
1144 if (parseTranslateTransform(declaration, propertyID, string, important)) | 1144 if (parseTranslateTransform(declaration, propertyID, string, important)) |
1145 return true; | 1145 return true; |
1146 | 1146 |
1147 CSSParser parser(context); | 1147 BisonCSSParser parser(context); |
1148 return parser.parseValue(declaration, propertyID, string, important, context
StyleSheet); | 1148 return parser.parseValue(declaration, propertyID, string, important, context
StyleSheet); |
1149 } | 1149 } |
1150 | 1150 |
1151 bool CSSParser::parseValue(MutableStylePropertySet* declaration, CSSPropertyID p
ropertyID, const String& string, bool important, StyleSheetContents* contextStyl
eSheet) | 1151 bool BisonCSSParser::parseValue(MutableStylePropertySet* declaration, CSSPropert
yID propertyID, const String& string, bool important, StyleSheetContents* contex
tStyleSheet) |
1152 { | 1152 { |
1153 // FIXME: Check RuntimeCSSEnabled::isPropertyEnabled or isValueEnabledForPro
perty. | 1153 // FIXME: Check RuntimeCSSEnabled::isPropertyEnabled or isValueEnabledForPro
perty. |
1154 | 1154 |
1155 if (m_useCounter) | 1155 if (m_useCounter) |
1156 m_useCounter->count(m_context, propertyID); | 1156 m_useCounter->count(m_context, propertyID); |
1157 | 1157 |
1158 setStyleSheet(contextStyleSheet); | 1158 setStyleSheet(contextStyleSheet); |
1159 | 1159 |
1160 setupParser("@-internal-value ", string, ""); | 1160 setupParser("@-internal-value ", string, ""); |
1161 | 1161 |
(...skipping 15 matching lines...) Expand all Loading... |
1177 ok = true; | 1177 ok = true; |
1178 declaration->addParsedProperties(m_parsedProperties); | 1178 declaration->addParsedProperties(m_parsedProperties); |
1179 clearProperties(); | 1179 clearProperties(); |
1180 } | 1180 } |
1181 | 1181 |
1182 return ok; | 1182 return ok; |
1183 } | 1183 } |
1184 | 1184 |
1185 // The color will only be changed when string contains a valid CSS color, so cal
lers | 1185 // The color will only be changed when string contains a valid CSS color, so cal
lers |
1186 // can set it to a default color and ignore the boolean result. | 1186 // can set it to a default color and ignore the boolean result. |
1187 bool CSSParser::parseColor(RGBA32& color, const String& string, bool strict) | 1187 bool BisonCSSParser::parseColor(RGBA32& color, const String& string, bool strict
) |
1188 { | 1188 { |
1189 // First try creating a color specified by name, rgba(), rgb() or "#" syntax
. | 1189 // First try creating a color specified by name, rgba(), rgb() or "#" syntax
. |
1190 if (fastParseColor(color, string, strict)) | 1190 if (fastParseColor(color, string, strict)) |
1191 return true; | 1191 return true; |
1192 | 1192 |
1193 CSSParser parser(HTMLStandardMode); | 1193 BisonCSSParser parser(HTMLStandardMode); |
1194 | 1194 |
1195 // In case the fast-path parser didn't understand the color, try the full pa
rser. | 1195 // In case the fast-path parser didn't understand the color, try the full pa
rser. |
1196 if (!parser.parseColor(string)) | 1196 if (!parser.parseColor(string)) |
1197 return false; | 1197 return false; |
1198 | 1198 |
1199 CSSValue* value = parser.m_parsedProperties.first().value(); | 1199 CSSValue* value = parser.m_parsedProperties.first().value(); |
1200 if (!value->isPrimitiveValue()) | 1200 if (!value->isPrimitiveValue()) |
1201 return false; | 1201 return false; |
1202 | 1202 |
1203 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 1203 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); |
1204 if (!primitiveValue->isRGBColor()) | 1204 if (!primitiveValue->isRGBColor()) |
1205 return false; | 1205 return false; |
1206 | 1206 |
1207 color = primitiveValue->getRGBA32Value(); | 1207 color = primitiveValue->getRGBA32Value(); |
1208 return true; | 1208 return true; |
1209 } | 1209 } |
1210 | 1210 |
1211 bool CSSParser::parseColor(const String& string) | 1211 bool BisonCSSParser::parseColor(const String& string) |
1212 { | 1212 { |
1213 setupParser("@-internal-decls color:", string, ""); | 1213 setupParser("@-internal-decls color:", string, ""); |
1214 cssyyparse(this); | 1214 cssyyparse(this); |
1215 m_rule = 0; | 1215 m_rule = 0; |
1216 | 1216 |
1217 return !m_parsedProperties.isEmpty() && m_parsedProperties.first().id() == C
SSPropertyColor; | 1217 return !m_parsedProperties.isEmpty() && m_parsedProperties.first().id() == C
SSPropertyColor; |
1218 } | 1218 } |
1219 | 1219 |
1220 bool CSSParser::parseSystemColor(RGBA32& color, const String& string, Document*
document) | 1220 bool BisonCSSParser::parseSystemColor(RGBA32& color, const String& string, Docum
ent* document) |
1221 { | 1221 { |
1222 if (!document) | 1222 if (!document) |
1223 return false; | 1223 return false; |
1224 | 1224 |
1225 CSSParserString cssColor; | 1225 CSSParserString cssColor; |
1226 cssColor.init(string); | 1226 cssColor.init(string); |
1227 CSSValueID id = cssValueKeywordID(cssColor); | 1227 CSSValueID id = cssValueKeywordID(cssColor); |
1228 if (id <= 0) | 1228 if (id <= 0) |
1229 return false; | 1229 return false; |
1230 | 1230 |
1231 color = RenderTheme::theme().systemColor(id).rgb(); | 1231 color = RenderTheme::theme().systemColor(id).rgb(); |
1232 return true; | 1232 return true; |
1233 } | 1233 } |
1234 | 1234 |
1235 void CSSParser::parseSelector(const String& string, CSSSelectorList& selectorLis
t) | 1235 void BisonCSSParser::parseSelector(const String& string, CSSSelectorList& select
orList) |
1236 { | 1236 { |
1237 m_selectorListForParseSelector = &selectorList; | 1237 m_selectorListForParseSelector = &selectorList; |
1238 | 1238 |
1239 setupParser("@-internal-selector ", string, ""); | 1239 setupParser("@-internal-selector ", string, ""); |
1240 | 1240 |
1241 cssyyparse(this); | 1241 cssyyparse(this); |
1242 | 1242 |
1243 m_selectorListForParseSelector = 0; | 1243 m_selectorListForParseSelector = 0; |
1244 } | 1244 } |
1245 | 1245 |
1246 PassRefPtr<ImmutableStylePropertySet> CSSParser::parseInlineStyleDeclaration(con
st String& string, Element* element) | 1246 PassRefPtr<ImmutableStylePropertySet> BisonCSSParser::parseInlineStyleDeclaratio
n(const String& string, Element* element) |
1247 { | 1247 { |
1248 Document& document = element->document(); | 1248 Document& document = element->document(); |
1249 CSSParserContext context = document.elementSheet()->contents()->parserContex
t(); | 1249 CSSParserContext context = document.elementSheet()->contents()->parserContex
t(); |
1250 context.setMode((element->isHTMLElement() && !document.inQuirksMode()) ? HTM
LStandardMode : HTMLQuirksMode); | 1250 context.setMode((element->isHTMLElement() && !document.inQuirksMode()) ? HTM
LStandardMode : HTMLQuirksMode); |
1251 return CSSParser(context, UseCounter::getFrom(&document)).parseDeclaration(s
tring, document.elementSheet()->contents()); | 1251 return BisonCSSParser(context, UseCounter::getFrom(&document)).parseDeclarat
ion(string, document.elementSheet()->contents()); |
1252 } | 1252 } |
1253 | 1253 |
1254 PassRefPtr<ImmutableStylePropertySet> CSSParser::parseDeclaration(const String&
string, StyleSheetContents* contextStyleSheet) | 1254 PassRefPtr<ImmutableStylePropertySet> BisonCSSParser::parseDeclaration(const Str
ing& string, StyleSheetContents* contextStyleSheet) |
1255 { | 1255 { |
1256 setStyleSheet(contextStyleSheet); | 1256 setStyleSheet(contextStyleSheet); |
1257 | 1257 |
1258 setupParser("@-internal-decls ", string, ""); | 1258 setupParser("@-internal-decls ", string, ""); |
1259 cssyyparse(this); | 1259 cssyyparse(this); |
1260 m_rule = 0; | 1260 m_rule = 0; |
1261 | 1261 |
1262 if (m_hasFontFaceOnlyValues) | 1262 if (m_hasFontFaceOnlyValues) |
1263 deleteFontFaceOnlyValues(); | 1263 deleteFontFaceOnlyValues(); |
1264 | 1264 |
1265 RefPtr<ImmutableStylePropertySet> style = createStylePropertySet(); | 1265 RefPtr<ImmutableStylePropertySet> style = createStylePropertySet(); |
1266 clearProperties(); | 1266 clearProperties(); |
1267 return style.release(); | 1267 return style.release(); |
1268 } | 1268 } |
1269 | 1269 |
1270 | 1270 |
1271 bool CSSParser::parseDeclaration(MutableStylePropertySet* declaration, const Str
ing& string, CSSParserObserver* observer, StyleSheetContents* contextStyleSheet) | 1271 bool BisonCSSParser::parseDeclaration(MutableStylePropertySet* declaration, cons
t String& string, CSSParserObserver* observer, StyleSheetContents* contextStyleS
heet) |
1272 { | 1272 { |
1273 setStyleSheet(contextStyleSheet); | 1273 setStyleSheet(contextStyleSheet); |
1274 | 1274 |
1275 TemporaryChange<CSSParserObserver*> scopedObsever(m_observer, observer); | 1275 TemporaryChange<CSSParserObserver*> scopedObsever(m_observer, observer); |
1276 | 1276 |
1277 setupParser("@-internal-decls ", string, ""); | 1277 setupParser("@-internal-decls ", string, ""); |
1278 if (m_observer) { | 1278 if (m_observer) { |
1279 m_observer->startRuleHeader(CSSRuleSourceData::STYLE_RULE, 0); | 1279 m_observer->startRuleHeader(CSSRuleSourceData::STYLE_RULE, 0); |
1280 m_observer->endRuleHeader(1); | 1280 m_observer->endRuleHeader(1); |
1281 m_observer->startRuleBody(0); | 1281 m_observer->startRuleBody(0); |
(...skipping 14 matching lines...) Expand all Loading... |
1296 declaration->addParsedProperties(m_parsedProperties); | 1296 declaration->addParsedProperties(m_parsedProperties); |
1297 clearProperties(); | 1297 clearProperties(); |
1298 } | 1298 } |
1299 | 1299 |
1300 if (m_observer) | 1300 if (m_observer) |
1301 m_observer->endRuleBody(string.length(), false); | 1301 m_observer->endRuleBody(string.length(), false); |
1302 | 1302 |
1303 return ok; | 1303 return ok; |
1304 } | 1304 } |
1305 | 1305 |
1306 PassRefPtr<MediaQuerySet> CSSParser::parseMediaQueryList(const String& string) | 1306 PassRefPtr<MediaQuerySet> BisonCSSParser::parseMediaQueryList(const String& stri
ng) |
1307 { | 1307 { |
1308 ASSERT(!m_mediaList); | 1308 ASSERT(!m_mediaList); |
1309 | 1309 |
1310 // can't use { because tokenizer state switches from mediaquery to initial s
tate when it sees { token. | 1310 // can't use { because tokenizer state switches from mediaquery to initial s
tate when it sees { token. |
1311 // instead insert one " " (which is caught by maybe_space in CSSGrammar.y) | 1311 // instead insert one " " (which is caught by maybe_space in CSSGrammar.y) |
1312 setupParser("@-internal-medialist ", string, ""); | 1312 setupParser("@-internal-medialist ", string, ""); |
1313 cssyyparse(this); | 1313 cssyyparse(this); |
1314 | 1314 |
1315 ASSERT(m_mediaList); | 1315 ASSERT(m_mediaList); |
1316 return m_mediaList.release(); | 1316 return m_mediaList.release(); |
1317 } | 1317 } |
1318 | 1318 |
1319 static inline void filterProperties(bool important, const CSSParser::ParsedPrope
rtyVector& input, Vector<CSSProperty, 256>& output, size_t& unusedEntries, BitAr
ray<numCSSProperties>& seenProperties, HashSet<AtomicString>& seenVariables) | 1319 static inline void filterProperties(bool important, const BisonCSSParser::Parsed
PropertyVector& input, Vector<CSSProperty, 256>& output, size_t& unusedEntries,
BitArray<numCSSProperties>& seenProperties, HashSet<AtomicString>& seenVariables
) |
1320 { | 1320 { |
1321 // Add properties in reverse order so that highest priority definitions are
reached first. Duplicate definitions can then be ignored when found. | 1321 // Add properties in reverse order so that highest priority definitions are
reached first. Duplicate definitions can then be ignored when found. |
1322 for (int i = input.size() - 1; i >= 0; --i) { | 1322 for (int i = input.size() - 1; i >= 0; --i) { |
1323 const CSSProperty& property = input[i]; | 1323 const CSSProperty& property = input[i]; |
1324 if (property.isImportant() != important) | 1324 if (property.isImportant() != important) |
1325 continue; | 1325 continue; |
1326 if (property.id() == CSSPropertyVariable) { | 1326 if (property.id() == CSSPropertyVariable) { |
1327 const AtomicString& name = toCSSVariableValue(property.value())->nam
e(); | 1327 const AtomicString& name = toCSSVariableValue(property.value())->nam
e(); |
1328 if (!seenVariables.add(name).isNewEntry) | 1328 if (!seenVariables.add(name).isNewEntry) |
1329 continue; | 1329 continue; |
1330 output[--unusedEntries] = property; | 1330 output[--unusedEntries] = property; |
1331 continue; | 1331 continue; |
1332 } | 1332 } |
1333 const unsigned propertyIDIndex = property.id() - firstCSSProperty; | 1333 const unsigned propertyIDIndex = property.id() - firstCSSProperty; |
1334 if (seenProperties.get(propertyIDIndex)) | 1334 if (seenProperties.get(propertyIDIndex)) |
1335 continue; | 1335 continue; |
1336 seenProperties.set(propertyIDIndex); | 1336 seenProperties.set(propertyIDIndex); |
1337 output[--unusedEntries] = property; | 1337 output[--unusedEntries] = property; |
1338 } | 1338 } |
1339 } | 1339 } |
1340 | 1340 |
1341 PassRefPtr<ImmutableStylePropertySet> CSSParser::createStylePropertySet() | 1341 PassRefPtr<ImmutableStylePropertySet> BisonCSSParser::createStylePropertySet() |
1342 { | 1342 { |
1343 BitArray<numCSSProperties> seenProperties; | 1343 BitArray<numCSSProperties> seenProperties; |
1344 size_t unusedEntries = m_parsedProperties.size(); | 1344 size_t unusedEntries = m_parsedProperties.size(); |
1345 Vector<CSSProperty, 256> results(unusedEntries); | 1345 Vector<CSSProperty, 256> results(unusedEntries); |
1346 | 1346 |
1347 // Important properties have higher priority, so add them first. Duplicate d
efinitions can then be ignored when found. | 1347 // Important properties have higher priority, so add them first. Duplicate d
efinitions can then be ignored when found. |
1348 HashSet<AtomicString> seenVariables; | 1348 HashSet<AtomicString> seenVariables; |
1349 filterProperties(true, m_parsedProperties, results, unusedEntries, seenPrope
rties, seenVariables); | 1349 filterProperties(true, m_parsedProperties, results, unusedEntries, seenPrope
rties, seenVariables); |
1350 filterProperties(false, m_parsedProperties, results, unusedEntries, seenProp
erties, seenVariables); | 1350 filterProperties(false, m_parsedProperties, results, unusedEntries, seenProp
erties, seenVariables); |
1351 if (unusedEntries) | 1351 if (unusedEntries) |
1352 results.remove(0, unusedEntries); | 1352 results.remove(0, unusedEntries); |
1353 | 1353 |
1354 CSSParserMode mode = inViewport() ? CSSViewportRuleMode : m_context.mode(); | 1354 CSSParserMode mode = inViewport() ? CSSViewportRuleMode : m_context.mode(); |
1355 | 1355 |
1356 return ImmutableStylePropertySet::create(results.data(), results.size(), mod
e); | 1356 return ImmutableStylePropertySet::create(results.data(), results.size(), mod
e); |
1357 } | 1357 } |
1358 | 1358 |
1359 void CSSParser::addPropertyWithPrefixingVariant(CSSPropertyID propId, PassRefPtr
<CSSValue> value, bool important, bool implicit) | 1359 void BisonCSSParser::addPropertyWithPrefixingVariant(CSSPropertyID propId, PassR
efPtr<CSSValue> value, bool important, bool implicit) |
1360 { | 1360 { |
1361 RefPtr<CSSValue> val = value.get(); | 1361 RefPtr<CSSValue> val = value.get(); |
1362 addProperty(propId, value, important, implicit); | 1362 addProperty(propId, value, important, implicit); |
1363 | 1363 |
1364 CSSPropertyID prefixingVariant = prefixingVariantForPropertyId(propId); | 1364 CSSPropertyID prefixingVariant = prefixingVariantForPropertyId(propId); |
1365 if (prefixingVariant == propId) | 1365 if (prefixingVariant == propId) |
1366 return; | 1366 return; |
1367 | 1367 |
1368 if (m_currentShorthand) { | 1368 if (m_currentShorthand) { |
1369 // We can't use ShorthandScope here as we can already be inside one (e.g
we are parsing CSSTransition). | 1369 // We can't use ShorthandScope here as we can already be inside one (e.g
we are parsing CSSTransition). |
1370 m_currentShorthand = prefixingVariantForPropertyId(m_currentShorthand); | 1370 m_currentShorthand = prefixingVariantForPropertyId(m_currentShorthand); |
1371 addProperty(prefixingVariant, val.release(), important, implicit); | 1371 addProperty(prefixingVariant, val.release(), important, implicit); |
1372 m_currentShorthand = prefixingVariantForPropertyId(m_currentShorthand); | 1372 m_currentShorthand = prefixingVariantForPropertyId(m_currentShorthand); |
1373 } else { | 1373 } else { |
1374 addProperty(prefixingVariant, val.release(), important, implicit); | 1374 addProperty(prefixingVariant, val.release(), important, implicit); |
1375 } | 1375 } |
1376 } | 1376 } |
1377 | 1377 |
1378 void CSSParser::addProperty(CSSPropertyID propId, PassRefPtr<CSSValue> value, bo
ol important, bool implicit) | 1378 void BisonCSSParser::addProperty(CSSPropertyID propId, PassRefPtr<CSSValue> valu
e, bool important, bool implicit) |
1379 { | 1379 { |
1380 CSSPrimitiveValue* primitiveValue = value->isPrimitiveValue() ? toCSSPrimiti
veValue(value.get()) : 0; | 1380 CSSPrimitiveValue* primitiveValue = value->isPrimitiveValue() ? toCSSPrimiti
veValue(value.get()) : 0; |
1381 // This property doesn't belong to a shorthand or is a CSS variable (which w
ill be resolved later). | 1381 // This property doesn't belong to a shorthand or is a CSS variable (which w
ill be resolved later). |
1382 if (!m_currentShorthand || (primitiveValue && primitiveValue->isVariableName
())) { | 1382 if (!m_currentShorthand || (primitiveValue && primitiveValue->isVariableName
())) { |
1383 m_parsedProperties.append(CSSProperty(propId, value, important, false, C
SSPropertyInvalid, m_implicitShorthand || implicit)); | 1383 m_parsedProperties.append(CSSProperty(propId, value, important, false, C
SSPropertyInvalid, m_implicitShorthand || implicit)); |
1384 return; | 1384 return; |
1385 } | 1385 } |
1386 | 1386 |
1387 Vector<StylePropertyShorthand, 4> shorthands; | 1387 Vector<StylePropertyShorthand, 4> shorthands; |
1388 getMatchingShorthandsForLonghand(propId, &shorthands); | 1388 getMatchingShorthandsForLonghand(propId, &shorthands); |
1389 // The longhand does not belong to multiple shorthands. | 1389 // The longhand does not belong to multiple shorthands. |
1390 if (shorthands.size() == 1) | 1390 if (shorthands.size() == 1) |
1391 m_parsedProperties.append(CSSProperty(propId, value, important, true, CS
SPropertyInvalid, m_implicitShorthand || implicit)); | 1391 m_parsedProperties.append(CSSProperty(propId, value, important, true, CS
SPropertyInvalid, m_implicitShorthand || implicit)); |
1392 else | 1392 else |
1393 m_parsedProperties.append(CSSProperty(propId, value, important, true, in
dexOfShorthandForLonghand(m_currentShorthand, shorthands), m_implicitShorthand |
| implicit)); | 1393 m_parsedProperties.append(CSSProperty(propId, value, important, true, in
dexOfShorthandForLonghand(m_currentShorthand, shorthands), m_implicitShorthand |
| implicit)); |
1394 } | 1394 } |
1395 | 1395 |
1396 void CSSParser::rollbackLastProperties(int num) | 1396 void BisonCSSParser::rollbackLastProperties(int num) |
1397 { | 1397 { |
1398 ASSERT(num >= 0); | 1398 ASSERT(num >= 0); |
1399 ASSERT(m_parsedProperties.size() >= static_cast<unsigned>(num)); | 1399 ASSERT(m_parsedProperties.size() >= static_cast<unsigned>(num)); |
1400 m_parsedProperties.shrink(m_parsedProperties.size() - num); | 1400 m_parsedProperties.shrink(m_parsedProperties.size() - num); |
1401 } | 1401 } |
1402 | 1402 |
1403 void CSSParser::clearProperties() | 1403 void BisonCSSParser::clearProperties() |
1404 { | 1404 { |
1405 m_parsedProperties.clear(); | 1405 m_parsedProperties.clear(); |
1406 m_numParsedPropertiesBeforeMarginBox = INVALID_NUM_PARSED_PROPERTIES; | 1406 m_numParsedPropertiesBeforeMarginBox = INVALID_NUM_PARSED_PROPERTIES; |
1407 m_hasFontFaceOnlyValues = false; | 1407 m_hasFontFaceOnlyValues = false; |
1408 } | 1408 } |
1409 | 1409 |
1410 KURL CSSParser::completeURL(const String& url) const | 1410 KURL BisonCSSParser::completeURL(const String& url) const |
1411 { | 1411 { |
1412 return m_context.completeURL(url); | 1412 return m_context.completeURL(url); |
1413 } | 1413 } |
1414 | 1414 |
1415 bool CSSParser::validCalculationUnit(CSSParserValue* value, Units unitflags, Rel
easeParsedCalcValueCondition releaseCalc) | 1415 bool BisonCSSParser::validCalculationUnit(CSSParserValue* value, Units unitflags
, ReleaseParsedCalcValueCondition releaseCalc) |
1416 { | 1416 { |
1417 bool mustBeNonNegative = unitflags & FNonNeg; | 1417 bool mustBeNonNegative = unitflags & FNonNeg; |
1418 | 1418 |
1419 if (!parseCalculation(value, mustBeNonNegative ? ValueRangeNonNegative : Val
ueRangeAll)) | 1419 if (!parseCalculation(value, mustBeNonNegative ? ValueRangeNonNegative : Val
ueRangeAll)) |
1420 return false; | 1420 return false; |
1421 | 1421 |
1422 bool b = false; | 1422 bool b = false; |
1423 switch (m_parsedCalculation->category()) { | 1423 switch (m_parsedCalculation->category()) { |
1424 case CalcLength: | 1424 case CalcLength: |
1425 b = (unitflags & FLength); | 1425 b = (unitflags & FLength); |
(...skipping 20 matching lines...) Expand all Loading... |
1446 b = true; | 1446 b = true; |
1447 break; | 1447 break; |
1448 case CalcOther: | 1448 case CalcOther: |
1449 break; | 1449 break; |
1450 } | 1450 } |
1451 if (!b || releaseCalc == ReleaseParsedCalcValue) | 1451 if (!b || releaseCalc == ReleaseParsedCalcValue) |
1452 m_parsedCalculation.release(); | 1452 m_parsedCalculation.release(); |
1453 return b; | 1453 return b; |
1454 } | 1454 } |
1455 | 1455 |
1456 inline bool CSSParser::shouldAcceptUnitLessValues(CSSParserValue* value, Units u
nitflags, CSSParserMode cssParserMode) | 1456 inline bool BisonCSSParser::shouldAcceptUnitLessValues(CSSParserValue* value, Un
its unitflags, CSSParserMode cssParserMode) |
1457 { | 1457 { |
1458 // Quirks mode and presentation attributes accept unit less values. | 1458 // Quirks mode and presentation attributes accept unit less values. |
1459 return (unitflags & (FLength | FAngle | FTime)) && (!value->fValue || isUnit
LessLengthParsingEnabledForMode(cssParserMode)); | 1459 return (unitflags & (FLength | FAngle | FTime)) && (!value->fValue || isUnit
LessLengthParsingEnabledForMode(cssParserMode)); |
1460 } | 1460 } |
1461 | 1461 |
1462 bool CSSParser::validUnit(CSSParserValue* value, Units unitflags, CSSParserMode
cssParserMode, ReleaseParsedCalcValueCondition releaseCalc) | 1462 bool BisonCSSParser::validUnit(CSSParserValue* value, Units unitflags, CSSParser
Mode cssParserMode, ReleaseParsedCalcValueCondition releaseCalc) |
1463 { | 1463 { |
1464 if (isCalculation(value)) | 1464 if (isCalculation(value)) |
1465 return validCalculationUnit(value, unitflags, releaseCalc); | 1465 return validCalculationUnit(value, unitflags, releaseCalc); |
1466 | 1466 |
1467 bool b = false; | 1467 bool b = false; |
1468 switch (value->unit) { | 1468 switch (value->unit) { |
1469 case CSSPrimitiveValue::CSS_VARIABLE_NAME: | 1469 case CSSPrimitiveValue::CSS_VARIABLE_NAME: |
1470 // Variables are checked at the point they are dereferenced because unit
type is not available here. | 1470 // Variables are checked at the point they are dereferenced because unit
type is not available here. |
1471 b = true; | 1471 b = true; |
1472 break; | 1472 break; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1521 case CSSPrimitiveValue::CSS_KHZ: | 1521 case CSSPrimitiveValue::CSS_KHZ: |
1522 case CSSPrimitiveValue::CSS_DIMENSION: | 1522 case CSSPrimitiveValue::CSS_DIMENSION: |
1523 default: | 1523 default: |
1524 break; | 1524 break; |
1525 } | 1525 } |
1526 if (b && unitflags & FNonNeg && value->fValue < 0) | 1526 if (b && unitflags & FNonNeg && value->fValue < 0) |
1527 b = false; | 1527 b = false; |
1528 return b; | 1528 return b; |
1529 } | 1529 } |
1530 | 1530 |
1531 inline PassRefPtr<CSSPrimitiveValue> CSSParser::createPrimitiveNumericValue(CSSP
arserValue* value) | 1531 inline PassRefPtr<CSSPrimitiveValue> BisonCSSParser::createPrimitiveNumericValue
(CSSParserValue* value) |
1532 { | 1532 { |
1533 if (value->unit == CSSPrimitiveValue::CSS_VARIABLE_NAME) | 1533 if (value->unit == CSSPrimitiveValue::CSS_VARIABLE_NAME) |
1534 return createPrimitiveVariableNameValue(value); | 1534 return createPrimitiveVariableNameValue(value); |
1535 | 1535 |
1536 if (m_parsedCalculation) { | 1536 if (m_parsedCalculation) { |
1537 ASSERT(isCalculation(value)); | 1537 ASSERT(isCalculation(value)); |
1538 return CSSPrimitiveValue::create(m_parsedCalculation.release()); | 1538 return CSSPrimitiveValue::create(m_parsedCalculation.release()); |
1539 } | 1539 } |
1540 | 1540 |
1541 ASSERT((value->unit >= CSSPrimitiveValue::CSS_NUMBER && value->unit <= CSSPr
imitiveValue::CSS_KHZ) | 1541 ASSERT((value->unit >= CSSPrimitiveValue::CSS_NUMBER && value->unit <= CSSPr
imitiveValue::CSS_KHZ) |
1542 || (value->unit >= CSSPrimitiveValue::CSS_TURN && value->unit <= CSSPrim
itiveValue::CSS_CHS) | 1542 || (value->unit >= CSSPrimitiveValue::CSS_TURN && value->unit <= CSSPrim
itiveValue::CSS_CHS) |
1543 || (value->unit >= CSSPrimitiveValue::CSS_VW && value->unit <= CSSPrimit
iveValue::CSS_VMAX) | 1543 || (value->unit >= CSSPrimitiveValue::CSS_VW && value->unit <= CSSPrimit
iveValue::CSS_VMAX) |
1544 || (value->unit >= CSSPrimitiveValue::CSS_DPPX && value->unit <= CSSPrim
itiveValue::CSS_DPCM)); | 1544 || (value->unit >= CSSPrimitiveValue::CSS_DPPX && value->unit <= CSSPrim
itiveValue::CSS_DPCM)); |
1545 return cssValuePool().createValue(value->fValue, static_cast<CSSPrimitiveVal
ue::UnitTypes>(value->unit)); | 1545 return cssValuePool().createValue(value->fValue, static_cast<CSSPrimitiveVal
ue::UnitTypes>(value->unit)); |
1546 } | 1546 } |
1547 | 1547 |
1548 inline PassRefPtr<CSSPrimitiveValue> CSSParser::createPrimitiveStringValue(CSSPa
rserValue* value) | 1548 inline PassRefPtr<CSSPrimitiveValue> BisonCSSParser::createPrimitiveStringValue(
CSSParserValue* value) |
1549 { | 1549 { |
1550 ASSERT(value->unit == CSSPrimitiveValue::CSS_STRING || value->unit == CSSPri
mitiveValue::CSS_IDENT); | 1550 ASSERT(value->unit == CSSPrimitiveValue::CSS_STRING || value->unit == CSSPri
mitiveValue::CSS_IDENT); |
1551 return cssValuePool().createValue(value->string, CSSPrimitiveValue::CSS_STRI
NG); | 1551 return cssValuePool().createValue(value->string, CSSPrimitiveValue::CSS_STRI
NG); |
1552 } | 1552 } |
1553 | 1553 |
1554 inline PassRefPtr<CSSPrimitiveValue> CSSParser::createPrimitiveVariableNameValue
(CSSParserValue* value) | 1554 inline PassRefPtr<CSSPrimitiveValue> BisonCSSParser::createPrimitiveVariableName
Value(CSSParserValue* value) |
1555 { | 1555 { |
1556 ASSERT(value->unit == CSSPrimitiveValue::CSS_VARIABLE_NAME); | 1556 ASSERT(value->unit == CSSPrimitiveValue::CSS_VARIABLE_NAME); |
1557 return CSSPrimitiveValue::create(value->string, CSSPrimitiveValue::CSS_VARIA
BLE_NAME); | 1557 return CSSPrimitiveValue::create(value->string, CSSPrimitiveValue::CSS_VARIA
BLE_NAME); |
1558 } | 1558 } |
1559 | 1559 |
1560 static inline bool isComma(CSSParserValue* value) | 1560 static inline bool isComma(CSSParserValue* value) |
1561 { | 1561 { |
1562 return value && value->unit == CSSParserValue::Operator && value->iValue ==
','; | 1562 return value && value->unit == CSSParserValue::Operator && value->iValue ==
','; |
1563 } | 1563 } |
1564 | 1564 |
(...skipping 14 matching lines...) Expand all Loading... |
1579 || equalIgnoringCase(val->function->name, "-webkit-repeating-linear-grad
ient(") | 1579 || equalIgnoringCase(val->function->name, "-webkit-repeating-linear-grad
ient(") |
1580 || equalIgnoringCase(val->function->name, "repeating-linear-gradient(") | 1580 || equalIgnoringCase(val->function->name, "repeating-linear-gradient(") |
1581 || equalIgnoringCase(val->function->name, "-webkit-radial-gradient(") | 1581 || equalIgnoringCase(val->function->name, "-webkit-radial-gradient(") |
1582 || equalIgnoringCase(val->function->name, "radial-gradient(") | 1582 || equalIgnoringCase(val->function->name, "radial-gradient(") |
1583 || equalIgnoringCase(val->function->name, "-webkit-repeating-radial-grad
ient(") | 1583 || equalIgnoringCase(val->function->name, "-webkit-repeating-radial-grad
ient(") |
1584 || equalIgnoringCase(val->function->name, "repeating-radial-gradient(") | 1584 || equalIgnoringCase(val->function->name, "repeating-radial-gradient(") |
1585 || equalIgnoringCase(val->function->name, "-webkit-canvas(") | 1585 || equalIgnoringCase(val->function->name, "-webkit-canvas(") |
1586 || equalIgnoringCase(val->function->name, "-webkit-cross-fade("); | 1586 || equalIgnoringCase(val->function->name, "-webkit-cross-fade("); |
1587 } | 1587 } |
1588 | 1588 |
1589 bool CSSParser::validWidthOrHeight(CSSParserValue* value) | 1589 bool BisonCSSParser::validWidthOrHeight(CSSParserValue* value) |
1590 { | 1590 { |
1591 int id = value->id; | 1591 int id = value->id; |
1592 if (id == CSSValueIntrinsic || id == CSSValueMinIntrinsic || id == CSSValueW
ebkitMinContent || id == CSSValueWebkitMaxContent || id == CSSValueWebkitFillAva
ilable || id == CSSValueWebkitFitContent) | 1592 if (id == CSSValueIntrinsic || id == CSSValueMinIntrinsic || id == CSSValueW
ebkitMinContent || id == CSSValueWebkitMaxContent || id == CSSValueWebkitFillAva
ilable || id == CSSValueWebkitFitContent) |
1593 return true; | 1593 return true; |
1594 return !id && validUnit(value, FLength | FPercent | FNonNeg); | 1594 return !id && validUnit(value, FLength | FPercent | FNonNeg); |
1595 } | 1595 } |
1596 | 1596 |
1597 inline PassRefPtr<CSSPrimitiveValue> CSSParser::parseValidPrimitive(CSSValueID i
dentifier, CSSParserValue* value) | 1597 inline PassRefPtr<CSSPrimitiveValue> BisonCSSParser::parseValidPrimitive(CSSValu
eID identifier, CSSParserValue* value) |
1598 { | 1598 { |
1599 if (identifier) | 1599 if (identifier) |
1600 return cssValuePool().createIdentifierValue(identifier); | 1600 return cssValuePool().createIdentifierValue(identifier); |
1601 if (value->unit == CSSPrimitiveValue::CSS_STRING) | 1601 if (value->unit == CSSPrimitiveValue::CSS_STRING) |
1602 return createPrimitiveStringValue(value); | 1602 return createPrimitiveStringValue(value); |
1603 if (value->unit >= CSSPrimitiveValue::CSS_NUMBER && value->unit <= CSSPrimit
iveValue::CSS_KHZ) | 1603 if (value->unit >= CSSPrimitiveValue::CSS_NUMBER && value->unit <= CSSPrimit
iveValue::CSS_KHZ) |
1604 return createPrimitiveNumericValue(value); | 1604 return createPrimitiveNumericValue(value); |
1605 if (value->unit >= CSSPrimitiveValue::CSS_TURN && value->unit <= CSSPrimitiv
eValue::CSS_CHS) | 1605 if (value->unit >= CSSPrimitiveValue::CSS_TURN && value->unit <= CSSPrimitiv
eValue::CSS_CHS) |
1606 return createPrimitiveNumericValue(value); | 1606 return createPrimitiveNumericValue(value); |
1607 if (value->unit >= CSSPrimitiveValue::CSS_VW && value->unit <= CSSPrimitiveV
alue::CSS_VMAX) | 1607 if (value->unit >= CSSPrimitiveValue::CSS_VW && value->unit <= CSSPrimitiveV
alue::CSS_VMAX) |
1608 return createPrimitiveNumericValue(value); | 1608 return createPrimitiveNumericValue(value); |
1609 if (value->unit >= CSSPrimitiveValue::CSS_DPPX && value->unit <= CSSPrimitiv
eValue::CSS_DPCM) | 1609 if (value->unit >= CSSPrimitiveValue::CSS_DPPX && value->unit <= CSSPrimitiv
eValue::CSS_DPCM) |
1610 return createPrimitiveNumericValue(value); | 1610 return createPrimitiveNumericValue(value); |
1611 if (value->unit == CSSPrimitiveValue::CSS_VARIABLE_NAME) | 1611 if (value->unit == CSSPrimitiveValue::CSS_VARIABLE_NAME) |
1612 return createPrimitiveVariableNameValue(value); | 1612 return createPrimitiveVariableNameValue(value); |
1613 if (value->unit >= CSSParserValue::Q_EMS) | 1613 if (value->unit >= CSSParserValue::Q_EMS) |
1614 return CSSPrimitiveValue::createAllowingMarginQuirk(value->fValue, CSSPr
imitiveValue::CSS_EMS); | 1614 return CSSPrimitiveValue::createAllowingMarginQuirk(value->fValue, CSSPr
imitiveValue::CSS_EMS); |
1615 if (isCalculation(value)) | 1615 if (isCalculation(value)) |
1616 return CSSPrimitiveValue::create(m_parsedCalculation.release()); | 1616 return CSSPrimitiveValue::create(m_parsedCalculation.release()); |
1617 | 1617 |
1618 return 0; | 1618 return 0; |
1619 } | 1619 } |
1620 | 1620 |
1621 void CSSParser::addExpandedPropertyForValue(CSSPropertyID propId, PassRefPtr<CSS
Value> prpValue, bool important) | 1621 void BisonCSSParser::addExpandedPropertyForValue(CSSPropertyID propId, PassRefPt
r<CSSValue> prpValue, bool important) |
1622 { | 1622 { |
1623 const StylePropertyShorthand& shorthand = shorthandForProperty(propId); | 1623 const StylePropertyShorthand& shorthand = shorthandForProperty(propId); |
1624 unsigned shorthandLength = shorthand.length(); | 1624 unsigned shorthandLength = shorthand.length(); |
1625 if (!shorthandLength) { | 1625 if (!shorthandLength) { |
1626 addProperty(propId, prpValue, important); | 1626 addProperty(propId, prpValue, important); |
1627 return; | 1627 return; |
1628 } | 1628 } |
1629 | 1629 |
1630 RefPtr<CSSValue> value = prpValue; | 1630 RefPtr<CSSValue> value = prpValue; |
1631 ShorthandScope scope(this, propId); | 1631 ShorthandScope scope(this, propId); |
1632 const CSSPropertyID* longhands = shorthand.properties(); | 1632 const CSSPropertyID* longhands = shorthand.properties(); |
1633 for (unsigned i = 0; i < shorthandLength; ++i) | 1633 for (unsigned i = 0; i < shorthandLength; ++i) |
1634 addProperty(longhands[i], value, important); | 1634 addProperty(longhands[i], value, important); |
1635 } | 1635 } |
1636 | 1636 |
1637 void CSSParser::setCurrentProperty(CSSPropertyID propId) | 1637 void BisonCSSParser::setCurrentProperty(CSSPropertyID propId) |
1638 { | 1638 { |
1639 m_id = propId; | 1639 m_id = propId; |
1640 } | 1640 } |
1641 | 1641 |
1642 bool CSSParser::parseValue(CSSPropertyID propId, bool important) | 1642 bool BisonCSSParser::parseValue(CSSPropertyID propId, bool important) |
1643 { | 1643 { |
1644 if (!isInternalPropertyAndValueParsingEnabledForMode(m_context.mode()) && is
InternalProperty(propId)) | 1644 if (!isInternalPropertyAndValueParsingEnabledForMode(m_context.mode()) && is
InternalProperty(propId)) |
1645 return false; | 1645 return false; |
1646 | 1646 |
1647 // We don't count the UA style sheet in our statistics. | 1647 // We don't count the UA style sheet in our statistics. |
1648 if (m_useCounter) | 1648 if (m_useCounter) |
1649 m_useCounter->count(m_context, propId); | 1649 m_useCounter->count(m_context, propId); |
1650 | 1650 |
1651 if (!m_valueList) | 1651 if (!m_valueList) |
1652 return false; | 1652 return false; |
(...skipping 1201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2854 ASSERT(!m_parsedCalculation); | 2854 ASSERT(!m_parsedCalculation); |
2855 if (parsedValue) { | 2855 if (parsedValue) { |
2856 if (!m_valueList->current() || inShorthand()) { | 2856 if (!m_valueList->current() || inShorthand()) { |
2857 addProperty(propId, parsedValue.release(), important); | 2857 addProperty(propId, parsedValue.release(), important); |
2858 return true; | 2858 return true; |
2859 } | 2859 } |
2860 } | 2860 } |
2861 return false; | 2861 return false; |
2862 } | 2862 } |
2863 | 2863 |
2864 void CSSParser::addFillValue(RefPtr<CSSValue>& lval, PassRefPtr<CSSValue> rval) | 2864 void BisonCSSParser::addFillValue(RefPtr<CSSValue>& lval, PassRefPtr<CSSValue> r
val) |
2865 { | 2865 { |
2866 if (lval) { | 2866 if (lval) { |
2867 if (lval->isBaseValueList()) | 2867 if (lval->isBaseValueList()) |
2868 toCSSValueList(lval.get())->append(rval); | 2868 toCSSValueList(lval.get())->append(rval); |
2869 else { | 2869 else { |
2870 PassRefPtr<CSSValue> oldlVal(lval.release()); | 2870 PassRefPtr<CSSValue> oldlVal(lval.release()); |
2871 PassRefPtr<CSSValueList> list = CSSValueList::createCommaSeparated()
; | 2871 PassRefPtr<CSSValueList> list = CSSValueList::createCommaSeparated()
; |
2872 list->append(oldlVal); | 2872 list->append(oldlVal); |
2873 list->append(rval); | 2873 list->append(rval); |
2874 lval = list; | 2874 lval = list; |
2875 } | 2875 } |
2876 } | 2876 } |
2877 else | 2877 else |
2878 lval = rval; | 2878 lval = rval; |
2879 } | 2879 } |
2880 | 2880 |
2881 static bool parseBackgroundClip(CSSParserValue* parserValue, RefPtr<CSSValue>& c
ssValue) | 2881 static bool parseBackgroundClip(CSSParserValue* parserValue, RefPtr<CSSValue>& c
ssValue) |
2882 { | 2882 { |
2883 if (parserValue->id == CSSValueBorderBox || parserValue->id == CSSValuePaddi
ngBox | 2883 if (parserValue->id == CSSValueBorderBox || parserValue->id == CSSValuePaddi
ngBox |
2884 || parserValue->id == CSSValueContentBox || parserValue->id == CSSValueW
ebkitText) { | 2884 || parserValue->id == CSSValueContentBox || parserValue->id == CSSValueW
ebkitText) { |
2885 cssValue = cssValuePool().createIdentifierValue(parserValue->id); | 2885 cssValue = cssValuePool().createIdentifierValue(parserValue->id); |
2886 return true; | 2886 return true; |
2887 } | 2887 } |
2888 return false; | 2888 return false; |
2889 } | 2889 } |
2890 | 2890 |
2891 bool CSSParser::useLegacyBackgroundSizeShorthandBehavior() const | 2891 bool BisonCSSParser::useLegacyBackgroundSizeShorthandBehavior() const |
2892 { | 2892 { |
2893 return m_context.useLegacyBackgroundSizeShorthandBehavior(); | 2893 return m_context.useLegacyBackgroundSizeShorthandBehavior(); |
2894 } | 2894 } |
2895 | 2895 |
2896 const int cMaxFillProperties = 9; | 2896 const int cMaxFillProperties = 9; |
2897 | 2897 |
2898 bool CSSParser::parseFillShorthand(CSSPropertyID propId, const CSSPropertyID* pr
operties, int numProperties, bool important) | 2898 bool BisonCSSParser::parseFillShorthand(CSSPropertyID propId, const CSSPropertyI
D* properties, int numProperties, bool important) |
2899 { | 2899 { |
2900 ASSERT(numProperties <= cMaxFillProperties); | 2900 ASSERT(numProperties <= cMaxFillProperties); |
2901 if (numProperties > cMaxFillProperties) | 2901 if (numProperties > cMaxFillProperties) |
2902 return false; | 2902 return false; |
2903 | 2903 |
2904 ShorthandScope scope(this, propId); | 2904 ShorthandScope scope(this, propId); |
2905 | 2905 |
2906 bool parsedProperty[cMaxFillProperties] = { false }; | 2906 bool parsedProperty[cMaxFillProperties] = { false }; |
2907 RefPtr<CSSValue> values[cMaxFillProperties]; | 2907 RefPtr<CSSValue> values[cMaxFillProperties]; |
2908 RefPtr<CSSValue> clipValue; | 2908 RefPtr<CSSValue> clipValue; |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3037 if (properties[i] == CSSPropertyBackgroundOrigin && !foundClip) | 3037 if (properties[i] == CSSPropertyBackgroundOrigin && !foundClip) |
3038 addProperty(CSSPropertyBackgroundClip, clipValue.release(), importan
t); | 3038 addProperty(CSSPropertyBackgroundClip, clipValue.release(), importan
t); |
3039 else if (properties[i] == CSSPropertyWebkitMaskOrigin && !foundClip) | 3039 else if (properties[i] == CSSPropertyWebkitMaskOrigin && !foundClip) |
3040 addProperty(CSSPropertyWebkitMaskClip, clipValue.release(), importan
t); | 3040 addProperty(CSSPropertyWebkitMaskClip, clipValue.release(), importan
t); |
3041 } | 3041 } |
3042 | 3042 |
3043 m_implicitShorthand = false; | 3043 m_implicitShorthand = false; |
3044 return true; | 3044 return true; |
3045 } | 3045 } |
3046 | 3046 |
3047 void CSSParser::storeVariableDeclaration(const CSSParserString& name, PassOwnPtr
<CSSParserValueList> value, bool important) | 3047 void BisonCSSParser::storeVariableDeclaration(const CSSParserString& name, PassO
wnPtr<CSSParserValueList> value, bool important) |
3048 { | 3048 { |
3049 // When CSSGrammar.y encounters an invalid declaration it passes null for th
e CSSParserValueList, just bail. | 3049 // When CSSGrammar.y encounters an invalid declaration it passes null for th
e CSSParserValueList, just bail. |
3050 if (!value) | 3050 if (!value) |
3051 return; | 3051 return; |
3052 | 3052 |
3053 static const unsigned prefixLength = sizeof("var-") - 1; | 3053 static const unsigned prefixLength = sizeof("var-") - 1; |
3054 | 3054 |
3055 ASSERT(name.length() > prefixLength); | 3055 ASSERT(name.length() > prefixLength); |
3056 AtomicString variableName = name.atomicSubstring(prefixLength, name.length()
- prefixLength); | 3056 AtomicString variableName = name.atomicSubstring(prefixLength, name.length()
- prefixLength); |
3057 | 3057 |
3058 StringBuilder builder; | 3058 StringBuilder builder; |
3059 for (unsigned i = 0, size = value->size(); i < size; i++) { | 3059 for (unsigned i = 0, size = value->size(); i < size; i++) { |
3060 if (i) | 3060 if (i) |
3061 builder.append(' '); | 3061 builder.append(' '); |
3062 RefPtr<CSSValue> cssValue = value->valueAt(i)->createCSSValue(); | 3062 RefPtr<CSSValue> cssValue = value->valueAt(i)->createCSSValue(); |
3063 if (!cssValue) | 3063 if (!cssValue) |
3064 return; | 3064 return; |
3065 builder.append(cssValue->cssText()); | 3065 builder.append(cssValue->cssText()); |
3066 } | 3066 } |
3067 | 3067 |
3068 addProperty(CSSPropertyVariable, CSSVariableValue::create(variableName, buil
der.toString()), important, false); | 3068 addProperty(CSSPropertyVariable, CSSVariableValue::create(variableName, buil
der.toString()), important, false); |
3069 } | 3069 } |
3070 | 3070 |
3071 void CSSParser::addAnimationValue(RefPtr<CSSValue>& lval, PassRefPtr<CSSValue> r
val) | 3071 void BisonCSSParser::addAnimationValue(RefPtr<CSSValue>& lval, PassRefPtr<CSSVal
ue> rval) |
3072 { | 3072 { |
3073 if (lval) { | 3073 if (lval) { |
3074 if (lval->isValueList()) | 3074 if (lval->isValueList()) |
3075 toCSSValueList(lval.get())->append(rval); | 3075 toCSSValueList(lval.get())->append(rval); |
3076 else { | 3076 else { |
3077 PassRefPtr<CSSValue> oldVal(lval.release()); | 3077 PassRefPtr<CSSValue> oldVal(lval.release()); |
3078 PassRefPtr<CSSValueList> list = CSSValueList::createCommaSeparated()
; | 3078 PassRefPtr<CSSValueList> list = CSSValueList::createCommaSeparated()
; |
3079 list->append(oldVal); | 3079 list->append(oldVal); |
3080 list->append(rval); | 3080 list->append(rval); |
3081 lval = list; | 3081 lval = list; |
3082 } | 3082 } |
3083 } | 3083 } |
3084 else | 3084 else |
3085 lval = rval; | 3085 lval = rval; |
3086 } | 3086 } |
3087 | 3087 |
3088 bool CSSParser::parseAnimationShorthand(CSSPropertyID propId, bool important) | 3088 bool BisonCSSParser::parseAnimationShorthand(CSSPropertyID propId, bool importan
t) |
3089 { | 3089 { |
3090 const StylePropertyShorthand& animationProperties = parsingShorthandForPrope
rty(propId); | 3090 const StylePropertyShorthand& animationProperties = parsingShorthandForPrope
rty(propId); |
3091 const unsigned numProperties = 8; | 3091 const unsigned numProperties = 8; |
3092 | 3092 |
3093 // The list of properties in the shorthand should be the same | 3093 // The list of properties in the shorthand should be the same |
3094 // length as the list with animation name in last position, even though they
are | 3094 // length as the list with animation name in last position, even though they
are |
3095 // in a different order. | 3095 // in a different order. |
3096 ASSERT(numProperties == animationProperties.length()); | 3096 ASSERT(numProperties == animationProperties.length()); |
3097 ASSERT(numProperties == shorthandForProperty(propId).length()); | 3097 ASSERT(numProperties == shorthandForProperty(propId).length()); |
3098 | 3098 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3140 // If we didn't find the property, set an intial value. | 3140 // If we didn't find the property, set an intial value. |
3141 if (!parsedProperty[i]) | 3141 if (!parsedProperty[i]) |
3142 addAnimationValue(values[i], cssValuePool().createImplicitInitialVal
ue()); | 3142 addAnimationValue(values[i], cssValuePool().createImplicitInitialVal
ue()); |
3143 | 3143 |
3144 addProperty(animationProperties.properties()[i], values[i].release(), im
portant); | 3144 addProperty(animationProperties.properties()[i], values[i].release(), im
portant); |
3145 } | 3145 } |
3146 | 3146 |
3147 return true; | 3147 return true; |
3148 } | 3148 } |
3149 | 3149 |
3150 bool CSSParser::parseTransitionShorthand(CSSPropertyID propId, bool important) | 3150 bool BisonCSSParser::parseTransitionShorthand(CSSPropertyID propId, bool importa
nt) |
3151 { | 3151 { |
3152 const unsigned numProperties = 4; | 3152 const unsigned numProperties = 4; |
3153 const StylePropertyShorthand& shorthand = shorthandForProperty(propId); | 3153 const StylePropertyShorthand& shorthand = shorthandForProperty(propId); |
3154 ASSERT(numProperties == shorthand.length()); | 3154 ASSERT(numProperties == shorthand.length()); |
3155 | 3155 |
3156 ShorthandScope scope(this, propId); | 3156 ShorthandScope scope(this, propId); |
3157 | 3157 |
3158 bool parsedProperty[numProperties] = { false }; | 3158 bool parsedProperty[numProperties] = { false }; |
3159 AnimationParseContext context; | 3159 AnimationParseContext context; |
3160 RefPtr<CSSValue> values[numProperties]; | 3160 RefPtr<CSSValue> values[numProperties]; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3202 addAnimationValue(values[i], cssValuePool().createImplicitInitialVal
ue()); | 3202 addAnimationValue(values[i], cssValuePool().createImplicitInitialVal
ue()); |
3203 } | 3203 } |
3204 | 3204 |
3205 // Now add all of the properties we found. | 3205 // Now add all of the properties we found. |
3206 for (i = 0; i < numProperties; i++) | 3206 for (i = 0; i < numProperties; i++) |
3207 addPropertyWithPrefixingVariant(shorthand.properties()[i], values[i].rel
ease(), important); | 3207 addPropertyWithPrefixingVariant(shorthand.properties()[i], values[i].rel
ease(), important); |
3208 | 3208 |
3209 return true; | 3209 return true; |
3210 } | 3210 } |
3211 | 3211 |
3212 PassRefPtr<CSSValue> CSSParser::parseColumnWidth() | 3212 PassRefPtr<CSSValue> BisonCSSParser::parseColumnWidth() |
3213 { | 3213 { |
3214 CSSParserValue* value = m_valueList->current(); | 3214 CSSParserValue* value = m_valueList->current(); |
3215 // Always parse lengths in strict mode here, since it would be ambiguous oth
erwise when used in | 3215 // Always parse lengths in strict mode here, since it would be ambiguous oth
erwise when used in |
3216 // the 'columns' shorthand property. | 3216 // the 'columns' shorthand property. |
3217 if (value->id == CSSValueAuto | 3217 if (value->id == CSSValueAuto |
3218 || (validUnit(value, FLength | FNonNeg, HTMLStandardMode) && value->fVal
ue)) { | 3218 || (validUnit(value, FLength | FNonNeg, HTMLStandardMode) && value->fVal
ue)) { |
3219 RefPtr<CSSValue> parsedValue = parseValidPrimitive(value->id, value); | 3219 RefPtr<CSSValue> parsedValue = parseValidPrimitive(value->id, value); |
3220 m_valueList->next(); | 3220 m_valueList->next(); |
3221 return parsedValue; | 3221 return parsedValue; |
3222 } | 3222 } |
3223 return 0; | 3223 return 0; |
3224 } | 3224 } |
3225 | 3225 |
3226 PassRefPtr<CSSValue> CSSParser::parseColumnCount() | 3226 PassRefPtr<CSSValue> BisonCSSParser::parseColumnCount() |
3227 { | 3227 { |
3228 CSSParserValue* value = m_valueList->current(); | 3228 CSSParserValue* value = m_valueList->current(); |
3229 if (value->id == CSSValueAuto | 3229 if (value->id == CSSValueAuto |
3230 || (!value->id && validUnit(value, FPositiveInteger, HTMLQuirksMode))) { | 3230 || (!value->id && validUnit(value, FPositiveInteger, HTMLQuirksMode))) { |
3231 RefPtr<CSSValue> parsedValue = parseValidPrimitive(value->id, value); | 3231 RefPtr<CSSValue> parsedValue = parseValidPrimitive(value->id, value); |
3232 m_valueList->next(); | 3232 m_valueList->next(); |
3233 return parsedValue; | 3233 return parsedValue; |
3234 } | 3234 } |
3235 return 0; | 3235 return 0; |
3236 } | 3236 } |
3237 | 3237 |
3238 bool CSSParser::parseColumnsShorthand(bool important) | 3238 bool BisonCSSParser::parseColumnsShorthand(bool important) |
3239 { | 3239 { |
3240 RefPtr <CSSValue> columnWidth; | 3240 RefPtr <CSSValue> columnWidth; |
3241 RefPtr <CSSValue> columnCount; | 3241 RefPtr <CSSValue> columnCount; |
3242 bool hasPendingExplicitAuto = false; | 3242 bool hasPendingExplicitAuto = false; |
3243 | 3243 |
3244 for (unsigned propertiesParsed = 0; CSSParserValue* value = m_valueList->cur
rent(); propertiesParsed++) { | 3244 for (unsigned propertiesParsed = 0; CSSParserValue* value = m_valueList->cur
rent(); propertiesParsed++) { |
3245 if (propertiesParsed >= 2) | 3245 if (propertiesParsed >= 2) |
3246 return false; // Too many values for this shorthand. Invalid declara
tion. | 3246 return false; // Too many values for this shorthand. Invalid declara
tion. |
3247 if (!propertiesParsed && value->id == CSSValueAuto) { | 3247 if (!propertiesParsed && value->id == CSSValueAuto) { |
3248 // 'auto' is a valid value for any of the two longhands, and at this
point we | 3248 // 'auto' is a valid value for any of the two longhands, and at this
point we |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3283 addProperty(CSSPropertyWebkitColumnWidth, columnWidth, important); | 3283 addProperty(CSSPropertyWebkitColumnWidth, columnWidth, important); |
3284 else | 3284 else |
3285 addProperty(CSSPropertyWebkitColumnWidth, cssValuePool().createIdentifie
rValue(CSSValueAuto), important, true /* implicit */); | 3285 addProperty(CSSPropertyWebkitColumnWidth, cssValuePool().createIdentifie
rValue(CSSValueAuto), important, true /* implicit */); |
3286 if (columnCount) | 3286 if (columnCount) |
3287 addProperty(CSSPropertyWebkitColumnCount, columnCount, important); | 3287 addProperty(CSSPropertyWebkitColumnCount, columnCount, important); |
3288 else | 3288 else |
3289 addProperty(CSSPropertyWebkitColumnCount, cssValuePool().createIdentifie
rValue(CSSValueAuto), important, true /* implicit */); | 3289 addProperty(CSSPropertyWebkitColumnCount, cssValuePool().createIdentifie
rValue(CSSValueAuto), important, true /* implicit */); |
3290 return true; | 3290 return true; |
3291 } | 3291 } |
3292 | 3292 |
3293 bool CSSParser::parseShorthand(CSSPropertyID propId, const StylePropertyShorthan
d& shorthand, bool important) | 3293 bool BisonCSSParser::parseShorthand(CSSPropertyID propId, const StylePropertySho
rthand& shorthand, bool important) |
3294 { | 3294 { |
3295 // We try to match as many properties as possible | 3295 // We try to match as many properties as possible |
3296 // We set up an array of booleans to mark which property has been found, | 3296 // We set up an array of booleans to mark which property has been found, |
3297 // and we try to search for properties until it makes no longer any sense. | 3297 // and we try to search for properties until it makes no longer any sense. |
3298 ShorthandScope scope(this, propId); | 3298 ShorthandScope scope(this, propId); |
3299 | 3299 |
3300 bool found = false; | 3300 bool found = false; |
3301 unsigned propertiesParsed = 0; | 3301 unsigned propertiesParsed = 0; |
3302 bool propertyFound[6] = { false, false, false, false, false, false }; // 6 i
s enough size. | 3302 bool propertyFound[6] = { false, false, false, false, false, false }; // 6 i
s enough size. |
3303 | 3303 |
(...skipping 26 matching lines...) Expand all Loading... |
3330 const StylePropertyShorthand& initProperties = *(propertiesForInitia
lization[i]); | 3330 const StylePropertyShorthand& initProperties = *(propertiesForInitia
lization[i]); |
3331 for (unsigned propIndex = 0; propIndex < initProperties.length(); ++
propIndex) | 3331 for (unsigned propIndex = 0; propIndex < initProperties.length(); ++
propIndex) |
3332 addProperty(initProperties.properties()[propIndex], cssValuePool
().createImplicitInitialValue(), important); | 3332 addProperty(initProperties.properties()[propIndex], cssValuePool
().createImplicitInitialValue(), important); |
3333 } else | 3333 } else |
3334 addProperty(shorthand.properties()[i], cssValuePool().createImplicit
InitialValue(), important); | 3334 addProperty(shorthand.properties()[i], cssValuePool().createImplicit
InitialValue(), important); |
3335 } | 3335 } |
3336 | 3336 |
3337 return true; | 3337 return true; |
3338 } | 3338 } |
3339 | 3339 |
3340 bool CSSParser::parse4Values(CSSPropertyID propId, const CSSPropertyID *properti
es, bool important) | 3340 bool BisonCSSParser::parse4Values(CSSPropertyID propId, const CSSPropertyID *pro
perties, bool important) |
3341 { | 3341 { |
3342 /* From the CSS 2 specs, 8.3 | 3342 /* From the CSS 2 specs, 8.3 |
3343 * If there is only one value, it applies to all sides. If there are two val
ues, the top and | 3343 * If there is only one value, it applies to all sides. If there are two val
ues, the top and |
3344 * bottom margins are set to the first value and the right and left margins
are set to the second. | 3344 * bottom margins are set to the first value and the right and left margins
are set to the second. |
3345 * If there are three values, the top is set to the first value, the left an
d right are set to the | 3345 * If there are three values, the top is set to the first value, the left an
d right are set to the |
3346 * second, and the bottom is set to the third. If there are four values, the
y apply to the top, | 3346 * second, and the bottom is set to the third. If there are four values, the
y apply to the top, |
3347 * right, bottom, and left, respectively. | 3347 * right, bottom, and left, respectively. |
3348 */ | 3348 */ |
3349 | 3349 |
3350 int num = inShorthand() ? 1 : m_valueList->size(); | 3350 int num = inShorthand() ? 1 : m_valueList->size(); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3389 } | 3389 } |
3390 default: { | 3390 default: { |
3391 return false; | 3391 return false; |
3392 } | 3392 } |
3393 } | 3393 } |
3394 | 3394 |
3395 return true; | 3395 return true; |
3396 } | 3396 } |
3397 | 3397 |
3398 // auto | <identifier> | 3398 // auto | <identifier> |
3399 bool CSSParser::parsePage(CSSPropertyID propId, bool important) | 3399 bool BisonCSSParser::parsePage(CSSPropertyID propId, bool important) |
3400 { | 3400 { |
3401 ASSERT(propId == CSSPropertyPage); | 3401 ASSERT(propId == CSSPropertyPage); |
3402 | 3402 |
3403 if (m_valueList->size() != 1) | 3403 if (m_valueList->size() != 1) |
3404 return false; | 3404 return false; |
3405 | 3405 |
3406 CSSParserValue* value = m_valueList->current(); | 3406 CSSParserValue* value = m_valueList->current(); |
3407 if (!value) | 3407 if (!value) |
3408 return false; | 3408 return false; |
3409 | 3409 |
3410 if (value->id == CSSValueAuto) { | 3410 if (value->id == CSSValueAuto) { |
3411 addProperty(propId, cssValuePool().createIdentifierValue(value->id), imp
ortant); | 3411 addProperty(propId, cssValuePool().createIdentifierValue(value->id), imp
ortant); |
3412 return true; | 3412 return true; |
3413 } else if (value->id == 0 && value->unit == CSSPrimitiveValue::CSS_IDENT) { | 3413 } else if (value->id == 0 && value->unit == CSSPrimitiveValue::CSS_IDENT) { |
3414 addProperty(propId, createPrimitiveStringValue(value), important); | 3414 addProperty(propId, createPrimitiveStringValue(value), important); |
3415 return true; | 3415 return true; |
3416 } | 3416 } |
3417 return false; | 3417 return false; |
3418 } | 3418 } |
3419 | 3419 |
3420 // <length>{1,2} | auto | [ <page-size> || [ portrait | landscape] ] | 3420 // <length>{1,2} | auto | [ <page-size> || [ portrait | landscape] ] |
3421 bool CSSParser::parseSize(CSSPropertyID propId, bool important) | 3421 bool BisonCSSParser::parseSize(CSSPropertyID propId, bool important) |
3422 { | 3422 { |
3423 ASSERT(propId == CSSPropertySize); | 3423 ASSERT(propId == CSSPropertySize); |
3424 | 3424 |
3425 if (m_valueList->size() > 2) | 3425 if (m_valueList->size() > 2) |
3426 return false; | 3426 return false; |
3427 | 3427 |
3428 CSSParserValue* value = m_valueList->current(); | 3428 CSSParserValue* value = m_valueList->current(); |
3429 if (!value) | 3429 if (!value) |
3430 return false; | 3430 return false; |
3431 | 3431 |
3432 RefPtr<CSSValueList> parsedValues = CSSValueList::createSpaceSeparated(); | 3432 RefPtr<CSSValueList> parsedValues = CSSValueList::createSpaceSeparated(); |
3433 | 3433 |
3434 // First parameter. | 3434 // First parameter. |
3435 SizeParameterType paramType = parseSizeParameter(parsedValues.get(), value,
None); | 3435 SizeParameterType paramType = parseSizeParameter(parsedValues.get(), value,
None); |
3436 if (paramType == None) | 3436 if (paramType == None) |
3437 return false; | 3437 return false; |
3438 | 3438 |
3439 // Second parameter, if any. | 3439 // Second parameter, if any. |
3440 value = m_valueList->next(); | 3440 value = m_valueList->next(); |
3441 if (value) { | 3441 if (value) { |
3442 paramType = parseSizeParameter(parsedValues.get(), value, paramType); | 3442 paramType = parseSizeParameter(parsedValues.get(), value, paramType); |
3443 if (paramType == None) | 3443 if (paramType == None) |
3444 return false; | 3444 return false; |
3445 } | 3445 } |
3446 | 3446 |
3447 addProperty(propId, parsedValues.release(), important); | 3447 addProperty(propId, parsedValues.release(), important); |
3448 return true; | 3448 return true; |
3449 } | 3449 } |
3450 | 3450 |
3451 CSSParser::SizeParameterType CSSParser::parseSizeParameter(CSSValueList* parsedV
alues, CSSParserValue* value, SizeParameterType prevParamType) | 3451 BisonCSSParser::SizeParameterType BisonCSSParser::parseSizeParameter(CSSValueLis
t* parsedValues, CSSParserValue* value, SizeParameterType prevParamType) |
3452 { | 3452 { |
3453 switch (value->id) { | 3453 switch (value->id) { |
3454 case CSSValueAuto: | 3454 case CSSValueAuto: |
3455 if (prevParamType == None) { | 3455 if (prevParamType == None) { |
3456 parsedValues->append(cssValuePool().createIdentifierValue(value->id)
); | 3456 parsedValues->append(cssValuePool().createIdentifierValue(value->id)
); |
3457 return Auto; | 3457 return Auto; |
3458 } | 3458 } |
3459 return None; | 3459 return None; |
3460 case CSSValueLandscape: | 3460 case CSSValueLandscape: |
3461 case CSSValuePortrait: | 3461 case CSSValuePortrait: |
(...skipping 23 matching lines...) Expand all Loading... |
3485 return Length; | 3485 return Length; |
3486 } | 3486 } |
3487 return None; | 3487 return None; |
3488 default: | 3488 default: |
3489 return None; | 3489 return None; |
3490 } | 3490 } |
3491 } | 3491 } |
3492 | 3492 |
3493 // [ <string> <string> ]+ | inherit | none | 3493 // [ <string> <string> ]+ | inherit | none |
3494 // inherit and none are handled in parseValue. | 3494 // inherit and none are handled in parseValue. |
3495 bool CSSParser::parseQuotes(CSSPropertyID propId, bool important) | 3495 bool BisonCSSParser::parseQuotes(CSSPropertyID propId, bool important) |
3496 { | 3496 { |
3497 RefPtr<CSSValueList> values = CSSValueList::createCommaSeparated(); | 3497 RefPtr<CSSValueList> values = CSSValueList::createCommaSeparated(); |
3498 while (CSSParserValue* val = m_valueList->current()) { | 3498 while (CSSParserValue* val = m_valueList->current()) { |
3499 RefPtr<CSSValue> parsedValue; | 3499 RefPtr<CSSValue> parsedValue; |
3500 if (val->unit == CSSPrimitiveValue::CSS_STRING) | 3500 if (val->unit == CSSPrimitiveValue::CSS_STRING) |
3501 parsedValue = CSSPrimitiveValue::create(val->string, CSSPrimitiveVal
ue::CSS_STRING); | 3501 parsedValue = CSSPrimitiveValue::create(val->string, CSSPrimitiveVal
ue::CSS_STRING); |
3502 else | 3502 else |
3503 break; | 3503 break; |
3504 values->append(parsedValue.release()); | 3504 values->append(parsedValue.release()); |
3505 m_valueList->next(); | 3505 m_valueList->next(); |
3506 } | 3506 } |
3507 if (values->length()) { | 3507 if (values->length()) { |
3508 addProperty(propId, values.release(), important); | 3508 addProperty(propId, values.release(), important); |
3509 m_valueList->next(); | 3509 m_valueList->next(); |
3510 return true; | 3510 return true; |
3511 } | 3511 } |
3512 return false; | 3512 return false; |
3513 } | 3513 } |
3514 | 3514 |
3515 // [ <string> | <uri> | <counter> | attr(X) | open-quote | close-quote | no-open
-quote | no-close-quote ]+ | inherit | 3515 // [ <string> | <uri> | <counter> | attr(X) | open-quote | close-quote | no-open
-quote | no-close-quote ]+ | inherit |
3516 // in CSS 2.1 this got somewhat reduced: | 3516 // in CSS 2.1 this got somewhat reduced: |
3517 // [ <string> | attr(X) | open-quote | close-quote | no-open-quote | no-close-qu
ote ]+ | inherit | 3517 // [ <string> | attr(X) | open-quote | close-quote | no-open-quote | no-close-qu
ote ]+ | inherit |
3518 bool CSSParser::parseContent(CSSPropertyID propId, bool important) | 3518 bool BisonCSSParser::parseContent(CSSPropertyID propId, bool important) |
3519 { | 3519 { |
3520 RefPtr<CSSValueList> values = CSSValueList::createCommaSeparated(); | 3520 RefPtr<CSSValueList> values = CSSValueList::createCommaSeparated(); |
3521 | 3521 |
3522 while (CSSParserValue* val = m_valueList->current()) { | 3522 while (CSSParserValue* val = m_valueList->current()) { |
3523 RefPtr<CSSValue> parsedValue; | 3523 RefPtr<CSSValue> parsedValue; |
3524 if (val->unit == CSSPrimitiveValue::CSS_URI) { | 3524 if (val->unit == CSSPrimitiveValue::CSS_URI) { |
3525 // url | 3525 // url |
3526 parsedValue = CSSImageValue::create(completeURL(val->string)); | 3526 parsedValue = CSSImageValue::create(completeURL(val->string)); |
3527 } else if (val->unit == CSSParserValue::Function) { | 3527 } else if (val->unit == CSSParserValue::Function) { |
3528 // attr(X) | counter(X [,Y]) | counters(X, Y, [,Z]) | -webkit-gradie
nt(...) | 3528 // attr(X) | counter(X [,Y]) | counters(X, Y, [,Z]) | -webkit-gradie
nt(...) |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3581 | 3581 |
3582 if (values->length()) { | 3582 if (values->length()) { |
3583 addProperty(propId, values.release(), important); | 3583 addProperty(propId, values.release(), important); |
3584 m_valueList->next(); | 3584 m_valueList->next(); |
3585 return true; | 3585 return true; |
3586 } | 3586 } |
3587 | 3587 |
3588 return false; | 3588 return false; |
3589 } | 3589 } |
3590 | 3590 |
3591 PassRefPtr<CSSValue> CSSParser::parseAttr(CSSParserValueList* args) | 3591 PassRefPtr<CSSValue> BisonCSSParser::parseAttr(CSSParserValueList* args) |
3592 { | 3592 { |
3593 if (args->size() != 1) | 3593 if (args->size() != 1) |
3594 return 0; | 3594 return 0; |
3595 | 3595 |
3596 CSSParserValue* a = args->current(); | 3596 CSSParserValue* a = args->current(); |
3597 | 3597 |
3598 if (a->unit != CSSPrimitiveValue::CSS_IDENT) | 3598 if (a->unit != CSSPrimitiveValue::CSS_IDENT) |
3599 return 0; | 3599 return 0; |
3600 | 3600 |
3601 String attrName = a->string; | 3601 String attrName = a->string; |
3602 // CSS allows identifiers with "-" at the start, like "-webkit-mask-image". | 3602 // CSS allows identifiers with "-" at the start, like "-webkit-mask-image". |
3603 // But HTML attribute names can't have those characters, and we should not | 3603 // But HTML attribute names can't have those characters, and we should not |
3604 // even parse them inside attr(). | 3604 // even parse them inside attr(). |
3605 if (attrName[0] == '-') | 3605 if (attrName[0] == '-') |
3606 return 0; | 3606 return 0; |
3607 | 3607 |
3608 if (m_context.isHTMLDocument()) | 3608 if (m_context.isHTMLDocument()) |
3609 attrName = attrName.lower(); | 3609 attrName = attrName.lower(); |
3610 | 3610 |
3611 return cssValuePool().createValue(attrName, CSSPrimitiveValue::CSS_ATTR); | 3611 return cssValuePool().createValue(attrName, CSSPrimitiveValue::CSS_ATTR); |
3612 } | 3612 } |
3613 | 3613 |
3614 PassRefPtr<CSSValue> CSSParser::parseBackgroundColor() | 3614 PassRefPtr<CSSValue> BisonCSSParser::parseBackgroundColor() |
3615 { | 3615 { |
3616 CSSValueID id = m_valueList->current()->id; | 3616 CSSValueID id = m_valueList->current()->id; |
3617 if (id == CSSValueWebkitText || (id >= CSSValueAqua && id <= CSSValueWindowt
ext) || id == CSSValueMenu || id == CSSValueCurrentcolor || | 3617 if (id == CSSValueWebkitText || (id >= CSSValueAqua && id <= CSSValueWindowt
ext) || id == CSSValueMenu || id == CSSValueCurrentcolor || |
3618 (id >= CSSValueGrey && id < CSSValueWebkitText && inQuirksMode())) | 3618 (id >= CSSValueGrey && id < CSSValueWebkitText && inQuirksMode())) |
3619 return cssValuePool().createIdentifierValue(id); | 3619 return cssValuePool().createIdentifierValue(id); |
3620 return parseColor(); | 3620 return parseColor(); |
3621 } | 3621 } |
3622 | 3622 |
3623 bool CSSParser::parseFillImage(CSSParserValueList* valueList, RefPtr<CSSValue>&
value) | 3623 bool BisonCSSParser::parseFillImage(CSSParserValueList* valueList, RefPtr<CSSVal
ue>& value) |
3624 { | 3624 { |
3625 if (valueList->current()->id == CSSValueNone) { | 3625 if (valueList->current()->id == CSSValueNone) { |
3626 value = cssValuePool().createIdentifierValue(CSSValueNone); | 3626 value = cssValuePool().createIdentifierValue(CSSValueNone); |
3627 return true; | 3627 return true; |
3628 } | 3628 } |
3629 if (valueList->current()->unit == CSSPrimitiveValue::CSS_URI) { | 3629 if (valueList->current()->unit == CSSPrimitiveValue::CSS_URI) { |
3630 value = CSSImageValue::create(completeURL(valueList->current()->string))
; | 3630 value = CSSImageValue::create(completeURL(valueList->current()->string))
; |
3631 return true; | 3631 return true; |
3632 } | 3632 } |
3633 | 3633 |
3634 if (isGeneratedImageValue(valueList->current())) | 3634 if (isGeneratedImageValue(valueList->current())) |
3635 return parseGeneratedImage(valueList, value); | 3635 return parseGeneratedImage(valueList, value); |
3636 | 3636 |
3637 if (valueList->current()->unit == CSSParserValue::Function && equalIgnoringC
ase(valueList->current()->function->name, "-webkit-image-set(")) { | 3637 if (valueList->current()->unit == CSSParserValue::Function && equalIgnoringC
ase(valueList->current()->function->name, "-webkit-image-set(")) { |
3638 value = parseImageSet(m_valueList.get()); | 3638 value = parseImageSet(m_valueList.get()); |
3639 if (value) | 3639 if (value) |
3640 return true; | 3640 return true; |
3641 } | 3641 } |
3642 | 3642 |
3643 return false; | 3643 return false; |
3644 } | 3644 } |
3645 | 3645 |
3646 PassRefPtr<CSSValue> CSSParser::parseFillPositionX(CSSParserValueList* valueList
) | 3646 PassRefPtr<CSSValue> BisonCSSParser::parseFillPositionX(CSSParserValueList* valu
eList) |
3647 { | 3647 { |
3648 int id = valueList->current()->id; | 3648 int id = valueList->current()->id; |
3649 if (id == CSSValueLeft || id == CSSValueRight || id == CSSValueCenter) { | 3649 if (id == CSSValueLeft || id == CSSValueRight || id == CSSValueCenter) { |
3650 int percent = 0; | 3650 int percent = 0; |
3651 if (id == CSSValueRight) | 3651 if (id == CSSValueRight) |
3652 percent = 100; | 3652 percent = 100; |
3653 else if (id == CSSValueCenter) | 3653 else if (id == CSSValueCenter) |
3654 percent = 50; | 3654 percent = 50; |
3655 return cssValuePool().createValue(percent, CSSPrimitiveValue::CSS_PERCEN
TAGE); | 3655 return cssValuePool().createValue(percent, CSSPrimitiveValue::CSS_PERCEN
TAGE); |
3656 } | 3656 } |
3657 if (validUnit(valueList->current(), FPercent | FLength)) | 3657 if (validUnit(valueList->current(), FPercent | FLength)) |
3658 return createPrimitiveNumericValue(valueList->current()); | 3658 return createPrimitiveNumericValue(valueList->current()); |
3659 return 0; | 3659 return 0; |
3660 } | 3660 } |
3661 | 3661 |
3662 PassRefPtr<CSSValue> CSSParser::parseFillPositionY(CSSParserValueList* valueList
) | 3662 PassRefPtr<CSSValue> BisonCSSParser::parseFillPositionY(CSSParserValueList* valu
eList) |
3663 { | 3663 { |
3664 int id = valueList->current()->id; | 3664 int id = valueList->current()->id; |
3665 if (id == CSSValueTop || id == CSSValueBottom || id == CSSValueCenter) { | 3665 if (id == CSSValueTop || id == CSSValueBottom || id == CSSValueCenter) { |
3666 int percent = 0; | 3666 int percent = 0; |
3667 if (id == CSSValueBottom) | 3667 if (id == CSSValueBottom) |
3668 percent = 100; | 3668 percent = 100; |
3669 else if (id == CSSValueCenter) | 3669 else if (id == CSSValueCenter) |
3670 percent = 50; | 3670 percent = 50; |
3671 return cssValuePool().createValue(percent, CSSPrimitiveValue::CSS_PERCEN
TAGE); | 3671 return cssValuePool().createValue(percent, CSSPrimitiveValue::CSS_PERCEN
TAGE); |
3672 } | 3672 } |
3673 if (validUnit(valueList->current(), FPercent | FLength)) | 3673 if (validUnit(valueList->current(), FPercent | FLength)) |
3674 return createPrimitiveNumericValue(valueList->current()); | 3674 return createPrimitiveNumericValue(valueList->current()); |
3675 return 0; | 3675 return 0; |
3676 } | 3676 } |
3677 | 3677 |
3678 PassRefPtr<CSSPrimitiveValue> CSSParser::parseFillPositionComponent(CSSParserVal
ueList* valueList, unsigned& cumulativeFlags, FillPositionFlag& individualFlag,
FillPositionParsingMode parsingMode) | 3678 PassRefPtr<CSSPrimitiveValue> BisonCSSParser::parseFillPositionComponent(CSSPars
erValueList* valueList, unsigned& cumulativeFlags, FillPositionFlag& individualF
lag, FillPositionParsingMode parsingMode) |
3679 { | 3679 { |
3680 CSSValueID id = valueList->current()->id; | 3680 CSSValueID id = valueList->current()->id; |
3681 if (id == CSSValueLeft || id == CSSValueTop || id == CSSValueRight || id ==
CSSValueBottom || id == CSSValueCenter) { | 3681 if (id == CSSValueLeft || id == CSSValueTop || id == CSSValueRight || id ==
CSSValueBottom || id == CSSValueCenter) { |
3682 int percent = 0; | 3682 int percent = 0; |
3683 if (id == CSSValueLeft || id == CSSValueRight) { | 3683 if (id == CSSValueLeft || id == CSSValueRight) { |
3684 if (cumulativeFlags & XFillPosition) | 3684 if (cumulativeFlags & XFillPosition) |
3685 return 0; | 3685 return 0; |
3686 cumulativeFlags |= XFillPosition; | 3686 cumulativeFlags |= XFillPosition; |
3687 individualFlag = XFillPosition; | 3687 individualFlag = XFillPosition; |
3688 if (id == CSSValueRight) | 3688 if (id == CSSValueRight) |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3733 return true; | 3733 return true; |
3734 | 3734 |
3735 return false; | 3735 return false; |
3736 } | 3736 } |
3737 | 3737 |
3738 static bool isFillPositionKeyword(CSSValueID value) | 3738 static bool isFillPositionKeyword(CSSValueID value) |
3739 { | 3739 { |
3740 return value == CSSValueLeft || value == CSSValueTop || value == CSSValueBot
tom || value == CSSValueRight || value == CSSValueCenter; | 3740 return value == CSSValueLeft || value == CSSValueTop || value == CSSValueBot
tom || value == CSSValueRight || value == CSSValueCenter; |
3741 } | 3741 } |
3742 | 3742 |
3743 void CSSParser::parse4ValuesFillPosition(CSSParserValueList* valueList, RefPtr<C
SSValue>& value1, RefPtr<CSSValue>& value2, PassRefPtr<CSSPrimitiveValue> parsed
Value1, PassRefPtr<CSSPrimitiveValue> parsedValue2) | 3743 void BisonCSSParser::parse4ValuesFillPosition(CSSParserValueList* valueList, Ref
Ptr<CSSValue>& value1, RefPtr<CSSValue>& value2, PassRefPtr<CSSPrimitiveValue> p
arsedValue1, PassRefPtr<CSSPrimitiveValue> parsedValue2) |
3744 { | 3744 { |
3745 // [ left | right ] [ <percentage] | <length> ] && [ top | bottom ] [ <perce
ntage> | <length> ] | 3745 // [ left | right ] [ <percentage] | <length> ] && [ top | bottom ] [ <perce
ntage> | <length> ] |
3746 // In the case of 4 values <position> requires the second value to be a leng
th or a percentage. | 3746 // In the case of 4 values <position> requires the second value to be a leng
th or a percentage. |
3747 if (isFillPositionKeyword(parsedValue2->getValueID())) | 3747 if (isFillPositionKeyword(parsedValue2->getValueID())) |
3748 return; | 3748 return; |
3749 | 3749 |
3750 unsigned cumulativeFlags = 0; | 3750 unsigned cumulativeFlags = 0; |
3751 FillPositionFlag value3Flag = InvalidFillPosition; | 3751 FillPositionFlag value3Flag = InvalidFillPosition; |
3752 RefPtr<CSSPrimitiveValue> value3 = parseFillPositionComponent(valueList, cum
ulativeFlags, value3Flag, ResolveValuesAsKeyword); | 3752 RefPtr<CSSPrimitiveValue> value3 = parseFillPositionComponent(valueList, cum
ulativeFlags, value3Flag, ResolveValuesAsKeyword); |
3753 if (!value3) | 3753 if (!value3) |
(...skipping 27 matching lines...) Expand all Loading... |
3781 return; | 3781 return; |
3782 | 3782 |
3783 value1 = createPrimitiveValuePair(parsedValue1, parsedValue2); | 3783 value1 = createPrimitiveValuePair(parsedValue1, parsedValue2); |
3784 value2 = createPrimitiveValuePair(value3, value4); | 3784 value2 = createPrimitiveValuePair(value3, value4); |
3785 | 3785 |
3786 if (ident1 == CSSValueTop || ident1 == CSSValueBottom) | 3786 if (ident1 == CSSValueTop || ident1 == CSSValueBottom) |
3787 value1.swap(value2); | 3787 value1.swap(value2); |
3788 | 3788 |
3789 valueList->next(); | 3789 valueList->next(); |
3790 } | 3790 } |
3791 void CSSParser::parse3ValuesFillPosition(CSSParserValueList* valueList, RefPtr<C
SSValue>& value1, RefPtr<CSSValue>& value2, PassRefPtr<CSSPrimitiveValue> parsed
Value1, PassRefPtr<CSSPrimitiveValue> parsedValue2) | 3791 void BisonCSSParser::parse3ValuesFillPosition(CSSParserValueList* valueList, Ref
Ptr<CSSValue>& value1, RefPtr<CSSValue>& value2, PassRefPtr<CSSPrimitiveValue> p
arsedValue1, PassRefPtr<CSSPrimitiveValue> parsedValue2) |
3792 { | 3792 { |
3793 unsigned cumulativeFlags = 0; | 3793 unsigned cumulativeFlags = 0; |
3794 FillPositionFlag value3Flag = InvalidFillPosition; | 3794 FillPositionFlag value3Flag = InvalidFillPosition; |
3795 RefPtr<CSSPrimitiveValue> value3 = parseFillPositionComponent(valueList, cum
ulativeFlags, value3Flag, ResolveValuesAsKeyword); | 3795 RefPtr<CSSPrimitiveValue> value3 = parseFillPositionComponent(valueList, cum
ulativeFlags, value3Flag, ResolveValuesAsKeyword); |
3796 | 3796 |
3797 // value3 is not an expected value, we return. | 3797 // value3 is not an expected value, we return. |
3798 if (!value3) | 3798 if (!value3) |
3799 return; | 3799 return; |
3800 | 3800 |
3801 valueList->next(); | 3801 valueList->next(); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3872 #ifndef NDEBUG | 3872 #ifndef NDEBUG |
3873 CSSPrimitiveValue* first = toCSSPrimitiveValue(value1.get()); | 3873 CSSPrimitiveValue* first = toCSSPrimitiveValue(value1.get()); |
3874 CSSPrimitiveValue* second = toCSSPrimitiveValue(value2.get()); | 3874 CSSPrimitiveValue* second = toCSSPrimitiveValue(value2.get()); |
3875 ident1 = first->getPairValue()->first()->getValueID(); | 3875 ident1 = first->getPairValue()->first()->getValueID(); |
3876 ident2 = second->getPairValue()->first()->getValueID(); | 3876 ident2 = second->getPairValue()->first()->getValueID(); |
3877 ASSERT(ident1 == CSSValueLeft || ident1 == CSSValueRight); | 3877 ASSERT(ident1 == CSSValueLeft || ident1 == CSSValueRight); |
3878 ASSERT(ident2 == CSSValueBottom || ident2 == CSSValueTop); | 3878 ASSERT(ident2 == CSSValueBottom || ident2 == CSSValueTop); |
3879 #endif | 3879 #endif |
3880 } | 3880 } |
3881 | 3881 |
3882 inline bool CSSParser::isPotentialPositionValue(CSSParserValue* value) | 3882 inline bool BisonCSSParser::isPotentialPositionValue(CSSParserValue* value) |
3883 { | 3883 { |
3884 return isFillPositionKeyword(value->id) || validUnit(value, FPercent | FLeng
th, ReleaseParsedCalcValue); | 3884 return isFillPositionKeyword(value->id) || validUnit(value, FPercent | FLeng
th, ReleaseParsedCalcValue); |
3885 } | 3885 } |
3886 | 3886 |
3887 void CSSParser::parseFillPosition(CSSParserValueList* valueList, RefPtr<CSSValue
>& value1, RefPtr<CSSValue>& value2) | 3887 void BisonCSSParser::parseFillPosition(CSSParserValueList* valueList, RefPtr<CSS
Value>& value1, RefPtr<CSSValue>& value2) |
3888 { | 3888 { |
3889 unsigned numberOfValues = 0; | 3889 unsigned numberOfValues = 0; |
3890 for (unsigned i = valueList->currentIndex(); i < valueList->size(); ++i, ++n
umberOfValues) { | 3890 for (unsigned i = valueList->currentIndex(); i < valueList->size(); ++i, ++n
umberOfValues) { |
3891 CSSParserValue* current = valueList->valueAt(i); | 3891 CSSParserValue* current = valueList->valueAt(i); |
3892 if (isComma(current) || !current || isForwardSlashOperator(current) || !
isPotentialPositionValue(current)) | 3892 if (isComma(current) || !current || isForwardSlashOperator(current) || !
isPotentialPositionValue(current)) |
3893 break; | 3893 break; |
3894 } | 3894 } |
3895 | 3895 |
3896 if (numberOfValues > 4) | 3896 if (numberOfValues > 4) |
3897 return; | 3897 return; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3940 // Per CSS3 syntax, <position> can't have 'center' as its second keyword as
we have more arguments to follow. | 3940 // Per CSS3 syntax, <position> can't have 'center' as its second keyword as
we have more arguments to follow. |
3941 if (parsedValue2->getValueID() == CSSValueCenter) | 3941 if (parsedValue2->getValueID() == CSSValueCenter) |
3942 return; | 3942 return; |
3943 | 3943 |
3944 if (numberOfValues == 3) | 3944 if (numberOfValues == 3) |
3945 parse3ValuesFillPosition(valueList, value1, value2, parsedValue1.release
(), parsedValue2.release()); | 3945 parse3ValuesFillPosition(valueList, value1, value2, parsedValue1.release
(), parsedValue2.release()); |
3946 else | 3946 else |
3947 parse4ValuesFillPosition(valueList, value1, value2, parsedValue1.release
(), parsedValue2.release()); | 3947 parse4ValuesFillPosition(valueList, value1, value2, parsedValue1.release
(), parsedValue2.release()); |
3948 } | 3948 } |
3949 | 3949 |
3950 void CSSParser::parse2ValuesFillPosition(CSSParserValueList* valueList, RefPtr<C
SSValue>& value1, RefPtr<CSSValue>& value2) | 3950 void BisonCSSParser::parse2ValuesFillPosition(CSSParserValueList* valueList, Ref
Ptr<CSSValue>& value1, RefPtr<CSSValue>& value2) |
3951 { | 3951 { |
3952 CSSParserValue* value = valueList->current(); | 3952 CSSParserValue* value = valueList->current(); |
3953 | 3953 |
3954 // Parse the first value. We're just making sure that it is one of the vali
d keywords or a percentage/length. | 3954 // Parse the first value. We're just making sure that it is one of the vali
d keywords or a percentage/length. |
3955 unsigned cumulativeFlags = 0; | 3955 unsigned cumulativeFlags = 0; |
3956 FillPositionFlag value1Flag = InvalidFillPosition; | 3956 FillPositionFlag value1Flag = InvalidFillPosition; |
3957 FillPositionFlag value2Flag = InvalidFillPosition; | 3957 FillPositionFlag value2Flag = InvalidFillPosition; |
3958 value1 = parseFillPositionComponent(valueList, cumulativeFlags, value1Flag); | 3958 value1 = parseFillPositionComponent(valueList, cumulativeFlags, value1Flag); |
3959 if (!value1) | 3959 if (!value1) |
3960 return; | 3960 return; |
(...skipping 23 matching lines...) Expand all Loading... |
3984 // Only one value was specified. If that value was not a keyword, then i
t sets the x position, and the y position | 3984 // Only one value was specified. If that value was not a keyword, then i
t sets the x position, and the y position |
3985 // is simply 50%. This is our default. | 3985 // is simply 50%. This is our default. |
3986 // For keywords, the keyword was either an x-keyword (left/right), a y-k
eyword (top/bottom), or an ambiguous keyword (center). | 3986 // For keywords, the keyword was either an x-keyword (left/right), a y-k
eyword (top/bottom), or an ambiguous keyword (center). |
3987 // For left/right/center, the default of 50% in the y is still correct. | 3987 // For left/right/center, the default of 50% in the y is still correct. |
3988 value2 = cssValuePool().createValue(50, CSSPrimitiveValue::CSS_PERCENTAG
E); | 3988 value2 = cssValuePool().createValue(50, CSSPrimitiveValue::CSS_PERCENTAG
E); |
3989 | 3989 |
3990 if (value1Flag == YFillPosition || value2Flag == XFillPosition) | 3990 if (value1Flag == YFillPosition || value2Flag == XFillPosition) |
3991 value1.swap(value2); | 3991 value1.swap(value2); |
3992 } | 3992 } |
3993 | 3993 |
3994 void CSSParser::parseFillRepeat(RefPtr<CSSValue>& value1, RefPtr<CSSValue>& valu
e2) | 3994 void BisonCSSParser::parseFillRepeat(RefPtr<CSSValue>& value1, RefPtr<CSSValue>&
value2) |
3995 { | 3995 { |
3996 CSSValueID id = m_valueList->current()->id; | 3996 CSSValueID id = m_valueList->current()->id; |
3997 if (id == CSSValueRepeatX) { | 3997 if (id == CSSValueRepeatX) { |
3998 m_implicitShorthand = true; | 3998 m_implicitShorthand = true; |
3999 value1 = cssValuePool().createIdentifierValue(CSSValueRepeat); | 3999 value1 = cssValuePool().createIdentifierValue(CSSValueRepeat); |
4000 value2 = cssValuePool().createIdentifierValue(CSSValueNoRepeat); | 4000 value2 = cssValuePool().createIdentifierValue(CSSValueNoRepeat); |
4001 m_valueList->next(); | 4001 m_valueList->next(); |
4002 return; | 4002 return; |
4003 } | 4003 } |
4004 if (id == CSSValueRepeatY) { | 4004 if (id == CSSValueRepeatY) { |
(...skipping 20 matching lines...) Expand all Loading... |
4025 m_valueList->next(); | 4025 m_valueList->next(); |
4026 return; | 4026 return; |
4027 } | 4027 } |
4028 } | 4028 } |
4029 | 4029 |
4030 // If only one value was specified, value2 is the same as value1. | 4030 // If only one value was specified, value2 is the same as value1. |
4031 m_implicitShorthand = true; | 4031 m_implicitShorthand = true; |
4032 value2 = cssValuePool().createIdentifierValue(toCSSPrimitiveValue(value1.get
())->getValueID()); | 4032 value2 = cssValuePool().createIdentifierValue(toCSSPrimitiveValue(value1.get
())->getValueID()); |
4033 } | 4033 } |
4034 | 4034 |
4035 PassRefPtr<CSSValue> CSSParser::parseFillSize(CSSPropertyID propId, bool& allowC
omma) | 4035 PassRefPtr<CSSValue> BisonCSSParser::parseFillSize(CSSPropertyID propId, bool& a
llowComma) |
4036 { | 4036 { |
4037 allowComma = true; | 4037 allowComma = true; |
4038 CSSParserValue* value = m_valueList->current(); | 4038 CSSParserValue* value = m_valueList->current(); |
4039 | 4039 |
4040 if (value->id == CSSValueContain || value->id == CSSValueCover) | 4040 if (value->id == CSSValueContain || value->id == CSSValueCover) |
4041 return cssValuePool().createIdentifierValue(value->id); | 4041 return cssValuePool().createIdentifierValue(value->id); |
4042 | 4042 |
4043 RefPtr<CSSPrimitiveValue> parsedValue1; | 4043 RefPtr<CSSPrimitiveValue> parsedValue1; |
4044 | 4044 |
4045 if (value->id == CSSValueAuto) | 4045 if (value->id == CSSValueAuto) |
(...skipping 22 matching lines...) Expand all Loading... |
4068 // We only need to do this for -webkit-background-size. It should be saf
e to let masks match | 4068 // We only need to do this for -webkit-background-size. It should be saf
e to let masks match |
4069 // the real property. | 4069 // the real property. |
4070 parsedValue2 = parsedValue1; | 4070 parsedValue2 = parsedValue1; |
4071 } | 4071 } |
4072 | 4072 |
4073 if (!parsedValue2) | 4073 if (!parsedValue2) |
4074 return parsedValue1; | 4074 return parsedValue1; |
4075 return createPrimitiveValuePair(parsedValue1.release(), parsedValue2.release
()); | 4075 return createPrimitiveValuePair(parsedValue1.release(), parsedValue2.release
()); |
4076 } | 4076 } |
4077 | 4077 |
4078 bool CSSParser::parseFillProperty(CSSPropertyID propId, CSSPropertyID& propId1,
CSSPropertyID& propId2, | 4078 bool BisonCSSParser::parseFillProperty(CSSPropertyID propId, CSSPropertyID& prop
Id1, CSSPropertyID& propId2, |
4079 RefPtr<CSSValue>& retValue1, RefPtr<CSSValue>&
retValue2) | 4079 RefPtr<CSSValue>& retValue1, RefPtr<CSSValue>&
retValue2) |
4080 { | 4080 { |
4081 RefPtr<CSSValueList> values; | 4081 RefPtr<CSSValueList> values; |
4082 RefPtr<CSSValueList> values2; | 4082 RefPtr<CSSValueList> values2; |
4083 CSSParserValue* val; | 4083 CSSParserValue* val; |
4084 RefPtr<CSSValue> value; | 4084 RefPtr<CSSValue> value; |
4085 RefPtr<CSSValue> value2; | 4085 RefPtr<CSSValue> value2; |
4086 | 4086 |
4087 bool allowComma = false; | 4087 bool allowComma = false; |
4088 | 4088 |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4257 return true; | 4257 return true; |
4258 } | 4258 } |
4259 if (value) { | 4259 if (value) { |
4260 retValue1 = value.release(); | 4260 retValue1 = value.release(); |
4261 retValue2 = value2.release(); | 4261 retValue2 = value2.release(); |
4262 return true; | 4262 return true; |
4263 } | 4263 } |
4264 return false; | 4264 return false; |
4265 } | 4265 } |
4266 | 4266 |
4267 PassRefPtr<CSSValue> CSSParser::parseAnimationDelay() | 4267 PassRefPtr<CSSValue> BisonCSSParser::parseAnimationDelay() |
4268 { | 4268 { |
4269 CSSParserValue* value = m_valueList->current(); | 4269 CSSParserValue* value = m_valueList->current(); |
4270 if (validUnit(value, FTime)) | 4270 if (validUnit(value, FTime)) |
4271 return createPrimitiveNumericValue(value); | 4271 return createPrimitiveNumericValue(value); |
4272 return 0; | 4272 return 0; |
4273 } | 4273 } |
4274 | 4274 |
4275 PassRefPtr<CSSValue> CSSParser::parseAnimationDirection() | 4275 PassRefPtr<CSSValue> BisonCSSParser::parseAnimationDirection() |
4276 { | 4276 { |
4277 CSSParserValue* value = m_valueList->current(); | 4277 CSSParserValue* value = m_valueList->current(); |
4278 if (value->id == CSSValueNormal || value->id == CSSValueAlternate || value->
id == CSSValueReverse || value->id == CSSValueAlternateReverse) | 4278 if (value->id == CSSValueNormal || value->id == CSSValueAlternate || value->
id == CSSValueReverse || value->id == CSSValueAlternateReverse) |
4279 return cssValuePool().createIdentifierValue(value->id); | 4279 return cssValuePool().createIdentifierValue(value->id); |
4280 return 0; | 4280 return 0; |
4281 } | 4281 } |
4282 | 4282 |
4283 PassRefPtr<CSSValue> CSSParser::parseAnimationDuration() | 4283 PassRefPtr<CSSValue> BisonCSSParser::parseAnimationDuration() |
4284 { | 4284 { |
4285 CSSParserValue* value = m_valueList->current(); | 4285 CSSParserValue* value = m_valueList->current(); |
4286 if (validUnit(value, FTime | FNonNeg)) | 4286 if (validUnit(value, FTime | FNonNeg)) |
4287 return createPrimitiveNumericValue(value); | 4287 return createPrimitiveNumericValue(value); |
4288 return 0; | 4288 return 0; |
4289 } | 4289 } |
4290 | 4290 |
4291 PassRefPtr<CSSValue> CSSParser::parseAnimationFillMode() | 4291 PassRefPtr<CSSValue> BisonCSSParser::parseAnimationFillMode() |
4292 { | 4292 { |
4293 CSSParserValue* value = m_valueList->current(); | 4293 CSSParserValue* value = m_valueList->current(); |
4294 if (value->id == CSSValueNone || value->id == CSSValueForwards || value->id
== CSSValueBackwards || value->id == CSSValueBoth) | 4294 if (value->id == CSSValueNone || value->id == CSSValueForwards || value->id
== CSSValueBackwards || value->id == CSSValueBoth) |
4295 return cssValuePool().createIdentifierValue(value->id); | 4295 return cssValuePool().createIdentifierValue(value->id); |
4296 return 0; | 4296 return 0; |
4297 } | 4297 } |
4298 | 4298 |
4299 PassRefPtr<CSSValue> CSSParser::parseAnimationIterationCount() | 4299 PassRefPtr<CSSValue> BisonCSSParser::parseAnimationIterationCount() |
4300 { | 4300 { |
4301 CSSParserValue* value = m_valueList->current(); | 4301 CSSParserValue* value = m_valueList->current(); |
4302 if (value->id == CSSValueInfinite) | 4302 if (value->id == CSSValueInfinite) |
4303 return cssValuePool().createIdentifierValue(value->id); | 4303 return cssValuePool().createIdentifierValue(value->id); |
4304 if (validUnit(value, FNumber | FNonNeg)) | 4304 if (validUnit(value, FNumber | FNonNeg)) |
4305 return createPrimitiveNumericValue(value); | 4305 return createPrimitiveNumericValue(value); |
4306 return 0; | 4306 return 0; |
4307 } | 4307 } |
4308 | 4308 |
4309 PassRefPtr<CSSValue> CSSParser::parseAnimationName() | 4309 PassRefPtr<CSSValue> BisonCSSParser::parseAnimationName() |
4310 { | 4310 { |
4311 CSSParserValue* value = m_valueList->current(); | 4311 CSSParserValue* value = m_valueList->current(); |
4312 if (value->unit == CSSPrimitiveValue::CSS_STRING || value->unit == CSSPrimit
iveValue::CSS_IDENT) { | 4312 if (value->unit == CSSPrimitiveValue::CSS_STRING || value->unit == CSSPrimit
iveValue::CSS_IDENT) { |
4313 if (value->id == CSSValueNone || (value->unit == CSSPrimitiveValue::CSS_
STRING && equalIgnoringCase(value, "none"))) { | 4313 if (value->id == CSSValueNone || (value->unit == CSSPrimitiveValue::CSS_
STRING && equalIgnoringCase(value, "none"))) { |
4314 return cssValuePool().createIdentifierValue(CSSValueNone); | 4314 return cssValuePool().createIdentifierValue(CSSValueNone); |
4315 } else { | 4315 } else { |
4316 return createPrimitiveStringValue(value); | 4316 return createPrimitiveStringValue(value); |
4317 } | 4317 } |
4318 } | 4318 } |
4319 return 0; | 4319 return 0; |
4320 } | 4320 } |
4321 | 4321 |
4322 PassRefPtr<CSSValue> CSSParser::parseAnimationPlayState() | 4322 PassRefPtr<CSSValue> BisonCSSParser::parseAnimationPlayState() |
4323 { | 4323 { |
4324 CSSParserValue* value = m_valueList->current(); | 4324 CSSParserValue* value = m_valueList->current(); |
4325 if (value->id == CSSValueRunning || value->id == CSSValuePaused) | 4325 if (value->id == CSSValueRunning || value->id == CSSValuePaused) |
4326 return cssValuePool().createIdentifierValue(value->id); | 4326 return cssValuePool().createIdentifierValue(value->id); |
4327 return 0; | 4327 return 0; |
4328 } | 4328 } |
4329 | 4329 |
4330 PassRefPtr<CSSValue> CSSParser::parseAnimationProperty(AnimationParseContext& co
ntext) | 4330 PassRefPtr<CSSValue> BisonCSSParser::parseAnimationProperty(AnimationParseContex
t& context) |
4331 { | 4331 { |
4332 CSSParserValue* value = m_valueList->current(); | 4332 CSSParserValue* value = m_valueList->current(); |
4333 if (value->unit != CSSPrimitiveValue::CSS_IDENT) | 4333 if (value->unit != CSSPrimitiveValue::CSS_IDENT) |
4334 return 0; | 4334 return 0; |
4335 CSSPropertyID result = cssPropertyID(value->string); | 4335 CSSPropertyID result = cssPropertyID(value->string); |
4336 if (result) | 4336 if (result) |
4337 return cssValuePool().createIdentifierValue(result); | 4337 return cssValuePool().createIdentifierValue(result); |
4338 if (equalIgnoringCase(value, "all")) { | 4338 if (equalIgnoringCase(value, "all")) { |
4339 context.sawAnimationPropertyKeyword(); | 4339 context.sawAnimationPropertyKeyword(); |
4340 return cssValuePool().createIdentifierValue(CSSValueAll); | 4340 return cssValuePool().createIdentifierValue(CSSValueAll); |
4341 } | 4341 } |
4342 if (equalIgnoringCase(value, "none")) { | 4342 if (equalIgnoringCase(value, "none")) { |
4343 context.commitAnimationPropertyKeyword(); | 4343 context.commitAnimationPropertyKeyword(); |
4344 context.sawAnimationPropertyKeyword(); | 4344 context.sawAnimationPropertyKeyword(); |
4345 return cssValuePool().createIdentifierValue(CSSValueNone); | 4345 return cssValuePool().createIdentifierValue(CSSValueNone); |
4346 } | 4346 } |
4347 return 0; | 4347 return 0; |
4348 } | 4348 } |
4349 | 4349 |
4350 bool CSSParser::parseTransformOriginShorthand(RefPtr<CSSValue>& value1, RefPtr<C
SSValue>& value2, RefPtr<CSSValue>& value3) | 4350 bool BisonCSSParser::parseTransformOriginShorthand(RefPtr<CSSValue>& value1, Ref
Ptr<CSSValue>& value2, RefPtr<CSSValue>& value3) |
4351 { | 4351 { |
4352 parse2ValuesFillPosition(m_valueList.get(), value1, value2); | 4352 parse2ValuesFillPosition(m_valueList.get(), value1, value2); |
4353 | 4353 |
4354 // now get z | 4354 // now get z |
4355 if (m_valueList->current()) { | 4355 if (m_valueList->current()) { |
4356 if (validUnit(m_valueList->current(), FLength)) { | 4356 if (validUnit(m_valueList->current(), FLength)) { |
4357 value3 = createPrimitiveNumericValue(m_valueList->current()); | 4357 value3 = createPrimitiveNumericValue(m_valueList->current()); |
4358 m_valueList->next(); | 4358 m_valueList->next(); |
4359 return true; | 4359 return true; |
4360 } | 4360 } |
4361 return false; | 4361 return false; |
4362 } | 4362 } |
4363 value3 = cssValuePool().createImplicitInitialValue(); | 4363 value3 = cssValuePool().createImplicitInitialValue(); |
4364 return true; | 4364 return true; |
4365 } | 4365 } |
4366 | 4366 |
4367 bool CSSParser::parseCubicBezierTimingFunctionValue(CSSParserValueList*& args, d
ouble& result) | 4367 bool BisonCSSParser::parseCubicBezierTimingFunctionValue(CSSParserValueList*& ar
gs, double& result) |
4368 { | 4368 { |
4369 CSSParserValue* v = args->current(); | 4369 CSSParserValue* v = args->current(); |
4370 if (!validUnit(v, FNumber)) | 4370 if (!validUnit(v, FNumber)) |
4371 return false; | 4371 return false; |
4372 result = v->fValue; | 4372 result = v->fValue; |
4373 v = args->next(); | 4373 v = args->next(); |
4374 if (!v) | 4374 if (!v) |
4375 // The last number in the function has no comma after it, so we're done. | 4375 // The last number in the function has no comma after it, so we're done. |
4376 return true; | 4376 return true; |
4377 if (!isComma(v)) | 4377 if (!isComma(v)) |
4378 return false; | 4378 return false; |
4379 args->next(); | 4379 args->next(); |
4380 return true; | 4380 return true; |
4381 } | 4381 } |
4382 | 4382 |
4383 PassRefPtr<CSSValue> CSSParser::parseAnimationTimingFunction() | 4383 PassRefPtr<CSSValue> BisonCSSParser::parseAnimationTimingFunction() |
4384 { | 4384 { |
4385 CSSParserValue* value = m_valueList->current(); | 4385 CSSParserValue* value = m_valueList->current(); |
4386 if (value->id == CSSValueEase || value->id == CSSValueLinear || value->id ==
CSSValueEaseIn || value->id == CSSValueEaseOut | 4386 if (value->id == CSSValueEase || value->id == CSSValueLinear || value->id ==
CSSValueEaseIn || value->id == CSSValueEaseOut |
4387 || value->id == CSSValueEaseInOut || value->id == CSSValueStepStart || v
alue->id == CSSValueStepEnd) | 4387 || value->id == CSSValueEaseInOut || value->id == CSSValueStepStart || v
alue->id == CSSValueStepEnd) |
4388 return cssValuePool().createIdentifierValue(value->id); | 4388 return cssValuePool().createIdentifierValue(value->id); |
4389 | 4389 |
4390 // We must be a function. | 4390 // We must be a function. |
4391 if (value->unit != CSSParserValue::Function) | 4391 if (value->unit != CSSParserValue::Function) |
4392 return 0; | 4392 return 0; |
4393 | 4393 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4443 return 0; | 4443 return 0; |
4444 if (!parseCubicBezierTimingFunctionValue(args, y2)) | 4444 if (!parseCubicBezierTimingFunctionValue(args, y2)) |
4445 return 0; | 4445 return 0; |
4446 | 4446 |
4447 return CSSCubicBezierTimingFunctionValue::create(x1, y1, x2, y2); | 4447 return CSSCubicBezierTimingFunctionValue::create(x1, y1, x2, y2); |
4448 } | 4448 } |
4449 | 4449 |
4450 return 0; | 4450 return 0; |
4451 } | 4451 } |
4452 | 4452 |
4453 bool CSSParser::parseAnimationProperty(CSSPropertyID propId, RefPtr<CSSValue>& r
esult, AnimationParseContext& context) | 4453 bool BisonCSSParser::parseAnimationProperty(CSSPropertyID propId, RefPtr<CSSValu
e>& result, AnimationParseContext& context) |
4454 { | 4454 { |
4455 RefPtr<CSSValueList> values; | 4455 RefPtr<CSSValueList> values; |
4456 CSSParserValue* val; | 4456 CSSParserValue* val; |
4457 RefPtr<CSSValue> value; | 4457 RefPtr<CSSValue> value; |
4458 bool allowComma = false; | 4458 bool allowComma = false; |
4459 | 4459 |
4460 result = 0; | 4460 result = 0; |
4461 | 4461 |
4462 while ((val = m_valueList->current())) { | 4462 while ((val = m_valueList->current())) { |
4463 RefPtr<CSSValue> currValue; | 4463 RefPtr<CSSValue> currValue; |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4563 return true; | 4563 return true; |
4564 } | 4564 } |
4565 if (value) { | 4565 if (value) { |
4566 result = value.release(); | 4566 result = value.release(); |
4567 return true; | 4567 return true; |
4568 } | 4568 } |
4569 return false; | 4569 return false; |
4570 } | 4570 } |
4571 | 4571 |
4572 // The function parses [ <integer> || <string> ] in <grid-line> (which can be st
and alone or with 'span'). | 4572 // The function parses [ <integer> || <string> ] in <grid-line> (which can be st
and alone or with 'span'). |
4573 bool CSSParser::parseIntegerOrStringFromGridPosition(RefPtr<CSSPrimitiveValue>&
numericValue, RefPtr<CSSPrimitiveValue>& gridLineName) | 4573 bool BisonCSSParser::parseIntegerOrStringFromGridPosition(RefPtr<CSSPrimitiveVal
ue>& numericValue, RefPtr<CSSPrimitiveValue>& gridLineName) |
4574 { | 4574 { |
4575 CSSParserValue* value = m_valueList->current(); | 4575 CSSParserValue* value = m_valueList->current(); |
4576 if (validUnit(value, FInteger) && value->fValue) { | 4576 if (validUnit(value, FInteger) && value->fValue) { |
4577 numericValue = createPrimitiveNumericValue(value); | 4577 numericValue = createPrimitiveNumericValue(value); |
4578 value = m_valueList->next(); | 4578 value = m_valueList->next(); |
4579 if (value && value->unit == CSSPrimitiveValue::CSS_STRING) { | 4579 if (value && value->unit == CSSPrimitiveValue::CSS_STRING) { |
4580 gridLineName = createPrimitiveStringValue(m_valueList->current()); | 4580 gridLineName = createPrimitiveStringValue(m_valueList->current()); |
4581 m_valueList->next(); | 4581 m_valueList->next(); |
4582 } | 4582 } |
4583 return true; | 4583 return true; |
4584 } | 4584 } |
4585 | 4585 |
4586 if (value->unit == CSSPrimitiveValue::CSS_STRING) { | 4586 if (value->unit == CSSPrimitiveValue::CSS_STRING) { |
4587 gridLineName = createPrimitiveStringValue(m_valueList->current()); | 4587 gridLineName = createPrimitiveStringValue(m_valueList->current()); |
4588 value = m_valueList->next(); | 4588 value = m_valueList->next(); |
4589 if (value && validUnit(value, FInteger) && value->fValue) { | 4589 if (value && validUnit(value, FInteger) && value->fValue) { |
4590 numericValue = createPrimitiveNumericValue(value); | 4590 numericValue = createPrimitiveNumericValue(value); |
4591 m_valueList->next(); | 4591 m_valueList->next(); |
4592 } | 4592 } |
4593 return true; | 4593 return true; |
4594 } | 4594 } |
4595 | 4595 |
4596 return false; | 4596 return false; |
4597 } | 4597 } |
4598 | 4598 |
4599 PassRefPtr<CSSValue> CSSParser::parseGridPosition() | 4599 PassRefPtr<CSSValue> BisonCSSParser::parseGridPosition() |
4600 { | 4600 { |
4601 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); | 4601 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); |
4602 | 4602 |
4603 CSSParserValue* value = m_valueList->current(); | 4603 CSSParserValue* value = m_valueList->current(); |
4604 if (value->id == CSSValueAuto) { | 4604 if (value->id == CSSValueAuto) { |
4605 m_valueList->next(); | 4605 m_valueList->next(); |
4606 return cssValuePool().createIdentifierValue(CSSValueAuto); | 4606 return cssValuePool().createIdentifierValue(CSSValueAuto); |
4607 } | 4607 } |
4608 | 4608 |
4609 if (value->id != CSSValueSpan && value->unit == CSSPrimitiveValue::CSS_IDENT
) { | 4609 if (value->id != CSSValueSpan && value->unit == CSSPrimitiveValue::CSS_IDENT
) { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4652 } | 4652 } |
4653 | 4653 |
4654 static PassRefPtr<CSSValue> gridMissingGridPositionValue(CSSValue* value) | 4654 static PassRefPtr<CSSValue> gridMissingGridPositionValue(CSSValue* value) |
4655 { | 4655 { |
4656 if (value->isPrimitiveValue() && toCSSPrimitiveValue(value)->isString()) | 4656 if (value->isPrimitiveValue() && toCSSPrimitiveValue(value)->isString()) |
4657 return value; | 4657 return value; |
4658 | 4658 |
4659 return cssValuePool().createIdentifierValue(CSSValueAuto); | 4659 return cssValuePool().createIdentifierValue(CSSValueAuto); |
4660 } | 4660 } |
4661 | 4661 |
4662 bool CSSParser::parseGridItemPositionShorthand(CSSPropertyID shorthandId, bool i
mportant) | 4662 bool BisonCSSParser::parseGridItemPositionShorthand(CSSPropertyID shorthandId, b
ool important) |
4663 { | 4663 { |
4664 ShorthandScope scope(this, shorthandId); | 4664 ShorthandScope scope(this, shorthandId); |
4665 const StylePropertyShorthand& shorthand = shorthandForProperty(shorthandId); | 4665 const StylePropertyShorthand& shorthand = shorthandForProperty(shorthandId); |
4666 ASSERT(shorthand.length() == 2); | 4666 ASSERT(shorthand.length() == 2); |
4667 | 4667 |
4668 RefPtr<CSSValue> startValue = parseGridPosition(); | 4668 RefPtr<CSSValue> startValue = parseGridPosition(); |
4669 if (!startValue) | 4669 if (!startValue) |
4670 return false; | 4670 return false; |
4671 | 4671 |
4672 RefPtr<CSSValue> endValue; | 4672 RefPtr<CSSValue> endValue; |
4673 if (m_valueList->current()) { | 4673 if (m_valueList->current()) { |
4674 if (!isForwardSlashOperator(m_valueList->current())) | 4674 if (!isForwardSlashOperator(m_valueList->current())) |
4675 return false; | 4675 return false; |
4676 | 4676 |
4677 if (!m_valueList->next()) | 4677 if (!m_valueList->next()) |
4678 return false; | 4678 return false; |
4679 | 4679 |
4680 endValue = parseGridPosition(); | 4680 endValue = parseGridPosition(); |
4681 if (!endValue || m_valueList->current()) | 4681 if (!endValue || m_valueList->current()) |
4682 return false; | 4682 return false; |
4683 } else { | 4683 } else { |
4684 endValue = gridMissingGridPositionValue(startValue.get()); | 4684 endValue = gridMissingGridPositionValue(startValue.get()); |
4685 } | 4685 } |
4686 | 4686 |
4687 addProperty(shorthand.properties()[0], startValue, important); | 4687 addProperty(shorthand.properties()[0], startValue, important); |
4688 addProperty(shorthand.properties()[1], endValue, important); | 4688 addProperty(shorthand.properties()[1], endValue, important); |
4689 return true; | 4689 return true; |
4690 } | 4690 } |
4691 | 4691 |
4692 bool CSSParser::parseGridAreaShorthand(bool important) | 4692 bool BisonCSSParser::parseGridAreaShorthand(bool important) |
4693 { | 4693 { |
4694 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); | 4694 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); |
4695 | 4695 |
4696 ShorthandScope scope(this, CSSPropertyGridArea); | 4696 ShorthandScope scope(this, CSSPropertyGridArea); |
4697 const StylePropertyShorthand& shorthand = gridAreaShorthand(); | 4697 const StylePropertyShorthand& shorthand = gridAreaShorthand(); |
4698 ASSERT_UNUSED(shorthand, shorthand.length() == 4); | 4698 ASSERT_UNUSED(shorthand, shorthand.length() == 4); |
4699 | 4699 |
4700 RefPtr<CSSValue> rowStartValue = parseGridPosition(); | 4700 RefPtr<CSSValue> rowStartValue = parseGridPosition(); |
4701 if (!rowStartValue) | 4701 if (!rowStartValue) |
4702 return false; | 4702 return false; |
(...skipping 19 matching lines...) Expand all Loading... |
4722 if (!columnEndValue) | 4722 if (!columnEndValue) |
4723 columnEndValue = gridMissingGridPositionValue(columnStartValue.get()); | 4723 columnEndValue = gridMissingGridPositionValue(columnStartValue.get()); |
4724 | 4724 |
4725 addProperty(CSSPropertyGridRowStart, rowStartValue, important); | 4725 addProperty(CSSPropertyGridRowStart, rowStartValue, important); |
4726 addProperty(CSSPropertyGridColumnStart, columnStartValue, important); | 4726 addProperty(CSSPropertyGridColumnStart, columnStartValue, important); |
4727 addProperty(CSSPropertyGridRowEnd, rowEndValue, important); | 4727 addProperty(CSSPropertyGridRowEnd, rowEndValue, important); |
4728 addProperty(CSSPropertyGridColumnEnd, columnEndValue, important); | 4728 addProperty(CSSPropertyGridColumnEnd, columnEndValue, important); |
4729 return true; | 4729 return true; |
4730 } | 4730 } |
4731 | 4731 |
4732 bool CSSParser::parseSingleGridAreaLonghand(RefPtr<CSSValue>& property) | 4732 bool BisonCSSParser::parseSingleGridAreaLonghand(RefPtr<CSSValue>& property) |
4733 { | 4733 { |
4734 if (!m_valueList->current()) | 4734 if (!m_valueList->current()) |
4735 return true; | 4735 return true; |
4736 | 4736 |
4737 if (!isForwardSlashOperator(m_valueList->current())) | 4737 if (!isForwardSlashOperator(m_valueList->current())) |
4738 return false; | 4738 return false; |
4739 | 4739 |
4740 if (!m_valueList->next()) | 4740 if (!m_valueList->next()) |
4741 return false; | 4741 return false; |
4742 | 4742 |
4743 property = parseGridPosition(); | 4743 property = parseGridPosition(); |
4744 return true; | 4744 return true; |
4745 } | 4745 } |
4746 | 4746 |
4747 void CSSParser::parseGridLineNames(CSSParserValueList* parserValueList, CSSValue
List& valueList) | 4747 void BisonCSSParser::parseGridLineNames(CSSParserValueList* parserValueList, CSS
ValueList& valueList) |
4748 { | 4748 { |
4749 ASSERT(parserValueList->current() && parserValueList->current()->unit == CSS
ParserValue::ValueList); | 4749 ASSERT(parserValueList->current() && parserValueList->current()->unit == CSS
ParserValue::ValueList); |
4750 | 4750 |
4751 CSSParserValueList* identList = parserValueList->current()->valueList; | 4751 CSSParserValueList* identList = parserValueList->current()->valueList; |
4752 if (!identList->size()) { | 4752 if (!identList->size()) { |
4753 parserValueList->next(); | 4753 parserValueList->next(); |
4754 return; | 4754 return; |
4755 } | 4755 } |
4756 | 4756 |
4757 RefPtr<CSSGridLineNamesValue> lineNames = CSSGridLineNamesValue::create(); | 4757 RefPtr<CSSGridLineNamesValue> lineNames = CSSGridLineNamesValue::create(); |
4758 while (CSSParserValue* identValue = identList->current()) { | 4758 while (CSSParserValue* identValue = identList->current()) { |
4759 ASSERT(identValue->unit == CSSPrimitiveValue::CSS_IDENT); | 4759 ASSERT(identValue->unit == CSSPrimitiveValue::CSS_IDENT); |
4760 RefPtr<CSSPrimitiveValue> lineName = createPrimitiveStringValue(identVal
ue); | 4760 RefPtr<CSSPrimitiveValue> lineName = createPrimitiveStringValue(identVal
ue); |
4761 lineNames->append(lineName.release()); | 4761 lineNames->append(lineName.release()); |
4762 identList->next(); | 4762 identList->next(); |
4763 } | 4763 } |
4764 valueList.append(lineNames.release()); | 4764 valueList.append(lineNames.release()); |
4765 | 4765 |
4766 parserValueList->next(); | 4766 parserValueList->next(); |
4767 } | 4767 } |
4768 | 4768 |
4769 bool CSSParser::parseGridTrackList(CSSPropertyID propId, bool important) | 4769 bool BisonCSSParser::parseGridTrackList(CSSPropertyID propId, bool important) |
4770 { | 4770 { |
4771 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); | 4771 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); |
4772 | 4772 |
4773 CSSParserValue* value = m_valueList->current(); | 4773 CSSParserValue* value = m_valueList->current(); |
4774 if (value->id == CSSValueNone) { | 4774 if (value->id == CSSValueNone) { |
4775 if (m_valueList->next()) | 4775 if (m_valueList->next()) |
4776 return false; | 4776 return false; |
4777 | 4777 |
4778 addProperty(propId, cssValuePool().createIdentifierValue(value->id), imp
ortant); | 4778 addProperty(propId, cssValuePool().createIdentifierValue(value->id), imp
ortant); |
4779 return true; | 4779 return true; |
(...skipping 25 matching lines...) Expand all Loading... |
4805 } | 4805 } |
4806 | 4806 |
4807 // We should have found a <track-size> or else it is not a valid <track-list
> | 4807 // We should have found a <track-size> or else it is not a valid <track-list
> |
4808 if (!seenTrackSizeOrRepeatFunction) | 4808 if (!seenTrackSizeOrRepeatFunction) |
4809 return false; | 4809 return false; |
4810 | 4810 |
4811 addProperty(propId, values.release(), important); | 4811 addProperty(propId, values.release(), important); |
4812 return true; | 4812 return true; |
4813 } | 4813 } |
4814 | 4814 |
4815 bool CSSParser::parseGridTrackRepeatFunction(CSSValueList& list) | 4815 bool BisonCSSParser::parseGridTrackRepeatFunction(CSSValueList& list) |
4816 { | 4816 { |
4817 CSSParserValueList* arguments = m_valueList->current()->function->args.get()
; | 4817 CSSParserValueList* arguments = m_valueList->current()->function->args.get()
; |
4818 if (!arguments || arguments->size() < 3 || !validUnit(arguments->valueAt(0),
FPositiveInteger) || !isComma(arguments->valueAt(1))) | 4818 if (!arguments || arguments->size() < 3 || !validUnit(arguments->valueAt(0),
FPositiveInteger) || !isComma(arguments->valueAt(1))) |
4819 return false; | 4819 return false; |
4820 | 4820 |
4821 ASSERT_WITH_SECURITY_IMPLICATION(arguments->valueAt(0)->fValue > 0); | 4821 ASSERT_WITH_SECURITY_IMPLICATION(arguments->valueAt(0)->fValue > 0); |
4822 size_t repetitions = arguments->valueAt(0)->fValue; | 4822 size_t repetitions = arguments->valueAt(0)->fValue; |
4823 RefPtr<CSSValueList> repeatedValues = CSSValueList::createSpaceSeparated(); | 4823 RefPtr<CSSValueList> repeatedValues = CSSValueList::createSpaceSeparated(); |
4824 arguments->next(); // Skip the repetition count. | 4824 arguments->next(); // Skip the repetition count. |
4825 arguments->next(); // Skip the comma. | 4825 arguments->next(); // Skip the comma. |
(...skipping 19 matching lines...) Expand all Loading... |
4845 for (size_t i = 0; i < repetitions; ++i) { | 4845 for (size_t i = 0; i < repetitions; ++i) { |
4846 for (size_t j = 0; j < repeatedValues->length(); ++j) | 4846 for (size_t j = 0; j < repeatedValues->length(); ++j) |
4847 list.append(repeatedValues->itemWithoutBoundsCheck(j)); | 4847 list.append(repeatedValues->itemWithoutBoundsCheck(j)); |
4848 } | 4848 } |
4849 | 4849 |
4850 // parseGridTrackSize iterated over the repeat arguments, move to the next v
alue. | 4850 // parseGridTrackSize iterated over the repeat arguments, move to the next v
alue. |
4851 m_valueList->next(); | 4851 m_valueList->next(); |
4852 return true; | 4852 return true; |
4853 } | 4853 } |
4854 | 4854 |
4855 PassRefPtr<CSSValue> CSSParser::parseGridTrackSize(CSSParserValueList& inputList
) | 4855 PassRefPtr<CSSValue> BisonCSSParser::parseGridTrackSize(CSSParserValueList& inpu
tList) |
4856 { | 4856 { |
4857 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); | 4857 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); |
4858 | 4858 |
4859 CSSParserValue* currentValue = inputList.current(); | 4859 CSSParserValue* currentValue = inputList.current(); |
4860 inputList.next(); | 4860 inputList.next(); |
4861 | 4861 |
4862 if (currentValue->id == CSSValueAuto) | 4862 if (currentValue->id == CSSValueAuto) |
4863 return cssValuePool().createIdentifierValue(CSSValueAuto); | 4863 return cssValuePool().createIdentifierValue(CSSValueAuto); |
4864 | 4864 |
4865 if (currentValue->unit == CSSParserValue::Function && equalIgnoringCase(curr
entValue->function->name, "minmax(")) { | 4865 if (currentValue->unit == CSSParserValue::Function && equalIgnoringCase(curr
entValue->function->name, "minmax(")) { |
(...skipping 12 matching lines...) Expand all Loading... |
4878 | 4878 |
4879 RefPtr<CSSValueList> parsedArguments = CSSValueList::createCommaSeparate
d(); | 4879 RefPtr<CSSValueList> parsedArguments = CSSValueList::createCommaSeparate
d(); |
4880 parsedArguments->append(minTrackBreadth); | 4880 parsedArguments->append(minTrackBreadth); |
4881 parsedArguments->append(maxTrackBreadth); | 4881 parsedArguments->append(maxTrackBreadth); |
4882 return CSSFunctionValue::create("minmax(", parsedArguments); | 4882 return CSSFunctionValue::create("minmax(", parsedArguments); |
4883 } | 4883 } |
4884 | 4884 |
4885 return parseGridBreadth(currentValue); | 4885 return parseGridBreadth(currentValue); |
4886 } | 4886 } |
4887 | 4887 |
4888 PassRefPtr<CSSPrimitiveValue> CSSParser::parseGridBreadth(CSSParserValue* curren
tValue) | 4888 PassRefPtr<CSSPrimitiveValue> BisonCSSParser::parseGridBreadth(CSSParserValue* c
urrentValue) |
4889 { | 4889 { |
4890 if (currentValue->id == CSSValueMinContent || currentValue->id == CSSValueMa
xContent) | 4890 if (currentValue->id == CSSValueMinContent || currentValue->id == CSSValueMa
xContent) |
4891 return cssValuePool().createIdentifierValue(currentValue->id); | 4891 return cssValuePool().createIdentifierValue(currentValue->id); |
4892 | 4892 |
4893 if (currentValue->unit == CSSPrimitiveValue::CSS_FR) { | 4893 if (currentValue->unit == CSSPrimitiveValue::CSS_FR) { |
4894 double flexValue = currentValue->fValue; | 4894 double flexValue = currentValue->fValue; |
4895 | 4895 |
4896 // Fractional unit is a non-negative dimension. | 4896 // Fractional unit is a non-negative dimension. |
4897 if (flexValue <= 0) | 4897 if (flexValue <= 0) |
4898 return 0; | 4898 return 0; |
4899 | 4899 |
4900 return cssValuePool().createValue(flexValue, CSSPrimitiveValue::CSS_FR); | 4900 return cssValuePool().createValue(flexValue, CSSPrimitiveValue::CSS_FR); |
4901 } | 4901 } |
4902 | 4902 |
4903 if (!validUnit(currentValue, FNonNeg | FLength | FPercent)) | 4903 if (!validUnit(currentValue, FNonNeg | FLength | FPercent)) |
4904 return 0; | 4904 return 0; |
4905 | 4905 |
4906 return createPrimitiveNumericValue(currentValue); | 4906 return createPrimitiveNumericValue(currentValue); |
4907 } | 4907 } |
4908 | 4908 |
4909 PassRefPtr<CSSValue> CSSParser::parseGridTemplate() | 4909 PassRefPtr<CSSValue> BisonCSSParser::parseGridTemplate() |
4910 { | 4910 { |
4911 NamedGridAreaMap gridAreaMap; | 4911 NamedGridAreaMap gridAreaMap; |
4912 size_t rowCount = 0; | 4912 size_t rowCount = 0; |
4913 size_t columnCount = 0; | 4913 size_t columnCount = 0; |
4914 | 4914 |
4915 while (CSSParserValue* currentValue = m_valueList->current()) { | 4915 while (CSSParserValue* currentValue = m_valueList->current()) { |
4916 if (currentValue->unit != CSSPrimitiveValue::CSS_STRING) | 4916 if (currentValue->unit != CSSPrimitiveValue::CSS_STRING) |
4917 return 0; | 4917 return 0; |
4918 | 4918 |
4919 String gridRowNames = currentValue->string; | 4919 String gridRowNames = currentValue->string; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4972 ++rowCount; | 4972 ++rowCount; |
4973 m_valueList->next(); | 4973 m_valueList->next(); |
4974 } | 4974 } |
4975 | 4975 |
4976 if (!rowCount || !columnCount) | 4976 if (!rowCount || !columnCount) |
4977 return 0; | 4977 return 0; |
4978 | 4978 |
4979 return CSSGridTemplateValue::create(gridAreaMap, rowCount, columnCount); | 4979 return CSSGridTemplateValue::create(gridAreaMap, rowCount, columnCount); |
4980 } | 4980 } |
4981 | 4981 |
4982 PassRefPtr<CSSValue> CSSParser::parseCounterContent(CSSParserValueList* args, bo
ol counters) | 4982 PassRefPtr<CSSValue> BisonCSSParser::parseCounterContent(CSSParserValueList* arg
s, bool counters) |
4983 { | 4983 { |
4984 unsigned numArgs = args->size(); | 4984 unsigned numArgs = args->size(); |
4985 if (counters && numArgs != 3 && numArgs != 5) | 4985 if (counters && numArgs != 3 && numArgs != 5) |
4986 return 0; | 4986 return 0; |
4987 if (!counters && numArgs != 1 && numArgs != 3) | 4987 if (!counters && numArgs != 1 && numArgs != 3) |
4988 return 0; | 4988 return 0; |
4989 | 4989 |
4990 CSSParserValue* i = args->current(); | 4990 CSSParserValue* i = args->current(); |
4991 if (i->unit != CSSPrimitiveValue::CSS_IDENT) | 4991 if (i->unit != CSSPrimitiveValue::CSS_IDENT) |
4992 return 0; | 4992 return 0; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5024 listStyleID = i->id; | 5024 listStyleID = i->id; |
5025 else | 5025 else |
5026 return 0; | 5026 return 0; |
5027 | 5027 |
5028 listStyle = cssValuePool().createIdentifierValue(listStyleID); | 5028 listStyle = cssValuePool().createIdentifierValue(listStyleID); |
5029 } | 5029 } |
5030 | 5030 |
5031 return cssValuePool().createValue(Counter::create(identifier.release(), list
Style.release(), separator.release())); | 5031 return cssValuePool().createValue(Counter::create(identifier.release(), list
Style.release(), separator.release())); |
5032 } | 5032 } |
5033 | 5033 |
5034 bool CSSParser::parseClipShape(CSSPropertyID propId, bool important) | 5034 bool BisonCSSParser::parseClipShape(CSSPropertyID propId, bool important) |
5035 { | 5035 { |
5036 CSSParserValue* value = m_valueList->current(); | 5036 CSSParserValue* value = m_valueList->current(); |
5037 CSSParserValueList* args = value->function->args.get(); | 5037 CSSParserValueList* args = value->function->args.get(); |
5038 | 5038 |
5039 if (!equalIgnoringCase(value->function->name, "rect(") || !args) | 5039 if (!equalIgnoringCase(value->function->name, "rect(") || !args) |
5040 return false; | 5040 return false; |
5041 | 5041 |
5042 // rect(t, r, b, l) || rect(t r b l) | 5042 // rect(t, r, b, l) || rect(t r b l) |
5043 if (args->size() != 4 && args->size() != 7) | 5043 if (args->size() != 4 && args->size() != 7) |
5044 return false; | 5044 return false; |
(...skipping 28 matching lines...) Expand all Loading... |
5073 i++; | 5073 i++; |
5074 } | 5074 } |
5075 if (valid) { | 5075 if (valid) { |
5076 addProperty(propId, cssValuePool().createValue(rect.release()), importan
t); | 5076 addProperty(propId, cssValuePool().createValue(rect.release()), importan
t); |
5077 m_valueList->next(); | 5077 m_valueList->next(); |
5078 return true; | 5078 return true; |
5079 } | 5079 } |
5080 return false; | 5080 return false; |
5081 } | 5081 } |
5082 | 5082 |
5083 PassRefPtr<CSSBasicShape> CSSParser::parseBasicShapeRectangle(CSSParserValueList
* args) | 5083 PassRefPtr<CSSBasicShape> BisonCSSParser::parseBasicShapeRectangle(CSSParserValu
eList* args) |
5084 { | 5084 { |
5085 ASSERT(args); | 5085 ASSERT(args); |
5086 | 5086 |
5087 // rect(x, y, width, height, [[rx], ry]) | 5087 // rect(x, y, width, height, [[rx], ry]) |
5088 if (args->size() != 7 && args->size() != 9 && args->size() != 11) | 5088 if (args->size() != 7 && args->size() != 9 && args->size() != 11) |
5089 return 0; | 5089 return 0; |
5090 | 5090 |
5091 RefPtr<CSSBasicShapeRectangle> shape = CSSBasicShapeRectangle::create(); | 5091 RefPtr<CSSBasicShapeRectangle> shape = CSSBasicShapeRectangle::create(); |
5092 | 5092 |
5093 unsigned argumentNumber = 0; | 5093 unsigned argumentNumber = 0; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5131 argument = args->next(); | 5131 argument = args->next(); |
5132 } | 5132 } |
5133 argumentNumber++; | 5133 argumentNumber++; |
5134 } | 5134 } |
5135 | 5135 |
5136 if (argumentNumber < 4) | 5136 if (argumentNumber < 4) |
5137 return 0; | 5137 return 0; |
5138 return shape; | 5138 return shape; |
5139 } | 5139 } |
5140 | 5140 |
5141 PassRefPtr<CSSBasicShape> CSSParser::parseBasicShapeInsetRectangle(CSSParserValu
eList* args) | 5141 PassRefPtr<CSSBasicShape> BisonCSSParser::parseBasicShapeInsetRectangle(CSSParse
rValueList* args) |
5142 { | 5142 { |
5143 ASSERT(args); | 5143 ASSERT(args); |
5144 | 5144 |
5145 // inset-rectangle(top, right, bottom, left, [[rx], ry]) | 5145 // inset-rectangle(top, right, bottom, left, [[rx], ry]) |
5146 if (args->size() != 7 && args->size() != 9 && args->size() != 11) | 5146 if (args->size() != 7 && args->size() != 9 && args->size() != 11) |
5147 return 0; | 5147 return 0; |
5148 | 5148 |
5149 RefPtr<CSSBasicShapeInsetRectangle> shape = CSSBasicShapeInsetRectangle::cre
ate(); | 5149 RefPtr<CSSBasicShapeInsetRectangle> shape = CSSBasicShapeInsetRectangle::cre
ate(); |
5150 | 5150 |
5151 unsigned argumentNumber = 0; | 5151 unsigned argumentNumber = 0; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5185 argument = args->next(); | 5185 argument = args->next(); |
5186 } | 5186 } |
5187 argumentNumber++; | 5187 argumentNumber++; |
5188 } | 5188 } |
5189 | 5189 |
5190 if (argumentNumber < 4) | 5190 if (argumentNumber < 4) |
5191 return 0; | 5191 return 0; |
5192 return shape; | 5192 return shape; |
5193 } | 5193 } |
5194 | 5194 |
5195 PassRefPtr<CSSPrimitiveValue> CSSParser::parseShapeRadius(CSSParserValue* value) | 5195 PassRefPtr<CSSPrimitiveValue> BisonCSSParser::parseShapeRadius(CSSParserValue* v
alue) |
5196 { | 5196 { |
5197 if (value->id == CSSValueClosestSide || value->id == CSSValueFarthestSide) | 5197 if (value->id == CSSValueClosestSide || value->id == CSSValueFarthestSide) |
5198 return cssValuePool().createIdentifierValue(value->id); | 5198 return cssValuePool().createIdentifierValue(value->id); |
5199 | 5199 |
5200 if (!validUnit(value, FLength | FPercent | FNonNeg)) | 5200 if (!validUnit(value, FLength | FPercent | FNonNeg)) |
5201 return 0; | 5201 return 0; |
5202 | 5202 |
5203 return createPrimitiveNumericValue(value); | 5203 return createPrimitiveNumericValue(value); |
5204 } | 5204 } |
5205 | 5205 |
5206 PassRefPtr<CSSBasicShape> CSSParser::parseBasicShapeCircle(CSSParserValueList* a
rgs) | 5206 PassRefPtr<CSSBasicShape> BisonCSSParser::parseBasicShapeCircle(CSSParserValueLi
st* args) |
5207 { | 5207 { |
5208 ASSERT(args); | 5208 ASSERT(args); |
5209 | 5209 |
5210 // circle(radius) | 5210 // circle(radius) |
5211 // circle(radius at <position> | 5211 // circle(radius at <position> |
5212 // circle(at <position>) | 5212 // circle(at <position>) |
5213 // where position defines centerX and centerY using a CSS <position> data ty
pe. | 5213 // where position defines centerX and centerY using a CSS <position> data ty
pe. |
5214 RefPtr<CSSBasicShapeCircle> shape = CSSBasicShapeCircle::create(); | 5214 RefPtr<CSSBasicShapeCircle> shape = CSSBasicShapeCircle::create(); |
5215 | 5215 |
5216 for (CSSParserValue* argument = args->current(); argument; argument = args->
next()) { | 5216 for (CSSParserValue* argument = args->current(); argument; argument = args->
next()) { |
(...skipping 26 matching lines...) Expand all Loading... |
5243 return 0; | 5243 return 0; |
5244 } | 5244 } |
5245 } else { | 5245 } else { |
5246 return 0; | 5246 return 0; |
5247 } | 5247 } |
5248 } | 5248 } |
5249 | 5249 |
5250 return shape; | 5250 return shape; |
5251 } | 5251 } |
5252 | 5252 |
5253 PassRefPtr<CSSBasicShape> CSSParser::parseDeprecatedBasicShapeCircle(CSSParserVa
lueList* args) | 5253 PassRefPtr<CSSBasicShape> BisonCSSParser::parseDeprecatedBasicShapeCircle(CSSPar
serValueList* args) |
5254 { | 5254 { |
5255 ASSERT(args); | 5255 ASSERT(args); |
5256 | 5256 |
5257 // circle(centerX, centerY, radius) | 5257 // circle(centerX, centerY, radius) |
5258 if (args->size() != 5) | 5258 if (args->size() != 5) |
5259 return 0; | 5259 return 0; |
5260 | 5260 |
5261 RefPtr<CSSDeprecatedBasicShapeCircle> shape = CSSDeprecatedBasicShapeCircle:
:create(); | 5261 RefPtr<CSSDeprecatedBasicShapeCircle> shape = CSSDeprecatedBasicShapeCircle:
:create(); |
5262 | 5262 |
5263 unsigned argumentNumber = 0; | 5263 unsigned argumentNumber = 0; |
(...skipping 29 matching lines...) Expand all Loading... |
5293 argument = args->next(); | 5293 argument = args->next(); |
5294 } | 5294 } |
5295 argumentNumber++; | 5295 argumentNumber++; |
5296 } | 5296 } |
5297 | 5297 |
5298 if (argumentNumber < 3) | 5298 if (argumentNumber < 3) |
5299 return 0; | 5299 return 0; |
5300 return shape; | 5300 return shape; |
5301 } | 5301 } |
5302 | 5302 |
5303 PassRefPtr<CSSBasicShape> CSSParser::parseBasicShapeEllipse(CSSParserValueList*
args) | 5303 PassRefPtr<CSSBasicShape> BisonCSSParser::parseBasicShapeEllipse(CSSParserValueL
ist* args) |
5304 { | 5304 { |
5305 ASSERT(args); | 5305 ASSERT(args); |
5306 | 5306 |
5307 // ellipse(centerX, centerY, radiusX, radiusY) | 5307 // ellipse(centerX, centerY, radiusX, radiusY) |
5308 if (args->size() != 7) | 5308 if (args->size() != 7) |
5309 return 0; | 5309 return 0; |
5310 | 5310 |
5311 RefPtr<CSSBasicShapeEllipse> shape = CSSBasicShapeEllipse::create(); | 5311 RefPtr<CSSBasicShapeEllipse> shape = CSSBasicShapeEllipse::create(); |
5312 unsigned argumentNumber = 0; | 5312 unsigned argumentNumber = 0; |
5313 CSSParserValue* argument = args->current(); | 5313 CSSParserValue* argument = args->current(); |
(...skipping 30 matching lines...) Expand all Loading... |
5344 argument = args->next(); | 5344 argument = args->next(); |
5345 } | 5345 } |
5346 argumentNumber++; | 5346 argumentNumber++; |
5347 } | 5347 } |
5348 | 5348 |
5349 if (argumentNumber < 4) | 5349 if (argumentNumber < 4) |
5350 return 0; | 5350 return 0; |
5351 return shape; | 5351 return shape; |
5352 } | 5352 } |
5353 | 5353 |
5354 PassRefPtr<CSSBasicShape> CSSParser::parseBasicShapePolygon(CSSParserValueList*
args) | 5354 PassRefPtr<CSSBasicShape> BisonCSSParser::parseBasicShapePolygon(CSSParserValueL
ist* args) |
5355 { | 5355 { |
5356 ASSERT(args); | 5356 ASSERT(args); |
5357 | 5357 |
5358 unsigned size = args->size(); | 5358 unsigned size = args->size(); |
5359 if (!size) | 5359 if (!size) |
5360 return 0; | 5360 return 0; |
5361 | 5361 |
5362 RefPtr<CSSBasicShapePolygon> shape = CSSBasicShapePolygon::create(); | 5362 RefPtr<CSSBasicShapePolygon> shape = CSSBasicShapePolygon::create(); |
5363 | 5363 |
5364 CSSParserValue* argument = args->current(); | 5364 CSSParserValue* argument = args->current(); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5424 { | 5424 { |
5425 for (unsigned i = args->currentIndex(); i < args->size(); ++i) { | 5425 for (unsigned i = args->currentIndex(); i < args->size(); ++i) { |
5426 CSSParserValue* value = args->valueAt(i); | 5426 CSSParserValue* value = args->valueAt(i); |
5427 if (isComma(value)) | 5427 if (isComma(value)) |
5428 return true; | 5428 return true; |
5429 } | 5429 } |
5430 | 5430 |
5431 return false; | 5431 return false; |
5432 } | 5432 } |
5433 | 5433 |
5434 PassRefPtr<CSSValue> CSSParser::parseShapeProperty(CSSPropertyID propId) | 5434 PassRefPtr<CSSValue> BisonCSSParser::parseShapeProperty(CSSPropertyID propId) |
5435 { | 5435 { |
5436 if (!RuntimeEnabledFeatures::cssShapesEnabled()) | 5436 if (!RuntimeEnabledFeatures::cssShapesEnabled()) |
5437 return 0; | 5437 return 0; |
5438 | 5438 |
5439 CSSParserValue* value = m_valueList->current(); | 5439 CSSParserValue* value = m_valueList->current(); |
5440 CSSValueID valueId = value->id; | 5440 CSSValueID valueId = value->id; |
5441 RefPtr<CSSPrimitiveValue> boxValue; | 5441 RefPtr<CSSPrimitiveValue> boxValue; |
5442 RefPtr<CSSPrimitiveValue> shapeValue; | 5442 RefPtr<CSSPrimitiveValue> shapeValue; |
5443 | 5443 |
5444 if (valueId == CSSValueAuto | 5444 if (valueId == CSSValueAuto |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5483 | 5483 |
5484 ASSERT(shapeValue && boxValue); | 5484 ASSERT(shapeValue && boxValue); |
5485 shapeValue->getShapeValue()->setLayoutBox(boxValue.release()); | 5485 shapeValue->getShapeValue()->setLayoutBox(boxValue.release()); |
5486 } | 5486 } |
5487 | 5487 |
5488 if (shapeValue) | 5488 if (shapeValue) |
5489 return shapeValue.release(); | 5489 return shapeValue.release(); |
5490 return boxValue.release(); | 5490 return boxValue.release(); |
5491 } | 5491 } |
5492 | 5492 |
5493 PassRefPtr<CSSPrimitiveValue> CSSParser::parseBasicShape() | 5493 PassRefPtr<CSSPrimitiveValue> BisonCSSParser::parseBasicShape() |
5494 { | 5494 { |
5495 CSSParserValue* value = m_valueList->current(); | 5495 CSSParserValue* value = m_valueList->current(); |
5496 ASSERT(value->unit == CSSParserValue::Function); | 5496 ASSERT(value->unit == CSSParserValue::Function); |
5497 CSSParserValueList* args = value->function->args.get(); | 5497 CSSParserValueList* args = value->function->args.get(); |
5498 | 5498 |
5499 if (!args) | 5499 if (!args) |
5500 return 0; | 5500 return 0; |
5501 | 5501 |
5502 RefPtr<CSSBasicShape> shape; | 5502 RefPtr<CSSBasicShape> shape; |
5503 if (equalIgnoringCase(value->function->name, "rectangle(")) | 5503 if (equalIgnoringCase(value->function->name, "rectangle(")) |
(...skipping 11 matching lines...) Expand all Loading... |
5515 shape = parseBasicShapeInsetRectangle(args); | 5515 shape = parseBasicShapeInsetRectangle(args); |
5516 | 5516 |
5517 if (!shape) | 5517 if (!shape) |
5518 return 0; | 5518 return 0; |
5519 | 5519 |
5520 m_valueList->next(); | 5520 m_valueList->next(); |
5521 return cssValuePool().createValue(shape.release()); | 5521 return cssValuePool().createValue(shape.release()); |
5522 } | 5522 } |
5523 | 5523 |
5524 // [ 'font-style' || 'font-variant' || 'font-weight' ]? 'font-size' [ / 'line-he
ight' ]? 'font-family' | 5524 // [ 'font-style' || 'font-variant' || 'font-weight' ]? 'font-size' [ / 'line-he
ight' ]? 'font-family' |
5525 bool CSSParser::parseFont(bool important) | 5525 bool BisonCSSParser::parseFont(bool important) |
5526 { | 5526 { |
5527 // Let's check if there is an inherit or initial somewhere in the shorthand. | 5527 // Let's check if there is an inherit or initial somewhere in the shorthand. |
5528 for (unsigned i = 0; i < m_valueList->size(); ++i) { | 5528 for (unsigned i = 0; i < m_valueList->size(); ++i) { |
5529 if (m_valueList->valueAt(i)->id == CSSValueInherit || m_valueList->value
At(i)->id == CSSValueInitial) | 5529 if (m_valueList->valueAt(i)->id == CSSValueInherit || m_valueList->value
At(i)->id == CSSValueInitial) |
5530 return false; | 5530 return false; |
5531 } | 5531 } |
5532 | 5532 |
5533 ShorthandScope scope(this, CSSPropertyFont); | 5533 ShorthandScope scope(this, CSSPropertyFont); |
5534 // Optional font-style, font-variant and font-weight. | 5534 // Optional font-style, font-variant and font-weight. |
5535 bool fontStyleParsed = false; | 5535 bool fontStyleParsed = false; |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5622 return; | 5622 return; |
5623 m_list->append(cssValuePool().createFontFamilyValue(m_builder.toString()
)); | 5623 m_list->append(cssValuePool().createFontFamilyValue(m_builder.toString()
)); |
5624 m_builder.clear(); | 5624 m_builder.clear(); |
5625 } | 5625 } |
5626 | 5626 |
5627 private: | 5627 private: |
5628 StringBuilder m_builder; | 5628 StringBuilder m_builder; |
5629 CSSValueList* m_list; | 5629 CSSValueList* m_list; |
5630 }; | 5630 }; |
5631 | 5631 |
5632 PassRefPtr<CSSValueList> CSSParser::parseFontFamily() | 5632 PassRefPtr<CSSValueList> BisonCSSParser::parseFontFamily() |
5633 { | 5633 { |
5634 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated(); | 5634 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated(); |
5635 CSSParserValue* value = m_valueList->current(); | 5635 CSSParserValue* value = m_valueList->current(); |
5636 | 5636 |
5637 FontFamilyValueBuilder familyBuilder(list.get()); | 5637 FontFamilyValueBuilder familyBuilder(list.get()); |
5638 bool inFamily = false; | 5638 bool inFamily = false; |
5639 | 5639 |
5640 while (value) { | 5640 while (value) { |
5641 CSSParserValue* nextValue = m_valueList->next(); | 5641 CSSParserValue* nextValue = m_valueList->next(); |
5642 bool nextValBreaksFont = !nextValue || | 5642 bool nextValBreaksFont = !nextValue || |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5696 else | 5696 else |
5697 break; | 5697 break; |
5698 } | 5698 } |
5699 familyBuilder.commit(); | 5699 familyBuilder.commit(); |
5700 | 5700 |
5701 if (!list->length()) | 5701 if (!list->length()) |
5702 list = 0; | 5702 list = 0; |
5703 return list.release(); | 5703 return list.release(); |
5704 } | 5704 } |
5705 | 5705 |
5706 bool CSSParser::parseLineHeight(bool important) | 5706 bool BisonCSSParser::parseLineHeight(bool important) |
5707 { | 5707 { |
5708 CSSParserValue* value = m_valueList->current(); | 5708 CSSParserValue* value = m_valueList->current(); |
5709 CSSValueID id = value->id; | 5709 CSSValueID id = value->id; |
5710 bool validPrimitive = false; | 5710 bool validPrimitive = false; |
5711 // normal | <number> | <length> | <percentage> | inherit | 5711 // normal | <number> | <length> | <percentage> | inherit |
5712 if (id == CSSValueNormal) | 5712 if (id == CSSValueNormal) |
5713 validPrimitive = true; | 5713 validPrimitive = true; |
5714 else | 5714 else |
5715 validPrimitive = (!id && validUnit(value, FNumber | FLength | FPercent |
FNonNeg)); | 5715 validPrimitive = (!id && validUnit(value, FNumber | FLength | FPercent |
FNonNeg)); |
5716 if (validPrimitive && (!m_valueList->next() || inShorthand())) | 5716 if (validPrimitive && (!m_valueList->next() || inShorthand())) |
5717 addProperty(CSSPropertyLineHeight, parseValidPrimitive(id, value), impor
tant); | 5717 addProperty(CSSPropertyLineHeight, parseValidPrimitive(id, value), impor
tant); |
5718 return validPrimitive; | 5718 return validPrimitive; |
5719 } | 5719 } |
5720 | 5720 |
5721 bool CSSParser::parseFontSize(bool important) | 5721 bool BisonCSSParser::parseFontSize(bool important) |
5722 { | 5722 { |
5723 CSSParserValue* value = m_valueList->current(); | 5723 CSSParserValue* value = m_valueList->current(); |
5724 CSSValueID id = value->id; | 5724 CSSValueID id = value->id; |
5725 bool validPrimitive = false; | 5725 bool validPrimitive = false; |
5726 // <absolute-size> | <relative-size> | <length> | <percentage> | inherit | 5726 // <absolute-size> | <relative-size> | <length> | <percentage> | inherit |
5727 if (id >= CSSValueXxSmall && id <= CSSValueLarger) | 5727 if (id >= CSSValueXxSmall && id <= CSSValueLarger) |
5728 validPrimitive = true; | 5728 validPrimitive = true; |
5729 else | 5729 else |
5730 validPrimitive = validUnit(value, FLength | FPercent | FNonNeg); | 5730 validPrimitive = validUnit(value, FLength | FPercent | FNonNeg); |
5731 if (validPrimitive && (!m_valueList->next() || inShorthand())) | 5731 if (validPrimitive && (!m_valueList->next() || inShorthand())) |
5732 addProperty(CSSPropertyFontSize, parseValidPrimitive(id, value), importa
nt); | 5732 addProperty(CSSPropertyFontSize, parseValidPrimitive(id, value), importa
nt); |
5733 return validPrimitive; | 5733 return validPrimitive; |
5734 } | 5734 } |
5735 | 5735 |
5736 bool CSSParser::parseFontVariant(bool important) | 5736 bool BisonCSSParser::parseFontVariant(bool important) |
5737 { | 5737 { |
5738 RefPtr<CSSValueList> values; | 5738 RefPtr<CSSValueList> values; |
5739 if (m_valueList->size() > 1) | 5739 if (m_valueList->size() > 1) |
5740 values = CSSValueList::createCommaSeparated(); | 5740 values = CSSValueList::createCommaSeparated(); |
5741 CSSParserValue* val; | 5741 CSSParserValue* val; |
5742 bool expectComma = false; | 5742 bool expectComma = false; |
5743 while ((val = m_valueList->current())) { | 5743 while ((val = m_valueList->current())) { |
5744 RefPtr<CSSPrimitiveValue> parsedValue; | 5744 RefPtr<CSSPrimitiveValue> parsedValue; |
5745 if (!expectComma) { | 5745 if (!expectComma) { |
5746 expectComma = true; | 5746 expectComma = true; |
(...skipping 26 matching lines...) Expand all Loading... |
5773 | 5773 |
5774 if (values && values->length()) { | 5774 if (values && values->length()) { |
5775 m_hasFontFaceOnlyValues = true; | 5775 m_hasFontFaceOnlyValues = true; |
5776 addProperty(CSSPropertyFontVariant, values.release(), important); | 5776 addProperty(CSSPropertyFontVariant, values.release(), important); |
5777 return true; | 5777 return true; |
5778 } | 5778 } |
5779 | 5779 |
5780 return false; | 5780 return false; |
5781 } | 5781 } |
5782 | 5782 |
5783 bool CSSParser::parseFontWeight(bool important) | 5783 bool BisonCSSParser::parseFontWeight(bool important) |
5784 { | 5784 { |
5785 CSSParserValue* value = m_valueList->current(); | 5785 CSSParserValue* value = m_valueList->current(); |
5786 if ((value->id >= CSSValueNormal) && (value->id <= CSSValue900)) { | 5786 if ((value->id >= CSSValueNormal) && (value->id <= CSSValue900)) { |
5787 addProperty(CSSPropertyFontWeight, cssValuePool().createIdentifierValue(
value->id), important); | 5787 addProperty(CSSPropertyFontWeight, cssValuePool().createIdentifierValue(
value->id), important); |
5788 return true; | 5788 return true; |
5789 } | 5789 } |
5790 if (validUnit(value, FInteger | FNonNeg, HTMLQuirksMode)) { | 5790 if (validUnit(value, FInteger | FNonNeg, HTMLQuirksMode)) { |
5791 int weight = static_cast<int>(value->fValue); | 5791 int weight = static_cast<int>(value->fValue); |
5792 if (!(weight % 100) && weight >= 100 && weight <= 900) { | 5792 if (!(weight % 100) && weight >= 100 && weight <= 900) { |
5793 addProperty(CSSPropertyFontWeight, cssValuePool().createIdentifierVa
lue(static_cast<CSSValueID>(CSSValue100 + weight / 100 - 1)), important); | 5793 addProperty(CSSPropertyFontWeight, cssValuePool().createIdentifierVa
lue(static_cast<CSSValueID>(CSSValue100 + weight / 100 - 1)), important); |
5794 return true; | 5794 return true; |
5795 } | 5795 } |
5796 } | 5796 } |
5797 return false; | 5797 return false; |
5798 } | 5798 } |
5799 | 5799 |
5800 bool CSSParser::parseFontFaceSrcURI(CSSValueList* valueList) | 5800 bool BisonCSSParser::parseFontFaceSrcURI(CSSValueList* valueList) |
5801 { | 5801 { |
5802 RefPtr<CSSFontFaceSrcValue> uriValue(CSSFontFaceSrcValue::create(completeURL
(m_valueList->current()->string))); | 5802 RefPtr<CSSFontFaceSrcValue> uriValue(CSSFontFaceSrcValue::create(completeURL
(m_valueList->current()->string))); |
5803 | 5803 |
5804 CSSParserValue* value = m_valueList->next(); | 5804 CSSParserValue* value = m_valueList->next(); |
5805 if (!value) { | 5805 if (!value) { |
5806 valueList->append(uriValue.release()); | 5806 valueList->append(uriValue.release()); |
5807 return true; | 5807 return true; |
5808 } | 5808 } |
5809 if (value->unit == CSSParserValue::Operator && value->iValue == ',') { | 5809 if (value->unit == CSSParserValue::Operator && value->iValue == ',') { |
5810 m_valueList->next(); | 5810 m_valueList->next(); |
(...skipping 10 matching lines...) Expand all Loading... |
5821 if (!args || args->size() != 1 || (args->current()->unit != CSSPrimitiveValu
e::CSS_STRING && args->current()->unit != CSSPrimitiveValue::CSS_IDENT)) | 5821 if (!args || args->size() != 1 || (args->current()->unit != CSSPrimitiveValu
e::CSS_STRING && args->current()->unit != CSSPrimitiveValue::CSS_IDENT)) |
5822 return false; | 5822 return false; |
5823 uriValue->setFormat(args->current()->string); | 5823 uriValue->setFormat(args->current()->string); |
5824 valueList->append(uriValue.release()); | 5824 valueList->append(uriValue.release()); |
5825 value = m_valueList->next(); | 5825 value = m_valueList->next(); |
5826 if (value && value->unit == CSSParserValue::Operator && value->iValue == ','
) | 5826 if (value && value->unit == CSSParserValue::Operator && value->iValue == ','
) |
5827 m_valueList->next(); | 5827 m_valueList->next(); |
5828 return true; | 5828 return true; |
5829 } | 5829 } |
5830 | 5830 |
5831 bool CSSParser::parseFontFaceSrcLocal(CSSValueList* valueList) | 5831 bool BisonCSSParser::parseFontFaceSrcLocal(CSSValueList* valueList) |
5832 { | 5832 { |
5833 CSSParserValueList* args = m_valueList->current()->function->args.get(); | 5833 CSSParserValueList* args = m_valueList->current()->function->args.get(); |
5834 if (!args || !args->size()) | 5834 if (!args || !args->size()) |
5835 return false; | 5835 return false; |
5836 | 5836 |
5837 if (args->size() == 1 && args->current()->unit == CSSPrimitiveValue::CSS_STR
ING) | 5837 if (args->size() == 1 && args->current()->unit == CSSPrimitiveValue::CSS_STR
ING) |
5838 valueList->append(CSSFontFaceSrcValue::createLocal(args->current()->stri
ng)); | 5838 valueList->append(CSSFontFaceSrcValue::createLocal(args->current()->stri
ng)); |
5839 else if (args->current()->unit == CSSPrimitiveValue::CSS_IDENT) { | 5839 else if (args->current()->unit == CSSPrimitiveValue::CSS_IDENT) { |
5840 StringBuilder builder; | 5840 StringBuilder builder; |
5841 for (CSSParserValue* localValue = args->current(); localValue; localValu
e = args->next()) { | 5841 for (CSSParserValue* localValue = args->current(); localValue; localValu
e = args->next()) { |
5842 if (localValue->unit != CSSPrimitiveValue::CSS_IDENT) | 5842 if (localValue->unit != CSSPrimitiveValue::CSS_IDENT) |
5843 return false; | 5843 return false; |
5844 if (!builder.isEmpty()) | 5844 if (!builder.isEmpty()) |
5845 builder.append(' '); | 5845 builder.append(' '); |
5846 builder.append(localValue->string); | 5846 builder.append(localValue->string); |
5847 } | 5847 } |
5848 valueList->append(CSSFontFaceSrcValue::createLocal(builder.toString())); | 5848 valueList->append(CSSFontFaceSrcValue::createLocal(builder.toString())); |
5849 } else | 5849 } else |
5850 return false; | 5850 return false; |
5851 | 5851 |
5852 if (CSSParserValue* value = m_valueList->next()) { | 5852 if (CSSParserValue* value = m_valueList->next()) { |
5853 if (value->unit == CSSParserValue::Operator && value->iValue == ',') | 5853 if (value->unit == CSSParserValue::Operator && value->iValue == ',') |
5854 m_valueList->next(); | 5854 m_valueList->next(); |
5855 } | 5855 } |
5856 return true; | 5856 return true; |
5857 } | 5857 } |
5858 | 5858 |
5859 bool CSSParser::parseFontFaceSrc() | 5859 bool BisonCSSParser::parseFontFaceSrc() |
5860 { | 5860 { |
5861 RefPtr<CSSValueList> values(CSSValueList::createCommaSeparated()); | 5861 RefPtr<CSSValueList> values(CSSValueList::createCommaSeparated()); |
5862 | 5862 |
5863 while (CSSParserValue* value = m_valueList->current()) { | 5863 while (CSSParserValue* value = m_valueList->current()) { |
5864 if (value->unit == CSSPrimitiveValue::CSS_URI) { | 5864 if (value->unit == CSSPrimitiveValue::CSS_URI) { |
5865 if (!parseFontFaceSrcURI(values.get())) | 5865 if (!parseFontFaceSrcURI(values.get())) |
5866 return false; | 5866 return false; |
5867 } else if (value->unit == CSSParserValue::Function && equalIgnoringCase(
value->function->name, "local(")) { | 5867 } else if (value->unit == CSSParserValue::Function && equalIgnoringCase(
value->function->name, "local(")) { |
5868 if (!parseFontFaceSrcLocal(values.get())) | 5868 if (!parseFontFaceSrcLocal(values.get())) |
5869 return false; | 5869 return false; |
5870 } else | 5870 } else |
5871 return false; | 5871 return false; |
5872 } | 5872 } |
5873 if (!values->length()) | 5873 if (!values->length()) |
5874 return false; | 5874 return false; |
5875 | 5875 |
5876 addProperty(CSSPropertySrc, values.release(), m_important); | 5876 addProperty(CSSPropertySrc, values.release(), m_important); |
5877 m_valueList->next(); | 5877 m_valueList->next(); |
5878 return true; | 5878 return true; |
5879 } | 5879 } |
5880 | 5880 |
5881 bool CSSParser::parseFontFaceUnicodeRange() | 5881 bool BisonCSSParser::parseFontFaceUnicodeRange() |
5882 { | 5882 { |
5883 RefPtr<CSSValueList> values = CSSValueList::createCommaSeparated(); | 5883 RefPtr<CSSValueList> values = CSSValueList::createCommaSeparated(); |
5884 bool failed = false; | 5884 bool failed = false; |
5885 bool operatorExpected = false; | 5885 bool operatorExpected = false; |
5886 for (; m_valueList->current(); m_valueList->next(), operatorExpected = !oper
atorExpected) { | 5886 for (; m_valueList->current(); m_valueList->next(), operatorExpected = !oper
atorExpected) { |
5887 if (operatorExpected) { | 5887 if (operatorExpected) { |
5888 if (m_valueList->current()->unit == CSSParserValue::Operator && m_va
lueList->current()->iValue == ',') | 5888 if (m_valueList->current()->unit == CSSParserValue::Operator && m_va
lueList->current()->iValue == ',') |
5889 continue; | 5889 continue; |
5890 failed = true; | 5890 failed = true; |
5891 break; | 5891 break; |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6250 if (current != end) | 6250 if (current != end) |
6251 return false; | 6251 return false; |
6252 rgb = makeRGB(red, green, blue); | 6252 rgb = makeRGB(red, green, blue); |
6253 return true; | 6253 return true; |
6254 } | 6254 } |
6255 | 6255 |
6256 return false; | 6256 return false; |
6257 } | 6257 } |
6258 | 6258 |
6259 template<typename StringType> | 6259 template<typename StringType> |
6260 bool CSSParser::fastParseColor(RGBA32& rgb, const StringType& name, bool strict) | 6260 bool BisonCSSParser::fastParseColor(RGBA32& rgb, const StringType& name, bool st
rict) |
6261 { | 6261 { |
6262 unsigned length = name.length(); | 6262 unsigned length = name.length(); |
6263 bool parseResult; | 6263 bool parseResult; |
6264 | 6264 |
6265 if (!length) | 6265 if (!length) |
6266 return false; | 6266 return false; |
6267 | 6267 |
6268 if (name.is8Bit()) | 6268 if (name.is8Bit()) |
6269 parseResult = fastParseColorInternal(rgb, name.characters8(), length, st
rict); | 6269 parseResult = fastParseColorInternal(rgb, name.characters8(), length, st
rict); |
6270 else | 6270 else |
6271 parseResult = fastParseColorInternal(rgb, name.characters16(), length, s
trict); | 6271 parseResult = fastParseColorInternal(rgb, name.characters16(), length, s
trict); |
6272 | 6272 |
6273 if (parseResult) | 6273 if (parseResult) |
6274 return true; | 6274 return true; |
6275 | 6275 |
6276 // Try named colors. | 6276 // Try named colors. |
6277 Color tc; | 6277 Color tc; |
6278 tc.setNamedColor(name); | 6278 tc.setNamedColor(name); |
6279 if (tc.isValid()) { | 6279 if (tc.isValid()) { |
6280 rgb = tc.rgb(); | 6280 rgb = tc.rgb(); |
6281 return true; | 6281 return true; |
6282 } | 6282 } |
6283 return false; | 6283 return false; |
6284 } | 6284 } |
6285 | 6285 |
6286 inline double CSSParser::parsedDouble(CSSParserValue *v, ReleaseParsedCalcValueC
ondition releaseCalc) | 6286 inline double BisonCSSParser::parsedDouble(CSSParserValue *v, ReleaseParsedCalcV
alueCondition releaseCalc) |
6287 { | 6287 { |
6288 const double result = m_parsedCalculation ? m_parsedCalculation->doubleValue
() : v->fValue; | 6288 const double result = m_parsedCalculation ? m_parsedCalculation->doubleValue
() : v->fValue; |
6289 if (releaseCalc == ReleaseParsedCalcValue) | 6289 if (releaseCalc == ReleaseParsedCalcValue) |
6290 m_parsedCalculation.release(); | 6290 m_parsedCalculation.release(); |
6291 return result; | 6291 return result; |
6292 } | 6292 } |
6293 | 6293 |
6294 bool CSSParser::isCalculation(CSSParserValue* value) | 6294 bool BisonCSSParser::isCalculation(CSSParserValue* value) |
6295 { | 6295 { |
6296 return (value->unit == CSSParserValue::Function) | 6296 return (value->unit == CSSParserValue::Function) |
6297 && (equalIgnoringCase(value->function->name, "calc(") | 6297 && (equalIgnoringCase(value->function->name, "calc(") |
6298 || equalIgnoringCase(value->function->name, "-webkit-calc(") | 6298 || equalIgnoringCase(value->function->name, "-webkit-calc(") |
6299 || equalIgnoringCase(value->function->name, "-webkit-min(") | 6299 || equalIgnoringCase(value->function->name, "-webkit-min(") |
6300 || equalIgnoringCase(value->function->name, "-webkit-max(")); | 6300 || equalIgnoringCase(value->function->name, "-webkit-max(")); |
6301 } | 6301 } |
6302 | 6302 |
6303 inline int CSSParser::colorIntFromValue(CSSParserValue* v) | 6303 inline int BisonCSSParser::colorIntFromValue(CSSParserValue* v) |
6304 { | 6304 { |
6305 bool isPercent; | 6305 bool isPercent; |
6306 | 6306 |
6307 if (m_parsedCalculation) | 6307 if (m_parsedCalculation) |
6308 isPercent = m_parsedCalculation->category() == CalcPercent; | 6308 isPercent = m_parsedCalculation->category() == CalcPercent; |
6309 else | 6309 else |
6310 isPercent = v->unit == CSSPrimitiveValue::CSS_PERCENTAGE; | 6310 isPercent = v->unit == CSSPrimitiveValue::CSS_PERCENTAGE; |
6311 | 6311 |
6312 const double value = parsedDouble(v, ReleaseParsedCalcValue); | 6312 const double value = parsedDouble(v, ReleaseParsedCalcValue); |
6313 | 6313 |
6314 if (value <= 0.0) | 6314 if (value <= 0.0) |
6315 return 0; | 6315 return 0; |
6316 | 6316 |
6317 if (isPercent) { | 6317 if (isPercent) { |
6318 if (value >= 100.0) | 6318 if (value >= 100.0) |
6319 return 255; | 6319 return 255; |
6320 return static_cast<int>(value * 256.0 / 100.0); | 6320 return static_cast<int>(value * 256.0 / 100.0); |
6321 } | 6321 } |
6322 | 6322 |
6323 if (value >= 255.0) | 6323 if (value >= 255.0) |
6324 return 255; | 6324 return 255; |
6325 | 6325 |
6326 return static_cast<int>(value); | 6326 return static_cast<int>(value); |
6327 } | 6327 } |
6328 | 6328 |
6329 bool CSSParser::parseColorParameters(CSSParserValue* value, int* colorArray, boo
l parseAlpha) | 6329 bool BisonCSSParser::parseColorParameters(CSSParserValue* value, int* colorArray
, bool parseAlpha) |
6330 { | 6330 { |
6331 CSSParserValueList* args = value->function->args.get(); | 6331 CSSParserValueList* args = value->function->args.get(); |
6332 CSSParserValue* v = args->current(); | 6332 CSSParserValue* v = args->current(); |
6333 Units unitType = FUnknown; | 6333 Units unitType = FUnknown; |
6334 // Get the first value and its type | 6334 // Get the first value and its type |
6335 if (validUnit(v, FInteger, HTMLStandardMode)) | 6335 if (validUnit(v, FInteger, HTMLStandardMode)) |
6336 unitType = FInteger; | 6336 unitType = FInteger; |
6337 else if (validUnit(v, FPercent, HTMLStandardMode)) | 6337 else if (validUnit(v, FPercent, HTMLStandardMode)) |
6338 unitType = FPercent; | 6338 unitType = FPercent; |
6339 else | 6339 else |
(...skipping 22 matching lines...) Expand all Loading... |
6362 colorArray[3] = static_cast<int>(max(0.0, min(1.0, value)) * nextafter(2
56.0, 0.0)); | 6362 colorArray[3] = static_cast<int>(max(0.0, min(1.0, value)) * nextafter(2
56.0, 0.0)); |
6363 } | 6363 } |
6364 return true; | 6364 return true; |
6365 } | 6365 } |
6366 | 6366 |
6367 // The CSS3 specification defines the format of a HSL color as | 6367 // The CSS3 specification defines the format of a HSL color as |
6368 // hsl(<number>, <percent>, <percent>) | 6368 // hsl(<number>, <percent>, <percent>) |
6369 // and with alpha, the format is | 6369 // and with alpha, the format is |
6370 // hsla(<number>, <percent>, <percent>, <number>) | 6370 // hsla(<number>, <percent>, <percent>, <number>) |
6371 // The first value, HUE, is in an angle with a value between 0 and 360 | 6371 // The first value, HUE, is in an angle with a value between 0 and 360 |
6372 bool CSSParser::parseHSLParameters(CSSParserValue* value, double* colorArray, bo
ol parseAlpha) | 6372 bool BisonCSSParser::parseHSLParameters(CSSParserValue* value, double* colorArra
y, bool parseAlpha) |
6373 { | 6373 { |
6374 CSSParserValueList* args = value->function->args.get(); | 6374 CSSParserValueList* args = value->function->args.get(); |
6375 CSSParserValue* v = args->current(); | 6375 CSSParserValue* v = args->current(); |
6376 // Get the first value | 6376 // Get the first value |
6377 if (!validUnit(v, FNumber, HTMLStandardMode)) | 6377 if (!validUnit(v, FNumber, HTMLStandardMode)) |
6378 return false; | 6378 return false; |
6379 // normalize the Hue value and change it to be between 0 and 1.0 | 6379 // normalize the Hue value and change it to be between 0 and 1.0 |
6380 colorArray[0] = (((static_cast<int>(parsedDouble(v, ReleaseParsedCalcValue))
% 360) + 360) % 360) / 360.0; | 6380 colorArray[0] = (((static_cast<int>(parsedDouble(v, ReleaseParsedCalcValue))
% 360) + 360) % 360) / 360.0; |
6381 for (int i = 1; i < 3; i++) { | 6381 for (int i = 1; i < 3; i++) { |
6382 v = args->next(); | 6382 v = args->next(); |
6383 if (v->unit != CSSParserValue::Operator && v->iValue != ',') | 6383 if (v->unit != CSSParserValue::Operator && v->iValue != ',') |
6384 return false; | 6384 return false; |
6385 v = args->next(); | 6385 v = args->next(); |
6386 if (!validUnit(v, FPercent, HTMLStandardMode)) | 6386 if (!validUnit(v, FPercent, HTMLStandardMode)) |
6387 return false; | 6387 return false; |
6388 colorArray[i] = max(0.0, min(100.0, parsedDouble(v, ReleaseParsedCalcVal
ue))) / 100.0; // needs to be value between 0 and 1.0 | 6388 colorArray[i] = max(0.0, min(100.0, parsedDouble(v, ReleaseParsedCalcVal
ue))) / 100.0; // needs to be value between 0 and 1.0 |
6389 } | 6389 } |
6390 if (parseAlpha) { | 6390 if (parseAlpha) { |
6391 v = args->next(); | 6391 v = args->next(); |
6392 if (v->unit != CSSParserValue::Operator && v->iValue != ',') | 6392 if (v->unit != CSSParserValue::Operator && v->iValue != ',') |
6393 return false; | 6393 return false; |
6394 v = args->next(); | 6394 v = args->next(); |
6395 if (!validUnit(v, FNumber, HTMLStandardMode)) | 6395 if (!validUnit(v, FNumber, HTMLStandardMode)) |
6396 return false; | 6396 return false; |
6397 colorArray[3] = max(0.0, min(1.0, parsedDouble(v, ReleaseParsedCalcValue
))); | 6397 colorArray[3] = max(0.0, min(1.0, parsedDouble(v, ReleaseParsedCalcValue
))); |
6398 } | 6398 } |
6399 return true; | 6399 return true; |
6400 } | 6400 } |
6401 | 6401 |
6402 PassRefPtr<CSSPrimitiveValue> CSSParser::parseColor(CSSParserValue* value) | 6402 PassRefPtr<CSSPrimitiveValue> BisonCSSParser::parseColor(CSSParserValue* value) |
6403 { | 6403 { |
6404 RGBA32 c = Color::transparent; | 6404 RGBA32 c = Color::transparent; |
6405 if (!parseColorFromValue(value ? value : m_valueList->current(), c)) | 6405 if (!parseColorFromValue(value ? value : m_valueList->current(), c)) |
6406 return 0; | 6406 return 0; |
6407 return cssValuePool().createColorValue(c); | 6407 return cssValuePool().createColorValue(c); |
6408 } | 6408 } |
6409 | 6409 |
6410 bool CSSParser::parseColorFromValue(CSSParserValue* value, RGBA32& c) | 6410 bool BisonCSSParser::parseColorFromValue(CSSParserValue* value, RGBA32& c) |
6411 { | 6411 { |
6412 if (inQuirksMode() && value->unit == CSSPrimitiveValue::CSS_NUMBER | 6412 if (inQuirksMode() && value->unit == CSSPrimitiveValue::CSS_NUMBER |
6413 && value->fValue >= 0. && value->fValue < 1000000.) { | 6413 && value->fValue >= 0. && value->fValue < 1000000.) { |
6414 String str = String::format("%06d", static_cast<int>((value->fValue+.5))
); | 6414 String str = String::format("%06d", static_cast<int>((value->fValue+.5))
); |
6415 // FIXME: This should be strict parsing for SVG as well. | 6415 // FIXME: This should be strict parsing for SVG as well. |
6416 if (!fastParseColor(c, str, !inQuirksMode())) | 6416 if (!fastParseColor(c, str, !inQuirksMode())) |
6417 return false; | 6417 return false; |
6418 } else if (value->unit == CSSPrimitiveValue::CSS_PARSER_HEXCOLOR || | 6418 } else if (value->unit == CSSPrimitiveValue::CSS_PARSER_HEXCOLOR || |
6419 value->unit == CSSPrimitiveValue::CSS_IDENT || | 6419 value->unit == CSSPrimitiveValue::CSS_IDENT || |
6420 (inQuirksMode() && value->unit == CSSPrimitiveValue::CSS_DIMENSI
ON)) { | 6420 (inQuirksMode() && value->unit == CSSPrimitiveValue::CSS_DIMENSI
ON)) { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6456 } else | 6456 } else |
6457 return false; | 6457 return false; |
6458 } | 6458 } |
6459 | 6459 |
6460 return true; | 6460 return true; |
6461 } | 6461 } |
6462 | 6462 |
6463 // This class tracks parsing state for shadow values. If it goes out of scope (
e.g., due to an early return) | 6463 // This class tracks parsing state for shadow values. If it goes out of scope (
e.g., due to an early return) |
6464 // without the allowBreak bit being set, then it will clean up all of the object
s and destroy them. | 6464 // without the allowBreak bit being set, then it will clean up all of the object
s and destroy them. |
6465 struct ShadowParseContext { | 6465 struct ShadowParseContext { |
6466 ShadowParseContext(CSSPropertyID prop, CSSParser* parser) | 6466 ShadowParseContext(CSSPropertyID prop, BisonCSSParser* parser) |
6467 : property(prop) | 6467 : property(prop) |
6468 , m_parser(parser) | 6468 , m_parser(parser) |
6469 , allowX(true) | 6469 , allowX(true) |
6470 , allowY(false) | 6470 , allowY(false) |
6471 , allowBlur(false) | 6471 , allowBlur(false) |
6472 , allowSpread(false) | 6472 , allowSpread(false) |
6473 , allowColor(true) | 6473 , allowColor(true) |
6474 , allowStyle(prop == CSSPropertyWebkitBoxShadow || prop == CSSPropertyBo
xShadow) | 6474 , allowStyle(prop == CSSPropertyWebkitBoxShadow || prop == CSSPropertyBo
xShadow) |
6475 , allowBreak(true) | 6475 , allowBreak(true) |
6476 { | 6476 { |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6555 if (allowX) | 6555 if (allowX) |
6556 allowBreak = false; | 6556 allowBreak = false; |
6557 else { | 6557 else { |
6558 allowBlur = false; | 6558 allowBlur = false; |
6559 allowSpread = false; | 6559 allowSpread = false; |
6560 allowColor = false; | 6560 allowColor = false; |
6561 } | 6561 } |
6562 } | 6562 } |
6563 | 6563 |
6564 CSSPropertyID property; | 6564 CSSPropertyID property; |
6565 CSSParser* m_parser; | 6565 BisonCSSParser* m_parser; |
6566 | 6566 |
6567 RefPtr<CSSValueList> values; | 6567 RefPtr<CSSValueList> values; |
6568 RefPtr<CSSPrimitiveValue> x; | 6568 RefPtr<CSSPrimitiveValue> x; |
6569 RefPtr<CSSPrimitiveValue> y; | 6569 RefPtr<CSSPrimitiveValue> y; |
6570 RefPtr<CSSPrimitiveValue> blur; | 6570 RefPtr<CSSPrimitiveValue> blur; |
6571 RefPtr<CSSPrimitiveValue> spread; | 6571 RefPtr<CSSPrimitiveValue> spread; |
6572 RefPtr<CSSPrimitiveValue> style; | 6572 RefPtr<CSSPrimitiveValue> style; |
6573 RefPtr<CSSPrimitiveValue> color; | 6573 RefPtr<CSSPrimitiveValue> color; |
6574 | 6574 |
6575 bool allowX; | 6575 bool allowX; |
6576 bool allowY; | 6576 bool allowY; |
6577 bool allowBlur; | 6577 bool allowBlur; |
6578 bool allowSpread; | 6578 bool allowSpread; |
6579 bool allowColor; | 6579 bool allowColor; |
6580 bool allowStyle; // inset or not. | 6580 bool allowStyle; // inset or not. |
6581 bool allowBreak; | 6581 bool allowBreak; |
6582 }; | 6582 }; |
6583 | 6583 |
6584 PassRefPtr<CSSValueList> CSSParser::parseShadow(CSSParserValueList* valueList, C
SSPropertyID propId) | 6584 PassRefPtr<CSSValueList> BisonCSSParser::parseShadow(CSSParserValueList* valueLi
st, CSSPropertyID propId) |
6585 { | 6585 { |
6586 ShadowParseContext context(propId, this); | 6586 ShadowParseContext context(propId, this); |
6587 CSSParserValue* val; | 6587 CSSParserValue* val; |
6588 while ((val = valueList->current())) { | 6588 while ((val = valueList->current())) { |
6589 // Check for a comma break first. | 6589 // Check for a comma break first. |
6590 if (val->unit == CSSParserValue::Operator) { | 6590 if (val->unit == CSSParserValue::Operator) { |
6591 if (val->iValue != ',' || !context.allowBreak) | 6591 if (val->iValue != ',' || !context.allowBreak) |
6592 // Other operators aren't legal or we aren't done with the curre
nt shadow | 6592 // Other operators aren't legal or we aren't done with the curre
nt shadow |
6593 // value. Treat as invalid. | 6593 // value. Treat as invalid. |
6594 return 0; | 6594 return 0; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6638 | 6638 |
6639 if (context.allowBreak) { | 6639 if (context.allowBreak) { |
6640 context.commitValue(); | 6640 context.commitValue(); |
6641 if (context.values && context.values->length()) | 6641 if (context.values && context.values->length()) |
6642 return context.values.release(); | 6642 return context.values.release(); |
6643 } | 6643 } |
6644 | 6644 |
6645 return 0; | 6645 return 0; |
6646 } | 6646 } |
6647 | 6647 |
6648 bool CSSParser::parseReflect(CSSPropertyID propId, bool important) | 6648 bool BisonCSSParser::parseReflect(CSSPropertyID propId, bool important) |
6649 { | 6649 { |
6650 // box-reflect: <direction> <offset> <mask> | 6650 // box-reflect: <direction> <offset> <mask> |
6651 | 6651 |
6652 // Direction comes first. | 6652 // Direction comes first. |
6653 CSSParserValue* val = m_valueList->current(); | 6653 CSSParserValue* val = m_valueList->current(); |
6654 RefPtr<CSSPrimitiveValue> direction; | 6654 RefPtr<CSSPrimitiveValue> direction; |
6655 if (val->unit == CSSPrimitiveValue::CSS_VARIABLE_NAME) | 6655 if (val->unit == CSSPrimitiveValue::CSS_VARIABLE_NAME) |
6656 direction = createPrimitiveVariableNameValue(val); | 6656 direction = createPrimitiveVariableNameValue(val); |
6657 else | 6657 else |
6658 switch (val->id) { | 6658 switch (val->id) { |
(...skipping 26 matching lines...) Expand all Loading... |
6685 if (!mask) | 6685 if (!mask) |
6686 return false; | 6686 return false; |
6687 } | 6687 } |
6688 | 6688 |
6689 RefPtr<CSSReflectValue> reflectValue = CSSReflectValue::create(direction.rel
ease(), offset.release(), mask.release()); | 6689 RefPtr<CSSReflectValue> reflectValue = CSSReflectValue::create(direction.rel
ease(), offset.release(), mask.release()); |
6690 addProperty(propId, reflectValue.release(), important); | 6690 addProperty(propId, reflectValue.release(), important); |
6691 m_valueList->next(); | 6691 m_valueList->next(); |
6692 return true; | 6692 return true; |
6693 } | 6693 } |
6694 | 6694 |
6695 bool CSSParser::parseFlex(CSSParserValueList* args, bool important) | 6695 bool BisonCSSParser::parseFlex(CSSParserValueList* args, bool important) |
6696 { | 6696 { |
6697 if (!args || !args->size() || args->size() > 3) | 6697 if (!args || !args->size() || args->size() > 3) |
6698 return false; | 6698 return false; |
6699 static const double unsetValue = -1; | 6699 static const double unsetValue = -1; |
6700 double flexGrow = unsetValue; | 6700 double flexGrow = unsetValue; |
6701 double flexShrink = unsetValue; | 6701 double flexShrink = unsetValue; |
6702 RefPtr<CSSPrimitiveValue> flexBasis; | 6702 RefPtr<CSSPrimitiveValue> flexBasis; |
6703 | 6703 |
6704 while (CSSParserValue* arg = args->current()) { | 6704 while (CSSParserValue* arg = args->current()) { |
6705 if (validUnit(arg, FNumber | FNonNeg)) { | 6705 if (validUnit(arg, FNumber | FNonNeg)) { |
(...skipping 23 matching lines...) Expand all Loading... |
6729 flexShrink = 1; | 6729 flexShrink = 1; |
6730 if (!flexBasis) | 6730 if (!flexBasis) |
6731 flexBasis = cssValuePool().createValue(0, CSSPrimitiveValue::CSS_PX); | 6731 flexBasis = cssValuePool().createValue(0, CSSPrimitiveValue::CSS_PX); |
6732 | 6732 |
6733 addProperty(CSSPropertyFlexGrow, cssValuePool().createValue(clampToFloat(fle
xGrow), CSSPrimitiveValue::CSS_NUMBER), important); | 6733 addProperty(CSSPropertyFlexGrow, cssValuePool().createValue(clampToFloat(fle
xGrow), CSSPrimitiveValue::CSS_NUMBER), important); |
6734 addProperty(CSSPropertyFlexShrink, cssValuePool().createValue(clampToFloat(f
lexShrink), CSSPrimitiveValue::CSS_NUMBER), important); | 6734 addProperty(CSSPropertyFlexShrink, cssValuePool().createValue(clampToFloat(f
lexShrink), CSSPrimitiveValue::CSS_NUMBER), important); |
6735 addProperty(CSSPropertyFlexBasis, flexBasis, important); | 6735 addProperty(CSSPropertyFlexBasis, flexBasis, important); |
6736 return true; | 6736 return true; |
6737 } | 6737 } |
6738 | 6738 |
6739 bool CSSParser::parseObjectPosition(bool important) | 6739 bool BisonCSSParser::parseObjectPosition(bool important) |
6740 { | 6740 { |
6741 RefPtr<CSSValue> xValue; | 6741 RefPtr<CSSValue> xValue; |
6742 RefPtr<CSSValue> yValue; | 6742 RefPtr<CSSValue> yValue; |
6743 parseFillPosition(m_valueList.get(), xValue, yValue); | 6743 parseFillPosition(m_valueList.get(), xValue, yValue); |
6744 if (!xValue || !yValue) | 6744 if (!xValue || !yValue) |
6745 return false; | 6745 return false; |
6746 addProperty( | 6746 addProperty( |
6747 CSSPropertyObjectPosition, | 6747 CSSPropertyObjectPosition, |
6748 createPrimitiveValuePair(toCSSPrimitiveValue(xValue.get()), toCSSPrimiti
veValue(yValue.get()), Pair::KeepIdenticalValues), | 6748 createPrimitiveValuePair(toCSSPrimitiveValue(xValue.get()), toCSSPrimiti
veValue(yValue.get()), Pair::KeepIdenticalValues), |
6749 important); | 6749 important); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6830 m_allowRepeat = m_allowForwardSlashOperator = m_requireWidth = m_require
Outset = false; | 6830 m_allowRepeat = m_allowForwardSlashOperator = m_requireWidth = m_require
Outset = false; |
6831 m_allowImageSlice = !m_imageSlice; | 6831 m_allowImageSlice = !m_imageSlice; |
6832 m_allowImage = !m_image; | 6832 m_allowImage = !m_image; |
6833 } | 6833 } |
6834 | 6834 |
6835 PassRefPtr<CSSValue> commitCSSValue() | 6835 PassRefPtr<CSSValue> commitCSSValue() |
6836 { | 6836 { |
6837 return createBorderImageValue(m_image, m_imageSlice, m_borderSlice, m_ou
tset, m_repeat); | 6837 return createBorderImageValue(m_image, m_imageSlice, m_borderSlice, m_ou
tset, m_repeat); |
6838 } | 6838 } |
6839 | 6839 |
6840 void commitMaskBoxImage(CSSParser* parser, bool important) | 6840 void commitMaskBoxImage(BisonCSSParser* parser, bool important) |
6841 { | 6841 { |
6842 commitBorderImageProperty(CSSPropertyWebkitMaskBoxImageSource, parser, m
_image, important); | 6842 commitBorderImageProperty(CSSPropertyWebkitMaskBoxImageSource, parser, m
_image, important); |
6843 commitBorderImageProperty(CSSPropertyWebkitMaskBoxImageSlice, parser, m_
imageSlice, important); | 6843 commitBorderImageProperty(CSSPropertyWebkitMaskBoxImageSlice, parser, m_
imageSlice, important); |
6844 commitBorderImageProperty(CSSPropertyWebkitMaskBoxImageWidth, parser, m_
borderSlice, important); | 6844 commitBorderImageProperty(CSSPropertyWebkitMaskBoxImageWidth, parser, m_
borderSlice, important); |
6845 commitBorderImageProperty(CSSPropertyWebkitMaskBoxImageOutset, parser, m
_outset, important); | 6845 commitBorderImageProperty(CSSPropertyWebkitMaskBoxImageOutset, parser, m
_outset, important); |
6846 commitBorderImageProperty(CSSPropertyWebkitMaskBoxImageRepeat, parser, m
_repeat, important); | 6846 commitBorderImageProperty(CSSPropertyWebkitMaskBoxImageRepeat, parser, m
_repeat, important); |
6847 } | 6847 } |
6848 | 6848 |
6849 void commitBorderImage(CSSParser* parser, bool important) | 6849 void commitBorderImage(BisonCSSParser* parser, bool important) |
6850 { | 6850 { |
6851 commitBorderImageProperty(CSSPropertyBorderImageSource, parser, m_image,
important); | 6851 commitBorderImageProperty(CSSPropertyBorderImageSource, parser, m_image,
important); |
6852 commitBorderImageProperty(CSSPropertyBorderImageSlice, parser, m_imageSl
ice, important); | 6852 commitBorderImageProperty(CSSPropertyBorderImageSlice, parser, m_imageSl
ice, important); |
6853 commitBorderImageProperty(CSSPropertyBorderImageWidth, parser, m_borderS
lice, important); | 6853 commitBorderImageProperty(CSSPropertyBorderImageWidth, parser, m_borderS
lice, important); |
6854 commitBorderImageProperty(CSSPropertyBorderImageOutset, parser, m_outset
, important); | 6854 commitBorderImageProperty(CSSPropertyBorderImageOutset, parser, m_outset
, important); |
6855 commitBorderImageProperty(CSSPropertyBorderImageRepeat, parser, m_repeat
, important); | 6855 commitBorderImageProperty(CSSPropertyBorderImageRepeat, parser, m_repeat
, important); |
6856 } | 6856 } |
6857 | 6857 |
6858 void commitBorderImageProperty(CSSPropertyID propId, CSSParser* parser, Pass
RefPtr<CSSValue> value, bool important) | 6858 void commitBorderImageProperty(CSSPropertyID propId, BisonCSSParser* parser,
PassRefPtr<CSSValue> value, bool important) |
6859 { | 6859 { |
6860 if (value) | 6860 if (value) |
6861 parser->addProperty(propId, value, important); | 6861 parser->addProperty(propId, value, important); |
6862 else | 6862 else |
6863 parser->addProperty(propId, cssValuePool().createImplicitInitialValu
e(), important, true); | 6863 parser->addProperty(propId, cssValuePool().createImplicitInitialValu
e(), important, true); |
6864 } | 6864 } |
6865 | 6865 |
6866 bool m_canAdvance; | 6866 bool m_canAdvance; |
6867 | 6867 |
6868 bool m_allowCommit; | 6868 bool m_allowCommit; |
6869 bool m_allowImage; | 6869 bool m_allowImage; |
6870 bool m_allowImageSlice; | 6870 bool m_allowImageSlice; |
6871 bool m_allowRepeat; | 6871 bool m_allowRepeat; |
6872 bool m_allowForwardSlashOperator; | 6872 bool m_allowForwardSlashOperator; |
6873 | 6873 |
6874 bool m_requireWidth; | 6874 bool m_requireWidth; |
6875 bool m_requireOutset; | 6875 bool m_requireOutset; |
6876 | 6876 |
6877 RefPtr<CSSValue> m_image; | 6877 RefPtr<CSSValue> m_image; |
6878 RefPtr<CSSBorderImageSliceValue> m_imageSlice; | 6878 RefPtr<CSSBorderImageSliceValue> m_imageSlice; |
6879 RefPtr<CSSPrimitiveValue> m_borderSlice; | 6879 RefPtr<CSSPrimitiveValue> m_borderSlice; |
6880 RefPtr<CSSPrimitiveValue> m_outset; | 6880 RefPtr<CSSPrimitiveValue> m_outset; |
6881 | 6881 |
6882 RefPtr<CSSValue> m_repeat; | 6882 RefPtr<CSSValue> m_repeat; |
6883 }; | 6883 }; |
6884 | 6884 |
6885 static bool buildBorderImageParseContext(CSSParser& parser, CSSPropertyID propId
, BorderImageParseContext& context) | 6885 static bool buildBorderImageParseContext(BisonCSSParser& parser, CSSPropertyID p
ropId, BorderImageParseContext& context) |
6886 { | 6886 { |
6887 ShorthandScope scope(&parser, propId); | 6887 ShorthandScope scope(&parser, propId); |
6888 while (CSSParserValue* val = parser.m_valueList->current()) { | 6888 while (CSSParserValue* val = parser.m_valueList->current()) { |
6889 context.setCanAdvance(false); | 6889 context.setCanAdvance(false); |
6890 | 6890 |
6891 if (!context.canAdvance() && context.allowForwardSlashOperator() && isFo
rwardSlashOperator(val)) | 6891 if (!context.canAdvance() && context.allowForwardSlashOperator() && isFo
rwardSlashOperator(val)) |
6892 context.commitForwardSlashOperator(); | 6892 context.commitForwardSlashOperator(); |
6893 | 6893 |
6894 if (!context.canAdvance() && context.allowImage()) { | 6894 if (!context.canAdvance() && context.allowImage()) { |
6895 if (val->unit == CSSPrimitiveValue::CSS_URI) { | 6895 if (val->unit == CSSPrimitiveValue::CSS_URI) { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6936 | 6936 |
6937 if (!context.canAdvance()) | 6937 if (!context.canAdvance()) |
6938 return false; | 6938 return false; |
6939 | 6939 |
6940 parser.m_valueList->next(); | 6940 parser.m_valueList->next(); |
6941 } | 6941 } |
6942 | 6942 |
6943 return context.allowCommit(); | 6943 return context.allowCommit(); |
6944 } | 6944 } |
6945 | 6945 |
6946 bool CSSParser::parseBorderImageShorthand(CSSPropertyID propId, bool important) | 6946 bool BisonCSSParser::parseBorderImageShorthand(CSSPropertyID propId, bool import
ant) |
6947 { | 6947 { |
6948 BorderImageParseContext context; | 6948 BorderImageParseContext context; |
6949 if (buildBorderImageParseContext(*this, propId, context)) { | 6949 if (buildBorderImageParseContext(*this, propId, context)) { |
6950 switch (propId) { | 6950 switch (propId) { |
6951 case CSSPropertyWebkitMaskBoxImage: | 6951 case CSSPropertyWebkitMaskBoxImage: |
6952 context.commitMaskBoxImage(this, important); | 6952 context.commitMaskBoxImage(this, important); |
6953 return true; | 6953 return true; |
6954 case CSSPropertyBorderImage: | 6954 case CSSPropertyBorderImage: |
6955 context.commitBorderImage(this, important); | 6955 context.commitBorderImage(this, important); |
6956 return true; | 6956 return true; |
6957 default: | 6957 default: |
6958 ASSERT_NOT_REACHED(); | 6958 ASSERT_NOT_REACHED(); |
6959 return false; | 6959 return false; |
6960 } | 6960 } |
6961 } | 6961 } |
6962 return false; | 6962 return false; |
6963 } | 6963 } |
6964 | 6964 |
6965 PassRefPtr<CSSValue> CSSParser::parseBorderImage(CSSPropertyID propId) | 6965 PassRefPtr<CSSValue> BisonCSSParser::parseBorderImage(CSSPropertyID propId) |
6966 { | 6966 { |
6967 BorderImageParseContext context; | 6967 BorderImageParseContext context; |
6968 if (buildBorderImageParseContext(*this, propId, context)) { | 6968 if (buildBorderImageParseContext(*this, propId, context)) { |
6969 return context.commitCSSValue(); | 6969 return context.commitCSSValue(); |
6970 } | 6970 } |
6971 return 0; | 6971 return 0; |
6972 } | 6972 } |
6973 | 6973 |
6974 static bool isBorderImageRepeatKeyword(int id) | 6974 static bool isBorderImageRepeatKeyword(int id) |
6975 { | 6975 { |
6976 return id == CSSValueStretch || id == CSSValueRepeat || id == CSSValueSpace
|| id == CSSValueRound; | 6976 return id == CSSValueStretch || id == CSSValueRepeat || id == CSSValueSpace
|| id == CSSValueRound; |
6977 } | 6977 } |
6978 | 6978 |
6979 bool CSSParser::parseBorderImageRepeat(RefPtr<CSSValue>& result) | 6979 bool BisonCSSParser::parseBorderImageRepeat(RefPtr<CSSValue>& result) |
6980 { | 6980 { |
6981 RefPtr<CSSPrimitiveValue> firstValue; | 6981 RefPtr<CSSPrimitiveValue> firstValue; |
6982 RefPtr<CSSPrimitiveValue> secondValue; | 6982 RefPtr<CSSPrimitiveValue> secondValue; |
6983 CSSParserValue* val = m_valueList->current(); | 6983 CSSParserValue* val = m_valueList->current(); |
6984 if (!val) | 6984 if (!val) |
6985 return false; | 6985 return false; |
6986 if (isBorderImageRepeatKeyword(val->id)) | 6986 if (isBorderImageRepeatKeyword(val->id)) |
6987 firstValue = cssValuePool().createIdentifierValue(val->id); | 6987 firstValue = cssValuePool().createIdentifierValue(val->id); |
6988 else | 6988 else |
6989 return false; | 6989 return false; |
(...skipping 13 matching lines...) Expand all Loading... |
7003 } | 7003 } |
7004 } else | 7004 } else |
7005 secondValue = firstValue; | 7005 secondValue = firstValue; |
7006 | 7006 |
7007 result = createPrimitiveValuePair(firstValue, secondValue); | 7007 result = createPrimitiveValuePair(firstValue, secondValue); |
7008 return true; | 7008 return true; |
7009 } | 7009 } |
7010 | 7010 |
7011 class BorderImageSliceParseContext { | 7011 class BorderImageSliceParseContext { |
7012 public: | 7012 public: |
7013 BorderImageSliceParseContext(CSSParser* parser) | 7013 BorderImageSliceParseContext(BisonCSSParser* parser) |
7014 : m_parser(parser) | 7014 : m_parser(parser) |
7015 , m_allowNumber(true) | 7015 , m_allowNumber(true) |
7016 , m_allowFill(true) | 7016 , m_allowFill(true) |
7017 , m_allowFinalCommit(false) | 7017 , m_allowFinalCommit(false) |
7018 , m_fill(false) | 7018 , m_fill(false) |
7019 { } | 7019 { } |
7020 | 7020 |
7021 bool allowNumber() const { return m_allowNumber; } | 7021 bool allowNumber() const { return m_allowNumber; } |
7022 bool allowFill() const { return m_allowFill; } | 7022 bool allowFill() const { return m_allowFill; } |
7023 bool allowFinalCommit() const { return m_allowFinalCommit; } | 7023 bool allowFinalCommit() const { return m_allowFinalCommit; } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7064 quad->setTop(m_top); | 7064 quad->setTop(m_top); |
7065 quad->setRight(m_right); | 7065 quad->setRight(m_right); |
7066 quad->setBottom(m_bottom); | 7066 quad->setBottom(m_bottom); |
7067 quad->setLeft(m_left); | 7067 quad->setLeft(m_left); |
7068 | 7068 |
7069 // Make our new border image value now. | 7069 // Make our new border image value now. |
7070 return CSSBorderImageSliceValue::create(cssValuePool().createValue(quad.
release()), m_fill); | 7070 return CSSBorderImageSliceValue::create(cssValuePool().createValue(quad.
release()), m_fill); |
7071 } | 7071 } |
7072 | 7072 |
7073 private: | 7073 private: |
7074 CSSParser* m_parser; | 7074 BisonCSSParser* m_parser; |
7075 | 7075 |
7076 bool m_allowNumber; | 7076 bool m_allowNumber; |
7077 bool m_allowFill; | 7077 bool m_allowFill; |
7078 bool m_allowFinalCommit; | 7078 bool m_allowFinalCommit; |
7079 | 7079 |
7080 RefPtr<CSSPrimitiveValue> m_top; | 7080 RefPtr<CSSPrimitiveValue> m_top; |
7081 RefPtr<CSSPrimitiveValue> m_right; | 7081 RefPtr<CSSPrimitiveValue> m_right; |
7082 RefPtr<CSSPrimitiveValue> m_bottom; | 7082 RefPtr<CSSPrimitiveValue> m_bottom; |
7083 RefPtr<CSSPrimitiveValue> m_left; | 7083 RefPtr<CSSPrimitiveValue> m_left; |
7084 | 7084 |
7085 bool m_fill; | 7085 bool m_fill; |
7086 }; | 7086 }; |
7087 | 7087 |
7088 bool CSSParser::parseBorderImageSlice(CSSPropertyID propId, RefPtr<CSSBorderImag
eSliceValue>& result) | 7088 bool BisonCSSParser::parseBorderImageSlice(CSSPropertyID propId, RefPtr<CSSBorde
rImageSliceValue>& result) |
7089 { | 7089 { |
7090 BorderImageSliceParseContext context(this); | 7090 BorderImageSliceParseContext context(this); |
7091 CSSParserValue* val; | 7091 CSSParserValue* val; |
7092 while ((val = m_valueList->current())) { | 7092 while ((val = m_valueList->current())) { |
7093 // FIXME calc() http://webkit.org/b/16662 : calc is parsed but values ar
e not created yet. | 7093 // FIXME calc() http://webkit.org/b/16662 : calc is parsed but values ar
e not created yet. |
7094 if (context.allowNumber() && !isCalculation(val) && validUnit(val, FInte
ger | FNonNeg | FPercent, HTMLStandardMode)) { | 7094 if (context.allowNumber() && !isCalculation(val) && validUnit(val, FInte
ger | FNonNeg | FPercent, HTMLStandardMode)) { |
7095 context.commitNumber(val); | 7095 context.commitNumber(val); |
7096 } else if (context.allowFill() && val->id == CSSValueFill) | 7096 } else if (context.allowFill() && val->id == CSSValueFill) |
7097 context.commitFill(); | 7097 context.commitFill(); |
7098 else if (!inShorthand()) { | 7098 else if (!inShorthand()) { |
(...skipping 18 matching lines...) Expand all Loading... |
7117 // Need to fully commit as a single value. | 7117 // Need to fully commit as a single value. |
7118 result = context.commitBorderImageSlice(); | 7118 result = context.commitBorderImageSlice(); |
7119 return true; | 7119 return true; |
7120 } | 7120 } |
7121 | 7121 |
7122 return false; | 7122 return false; |
7123 } | 7123 } |
7124 | 7124 |
7125 class BorderImageQuadParseContext { | 7125 class BorderImageQuadParseContext { |
7126 public: | 7126 public: |
7127 BorderImageQuadParseContext(CSSParser* parser) | 7127 BorderImageQuadParseContext(BisonCSSParser* parser) |
7128 : m_parser(parser) | 7128 : m_parser(parser) |
7129 , m_allowNumber(true) | 7129 , m_allowNumber(true) |
7130 , m_allowFinalCommit(false) | 7130 , m_allowFinalCommit(false) |
7131 { } | 7131 { } |
7132 | 7132 |
7133 bool allowNumber() const { return m_allowNumber; } | 7133 bool allowNumber() const { return m_allowNumber; } |
7134 bool allowFinalCommit() const { return m_allowFinalCommit; } | 7134 bool allowFinalCommit() const { return m_allowFinalCommit; } |
7135 CSSPrimitiveValue* top() const { return m_top.get(); } | 7135 CSSPrimitiveValue* top() const { return m_top.get(); } |
7136 | 7136 |
7137 void commitNumber(CSSParserValue* v) | 7137 void commitNumber(CSSParserValue* v) |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7181 quad->setTop(m_top); | 7181 quad->setTop(m_top); |
7182 quad->setRight(m_right); | 7182 quad->setRight(m_right); |
7183 quad->setBottom(m_bottom); | 7183 quad->setBottom(m_bottom); |
7184 quad->setLeft(m_left); | 7184 quad->setLeft(m_left); |
7185 | 7185 |
7186 // Make our new value now. | 7186 // Make our new value now. |
7187 return cssValuePool().createValue(quad.release()); | 7187 return cssValuePool().createValue(quad.release()); |
7188 } | 7188 } |
7189 | 7189 |
7190 private: | 7190 private: |
7191 CSSParser* m_parser; | 7191 BisonCSSParser* m_parser; |
7192 | 7192 |
7193 bool m_allowNumber; | 7193 bool m_allowNumber; |
7194 bool m_allowFinalCommit; | 7194 bool m_allowFinalCommit; |
7195 | 7195 |
7196 RefPtr<CSSPrimitiveValue> m_top; | 7196 RefPtr<CSSPrimitiveValue> m_top; |
7197 RefPtr<CSSPrimitiveValue> m_right; | 7197 RefPtr<CSSPrimitiveValue> m_right; |
7198 RefPtr<CSSPrimitiveValue> m_bottom; | 7198 RefPtr<CSSPrimitiveValue> m_bottom; |
7199 RefPtr<CSSPrimitiveValue> m_left; | 7199 RefPtr<CSSPrimitiveValue> m_left; |
7200 }; | 7200 }; |
7201 | 7201 |
7202 bool CSSParser::parseBorderImageQuad(Units validUnits, RefPtr<CSSPrimitiveValue>
& result) | 7202 bool BisonCSSParser::parseBorderImageQuad(Units validUnits, RefPtr<CSSPrimitiveV
alue>& result) |
7203 { | 7203 { |
7204 BorderImageQuadParseContext context(this); | 7204 BorderImageQuadParseContext context(this); |
7205 CSSParserValue* val; | 7205 CSSParserValue* val; |
7206 while ((val = m_valueList->current())) { | 7206 while ((val = m_valueList->current())) { |
7207 if (context.allowNumber() && (validUnit(val, validUnits, HTMLStandardMod
e) || val->id == CSSValueAuto)) { | 7207 if (context.allowNumber() && (validUnit(val, validUnits, HTMLStandardMod
e) || val->id == CSSValueAuto)) { |
7208 context.commitNumber(val); | 7208 context.commitNumber(val); |
7209 } else if (!inShorthand()) { | 7209 } else if (!inShorthand()) { |
7210 // If we're not parsing a shorthand then we are invalid. | 7210 // If we're not parsing a shorthand then we are invalid. |
7211 return false; | 7211 return false; |
7212 } else { | 7212 } else { |
7213 if (context.allowFinalCommit()) | 7213 if (context.allowFinalCommit()) |
7214 m_valueList->previous(); // The shorthand loop will advance back
to this point. | 7214 m_valueList->previous(); // The shorthand loop will advance back
to this point. |
7215 break; | 7215 break; |
7216 } | 7216 } |
7217 m_valueList->next(); | 7217 m_valueList->next(); |
7218 } | 7218 } |
7219 | 7219 |
7220 if (context.allowFinalCommit()) { | 7220 if (context.allowFinalCommit()) { |
7221 // Need to fully commit as a single value. | 7221 // Need to fully commit as a single value. |
7222 result = context.commitBorderImageQuad(); | 7222 result = context.commitBorderImageQuad(); |
7223 return true; | 7223 return true; |
7224 } | 7224 } |
7225 return false; | 7225 return false; |
7226 } | 7226 } |
7227 | 7227 |
7228 bool CSSParser::parseBorderImageWidth(RefPtr<CSSPrimitiveValue>& result) | 7228 bool BisonCSSParser::parseBorderImageWidth(RefPtr<CSSPrimitiveValue>& result) |
7229 { | 7229 { |
7230 return parseBorderImageQuad(FLength | FNumber | FNonNeg | FPercent, result); | 7230 return parseBorderImageQuad(FLength | FNumber | FNonNeg | FPercent, result); |
7231 } | 7231 } |
7232 | 7232 |
7233 bool CSSParser::parseBorderImageOutset(RefPtr<CSSPrimitiveValue>& result) | 7233 bool BisonCSSParser::parseBorderImageOutset(RefPtr<CSSPrimitiveValue>& result) |
7234 { | 7234 { |
7235 return parseBorderImageQuad(FLength | FNumber | FNonNeg, result); | 7235 return parseBorderImageQuad(FLength | FNumber | FNonNeg, result); |
7236 } | 7236 } |
7237 | 7237 |
7238 static void completeBorderRadii(RefPtr<CSSPrimitiveValue> radii[4]) | 7238 static void completeBorderRadii(RefPtr<CSSPrimitiveValue> radii[4]) |
7239 { | 7239 { |
7240 if (radii[3]) | 7240 if (radii[3]) |
7241 return; | 7241 return; |
7242 if (!radii[2]) { | 7242 if (!radii[2]) { |
7243 if (!radii[1]) | 7243 if (!radii[1]) |
7244 radii[1] = radii[0]; | 7244 radii[1] = radii[0]; |
7245 radii[2] = radii[0]; | 7245 radii[2] = radii[0]; |
7246 } | 7246 } |
7247 radii[3] = radii[1]; | 7247 radii[3] = radii[1]; |
7248 } | 7248 } |
7249 | 7249 |
7250 bool CSSParser::parseBorderRadius(CSSPropertyID propId, bool important) | 7250 bool BisonCSSParser::parseBorderRadius(CSSPropertyID propId, bool important) |
7251 { | 7251 { |
7252 unsigned num = m_valueList->size(); | 7252 unsigned num = m_valueList->size(); |
7253 if (num > 9) | 7253 if (num > 9) |
7254 return false; | 7254 return false; |
7255 | 7255 |
7256 ShorthandScope scope(this, propId); | 7256 ShorthandScope scope(this, propId); |
7257 RefPtr<CSSPrimitiveValue> radii[2][4]; | 7257 RefPtr<CSSPrimitiveValue> radii[2][4]; |
7258 | 7258 |
7259 unsigned indexAfterSlash = 0; | 7259 unsigned indexAfterSlash = 0; |
7260 for (unsigned i = 0; i < num; ++i) { | 7260 for (unsigned i = 0; i < num; ++i) { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7299 completeBorderRadii(radii[1]); | 7299 completeBorderRadii(radii[1]); |
7300 | 7300 |
7301 ImplicitScope implicitScope(this, PropertyImplicit); | 7301 ImplicitScope implicitScope(this, PropertyImplicit); |
7302 addProperty(CSSPropertyBorderTopLeftRadius, createPrimitiveValuePair(radii[0
][0].release(), radii[1][0].release()), important); | 7302 addProperty(CSSPropertyBorderTopLeftRadius, createPrimitiveValuePair(radii[0
][0].release(), radii[1][0].release()), important); |
7303 addProperty(CSSPropertyBorderTopRightRadius, createPrimitiveValuePair(radii[
0][1].release(), radii[1][1].release()), important); | 7303 addProperty(CSSPropertyBorderTopRightRadius, createPrimitiveValuePair(radii[
0][1].release(), radii[1][1].release()), important); |
7304 addProperty(CSSPropertyBorderBottomRightRadius, createPrimitiveValuePair(rad
ii[0][2].release(), radii[1][2].release()), important); | 7304 addProperty(CSSPropertyBorderBottomRightRadius, createPrimitiveValuePair(rad
ii[0][2].release(), radii[1][2].release()), important); |
7305 addProperty(CSSPropertyBorderBottomLeftRadius, createPrimitiveValuePair(radi
i[0][3].release(), radii[1][3].release()), important); | 7305 addProperty(CSSPropertyBorderBottomLeftRadius, createPrimitiveValuePair(radi
i[0][3].release(), radii[1][3].release()), important); |
7306 return true; | 7306 return true; |
7307 } | 7307 } |
7308 | 7308 |
7309 bool CSSParser::parseAspectRatio(bool important) | 7309 bool BisonCSSParser::parseAspectRatio(bool important) |
7310 { | 7310 { |
7311 unsigned num = m_valueList->size(); | 7311 unsigned num = m_valueList->size(); |
7312 if (num == 1 && m_valueList->valueAt(0)->id == CSSValueNone) { | 7312 if (num == 1 && m_valueList->valueAt(0)->id == CSSValueNone) { |
7313 addProperty(CSSPropertyWebkitAspectRatio, cssValuePool().createIdentifie
rValue(CSSValueNone), important); | 7313 addProperty(CSSPropertyWebkitAspectRatio, cssValuePool().createIdentifie
rValue(CSSValueNone), important); |
7314 return true; | 7314 return true; |
7315 } | 7315 } |
7316 | 7316 |
7317 if (num != 3) | 7317 if (num != 3) |
7318 return false; | 7318 return false; |
7319 | 7319 |
7320 CSSParserValue* lvalue = m_valueList->valueAt(0); | 7320 CSSParserValue* lvalue = m_valueList->valueAt(0); |
7321 CSSParserValue* op = m_valueList->valueAt(1); | 7321 CSSParserValue* op = m_valueList->valueAt(1); |
7322 CSSParserValue* rvalue = m_valueList->valueAt(2); | 7322 CSSParserValue* rvalue = m_valueList->valueAt(2); |
7323 | 7323 |
7324 if (!isForwardSlashOperator(op)) | 7324 if (!isForwardSlashOperator(op)) |
7325 return false; | 7325 return false; |
7326 | 7326 |
7327 if (!validUnit(lvalue, FNumber | FNonNeg) || !validUnit(rvalue, FNumber | FN
onNeg)) | 7327 if (!validUnit(lvalue, FNumber | FNonNeg) || !validUnit(rvalue, FNumber | FN
onNeg)) |
7328 return false; | 7328 return false; |
7329 | 7329 |
7330 if (!lvalue->fValue || !rvalue->fValue) | 7330 if (!lvalue->fValue || !rvalue->fValue) |
7331 return false; | 7331 return false; |
7332 | 7332 |
7333 addProperty(CSSPropertyWebkitAspectRatio, CSSAspectRatioValue::create(narrow
PrecisionToFloat(lvalue->fValue), narrowPrecisionToFloat(rvalue->fValue)), impor
tant); | 7333 addProperty(CSSPropertyWebkitAspectRatio, CSSAspectRatioValue::create(narrow
PrecisionToFloat(lvalue->fValue), narrowPrecisionToFloat(rvalue->fValue)), impor
tant); |
7334 | 7334 |
7335 return true; | 7335 return true; |
7336 } | 7336 } |
7337 | 7337 |
7338 bool CSSParser::parseCounter(CSSPropertyID propId, int defaultValue, bool import
ant) | 7338 bool BisonCSSParser::parseCounter(CSSPropertyID propId, int defaultValue, bool i
mportant) |
7339 { | 7339 { |
7340 enum { ID, VAL } state = ID; | 7340 enum { ID, VAL } state = ID; |
7341 | 7341 |
7342 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated(); | 7342 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated(); |
7343 RefPtr<CSSPrimitiveValue> counterName; | 7343 RefPtr<CSSPrimitiveValue> counterName; |
7344 | 7344 |
7345 while (true) { | 7345 while (true) { |
7346 CSSParserValue* val = m_valueList->current(); | 7346 CSSParserValue* val = m_valueList->current(); |
7347 switch (state) { | 7347 switch (state) { |
7348 case ID: | 7348 case ID: |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7388 else if ((equalIgnoringCase(a, "right") && horizontal) | 7388 else if ((equalIgnoringCase(a, "right") && horizontal) |
7389 || (equalIgnoringCase(a, "bottom") && !horizontal)) | 7389 || (equalIgnoringCase(a, "bottom") && !horizontal)) |
7390 result = cssValuePool().createValue(100., CSSPrimitiveValue::CSS_PER
CENTAGE); | 7390 result = cssValuePool().createValue(100., CSSPrimitiveValue::CSS_PER
CENTAGE); |
7391 else if (equalIgnoringCase(a, "center")) | 7391 else if (equalIgnoringCase(a, "center")) |
7392 result = cssValuePool().createValue(50., CSSPrimitiveValue::CSS_PERC
ENTAGE); | 7392 result = cssValuePool().createValue(50., CSSPrimitiveValue::CSS_PERC
ENTAGE); |
7393 } else if (a->unit == CSSPrimitiveValue::CSS_NUMBER || a->unit == CSSPrimiti
veValue::CSS_PERCENTAGE) | 7393 } else if (a->unit == CSSPrimitiveValue::CSS_NUMBER || a->unit == CSSPrimiti
veValue::CSS_PERCENTAGE) |
7394 result = cssValuePool().createValue(a->fValue, static_cast<CSSPrimitiveV
alue::UnitTypes>(a->unit)); | 7394 result = cssValuePool().createValue(a->fValue, static_cast<CSSPrimitiveV
alue::UnitTypes>(a->unit)); |
7395 return result; | 7395 return result; |
7396 } | 7396 } |
7397 | 7397 |
7398 static bool parseDeprecatedGradientColorStop(CSSParser* p, CSSParserValue* a, CS
SGradientColorStop& stop) | 7398 static bool parseDeprecatedGradientColorStop(BisonCSSParser* p, CSSParserValue*
a, CSSGradientColorStop& stop) |
7399 { | 7399 { |
7400 if (a->unit != CSSParserValue::Function) | 7400 if (a->unit != CSSParserValue::Function) |
7401 return false; | 7401 return false; |
7402 | 7402 |
7403 if (!equalIgnoringCase(a->function->name, "from(") && | 7403 if (!equalIgnoringCase(a->function->name, "from(") && |
7404 !equalIgnoringCase(a->function->name, "to(") && | 7404 !equalIgnoringCase(a->function->name, "to(") && |
7405 !equalIgnoringCase(a->function->name, "color-stop(")) | 7405 !equalIgnoringCase(a->function->name, "color-stop(")) |
7406 return false; | 7406 return false; |
7407 | 7407 |
7408 CSSParserValueList* args = a->function->args.get(); | 7408 CSSParserValueList* args = a->function->args.get(); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7452 stop.m_color = cssValuePool().createIdentifierValue(id); | 7452 stop.m_color = cssValuePool().createIdentifierValue(id); |
7453 else | 7453 else |
7454 stop.m_color = p->parseColor(stopArg); | 7454 stop.m_color = p->parseColor(stopArg); |
7455 if (!stop.m_color) | 7455 if (!stop.m_color) |
7456 return false; | 7456 return false; |
7457 } | 7457 } |
7458 | 7458 |
7459 return true; | 7459 return true; |
7460 } | 7460 } |
7461 | 7461 |
7462 bool CSSParser::parseDeprecatedGradient(CSSParserValueList* valueList, RefPtr<CS
SValue>& gradient) | 7462 bool BisonCSSParser::parseDeprecatedGradient(CSSParserValueList* valueList, RefP
tr<CSSValue>& gradient) |
7463 { | 7463 { |
7464 // Walk the arguments. | 7464 // Walk the arguments. |
7465 CSSParserValueList* args = valueList->current()->function->args.get(); | 7465 CSSParserValueList* args = valueList->current()->function->args.get(); |
7466 if (!args || args->size() == 0) | 7466 if (!args || args->size() == 0) |
7467 return false; | 7467 return false; |
7468 | 7468 |
7469 // The first argument is the gradient type. It is an identifier. | 7469 // The first argument is the gradient type. It is an identifier. |
7470 CSSGradientType gradientType; | 7470 CSSGradientType gradientType; |
7471 CSSParserValue* a = args->current(); | 7471 CSSParserValue* a = args->current(); |
7472 if (!a || a->unit != CSSPrimitiveValue::CSS_IDENT) | 7472 if (!a || a->unit != CSSPrimitiveValue::CSS_IDENT) |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7605 case CSSValueTop: | 7605 case CSSValueTop: |
7606 case CSSValueBottom: | 7606 case CSSValueBottom: |
7607 isHorizontal = false; | 7607 isHorizontal = false; |
7608 break; | 7608 break; |
7609 default: | 7609 default: |
7610 return 0; | 7610 return 0; |
7611 } | 7611 } |
7612 return cssValuePool().createIdentifierValue(a->id); | 7612 return cssValuePool().createIdentifierValue(a->id); |
7613 } | 7613 } |
7614 | 7614 |
7615 static PassRefPtr<CSSPrimitiveValue> parseGradientColorOrKeyword(CSSParser* p, C
SSParserValue* value) | 7615 static PassRefPtr<CSSPrimitiveValue> parseGradientColorOrKeyword(BisonCSSParser*
p, CSSParserValue* value) |
7616 { | 7616 { |
7617 CSSValueID id = value->id; | 7617 CSSValueID id = value->id; |
7618 if (id == CSSValueWebkitText || (id >= CSSValueAqua && id <= CSSValueWindowt
ext) || id == CSSValueMenu || id == CSSValueCurrentcolor) | 7618 if (id == CSSValueWebkitText || (id >= CSSValueAqua && id <= CSSValueWindowt
ext) || id == CSSValueMenu || id == CSSValueCurrentcolor) |
7619 return cssValuePool().createIdentifierValue(id); | 7619 return cssValuePool().createIdentifierValue(id); |
7620 | 7620 |
7621 return p->parseColor(value); | 7621 return p->parseColor(value); |
7622 } | 7622 } |
7623 | 7623 |
7624 bool CSSParser::parseDeprecatedLinearGradient(CSSParserValueList* valueList, Ref
Ptr<CSSValue>& gradient, CSSGradientRepeat repeating) | 7624 bool BisonCSSParser::parseDeprecatedLinearGradient(CSSParserValueList* valueList
, RefPtr<CSSValue>& gradient, CSSGradientRepeat repeating) |
7625 { | 7625 { |
7626 RefPtr<CSSLinearGradientValue> result = CSSLinearGradientValue::create(repea
ting, CSSPrefixedLinearGradient); | 7626 RefPtr<CSSLinearGradientValue> result = CSSLinearGradientValue::create(repea
ting, CSSPrefixedLinearGradient); |
7627 | 7627 |
7628 // Walk the arguments. | 7628 // Walk the arguments. |
7629 CSSParserValueList* args = valueList->current()->function->args.get(); | 7629 CSSParserValueList* args = valueList->current()->function->args.get(); |
7630 if (!args || !args->size()) | 7630 if (!args || !args->size()) |
7631 return false; | 7631 return false; |
7632 | 7632 |
7633 CSSParserValue* a = args->current(); | 7633 CSSParserValue* a = args->current(); |
7634 if (!a) | 7634 if (!a) |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7682 if (!parseGradientColorStops(args, result.get(), expectComma)) | 7682 if (!parseGradientColorStops(args, result.get(), expectComma)) |
7683 return false; | 7683 return false; |
7684 | 7684 |
7685 if (!result->stopCount()) | 7685 if (!result->stopCount()) |
7686 return false; | 7686 return false; |
7687 | 7687 |
7688 gradient = result.release(); | 7688 gradient = result.release(); |
7689 return true; | 7689 return true; |
7690 } | 7690 } |
7691 | 7691 |
7692 bool CSSParser::parseDeprecatedRadialGradient(CSSParserValueList* valueList, Ref
Ptr<CSSValue>& gradient, CSSGradientRepeat repeating) | 7692 bool BisonCSSParser::parseDeprecatedRadialGradient(CSSParserValueList* valueList
, RefPtr<CSSValue>& gradient, CSSGradientRepeat repeating) |
7693 { | 7693 { |
7694 RefPtr<CSSRadialGradientValue> result = CSSRadialGradientValue::create(repea
ting, CSSPrefixedRadialGradient); | 7694 RefPtr<CSSRadialGradientValue> result = CSSRadialGradientValue::create(repea
ting, CSSPrefixedRadialGradient); |
7695 | 7695 |
7696 // Walk the arguments. | 7696 // Walk the arguments. |
7697 CSSParserValueList* args = valueList->current()->function->args.get(); | 7697 CSSParserValueList* args = valueList->current()->function->args.get(); |
7698 if (!args || !args->size()) | 7698 if (!args || !args->size()) |
7699 return false; | 7699 return false; |
7700 | 7700 |
7701 CSSParserValue* a = args->current(); | 7701 CSSParserValue* a = args->current(); |
7702 if (!a) | 7702 if (!a) |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7800 result->setEndHorizontalSize(horizontalSize); | 7800 result->setEndHorizontalSize(horizontalSize); |
7801 result->setEndVerticalSize(verticalSize); | 7801 result->setEndVerticalSize(verticalSize); |
7802 | 7802 |
7803 if (!parseGradientColorStops(args, result.get(), expectComma)) | 7803 if (!parseGradientColorStops(args, result.get(), expectComma)) |
7804 return false; | 7804 return false; |
7805 | 7805 |
7806 gradient = result.release(); | 7806 gradient = result.release(); |
7807 return true; | 7807 return true; |
7808 } | 7808 } |
7809 | 7809 |
7810 bool CSSParser::parseLinearGradient(CSSParserValueList* valueList, RefPtr<CSSVal
ue>& gradient, CSSGradientRepeat repeating) | 7810 bool BisonCSSParser::parseLinearGradient(CSSParserValueList* valueList, RefPtr<C
SSValue>& gradient, CSSGradientRepeat repeating) |
7811 { | 7811 { |
7812 RefPtr<CSSLinearGradientValue> result = CSSLinearGradientValue::create(repea
ting, CSSLinearGradient); | 7812 RefPtr<CSSLinearGradientValue> result = CSSLinearGradientValue::create(repea
ting, CSSLinearGradient); |
7813 | 7813 |
7814 CSSParserValueList* args = valueList->current()->function->args.get(); | 7814 CSSParserValueList* args = valueList->current()->function->args.get(); |
7815 if (!args || !args->size()) | 7815 if (!args || !args->size()) |
7816 return false; | 7816 return false; |
7817 | 7817 |
7818 CSSParserValue* a = args->current(); | 7818 CSSParserValue* a = args->current(); |
7819 if (!a) | 7819 if (!a) |
7820 return false; | 7820 return false; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7872 if (!parseGradientColorStops(args, result.get(), expectComma)) | 7872 if (!parseGradientColorStops(args, result.get(), expectComma)) |
7873 return false; | 7873 return false; |
7874 | 7874 |
7875 if (!result->stopCount()) | 7875 if (!result->stopCount()) |
7876 return false; | 7876 return false; |
7877 | 7877 |
7878 gradient = result.release(); | 7878 gradient = result.release(); |
7879 return true; | 7879 return true; |
7880 } | 7880 } |
7881 | 7881 |
7882 bool CSSParser::parseRadialGradient(CSSParserValueList* valueList, RefPtr<CSSVal
ue>& gradient, CSSGradientRepeat repeating) | 7882 bool BisonCSSParser::parseRadialGradient(CSSParserValueList* valueList, RefPtr<C
SSValue>& gradient, CSSGradientRepeat repeating) |
7883 { | 7883 { |
7884 RefPtr<CSSRadialGradientValue> result = CSSRadialGradientValue::create(repea
ting, CSSRadialGradient); | 7884 RefPtr<CSSRadialGradientValue> result = CSSRadialGradientValue::create(repea
ting, CSSRadialGradient); |
7885 | 7885 |
7886 CSSParserValueList* args = valueList->current()->function->args.get(); | 7886 CSSParserValueList* args = valueList->current()->function->args.get(); |
7887 if (!args || !args->size()) | 7887 if (!args || !args->size()) |
7888 return false; | 7888 return false; |
7889 | 7889 |
7890 CSSParserValue* a = args->current(); | 7890 CSSParserValue* a = args->current(); |
7891 if (!a) | 7891 if (!a) |
7892 return false; | 7892 return false; |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7995 if (shapeValue || sizeValue || horizontalSize || centerX || centerY) | 7995 if (shapeValue || sizeValue || horizontalSize || centerX || centerY) |
7996 expectComma = true; | 7996 expectComma = true; |
7997 | 7997 |
7998 if (!parseGradientColorStops(args, result.get(), expectComma)) | 7998 if (!parseGradientColorStops(args, result.get(), expectComma)) |
7999 return false; | 7999 return false; |
8000 | 8000 |
8001 gradient = result.release(); | 8001 gradient = result.release(); |
8002 return true; | 8002 return true; |
8003 } | 8003 } |
8004 | 8004 |
8005 bool CSSParser::parseGradientColorStops(CSSParserValueList* valueList, CSSGradie
ntValue* gradient, bool expectComma) | 8005 bool BisonCSSParser::parseGradientColorStops(CSSParserValueList* valueList, CSSG
radientValue* gradient, bool expectComma) |
8006 { | 8006 { |
8007 CSSParserValue* a = valueList->current(); | 8007 CSSParserValue* a = valueList->current(); |
8008 | 8008 |
8009 // Now look for color stops. | 8009 // Now look for color stops. |
8010 while (a) { | 8010 while (a) { |
8011 // Look for the comma before the next stop. | 8011 // Look for the comma before the next stop. |
8012 if (expectComma) { | 8012 if (expectComma) { |
8013 if (!isComma(a)) | 8013 if (!isComma(a)) |
8014 return false; | 8014 return false; |
8015 | 8015 |
(...skipping 17 matching lines...) Expand all Loading... |
8033 } | 8033 } |
8034 | 8034 |
8035 gradient->addStop(stop); | 8035 gradient->addStop(stop); |
8036 expectComma = true; | 8036 expectComma = true; |
8037 } | 8037 } |
8038 | 8038 |
8039 // Must have 2 or more stops to be valid. | 8039 // Must have 2 or more stops to be valid. |
8040 return gradient->stopCount() >= 2; | 8040 return gradient->stopCount() >= 2; |
8041 } | 8041 } |
8042 | 8042 |
8043 bool CSSParser::parseGeneratedImage(CSSParserValueList* valueList, RefPtr<CSSVal
ue>& value) | 8043 bool BisonCSSParser::parseGeneratedImage(CSSParserValueList* valueList, RefPtr<C
SSValue>& value) |
8044 { | 8044 { |
8045 CSSParserValue* val = valueList->current(); | 8045 CSSParserValue* val = valueList->current(); |
8046 | 8046 |
8047 if (val->unit != CSSParserValue::Function) | 8047 if (val->unit != CSSParserValue::Function) |
8048 return false; | 8048 return false; |
8049 | 8049 |
8050 if (equalIgnoringCase(val->function->name, "-webkit-gradient(")) | 8050 if (equalIgnoringCase(val->function->name, "-webkit-gradient(")) |
8051 return parseDeprecatedGradient(valueList, value); | 8051 return parseDeprecatedGradient(valueList, value); |
8052 | 8052 |
8053 if (equalIgnoringCase(val->function->name, "-webkit-linear-gradient(")) | 8053 if (equalIgnoringCase(val->function->name, "-webkit-linear-gradient(")) |
(...skipping 22 matching lines...) Expand all Loading... |
8076 | 8076 |
8077 if (equalIgnoringCase(val->function->name, "-webkit-canvas(")) | 8077 if (equalIgnoringCase(val->function->name, "-webkit-canvas(")) |
8078 return parseCanvas(valueList, value); | 8078 return parseCanvas(valueList, value); |
8079 | 8079 |
8080 if (equalIgnoringCase(val->function->name, "-webkit-cross-fade(")) | 8080 if (equalIgnoringCase(val->function->name, "-webkit-cross-fade(")) |
8081 return parseCrossfade(valueList, value); | 8081 return parseCrossfade(valueList, value); |
8082 | 8082 |
8083 return false; | 8083 return false; |
8084 } | 8084 } |
8085 | 8085 |
8086 bool CSSParser::parseCrossfade(CSSParserValueList* valueList, RefPtr<CSSValue>&
crossfade) | 8086 bool BisonCSSParser::parseCrossfade(CSSParserValueList* valueList, RefPtr<CSSVal
ue>& crossfade) |
8087 { | 8087 { |
8088 RefPtr<CSSCrossfadeValue> result; | 8088 RefPtr<CSSCrossfadeValue> result; |
8089 | 8089 |
8090 // Walk the arguments. | 8090 // Walk the arguments. |
8091 CSSParserValueList* args = valueList->current()->function->args.get(); | 8091 CSSParserValueList* args = valueList->current()->function->args.get(); |
8092 if (!args || args->size() != 5) | 8092 if (!args || args->size() != 5) |
8093 return false; | 8093 return false; |
8094 CSSParserValue* a = args->current(); | 8094 CSSParserValue* a = args->current(); |
8095 RefPtr<CSSValue> fromImageValue; | 8095 RefPtr<CSSValue> fromImageValue; |
8096 RefPtr<CSSValue> toImageValue; | 8096 RefPtr<CSSValue> toImageValue; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8128 return false; | 8128 return false; |
8129 | 8129 |
8130 result = CSSCrossfadeValue::create(fromImageValue, toImageValue); | 8130 result = CSSCrossfadeValue::create(fromImageValue, toImageValue); |
8131 result->setPercentage(percentage); | 8131 result->setPercentage(percentage); |
8132 | 8132 |
8133 crossfade = result; | 8133 crossfade = result; |
8134 | 8134 |
8135 return true; | 8135 return true; |
8136 } | 8136 } |
8137 | 8137 |
8138 bool CSSParser::parseCanvas(CSSParserValueList* valueList, RefPtr<CSSValue>& can
vas) | 8138 bool BisonCSSParser::parseCanvas(CSSParserValueList* valueList, RefPtr<CSSValue>
& canvas) |
8139 { | 8139 { |
8140 // Walk the arguments. | 8140 // Walk the arguments. |
8141 CSSParserValueList* args = valueList->current()->function->args.get(); | 8141 CSSParserValueList* args = valueList->current()->function->args.get(); |
8142 if (!args || args->size() != 1) | 8142 if (!args || args->size() != 1) |
8143 return false; | 8143 return false; |
8144 | 8144 |
8145 // The first argument is the canvas name. It is an identifier. | 8145 // The first argument is the canvas name. It is an identifier. |
8146 CSSParserValue* value = args->current(); | 8146 CSSParserValue* value = args->current(); |
8147 if (!value || value->unit != CSSPrimitiveValue::CSS_IDENT) | 8147 if (!value || value->unit != CSSPrimitiveValue::CSS_IDENT) |
8148 return false; | 8148 return false; |
8149 | 8149 |
8150 canvas = CSSCanvasValue::create(value->string); | 8150 canvas = CSSCanvasValue::create(value->string); |
8151 return true; | 8151 return true; |
8152 } | 8152 } |
8153 | 8153 |
8154 PassRefPtr<CSSValue> CSSParser::parseImageSet(CSSParserValueList* valueList) | 8154 PassRefPtr<CSSValue> BisonCSSParser::parseImageSet(CSSParserValueList* valueList
) |
8155 { | 8155 { |
8156 CSSParserValue* function = valueList->current(); | 8156 CSSParserValue* function = valueList->current(); |
8157 | 8157 |
8158 if (function->unit != CSSParserValue::Function) | 8158 if (function->unit != CSSParserValue::Function) |
8159 return 0; | 8159 return 0; |
8160 | 8160 |
8161 CSSParserValueList* functionArgs = valueList->current()->function->args.get(
); | 8161 CSSParserValueList* functionArgs = valueList->current()->function->args.get(
); |
8162 if (!functionArgs || !functionArgs->size() || !functionArgs->current()) | 8162 if (!functionArgs || !functionArgs->size() || !functionArgs->current()) |
8163 return 0; | 8163 return 0; |
8164 | 8164 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8207 | 8207 |
8208 return imageSet.release(); | 8208 return imageSet.release(); |
8209 } | 8209 } |
8210 | 8210 |
8211 class TransformOperationInfo { | 8211 class TransformOperationInfo { |
8212 public: | 8212 public: |
8213 TransformOperationInfo(const CSSParserString& name) | 8213 TransformOperationInfo(const CSSParserString& name) |
8214 : m_type(CSSTransformValue::UnknownTransformOperation) | 8214 : m_type(CSSTransformValue::UnknownTransformOperation) |
8215 , m_argCount(1) | 8215 , m_argCount(1) |
8216 , m_allowSingleArgument(false) | 8216 , m_allowSingleArgument(false) |
8217 , m_unit(CSSParser::FUnknown) | 8217 , m_unit(BisonCSSParser::FUnknown) |
8218 { | 8218 { |
8219 const UChar* characters; | 8219 const UChar* characters; |
8220 unsigned nameLength = name.length(); | 8220 unsigned nameLength = name.length(); |
8221 | 8221 |
8222 const unsigned longestNameLength = 12; | 8222 const unsigned longestNameLength = 12; |
8223 UChar characterBuffer[longestNameLength]; | 8223 UChar characterBuffer[longestNameLength]; |
8224 if (name.is8Bit()) { | 8224 if (name.is8Bit()) { |
8225 unsigned length = std::min(longestNameLength, nameLength); | 8225 unsigned length = std::min(longestNameLength, nameLength); |
8226 const LChar* characters8 = name.characters8(); | 8226 const LChar* characters8 = name.characters8(); |
8227 for (unsigned i = 0; i < length; ++i) | 8227 for (unsigned i = 0; i < length; ++i) |
8228 characterBuffer[i] = characters8[i]; | 8228 characterBuffer[i] = characters8[i]; |
8229 characters = characterBuffer; | 8229 characters = characterBuffer; |
8230 } else | 8230 } else |
8231 characters = name.characters16(); | 8231 characters = name.characters16(); |
8232 | 8232 |
8233 SWITCH(characters, nameLength) { | 8233 SWITCH(characters, nameLength) { |
8234 CASE("skew(") { | 8234 CASE("skew(") { |
8235 m_unit = CSSParser::FAngle; | 8235 m_unit = BisonCSSParser::FAngle; |
8236 m_type = CSSTransformValue::SkewTransformOperation; | 8236 m_type = CSSTransformValue::SkewTransformOperation; |
8237 m_allowSingleArgument = true; | 8237 m_allowSingleArgument = true; |
8238 m_argCount = 3; | 8238 m_argCount = 3; |
8239 } | 8239 } |
8240 CASE("scale(") { | 8240 CASE("scale(") { |
8241 m_unit = CSSParser::FNumber; | 8241 m_unit = BisonCSSParser::FNumber; |
8242 m_type = CSSTransformValue::ScaleTransformOperation; | 8242 m_type = CSSTransformValue::ScaleTransformOperation; |
8243 m_allowSingleArgument = true; | 8243 m_allowSingleArgument = true; |
8244 m_argCount = 3; | 8244 m_argCount = 3; |
8245 } | 8245 } |
8246 CASE("skewx(") { | 8246 CASE("skewx(") { |
8247 m_unit = CSSParser::FAngle; | 8247 m_unit = BisonCSSParser::FAngle; |
8248 m_type = CSSTransformValue::SkewXTransformOperation; | 8248 m_type = CSSTransformValue::SkewXTransformOperation; |
8249 } | 8249 } |
8250 CASE("skewy(") { | 8250 CASE("skewy(") { |
8251 m_unit = CSSParser::FAngle; | 8251 m_unit = BisonCSSParser::FAngle; |
8252 m_type = CSSTransformValue::SkewYTransformOperation; | 8252 m_type = CSSTransformValue::SkewYTransformOperation; |
8253 } | 8253 } |
8254 CASE("matrix(") { | 8254 CASE("matrix(") { |
8255 m_unit = CSSParser::FNumber; | 8255 m_unit = BisonCSSParser::FNumber; |
8256 m_type = CSSTransformValue::MatrixTransformOperation; | 8256 m_type = CSSTransformValue::MatrixTransformOperation; |
8257 m_argCount = 11; | 8257 m_argCount = 11; |
8258 } | 8258 } |
8259 CASE("rotate(") { | 8259 CASE("rotate(") { |
8260 m_unit = CSSParser::FAngle; | 8260 m_unit = BisonCSSParser::FAngle; |
8261 m_type = CSSTransformValue::RotateTransformOperation; | 8261 m_type = CSSTransformValue::RotateTransformOperation; |
8262 } | 8262 } |
8263 CASE("scalex(") { | 8263 CASE("scalex(") { |
8264 m_unit = CSSParser::FNumber; | 8264 m_unit = BisonCSSParser::FNumber; |
8265 m_type = CSSTransformValue::ScaleXTransformOperation; | 8265 m_type = CSSTransformValue::ScaleXTransformOperation; |
8266 } | 8266 } |
8267 CASE("scaley(") { | 8267 CASE("scaley(") { |
8268 m_unit = CSSParser::FNumber; | 8268 m_unit = BisonCSSParser::FNumber; |
8269 m_type = CSSTransformValue::ScaleYTransformOperation; | 8269 m_type = CSSTransformValue::ScaleYTransformOperation; |
8270 } | 8270 } |
8271 CASE("scalez(") { | 8271 CASE("scalez(") { |
8272 m_unit = CSSParser::FNumber; | 8272 m_unit = BisonCSSParser::FNumber; |
8273 m_type = CSSTransformValue::ScaleZTransformOperation; | 8273 m_type = CSSTransformValue::ScaleZTransformOperation; |
8274 } | 8274 } |
8275 CASE("scale3d(") { | 8275 CASE("scale3d(") { |
8276 m_unit = CSSParser::FNumber; | 8276 m_unit = BisonCSSParser::FNumber; |
8277 m_type = CSSTransformValue::Scale3DTransformOperation; | 8277 m_type = CSSTransformValue::Scale3DTransformOperation; |
8278 m_argCount = 5; | 8278 m_argCount = 5; |
8279 } | 8279 } |
8280 CASE("rotatex(") { | 8280 CASE("rotatex(") { |
8281 m_unit = CSSParser::FAngle; | 8281 m_unit = BisonCSSParser::FAngle; |
8282 m_type = CSSTransformValue::RotateXTransformOperation; | 8282 m_type = CSSTransformValue::RotateXTransformOperation; |
8283 } | 8283 } |
8284 CASE("rotatey(") { | 8284 CASE("rotatey(") { |
8285 m_unit = CSSParser::FAngle; | 8285 m_unit = BisonCSSParser::FAngle; |
8286 m_type = CSSTransformValue::RotateYTransformOperation; | 8286 m_type = CSSTransformValue::RotateYTransformOperation; |
8287 } | 8287 } |
8288 CASE("rotatez(") { | 8288 CASE("rotatez(") { |
8289 m_unit = CSSParser::FAngle; | 8289 m_unit = BisonCSSParser::FAngle; |
8290 m_type = CSSTransformValue::RotateZTransformOperation; | 8290 m_type = CSSTransformValue::RotateZTransformOperation; |
8291 } | 8291 } |
8292 CASE("matrix3d(") { | 8292 CASE("matrix3d(") { |
8293 m_unit = CSSParser::FNumber; | 8293 m_unit = BisonCSSParser::FNumber; |
8294 m_type = CSSTransformValue::Matrix3DTransformOperation; | 8294 m_type = CSSTransformValue::Matrix3DTransformOperation; |
8295 m_argCount = 31; | 8295 m_argCount = 31; |
8296 } | 8296 } |
8297 CASE("rotate3d(") { | 8297 CASE("rotate3d(") { |
8298 m_unit = CSSParser::FNumber; | 8298 m_unit = BisonCSSParser::FNumber; |
8299 m_type = CSSTransformValue::Rotate3DTransformOperation; | 8299 m_type = CSSTransformValue::Rotate3DTransformOperation; |
8300 m_argCount = 7; | 8300 m_argCount = 7; |
8301 } | 8301 } |
8302 CASE("translate(") { | 8302 CASE("translate(") { |
8303 m_unit = CSSParser::FLength | CSSParser::FPercent; | 8303 m_unit = BisonCSSParser::FLength | BisonCSSParser::FPercent; |
8304 m_type = CSSTransformValue::TranslateTransformOperation; | 8304 m_type = CSSTransformValue::TranslateTransformOperation; |
8305 m_allowSingleArgument = true; | 8305 m_allowSingleArgument = true; |
8306 m_argCount = 3; | 8306 m_argCount = 3; |
8307 } | 8307 } |
8308 CASE("translatex(") { | 8308 CASE("translatex(") { |
8309 m_unit = CSSParser::FLength | CSSParser::FPercent; | 8309 m_unit = BisonCSSParser::FLength | BisonCSSParser::FPercent; |
8310 m_type = CSSTransformValue::TranslateXTransformOperation; | 8310 m_type = CSSTransformValue::TranslateXTransformOperation; |
8311 } | 8311 } |
8312 CASE("translatey(") { | 8312 CASE("translatey(") { |
8313 m_unit = CSSParser::FLength | CSSParser::FPercent; | 8313 m_unit = BisonCSSParser::FLength | BisonCSSParser::FPercent; |
8314 m_type = CSSTransformValue::TranslateYTransformOperation; | 8314 m_type = CSSTransformValue::TranslateYTransformOperation; |
8315 } | 8315 } |
8316 CASE("translatez(") { | 8316 CASE("translatez(") { |
8317 m_unit = CSSParser::FLength | CSSParser::FPercent; | 8317 m_unit = BisonCSSParser::FLength | BisonCSSParser::FPercent; |
8318 m_type = CSSTransformValue::TranslateZTransformOperation; | 8318 m_type = CSSTransformValue::TranslateZTransformOperation; |
8319 } | 8319 } |
8320 CASE("perspective(") { | 8320 CASE("perspective(") { |
8321 m_unit = CSSParser::FNumber; | 8321 m_unit = BisonCSSParser::FNumber; |
8322 m_type = CSSTransformValue::PerspectiveTransformOperation; | 8322 m_type = CSSTransformValue::PerspectiveTransformOperation; |
8323 } | 8323 } |
8324 CASE("translate3d(") { | 8324 CASE("translate3d(") { |
8325 m_unit = CSSParser::FLength | CSSParser::FPercent; | 8325 m_unit = BisonCSSParser::FLength | BisonCSSParser::FPercent; |
8326 m_type = CSSTransformValue::Translate3DTransformOperation; | 8326 m_type = CSSTransformValue::Translate3DTransformOperation; |
8327 m_argCount = 5; | 8327 m_argCount = 5; |
8328 } | 8328 } |
8329 } | 8329 } |
8330 } | 8330 } |
8331 | 8331 |
8332 CSSTransformValue::TransformOperationType type() const { return m_type; } | 8332 CSSTransformValue::TransformOperationType type() const { return m_type; } |
8333 unsigned argCount() const { return m_argCount; } | 8333 unsigned argCount() const { return m_argCount; } |
8334 CSSParser::Units unit() const { return m_unit; } | 8334 BisonCSSParser::Units unit() const { return m_unit; } |
8335 | 8335 |
8336 bool unknown() const { return m_type == CSSTransformValue::UnknownTransformO
peration; } | 8336 bool unknown() const { return m_type == CSSTransformValue::UnknownTransformO
peration; } |
8337 bool hasCorrectArgCount(unsigned argCount) { return m_argCount == argCount |
| (m_allowSingleArgument && argCount == 1); } | 8337 bool hasCorrectArgCount(unsigned argCount) { return m_argCount == argCount |
| (m_allowSingleArgument && argCount == 1); } |
8338 | 8338 |
8339 private: | 8339 private: |
8340 CSSTransformValue::TransformOperationType m_type; | 8340 CSSTransformValue::TransformOperationType m_type; |
8341 unsigned m_argCount; | 8341 unsigned m_argCount; |
8342 bool m_allowSingleArgument; | 8342 bool m_allowSingleArgument; |
8343 CSSParser::Units m_unit; | 8343 BisonCSSParser::Units m_unit; |
8344 }; | 8344 }; |
8345 | 8345 |
8346 PassRefPtr<CSSValueList> CSSParser::parseTransform() | 8346 PassRefPtr<CSSValueList> BisonCSSParser::parseTransform() |
8347 { | 8347 { |
8348 if (!m_valueList) | 8348 if (!m_valueList) |
8349 return 0; | 8349 return 0; |
8350 | 8350 |
8351 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); | 8351 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); |
8352 for (CSSParserValue* value = m_valueList->current(); value; value = m_valueL
ist->next()) { | 8352 for (CSSParserValue* value = m_valueList->current(); value; value = m_valueL
ist->next()) { |
8353 RefPtr<CSSValue> parsedTransformValue = parseTransformValue(value); | 8353 RefPtr<CSSValue> parsedTransformValue = parseTransformValue(value); |
8354 if (!parsedTransformValue) | 8354 if (!parsedTransformValue) |
8355 return 0; | 8355 return 0; |
8356 | 8356 |
8357 list->append(parsedTransformValue.release()); | 8357 list->append(parsedTransformValue.release()); |
8358 } | 8358 } |
8359 | 8359 |
8360 return list.release(); | 8360 return list.release(); |
8361 } | 8361 } |
8362 | 8362 |
8363 PassRefPtr<CSSValue> CSSParser::parseTransformValue(CSSParserValue *value) | 8363 PassRefPtr<CSSValue> BisonCSSParser::parseTransformValue(CSSParserValue *value) |
8364 { | 8364 { |
8365 if (value->unit != CSSParserValue::Function || !value->function) | 8365 if (value->unit != CSSParserValue::Function || !value->function) |
8366 return 0; | 8366 return 0; |
8367 | 8367 |
8368 // Every primitive requires at least one argument. | 8368 // Every primitive requires at least one argument. |
8369 CSSParserValueList* args = value->function->args.get(); | 8369 CSSParserValueList* args = value->function->args.get(); |
8370 if (!args) | 8370 if (!args) |
8371 return 0; | 8371 return 0; |
8372 | 8372 |
8373 // See if the specified primitive is one we understand. | 8373 // See if the specified primitive is one we understand. |
8374 TransformOperationInfo info(value->function->name); | 8374 TransformOperationInfo info(value->function->name); |
8375 if (info.unknown()) | 8375 if (info.unknown()) |
8376 return 0; | 8376 return 0; |
8377 | 8377 |
8378 if (!info.hasCorrectArgCount(args->size())) | 8378 if (!info.hasCorrectArgCount(args->size())) |
8379 return 0; | 8379 return 0; |
8380 | 8380 |
8381 // The transform is a list of functional primitives that specify transform o
perations. | 8381 // The transform is a list of functional primitives that specify transform o
perations. |
8382 // We collect a list of CSSTransformValues, where each value specifies a sin
gle operation. | 8382 // We collect a list of CSSTransformValues, where each value specifies a sin
gle operation. |
8383 | 8383 |
8384 // Create the new CSSTransformValue for this operation and add it to our lis
t. | 8384 // Create the new CSSTransformValue for this operation and add it to our lis
t. |
8385 RefPtr<CSSTransformValue> transformValue = CSSTransformValue::create(info.ty
pe()); | 8385 RefPtr<CSSTransformValue> transformValue = CSSTransformValue::create(info.ty
pe()); |
8386 | 8386 |
8387 // Snag our values. | 8387 // Snag our values. |
8388 CSSParserValue* a = args->current(); | 8388 CSSParserValue* a = args->current(); |
8389 unsigned argNumber = 0; | 8389 unsigned argNumber = 0; |
8390 while (a) { | 8390 while (a) { |
8391 CSSParser::Units unit = info.unit(); | 8391 BisonCSSParser::Units unit = info.unit(); |
8392 | 8392 |
8393 if (info.type() == CSSTransformValue::Rotate3DTransformOperation && argN
umber == 3) { | 8393 if (info.type() == CSSTransformValue::Rotate3DTransformOperation && argN
umber == 3) { |
8394 // 4th param of rotate3d() is an angle rather than a bare number, va
lidate it as such | 8394 // 4th param of rotate3d() is an angle rather than a bare number, va
lidate it as such |
8395 if (!validUnit(a, FAngle, HTMLStandardMode)) | 8395 if (!validUnit(a, FAngle, HTMLStandardMode)) |
8396 return 0; | 8396 return 0; |
8397 } else if (info.type() == CSSTransformValue::Translate3DTransformOperati
on && argNumber == 2) { | 8397 } else if (info.type() == CSSTransformValue::Translate3DTransformOperati
on && argNumber == 2) { |
8398 // 3rd param of translate3d() cannot be a percentage | 8398 // 3rd param of translate3d() cannot be a percentage |
8399 if (!validUnit(a, FLength, HTMLStandardMode)) | 8399 if (!validUnit(a, FLength, HTMLStandardMode)) |
8400 return 0; | 8400 return 0; |
8401 } else if (info.type() == CSSTransformValue::TranslateZTransformOperatio
n && !argNumber) { | 8401 } else if (info.type() == CSSTransformValue::TranslateZTransformOperatio
n && !argNumber) { |
(...skipping 16 matching lines...) Expand all Loading... |
8418 if (a->unit != CSSParserValue::Operator || a->iValue != ',') | 8418 if (a->unit != CSSParserValue::Operator || a->iValue != ',') |
8419 return 0; | 8419 return 0; |
8420 a = args->next(); | 8420 a = args->next(); |
8421 | 8421 |
8422 argNumber++; | 8422 argNumber++; |
8423 } | 8423 } |
8424 | 8424 |
8425 return transformValue.release(); | 8425 return transformValue.release(); |
8426 } | 8426 } |
8427 | 8427 |
8428 bool CSSParser::isBlendMode(CSSValueID valueID) | 8428 bool BisonCSSParser::isBlendMode(CSSValueID valueID) |
8429 { | 8429 { |
8430 return (valueID >= CSSValueMultiply && valueID <= CSSValueLuminosity) | 8430 return (valueID >= CSSValueMultiply && valueID <= CSSValueLuminosity) |
8431 || valueID == CSSValueNormal | 8431 || valueID == CSSValueNormal |
8432 || valueID == CSSValueOverlay; | 8432 || valueID == CSSValueOverlay; |
8433 } | 8433 } |
8434 | 8434 |
8435 bool CSSParser::isCompositeOperator(CSSValueID valueID) | 8435 bool BisonCSSParser::isCompositeOperator(CSSValueID valueID) |
8436 { | 8436 { |
8437 // FIXME: Add CSSValueDestination and CSSValueLighter when the Compositing s
pec updates. | 8437 // FIXME: Add CSSValueDestination and CSSValueLighter when the Compositing s
pec updates. |
8438 return valueID >= CSSValueClear && valueID <= CSSValueXor; | 8438 return valueID >= CSSValueClear && valueID <= CSSValueXor; |
8439 } | 8439 } |
8440 | 8440 |
8441 static void filterInfoForName(const CSSParserString& name, CSSFilterValue::Filte
rOperationType& filterType, unsigned& maximumArgumentCount) | 8441 static void filterInfoForName(const CSSParserString& name, CSSFilterValue::Filte
rOperationType& filterType, unsigned& maximumArgumentCount) |
8442 { | 8442 { |
8443 if (equalIgnoringCase(name, "grayscale(")) | 8443 if (equalIgnoringCase(name, "grayscale(")) |
8444 filterType = CSSFilterValue::GrayscaleFilterOperation; | 8444 filterType = CSSFilterValue::GrayscaleFilterOperation; |
8445 else if (equalIgnoringCase(name, "sepia(")) | 8445 else if (equalIgnoringCase(name, "sepia(")) |
(...skipping 23 matching lines...) Expand all Loading... |
8469 static bool acceptCommaOperator(CSSParserValueList* argsList) | 8469 static bool acceptCommaOperator(CSSParserValueList* argsList) |
8470 { | 8470 { |
8471 if (CSSParserValue* arg = argsList->current()) { | 8471 if (CSSParserValue* arg = argsList->current()) { |
8472 if (!isComma(arg)) | 8472 if (!isComma(arg)) |
8473 return false; | 8473 return false; |
8474 argsList->next(); | 8474 argsList->next(); |
8475 } | 8475 } |
8476 return true; | 8476 return true; |
8477 } | 8477 } |
8478 | 8478 |
8479 PassRefPtr<CSSArrayFunctionValue> CSSParser::parseCustomFilterArrayFunction(CSSP
arserValue* value) | 8479 PassRefPtr<CSSArrayFunctionValue> BisonCSSParser::parseCustomFilterArrayFunction
(CSSParserValue* value) |
8480 { | 8480 { |
8481 ASSERT(value->unit == CSSParserValue::Function && value->function); | 8481 ASSERT(value->unit == CSSParserValue::Function && value->function); |
8482 | 8482 |
8483 if (!equalIgnoringCase(value->function->name, "array(")) | 8483 if (!equalIgnoringCase(value->function->name, "array(")) |
8484 return 0; | 8484 return 0; |
8485 | 8485 |
8486 CSSParserValueList* arrayArgsParserValueList = value->function->args.get(); | 8486 CSSParserValueList* arrayArgsParserValueList = value->function->args.get(); |
8487 if (!arrayArgsParserValueList || !arrayArgsParserValueList->size()) | 8487 if (!arrayArgsParserValueList || !arrayArgsParserValueList->size()) |
8488 return 0; | 8488 return 0; |
8489 | 8489 |
(...skipping 14 matching lines...) Expand all Loading... |
8504 | 8504 |
8505 if (!isComma(nextParserValue)) | 8505 if (!isComma(nextParserValue)) |
8506 return 0; | 8506 return 0; |
8507 | 8507 |
8508 arrayArgsParserValueList->next(); | 8508 arrayArgsParserValueList->next(); |
8509 } | 8509 } |
8510 | 8510 |
8511 return arrayFunction; | 8511 return arrayFunction; |
8512 } | 8512 } |
8513 | 8513 |
8514 PassRefPtr<CSSMixFunctionValue> CSSParser::parseMixFunction(CSSParserValue* valu
e) | 8514 PassRefPtr<CSSMixFunctionValue> BisonCSSParser::parseMixFunction(CSSParserValue*
value) |
8515 { | 8515 { |
8516 ASSERT(value->unit == CSSParserValue::Function && value->function); | 8516 ASSERT(value->unit == CSSParserValue::Function && value->function); |
8517 | 8517 |
8518 if (!equalIgnoringCase(value->function->name, "mix(")) | 8518 if (!equalIgnoringCase(value->function->name, "mix(")) |
8519 return 0; | 8519 return 0; |
8520 | 8520 |
8521 CSSParserValueList* argsList = value->function->args.get(); | 8521 CSSParserValueList* argsList = value->function->args.get(); |
8522 if (!argsList) | 8522 if (!argsList) |
8523 return 0; | 8523 return 0; |
8524 | 8524 |
(...skipping 27 matching lines...) Expand all Loading... |
8552 | 8552 |
8553 if (!value) | 8553 if (!value) |
8554 return 0; | 8554 return 0; |
8555 | 8555 |
8556 mixFunction->append(value.release()); | 8556 mixFunction->append(value.release()); |
8557 } | 8557 } |
8558 | 8558 |
8559 return mixFunction; | 8559 return mixFunction; |
8560 } | 8560 } |
8561 | 8561 |
8562 PassRefPtr<CSSValueList> CSSParser::parseCustomFilterParameters(CSSParserValueLi
st* argsList) | 8562 PassRefPtr<CSSValueList> BisonCSSParser::parseCustomFilterParameters(CSSParserVa
lueList* argsList) |
8563 { | 8563 { |
8564 // | 8564 // |
8565 // params: [<param-def>[,<param-def>*]] | 8565 // params: [<param-def>[,<param-def>*]] |
8566 // param-def: <param-name>wsp<param-value> | 8566 // param-def: <param-name>wsp<param-value> |
8567 // param-name: <ident> | 8567 // param-name: <ident> |
8568 // param-value: true|false[wsp+true|false]{0-3} | | 8568 // param-value: true|false[wsp+true|false]{0-3} | |
8569 // <number>[wsp+<number>]{0-3} | | 8569 // <number>[wsp+<number>]{0-3} | |
8570 // <array> | | 8570 // <array> | |
8571 // <transform> | | 8571 // <transform> | |
8572 // <texture(<uri>)> | 8572 // <texture(<uri>)> |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8624 if (!parameterValue || !acceptCommaOperator(argsList)) | 8624 if (!parameterValue || !acceptCommaOperator(argsList)) |
8625 return 0; | 8625 return 0; |
8626 | 8626 |
8627 parameter->append(parameterValue.release()); | 8627 parameter->append(parameterValue.release()); |
8628 paramList->append(parameter.release()); | 8628 paramList->append(parameter.release()); |
8629 } | 8629 } |
8630 | 8630 |
8631 return paramList; | 8631 return paramList; |
8632 } | 8632 } |
8633 | 8633 |
8634 PassRefPtr<CSSFilterValue> CSSParser::parseCustomFilterFunctionWithAtRuleReferen
ceSyntax(CSSParserValue* value) | 8634 PassRefPtr<CSSFilterValue> BisonCSSParser::parseCustomFilterFunctionWithAtRuleRe
ferenceSyntax(CSSParserValue* value) |
8635 { | 8635 { |
8636 // | 8636 // |
8637 // Custom filter function "at-rule reference" syntax: | 8637 // Custom filter function "at-rule reference" syntax: |
8638 // | 8638 // |
8639 // custom(<filter-name>wsp[,wsp<params>]) | 8639 // custom(<filter-name>wsp[,wsp<params>]) |
8640 // | 8640 // |
8641 // filter-name: <filter-name> | 8641 // filter-name: <filter-name> |
8642 // params: See the comment in CSSParser::parseCustomFilterParameters. | 8642 // params: See the comment in BisonCSSParser::parseCustomFilterParameters. |
8643 // | 8643 // |
8644 | 8644 |
8645 ASSERT(value->function); | 8645 ASSERT(value->function); |
8646 | 8646 |
8647 CSSParserValueList* argsList = value->function->args.get(); | 8647 CSSParserValueList* argsList = value->function->args.get(); |
8648 if (!argsList || !argsList->size()) | 8648 if (!argsList || !argsList->size()) |
8649 return 0; | 8649 return 0; |
8650 | 8650 |
8651 // 1. Parse the filter name. | 8651 // 1. Parse the filter name. |
8652 CSSParserValue* arg = argsList->current(); | 8652 CSSParserValue* arg = argsList->current(); |
(...skipping 14 matching lines...) Expand all Loading... |
8667 if (!paramList) | 8667 if (!paramList) |
8668 return 0; | 8668 return 0; |
8669 | 8669 |
8670 if (paramList->length()) | 8670 if (paramList->length()) |
8671 filterValue->append(paramList.release()); | 8671 filterValue->append(paramList.release()); |
8672 | 8672 |
8673 return filterValue; | 8673 return filterValue; |
8674 } | 8674 } |
8675 | 8675 |
8676 // FIXME: The custom filters "inline" syntax is deprecated. We will remove it ev
entually. | 8676 // FIXME: The custom filters "inline" syntax is deprecated. We will remove it ev
entually. |
8677 PassRefPtr<CSSFilterValue> CSSParser::parseCustomFilterFunctionWithInlineSyntax(
CSSParserValue* value) | 8677 PassRefPtr<CSSFilterValue> BisonCSSParser::parseCustomFilterFunctionWithInlineSy
ntax(CSSParserValue* value) |
8678 { | 8678 { |
8679 // | 8679 // |
8680 // Custom filter function "inline" syntax: | 8680 // Custom filter function "inline" syntax: |
8681 // | 8681 // |
8682 // custom(<vertex-shader>[wsp<fragment-shader>][,<vertex-mesh>][,<params>]) | 8682 // custom(<vertex-shader>[wsp<fragment-shader>][,<vertex-mesh>][,<params>]) |
8683 // | 8683 // |
8684 // vertexShader: <uri> | none | 8684 // vertexShader: <uri> | none |
8685 // fragmentShader: <uri> | none | mix(<uri> [ <blend-mode> || <alpha-compos
iting> ]?) | 8685 // fragmentShader: <uri> | none | mix(<uri> [ <blend-mode> || <alpha-compos
iting> ]?) |
8686 // | 8686 // |
8687 // blend-mode: normal | multiply | screen | overlay | darken | lighten | col
or-dodge | | 8687 // blend-mode: normal | multiply | screen | overlay | darken | lighten | col
or-dodge | |
8688 // color-burn | hard-light | soft-light | difference | exclusion
| hue | | 8688 // color-burn | hard-light | soft-light | difference | exclusion
| hue | |
8689 // saturation | color | luminosity | 8689 // saturation | color | luminosity |
8690 // alpha-compositing: clear | src | dst | src-over | dst-over | src-in | dst
-in | | 8690 // alpha-compositing: clear | src | dst | src-over | dst-over | src-in | dst
-in | |
8691 // src-out | dst-out | src-atop | dst-atop | xor | plus | 8691 // src-out | dst-out | src-atop | dst-atop | xor | plus |
8692 // | 8692 // |
8693 // vertexMesh: +<integer>{1,2}[wsp<box>][wsp'detached'] | 8693 // vertexMesh: +<integer>{1,2}[wsp<box>][wsp'detached'] |
8694 // box: filter-box | border-box | padding-box | content-box | 8694 // box: filter-box | border-box | padding-box | content-box |
8695 // | 8695 // |
8696 // params: See the comment in CSSParser::parseCustomFilterParameters. | 8696 // params: See the comment in BisonCSSParser::parseCustomFilterParameters. |
8697 // | 8697 // |
8698 | 8698 |
8699 ASSERT(value->function); | 8699 ASSERT(value->function); |
8700 | 8700 |
8701 CSSParserValueList* argsList = value->function->args.get(); | 8701 CSSParserValueList* argsList = value->function->args.get(); |
8702 if (!argsList) | 8702 if (!argsList) |
8703 return 0; | 8703 return 0; |
8704 | 8704 |
8705 RefPtr<CSSFilterValue> filterValue = CSSFilterValue::create(CSSFilterValue::
CustomFilterOperation); | 8705 RefPtr<CSSFilterValue> filterValue = CSSFilterValue::create(CSSFilterValue::
CustomFilterOperation); |
8706 | 8706 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8770 RefPtr<CSSValueList> paramList = parseCustomFilterParameters(argsList); | 8770 RefPtr<CSSValueList> paramList = parseCustomFilterParameters(argsList); |
8771 if (!paramList) | 8771 if (!paramList) |
8772 return 0; | 8772 return 0; |
8773 | 8773 |
8774 if (paramList->length()) | 8774 if (paramList->length()) |
8775 filterValue->append(paramList.release()); | 8775 filterValue->append(paramList.release()); |
8776 | 8776 |
8777 return filterValue; | 8777 return filterValue; |
8778 } | 8778 } |
8779 | 8779 |
8780 PassRefPtr<CSSFilterValue> CSSParser::parseCustomFilterFunction(CSSParserValue*
value) | 8780 PassRefPtr<CSSFilterValue> BisonCSSParser::parseCustomFilterFunction(CSSParserVa
lue* value) |
8781 { | 8781 { |
8782 ASSERT(value->function); | 8782 ASSERT(value->function); |
8783 | 8783 |
8784 // Look ahead to determine which syntax the custom function is using. | 8784 // Look ahead to determine which syntax the custom function is using. |
8785 // Both the at-rule reference syntax and the inline syntax require at least
one argument. | 8785 // Both the at-rule reference syntax and the inline syntax require at least
one argument. |
8786 CSSParserValueList* argsList = value->function->args.get(); | 8786 CSSParserValueList* argsList = value->function->args.get(); |
8787 if (!argsList || !argsList->size()) | 8787 if (!argsList || !argsList->size()) |
8788 return 0; | 8788 return 0; |
8789 | 8789 |
8790 // The at-rule reference syntax expects a single ident or an ident followed
by a comma. | 8790 // The at-rule reference syntax expects a single ident or an ident followed
by a comma. |
8791 // e.g. custom(my-filter) or custom(my-filter, ...) | 8791 // e.g. custom(my-filter) or custom(my-filter, ...) |
8792 // In contrast, when the inline syntax starts with an ident like "none", it
expects a uri or a mix function next. | 8792 // In contrast, when the inline syntax starts with an ident like "none", it
expects a uri or a mix function next. |
8793 // e.g. custom(none url(...)) or custom(none mix(...) | 8793 // e.g. custom(none url(...)) or custom(none mix(...) |
8794 bool isAtRuleReferenceSyntax = argsList->valueAt(0)->unit == CSSPrimitiveVal
ue::CSS_IDENT | 8794 bool isAtRuleReferenceSyntax = argsList->valueAt(0)->unit == CSSPrimitiveVal
ue::CSS_IDENT |
8795 && (argsList->size() == 1 || isComma(argsList->valueAt(1))); | 8795 && (argsList->size() == 1 || isComma(argsList->valueAt(1))); |
8796 return isAtRuleReferenceSyntax ? parseCustomFilterFunctionWithAtRuleReferenc
eSyntax(value) : parseCustomFilterFunctionWithInlineSyntax(value); | 8796 return isAtRuleReferenceSyntax ? parseCustomFilterFunctionWithAtRuleReferenc
eSyntax(value) : parseCustomFilterFunctionWithInlineSyntax(value); |
8797 } | 8797 } |
8798 | 8798 |
8799 PassRefPtr<CSSValueList> CSSParser::parseCustomFilterTransform(CSSParserValueLis
t* valueList) | 8799 PassRefPtr<CSSValueList> BisonCSSParser::parseCustomFilterTransform(CSSParserVal
ueList* valueList) |
8800 { | 8800 { |
8801 if (!valueList) | 8801 if (!valueList) |
8802 return 0; | 8802 return 0; |
8803 | 8803 |
8804 // CSS Shaders' custom() transforms are space separated and comma terminated
. | 8804 // CSS Shaders' custom() transforms are space separated and comma terminated
. |
8805 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); | 8805 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); |
8806 for (CSSParserValue* value = valueList->current(); value; value = valueList-
>next()) { | 8806 for (CSSParserValue* value = valueList->current(); value; value = valueList-
>next()) { |
8807 if (isComma(value)) | 8807 if (isComma(value)) |
8808 break; | 8808 break; |
8809 | 8809 |
8810 RefPtr<CSSValue> parsedTransformValue = parseTransformValue(value); | 8810 RefPtr<CSSValue> parsedTransformValue = parseTransformValue(value); |
8811 if (!parsedTransformValue) | 8811 if (!parsedTransformValue) |
8812 return 0; | 8812 return 0; |
8813 | 8813 |
8814 list->append(parsedTransformValue.release()); | 8814 list->append(parsedTransformValue.release()); |
8815 } | 8815 } |
8816 | 8816 |
8817 return list.release(); | 8817 return list.release(); |
8818 } | 8818 } |
8819 | 8819 |
8820 PassRefPtr<CSSShaderValue> CSSParser::parseFilterRuleSrcUriAndFormat(CSSParserVa
lueList* valueList) | 8820 PassRefPtr<CSSShaderValue> BisonCSSParser::parseFilterRuleSrcUriAndFormat(CSSPar
serValueList* valueList) |
8821 { | 8821 { |
8822 CSSParserValue* value = valueList->current(); | 8822 CSSParserValue* value = valueList->current(); |
8823 ASSERT(value && value->unit == CSSPrimitiveValue::CSS_URI); | 8823 ASSERT(value && value->unit == CSSPrimitiveValue::CSS_URI); |
8824 RefPtr<CSSShaderValue> shaderValue = CSSShaderValue::create(completeURL(valu
e->string)); | 8824 RefPtr<CSSShaderValue> shaderValue = CSSShaderValue::create(completeURL(valu
e->string)); |
8825 | 8825 |
8826 value = valueList->next(); | 8826 value = valueList->next(); |
8827 if (value && value->unit == CSSParserValue::Function && equalIgnoringCase(va
lue->function->name, "format(")) { | 8827 if (value && value->unit == CSSParserValue::Function && equalIgnoringCase(va
lue->function->name, "format(")) { |
8828 CSSParserValueList* args = value->function->args.get(); | 8828 CSSParserValueList* args = value->function->args.get(); |
8829 if (!args || args->size() != 1) | 8829 if (!args || args->size() != 1) |
8830 return 0; | 8830 return 0; |
8831 | 8831 |
8832 CSSParserValue* arg = args->current(); | 8832 CSSParserValue* arg = args->current(); |
8833 if (arg->unit != CSSPrimitiveValue::CSS_STRING) | 8833 if (arg->unit != CSSPrimitiveValue::CSS_STRING) |
8834 return 0; | 8834 return 0; |
8835 | 8835 |
8836 shaderValue->setFormat(arg->string); | 8836 shaderValue->setFormat(arg->string); |
8837 valueList->next(); | 8837 valueList->next(); |
8838 } | 8838 } |
8839 | 8839 |
8840 return shaderValue.release(); | 8840 return shaderValue.release(); |
8841 } | 8841 } |
8842 | 8842 |
8843 bool CSSParser::parseFilterRuleSrc() | 8843 bool BisonCSSParser::parseFilterRuleSrc() |
8844 { | 8844 { |
8845 RefPtr<CSSValueList> srcList = CSSValueList::createCommaSeparated(); | 8845 RefPtr<CSSValueList> srcList = CSSValueList::createCommaSeparated(); |
8846 | 8846 |
8847 CSSParserValue* value = m_valueList->current(); | 8847 CSSParserValue* value = m_valueList->current(); |
8848 while (value) { | 8848 while (value) { |
8849 if (value->unit != CSSPrimitiveValue::CSS_URI) | 8849 if (value->unit != CSSPrimitiveValue::CSS_URI) |
8850 return false; | 8850 return false; |
8851 | 8851 |
8852 RefPtr<CSSShaderValue> shaderValue = parseFilterRuleSrcUriAndFormat(m_va
lueList.get()); | 8852 RefPtr<CSSShaderValue> shaderValue = parseFilterRuleSrcUriAndFormat(m_va
lueList.get()); |
8853 if (!shaderValue) | 8853 if (!shaderValue) |
8854 return false; | 8854 return false; |
8855 srcList->append(shaderValue.release()); | 8855 srcList->append(shaderValue.release()); |
8856 | 8856 |
8857 if (!acceptCommaOperator(m_valueList.get())) | 8857 if (!acceptCommaOperator(m_valueList.get())) |
8858 return false; | 8858 return false; |
8859 | 8859 |
8860 value = m_valueList->current(); | 8860 value = m_valueList->current(); |
8861 } | 8861 } |
8862 | 8862 |
8863 if (!srcList->length()) | 8863 if (!srcList->length()) |
8864 return false; | 8864 return false; |
8865 | 8865 |
8866 addProperty(CSSPropertySrc, srcList.release(), m_important); | 8866 addProperty(CSSPropertySrc, srcList.release(), m_important); |
8867 return true; | 8867 return true; |
8868 } | 8868 } |
8869 | 8869 |
8870 StyleRuleBase* CSSParser::createFilterRule(const CSSParserString& filterName) | 8870 StyleRuleBase* BisonCSSParser::createFilterRule(const CSSParserString& filterNam
e) |
8871 { | 8871 { |
8872 RefPtr<StyleRuleFilter> rule = StyleRuleFilter::create(filterName); | 8872 RefPtr<StyleRuleFilter> rule = StyleRuleFilter::create(filterName); |
8873 rule->setProperties(createStylePropertySet()); | 8873 rule->setProperties(createStylePropertySet()); |
8874 clearProperties(); | 8874 clearProperties(); |
8875 StyleRuleFilter* result = rule.get(); | 8875 StyleRuleFilter* result = rule.get(); |
8876 m_parsedRules.append(rule.release()); | 8876 m_parsedRules.append(rule.release()); |
8877 return result; | 8877 return result; |
8878 } | 8878 } |
8879 | 8879 |
8880 | 8880 |
8881 PassRefPtr<CSSFilterValue> CSSParser::parseBuiltinFilterArguments(CSSParserValue
List* args, CSSFilterValue::FilterOperationType filterType) | 8881 PassRefPtr<CSSFilterValue> BisonCSSParser::parseBuiltinFilterArguments(CSSParser
ValueList* args, CSSFilterValue::FilterOperationType filterType) |
8882 { | 8882 { |
8883 RefPtr<CSSFilterValue> filterValue = CSSFilterValue::create(filterType); | 8883 RefPtr<CSSFilterValue> filterValue = CSSFilterValue::create(filterType); |
8884 ASSERT(args); | 8884 ASSERT(args); |
8885 | 8885 |
8886 switch (filterType) { | 8886 switch (filterType) { |
8887 case CSSFilterValue::GrayscaleFilterOperation: | 8887 case CSSFilterValue::GrayscaleFilterOperation: |
8888 case CSSFilterValue::SepiaFilterOperation: | 8888 case CSSFilterValue::SepiaFilterOperation: |
8889 case CSSFilterValue::SaturateFilterOperation: | 8889 case CSSFilterValue::SaturateFilterOperation: |
8890 case CSSFilterValue::InvertFilterOperation: | 8890 case CSSFilterValue::InvertFilterOperation: |
8891 case CSSFilterValue::OpacityFilterOperation: | 8891 case CSSFilterValue::OpacityFilterOperation: |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8963 | 8963 |
8964 filterValue->append((shadowValueList.release())->itemWithoutBoundsCheck(
0)); | 8964 filterValue->append((shadowValueList.release())->itemWithoutBoundsCheck(
0)); |
8965 break; | 8965 break; |
8966 } | 8966 } |
8967 default: | 8967 default: |
8968 ASSERT_NOT_REACHED(); | 8968 ASSERT_NOT_REACHED(); |
8969 } | 8969 } |
8970 return filterValue.release(); | 8970 return filterValue.release(); |
8971 } | 8971 } |
8972 | 8972 |
8973 PassRefPtr<CSSValueList> CSSParser::parseFilter() | 8973 PassRefPtr<CSSValueList> BisonCSSParser::parseFilter() |
8974 { | 8974 { |
8975 if (!m_valueList) | 8975 if (!m_valueList) |
8976 return 0; | 8976 return 0; |
8977 | 8977 |
8978 // The filter is a list of functional primitives that specify individual ope
rations. | 8978 // The filter is a list of functional primitives that specify individual ope
rations. |
8979 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); | 8979 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); |
8980 for (CSSParserValue* value = m_valueList->current(); value; value = m_valueL
ist->next()) { | 8980 for (CSSParserValue* value = m_valueList->current(); value; value = m_valueL
ist->next()) { |
8981 if (value->unit != CSSPrimitiveValue::CSS_URI && (value->unit != CSSPars
erValue::Function || !value->function)) | 8981 if (value->unit != CSSPrimitiveValue::CSS_URI && (value->unit != CSSPars
erValue::Function || !value->function)) |
8982 return 0; | 8982 return 0; |
8983 | 8983 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9025 | 9025 |
9026 static bool validFlowName(const String& flowName) | 9026 static bool validFlowName(const String& flowName) |
9027 { | 9027 { |
9028 return !(equalIgnoringCase(flowName, "auto") | 9028 return !(equalIgnoringCase(flowName, "auto") |
9029 || equalIgnoringCase(flowName, "default") | 9029 || equalIgnoringCase(flowName, "default") |
9030 || equalIgnoringCase(flowName, "inherit") | 9030 || equalIgnoringCase(flowName, "inherit") |
9031 || equalIgnoringCase(flowName, "initial") | 9031 || equalIgnoringCase(flowName, "initial") |
9032 || equalIgnoringCase(flowName, "none")); | 9032 || equalIgnoringCase(flowName, "none")); |
9033 } | 9033 } |
9034 | 9034 |
9035 bool CSSParser::parseFlowThread(const String& flowName) | 9035 bool BisonCSSParser::parseFlowThread(const String& flowName) |
9036 { | 9036 { |
9037 setupParser("@-internal-decls -webkit-flow-into:", flowName, ""); | 9037 setupParser("@-internal-decls -webkit-flow-into:", flowName, ""); |
9038 cssyyparse(this); | 9038 cssyyparse(this); |
9039 | 9039 |
9040 m_rule = 0; | 9040 m_rule = 0; |
9041 | 9041 |
9042 return ((m_parsedProperties.size() == 1) && (m_parsedProperties.first().id()
== CSSPropertyWebkitFlowInto)); | 9042 return ((m_parsedProperties.size() == 1) && (m_parsedProperties.first().id()
== CSSPropertyWebkitFlowInto)); |
9043 } | 9043 } |
9044 | 9044 |
9045 // none | <ident> | 9045 // none | <ident> |
9046 bool CSSParser::parseFlowThread(CSSPropertyID propId, bool important) | 9046 bool BisonCSSParser::parseFlowThread(CSSPropertyID propId, bool important) |
9047 { | 9047 { |
9048 ASSERT(propId == CSSPropertyWebkitFlowInto); | 9048 ASSERT(propId == CSSPropertyWebkitFlowInto); |
9049 ASSERT(RuntimeEnabledFeatures::cssRegionsEnabled()); | 9049 ASSERT(RuntimeEnabledFeatures::cssRegionsEnabled()); |
9050 | 9050 |
9051 if (m_valueList->size() != 1) | 9051 if (m_valueList->size() != 1) |
9052 return false; | 9052 return false; |
9053 | 9053 |
9054 CSSParserValue* value = m_valueList->current(); | 9054 CSSParserValue* value = m_valueList->current(); |
9055 if (!value) | 9055 if (!value) |
9056 return false; | 9056 return false; |
(...skipping 11 matching lines...) Expand all Loading... |
9068 if (!validFlowName(inputProperty)) | 9068 if (!validFlowName(inputProperty)) |
9069 return false; | 9069 return false; |
9070 addProperty(propId, cssValuePool().createValue(inputProperty, CSSPrimiti
veValue::CSS_STRING), important); | 9070 addProperty(propId, cssValuePool().createValue(inputProperty, CSSPrimiti
veValue::CSS_STRING), important); |
9071 } else | 9071 } else |
9072 addProperty(propId, cssValuePool().createIdentifierValue(CSSValueNone),
important); | 9072 addProperty(propId, cssValuePool().createIdentifierValue(CSSValueNone),
important); |
9073 | 9073 |
9074 return true; | 9074 return true; |
9075 } | 9075 } |
9076 | 9076 |
9077 // -webkit-flow-from: none | <ident> | 9077 // -webkit-flow-from: none | <ident> |
9078 bool CSSParser::parseRegionThread(CSSPropertyID propId, bool important) | 9078 bool BisonCSSParser::parseRegionThread(CSSPropertyID propId, bool important) |
9079 { | 9079 { |
9080 ASSERT(propId == CSSPropertyWebkitFlowFrom); | 9080 ASSERT(propId == CSSPropertyWebkitFlowFrom); |
9081 ASSERT(RuntimeEnabledFeatures::cssRegionsEnabled()); | 9081 ASSERT(RuntimeEnabledFeatures::cssRegionsEnabled()); |
9082 | 9082 |
9083 if (m_valueList->size() != 1) | 9083 if (m_valueList->size() != 1) |
9084 return false; | 9084 return false; |
9085 | 9085 |
9086 CSSParserValue* value = m_valueList->current(); | 9086 CSSParserValue* value = m_valueList->current(); |
9087 if (!value) | 9087 if (!value) |
9088 return false; | 9088 return false; |
9089 | 9089 |
9090 if (value->unit != CSSPrimitiveValue::CSS_IDENT) | 9090 if (value->unit != CSSPrimitiveValue::CSS_IDENT) |
9091 return false; | 9091 return false; |
9092 | 9092 |
9093 if (value->id == CSSValueNone) | 9093 if (value->id == CSSValueNone) |
9094 addProperty(propId, cssValuePool().createIdentifierValue(value->id), imp
ortant); | 9094 addProperty(propId, cssValuePool().createIdentifierValue(value->id), imp
ortant); |
9095 else { | 9095 else { |
9096 String inputProperty = String(value->string); | 9096 String inputProperty = String(value->string); |
9097 if (!inputProperty.isEmpty()) { | 9097 if (!inputProperty.isEmpty()) { |
9098 if (!validFlowName(inputProperty)) | 9098 if (!validFlowName(inputProperty)) |
9099 return false; | 9099 return false; |
9100 addProperty(propId, cssValuePool().createValue(inputProperty, CSSPri
mitiveValue::CSS_STRING), important); | 9100 addProperty(propId, cssValuePool().createValue(inputProperty, CSSPri
mitiveValue::CSS_STRING), important); |
9101 } else | 9101 } else |
9102 addProperty(propId, cssValuePool().createIdentifierValue(CSSValueNon
e), important); | 9102 addProperty(propId, cssValuePool().createIdentifierValue(CSSValueNon
e), important); |
9103 } | 9103 } |
9104 | 9104 |
9105 return true; | 9105 return true; |
9106 } | 9106 } |
9107 | 9107 |
9108 bool CSSParser::parseTransformOrigin(CSSPropertyID propId, CSSPropertyID& propId
1, CSSPropertyID& propId2, CSSPropertyID& propId3, RefPtr<CSSValue>& value, RefP
tr<CSSValue>& value2, RefPtr<CSSValue>& value3) | 9108 bool BisonCSSParser::parseTransformOrigin(CSSPropertyID propId, CSSPropertyID& p
ropId1, CSSPropertyID& propId2, CSSPropertyID& propId3, RefPtr<CSSValue>& value,
RefPtr<CSSValue>& value2, RefPtr<CSSValue>& value3) |
9109 { | 9109 { |
9110 propId1 = propId; | 9110 propId1 = propId; |
9111 propId2 = propId; | 9111 propId2 = propId; |
9112 propId3 = propId; | 9112 propId3 = propId; |
9113 if (propId == CSSPropertyWebkitTransformOrigin) { | 9113 if (propId == CSSPropertyWebkitTransformOrigin) { |
9114 propId1 = CSSPropertyWebkitTransformOriginX; | 9114 propId1 = CSSPropertyWebkitTransformOriginX; |
9115 propId2 = CSSPropertyWebkitTransformOriginY; | 9115 propId2 = CSSPropertyWebkitTransformOriginY; |
9116 propId3 = CSSPropertyWebkitTransformOriginZ; | 9116 propId3 = CSSPropertyWebkitTransformOriginZ; |
9117 } | 9117 } |
9118 | 9118 |
(...skipping 23 matching lines...) Expand all Loading... |
9142 break; | 9142 break; |
9143 } | 9143 } |
9144 default: | 9144 default: |
9145 ASSERT_NOT_REACHED(); | 9145 ASSERT_NOT_REACHED(); |
9146 return false; | 9146 return false; |
9147 } | 9147 } |
9148 | 9148 |
9149 return value; | 9149 return value; |
9150 } | 9150 } |
9151 | 9151 |
9152 bool CSSParser::parsePerspectiveOrigin(CSSPropertyID propId, CSSPropertyID& prop
Id1, CSSPropertyID& propId2, RefPtr<CSSValue>& value, RefPtr<CSSValue>& value2) | 9152 bool BisonCSSParser::parsePerspectiveOrigin(CSSPropertyID propId, CSSPropertyID&
propId1, CSSPropertyID& propId2, RefPtr<CSSValue>& value, RefPtr<CSSValue>& val
ue2) |
9153 { | 9153 { |
9154 propId1 = propId; | 9154 propId1 = propId; |
9155 propId2 = propId; | 9155 propId2 = propId; |
9156 if (propId == CSSPropertyWebkitPerspectiveOrigin) { | 9156 if (propId == CSSPropertyWebkitPerspectiveOrigin) { |
9157 propId1 = CSSPropertyWebkitPerspectiveOriginX; | 9157 propId1 = CSSPropertyWebkitPerspectiveOriginX; |
9158 propId2 = CSSPropertyWebkitPerspectiveOriginY; | 9158 propId2 = CSSPropertyWebkitPerspectiveOriginY; |
9159 } | 9159 } |
9160 | 9160 |
9161 switch (propId) { | 9161 switch (propId) { |
9162 case CSSPropertyWebkitPerspectiveOrigin: | 9162 case CSSPropertyWebkitPerspectiveOrigin: |
(...skipping 14 matching lines...) Expand all Loading... |
9177 break; | 9177 break; |
9178 } | 9178 } |
9179 default: | 9179 default: |
9180 ASSERT_NOT_REACHED(); | 9180 ASSERT_NOT_REACHED(); |
9181 return false; | 9181 return false; |
9182 } | 9182 } |
9183 | 9183 |
9184 return value; | 9184 return value; |
9185 } | 9185 } |
9186 | 9186 |
9187 bool CSSParser::parseTouchAction(bool important) | 9187 bool BisonCSSParser::parseTouchAction(bool important) |
9188 { | 9188 { |
9189 if (!RuntimeEnabledFeatures::cssTouchActionEnabled()) | 9189 if (!RuntimeEnabledFeatures::cssTouchActionEnabled()) |
9190 return false; | 9190 return false; |
9191 | 9191 |
9192 CSSParserValue* value = m_valueList->current(); | 9192 CSSParserValue* value = m_valueList->current(); |
9193 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); | 9193 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); |
9194 if (m_valueList->size() == 1 && value && (value->id == CSSValueAuto || value
->id == CSSValueNone)) { | 9194 if (m_valueList->size() == 1 && value && (value->id == CSSValueAuto || value
->id == CSSValueNone)) { |
9195 list->append(cssValuePool().createIdentifierValue(value->id)); | 9195 list->append(cssValuePool().createIdentifierValue(value->id)); |
9196 addProperty(CSSPropertyTouchAction, list.release(), important); | 9196 addProperty(CSSPropertyTouchAction, list.release(), important); |
9197 m_valueList->next(); | 9197 m_valueList->next(); |
(...skipping 22 matching lines...) Expand all Loading... |
9220 } | 9220 } |
9221 | 9221 |
9222 if (list->length() && isValid) { | 9222 if (list->length() && isValid) { |
9223 addProperty(CSSPropertyTouchAction, list.release(), important); | 9223 addProperty(CSSPropertyTouchAction, list.release(), important); |
9224 return true; | 9224 return true; |
9225 } | 9225 } |
9226 | 9226 |
9227 return false; | 9227 return false; |
9228 } | 9228 } |
9229 | 9229 |
9230 void CSSParser::addTextDecorationProperty(CSSPropertyID propId, PassRefPtr<CSSVa
lue> value, bool important) | 9230 void BisonCSSParser::addTextDecorationProperty(CSSPropertyID propId, PassRefPtr<
CSSValue> value, bool important) |
9231 { | 9231 { |
9232 // The text-decoration-line property takes priority over text-decoration, un
less the latter has important priority set. | 9232 // The text-decoration-line property takes priority over text-decoration, un
less the latter has important priority set. |
9233 if (propId == CSSPropertyTextDecoration && !important && !inShorthand()) { | 9233 if (propId == CSSPropertyTextDecoration && !important && !inShorthand()) { |
9234 for (unsigned i = 0; i < m_parsedProperties.size(); ++i) { | 9234 for (unsigned i = 0; i < m_parsedProperties.size(); ++i) { |
9235 if (m_parsedProperties[i].id() == CSSPropertyTextDecorationLine) | 9235 if (m_parsedProperties[i].id() == CSSPropertyTextDecorationLine) |
9236 return; | 9236 return; |
9237 } | 9237 } |
9238 } | 9238 } |
9239 addProperty(propId, value, important); | 9239 addProperty(propId, value, important); |
9240 } | 9240 } |
9241 | 9241 |
9242 bool CSSParser::parseTextDecoration(CSSPropertyID propId, bool important) | 9242 bool BisonCSSParser::parseTextDecoration(CSSPropertyID propId, bool important) |
9243 { | 9243 { |
9244 if (propId == CSSPropertyTextDecorationLine | 9244 if (propId == CSSPropertyTextDecorationLine |
9245 && !RuntimeEnabledFeatures::css3TextDecorationsEnabled()) | 9245 && !RuntimeEnabledFeatures::css3TextDecorationsEnabled()) |
9246 return false; | 9246 return false; |
9247 | 9247 |
9248 CSSParserValue* value = m_valueList->current(); | 9248 CSSParserValue* value = m_valueList->current(); |
9249 if (value && value->id == CSSValueNone) { | 9249 if (value && value->id == CSSValueNone) { |
9250 addTextDecorationProperty(propId, cssValuePool().createIdentifierValue(C
SSValueNone), important); | 9250 addTextDecorationProperty(propId, cssValuePool().createIdentifierValue(C
SSValueNone), important); |
9251 m_valueList->next(); | 9251 m_valueList->next(); |
9252 return true; | 9252 return true; |
(...skipping 19 matching lines...) Expand all Loading... |
9272 | 9272 |
9273 // Values are either valid or in shorthand scope. | 9273 // Values are either valid or in shorthand scope. |
9274 if (list->length() && (isValid || inShorthand())) { | 9274 if (list->length() && (isValid || inShorthand())) { |
9275 addTextDecorationProperty(propId, list.release(), important); | 9275 addTextDecorationProperty(propId, list.release(), important); |
9276 return true; | 9276 return true; |
9277 } | 9277 } |
9278 | 9278 |
9279 return false; | 9279 return false; |
9280 } | 9280 } |
9281 | 9281 |
9282 bool CSSParser::parseTextUnderlinePosition(bool important) | 9282 bool BisonCSSParser::parseTextUnderlinePosition(bool important) |
9283 { | 9283 { |
9284 // The text-underline-position property has syntax "auto | [ under || [ left
| right ] ]". | 9284 // The text-underline-position property has syntax "auto | [ under || [ left
| right ] ]". |
9285 // However, values 'left' and 'right' are not implemented yet, so we will pa
rse syntax | 9285 // However, values 'left' and 'right' are not implemented yet, so we will pa
rse syntax |
9286 // "auto | under" for now. | 9286 // "auto | under" for now. |
9287 CSSParserValue* value = m_valueList->current(); | 9287 CSSParserValue* value = m_valueList->current(); |
9288 switch (value->id) { | 9288 switch (value->id) { |
9289 case CSSValueAuto: | 9289 case CSSValueAuto: |
9290 case CSSValueUnder: | 9290 case CSSValueUnder: |
9291 if (m_valueList->next()) | 9291 if (m_valueList->next()) |
9292 return false; | 9292 return false; |
9293 addProperty(CSSPropertyTextUnderlinePosition, cssValuePool().createIdent
ifierValue(value->id), important); | 9293 addProperty(CSSPropertyTextUnderlinePosition, cssValuePool().createIdent
ifierValue(value->id), important); |
9294 return true; | 9294 return true; |
9295 default: | 9295 default: |
9296 return false; | 9296 return false; |
9297 } | 9297 } |
9298 } | 9298 } |
9299 | 9299 |
9300 bool CSSParser::parseTextEmphasisStyle(bool important) | 9300 bool BisonCSSParser::parseTextEmphasisStyle(bool important) |
9301 { | 9301 { |
9302 unsigned valueListSize = m_valueList->size(); | 9302 unsigned valueListSize = m_valueList->size(); |
9303 | 9303 |
9304 RefPtr<CSSPrimitiveValue> fill; | 9304 RefPtr<CSSPrimitiveValue> fill; |
9305 RefPtr<CSSPrimitiveValue> shape; | 9305 RefPtr<CSSPrimitiveValue> shape; |
9306 | 9306 |
9307 for (CSSParserValue* value = m_valueList->current(); value; value = m_valueL
ist->next()) { | 9307 for (CSSParserValue* value = m_valueList->current(); value; value = m_valueL
ist->next()) { |
9308 if (value->unit == CSSPrimitiveValue::CSS_STRING) { | 9308 if (value->unit == CSSPrimitiveValue::CSS_STRING) { |
9309 if (fill || shape || (valueListSize != 1 && !inShorthand())) | 9309 if (fill || shape || (valueListSize != 1 && !inShorthand())) |
9310 return false; | 9310 return false; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9347 return true; | 9347 return true; |
9348 } | 9348 } |
9349 if (shape) { | 9349 if (shape) { |
9350 addProperty(CSSPropertyWebkitTextEmphasisStyle, shape.release(), importa
nt); | 9350 addProperty(CSSPropertyWebkitTextEmphasisStyle, shape.release(), importa
nt); |
9351 return true; | 9351 return true; |
9352 } | 9352 } |
9353 | 9353 |
9354 return false; | 9354 return false; |
9355 } | 9355 } |
9356 | 9356 |
9357 PassRefPtr<CSSValue> CSSParser::parseTextIndent() | 9357 PassRefPtr<CSSValue> BisonCSSParser::parseTextIndent() |
9358 { | 9358 { |
9359 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); | 9359 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); |
9360 | 9360 |
9361 // <length> | <percentage> | inherit | 9361 // <length> | <percentage> | inherit |
9362 if (m_valueList->size() == 1) { | 9362 if (m_valueList->size() == 1) { |
9363 CSSParserValue* value = m_valueList->current(); | 9363 CSSParserValue* value = m_valueList->current(); |
9364 if (!value->id && validUnit(value, FLength | FPercent)) { | 9364 if (!value->id && validUnit(value, FLength | FPercent)) { |
9365 list->append(createPrimitiveNumericValue(value)); | 9365 list->append(createPrimitiveNumericValue(value)); |
9366 m_valueList->next(); | 9366 m_valueList->next(); |
9367 return list.release(); | 9367 return list.release(); |
(...skipping 24 matching lines...) Expand all Loading... |
9392 if (lengthOrPercentageValue) { | 9392 if (lengthOrPercentageValue) { |
9393 list->append(createPrimitiveNumericValue(lengthOrPercentageValue)); | 9393 list->append(createPrimitiveNumericValue(lengthOrPercentageValue)); |
9394 list->append(cssValuePool().createIdentifierValue(CSSValueEachLine)); | 9394 list->append(cssValuePool().createIdentifierValue(CSSValueEachLine)); |
9395 m_valueList->next(); | 9395 m_valueList->next(); |
9396 return list.release(); | 9396 return list.release(); |
9397 } | 9397 } |
9398 | 9398 |
9399 return 0; | 9399 return 0; |
9400 } | 9400 } |
9401 | 9401 |
9402 bool CSSParser::parseLineBoxContain(bool important) | 9402 bool BisonCSSParser::parseLineBoxContain(bool important) |
9403 { | 9403 { |
9404 LineBoxContain lineBoxContain = LineBoxContainNone; | 9404 LineBoxContain lineBoxContain = LineBoxContainNone; |
9405 | 9405 |
9406 for (CSSParserValue* value = m_valueList->current(); value; value = m_valueL
ist->next()) { | 9406 for (CSSParserValue* value = m_valueList->current(); value; value = m_valueL
ist->next()) { |
9407 if (value->id == CSSValueBlock) { | 9407 if (value->id == CSSValueBlock) { |
9408 if (lineBoxContain & LineBoxContainBlock) | 9408 if (lineBoxContain & LineBoxContainBlock) |
9409 return false; | 9409 return false; |
9410 lineBoxContain |= LineBoxContainBlock; | 9410 lineBoxContain |= LineBoxContainBlock; |
9411 } else if (value->id == CSSValueInline) { | 9411 } else if (value->id == CSSValueInline) { |
9412 if (lineBoxContain & LineBoxContainInline) | 9412 if (lineBoxContain & LineBoxContainInline) |
(...skipping 19 matching lines...) Expand all Loading... |
9432 return false; | 9432 return false; |
9433 } | 9433 } |
9434 | 9434 |
9435 if (!lineBoxContain) | 9435 if (!lineBoxContain) |
9436 return false; | 9436 return false; |
9437 | 9437 |
9438 addProperty(CSSPropertyWebkitLineBoxContain, CSSLineBoxContainValue::create(
lineBoxContain), important); | 9438 addProperty(CSSPropertyWebkitLineBoxContain, CSSLineBoxContainValue::create(
lineBoxContain), important); |
9439 return true; | 9439 return true; |
9440 } | 9440 } |
9441 | 9441 |
9442 bool CSSParser::parseFontFeatureTag(CSSValueList* settings) | 9442 bool BisonCSSParser::parseFontFeatureTag(CSSValueList* settings) |
9443 { | 9443 { |
9444 // Feature tag name consists of 4-letter characters. | 9444 // Feature tag name consists of 4-letter characters. |
9445 static const unsigned tagNameLength = 4; | 9445 static const unsigned tagNameLength = 4; |
9446 | 9446 |
9447 CSSParserValue* value = m_valueList->current(); | 9447 CSSParserValue* value = m_valueList->current(); |
9448 // Feature tag name comes first | 9448 // Feature tag name comes first |
9449 if (value->unit != CSSPrimitiveValue::CSS_STRING) | 9449 if (value->unit != CSSPrimitiveValue::CSS_STRING) |
9450 return false; | 9450 return false; |
9451 if (value->string.length() != tagNameLength) | 9451 if (value->string.length() != tagNameLength) |
9452 return false; | 9452 return false; |
(...skipping 16 matching lines...) Expand all Loading... |
9469 m_valueList->next(); | 9469 m_valueList->next(); |
9470 } else if (value->id == CSSValueOn || value->id == CSSValueOff) { | 9470 } else if (value->id == CSSValueOn || value->id == CSSValueOff) { |
9471 tagValue = value->id == CSSValueOn; | 9471 tagValue = value->id == CSSValueOn; |
9472 m_valueList->next(); | 9472 m_valueList->next(); |
9473 } | 9473 } |
9474 } | 9474 } |
9475 settings->append(CSSFontFeatureValue::create(tag, tagValue)); | 9475 settings->append(CSSFontFeatureValue::create(tag, tagValue)); |
9476 return true; | 9476 return true; |
9477 } | 9477 } |
9478 | 9478 |
9479 bool CSSParser::parseFontFeatureSettings(bool important) | 9479 bool BisonCSSParser::parseFontFeatureSettings(bool important) |
9480 { | 9480 { |
9481 if (m_valueList->size() == 1 && m_valueList->current()->id == CSSValueNormal
) { | 9481 if (m_valueList->size() == 1 && m_valueList->current()->id == CSSValueNormal
) { |
9482 RefPtr<CSSPrimitiveValue> normalValue = cssValuePool().createIdentifierV
alue(CSSValueNormal); | 9482 RefPtr<CSSPrimitiveValue> normalValue = cssValuePool().createIdentifierV
alue(CSSValueNormal); |
9483 m_valueList->next(); | 9483 m_valueList->next(); |
9484 addProperty(CSSPropertyWebkitFontFeatureSettings, normalValue.release(),
important); | 9484 addProperty(CSSPropertyWebkitFontFeatureSettings, normalValue.release(),
important); |
9485 return true; | 9485 return true; |
9486 } | 9486 } |
9487 | 9487 |
9488 RefPtr<CSSValueList> settings = CSSValueList::createCommaSeparated(); | 9488 RefPtr<CSSValueList> settings = CSSValueList::createCommaSeparated(); |
9489 for (CSSParserValue* value = m_valueList->current(); value; value = m_valueL
ist->next()) { | 9489 for (CSSParserValue* value = m_valueList->current(); value; value = m_valueL
ist->next()) { |
9490 if (!parseFontFeatureTag(settings.get())) | 9490 if (!parseFontFeatureTag(settings.get())) |
9491 return false; | 9491 return false; |
9492 | 9492 |
9493 // If the list isn't parsed fully, the current value should be comma. | 9493 // If the list isn't parsed fully, the current value should be comma. |
9494 value = m_valueList->current(); | 9494 value = m_valueList->current(); |
9495 if (value && !isComma(value)) | 9495 if (value && !isComma(value)) |
9496 return false; | 9496 return false; |
9497 } | 9497 } |
9498 if (settings->length()) { | 9498 if (settings->length()) { |
9499 addProperty(CSSPropertyWebkitFontFeatureSettings, settings.release(), im
portant); | 9499 addProperty(CSSPropertyWebkitFontFeatureSettings, settings.release(), im
portant); |
9500 return true; | 9500 return true; |
9501 } | 9501 } |
9502 return false; | 9502 return false; |
9503 } | 9503 } |
9504 | 9504 |
9505 bool CSSParser::parseFontVariantLigatures(bool important) | 9505 bool BisonCSSParser::parseFontVariantLigatures(bool important) |
9506 { | 9506 { |
9507 RefPtr<CSSValueList> ligatureValues = CSSValueList::createSpaceSeparated(); | 9507 RefPtr<CSSValueList> ligatureValues = CSSValueList::createSpaceSeparated(); |
9508 bool sawCommonLigaturesValue = false; | 9508 bool sawCommonLigaturesValue = false; |
9509 bool sawDiscretionaryLigaturesValue = false; | 9509 bool sawDiscretionaryLigaturesValue = false; |
9510 bool sawHistoricalLigaturesValue = false; | 9510 bool sawHistoricalLigaturesValue = false; |
9511 | 9511 |
9512 for (CSSParserValue* value = m_valueList->current(); value; value = m_valueL
ist->next()) { | 9512 for (CSSParserValue* value = m_valueList->current(); value; value = m_valueL
ist->next()) { |
9513 if (value->unit != CSSPrimitiveValue::CSS_IDENT) | 9513 if (value->unit != CSSPrimitiveValue::CSS_IDENT) |
9514 return false; | 9514 return false; |
9515 | 9515 |
(...skipping 24 matching lines...) Expand all Loading... |
9540 } | 9540 } |
9541 } | 9541 } |
9542 | 9542 |
9543 if (!ligatureValues->length()) | 9543 if (!ligatureValues->length()) |
9544 return false; | 9544 return false; |
9545 | 9545 |
9546 addProperty(CSSPropertyWebkitFontVariantLigatures, ligatureValues.release(),
important); | 9546 addProperty(CSSPropertyWebkitFontVariantLigatures, ligatureValues.release(),
important); |
9547 return true; | 9547 return true; |
9548 } | 9548 } |
9549 | 9549 |
9550 bool CSSParser::parseCalculation(CSSParserValue* value, ValueRange range) | 9550 bool BisonCSSParser::parseCalculation(CSSParserValue* value, ValueRange range) |
9551 { | 9551 { |
9552 ASSERT(isCalculation(value)); | 9552 ASSERT(isCalculation(value)); |
9553 | 9553 |
9554 CSSParserValueList* args = value->function->args.get(); | 9554 CSSParserValueList* args = value->function->args.get(); |
9555 if (!args || !args->size()) | 9555 if (!args || !args->size()) |
9556 return false; | 9556 return false; |
9557 | 9557 |
9558 ASSERT(!m_parsedCalculation); | 9558 ASSERT(!m_parsedCalculation); |
9559 m_parsedCalculation = CSSCalcValue::create(value->function->name, args, rang
e); | 9559 m_parsedCalculation = CSSCalcValue::create(value->function->name, args, rang
e); |
9560 | 9560 |
9561 if (!m_parsedCalculation) | 9561 if (!m_parsedCalculation) |
9562 return false; | 9562 return false; |
9563 | 9563 |
9564 return true; | 9564 return true; |
9565 } | 9565 } |
9566 | 9566 |
9567 #define END_TOKEN 0 | 9567 #define END_TOKEN 0 |
9568 | 9568 |
9569 void CSSParser::ensureLineEndings() | 9569 void BisonCSSParser::ensureLineEndings() |
9570 { | 9570 { |
9571 if (!m_lineEndings) | 9571 if (!m_lineEndings) |
9572 m_lineEndings = lineEndings(*m_source); | 9572 m_lineEndings = lineEndings(*m_source); |
9573 } | 9573 } |
9574 | 9574 |
9575 CSSParserSelector* CSSParser::createFloatingSelectorWithTagName(const QualifiedN
ame& tagQName) | 9575 CSSParserSelector* BisonCSSParser::createFloatingSelectorWithTagName(const Quali
fiedName& tagQName) |
9576 { | 9576 { |
9577 CSSParserSelector* selector = new CSSParserSelector(tagQName); | 9577 CSSParserSelector* selector = new CSSParserSelector(tagQName); |
9578 m_floatingSelectors.append(selector); | 9578 m_floatingSelectors.append(selector); |
9579 return selector; | 9579 return selector; |
9580 } | 9580 } |
9581 | 9581 |
9582 CSSParserSelector* CSSParser::createFloatingSelector() | 9582 CSSParserSelector* BisonCSSParser::createFloatingSelector() |
9583 { | 9583 { |
9584 CSSParserSelector* selector = new CSSParserSelector; | 9584 CSSParserSelector* selector = new CSSParserSelector; |
9585 m_floatingSelectors.append(selector); | 9585 m_floatingSelectors.append(selector); |
9586 return selector; | 9586 return selector; |
9587 } | 9587 } |
9588 | 9588 |
9589 PassOwnPtr<CSSParserSelector> CSSParser::sinkFloatingSelector(CSSParserSelector*
selector) | 9589 PassOwnPtr<CSSParserSelector> BisonCSSParser::sinkFloatingSelector(CSSParserSele
ctor* selector) |
9590 { | 9590 { |
9591 if (selector) { | 9591 if (selector) { |
9592 size_t index = m_floatingSelectors.reverseFind(selector); | 9592 size_t index = m_floatingSelectors.reverseFind(selector); |
9593 ASSERT(index != kNotFound); | 9593 ASSERT(index != kNotFound); |
9594 m_floatingSelectors.remove(index); | 9594 m_floatingSelectors.remove(index); |
9595 } | 9595 } |
9596 return adoptPtr(selector); | 9596 return adoptPtr(selector); |
9597 } | 9597 } |
9598 | 9598 |
9599 Vector<OwnPtr<CSSParserSelector> >* CSSParser::createFloatingSelectorVector() | 9599 Vector<OwnPtr<CSSParserSelector> >* BisonCSSParser::createFloatingSelectorVector
() |
9600 { | 9600 { |
9601 Vector<OwnPtr<CSSParserSelector> >* selectorVector = new Vector<OwnPtr<CSSPa
rserSelector> >; | 9601 Vector<OwnPtr<CSSParserSelector> >* selectorVector = new Vector<OwnPtr<CSSPa
rserSelector> >; |
9602 m_floatingSelectorVectors.append(selectorVector); | 9602 m_floatingSelectorVectors.append(selectorVector); |
9603 return selectorVector; | 9603 return selectorVector; |
9604 } | 9604 } |
9605 | 9605 |
9606 PassOwnPtr<Vector<OwnPtr<CSSParserSelector> > > CSSParser::sinkFloatingSelectorV
ector(Vector<OwnPtr<CSSParserSelector> >* selectorVector) | 9606 PassOwnPtr<Vector<OwnPtr<CSSParserSelector> > > BisonCSSParser::sinkFloatingSele
ctorVector(Vector<OwnPtr<CSSParserSelector> >* selectorVector) |
9607 { | 9607 { |
9608 if (selectorVector) { | 9608 if (selectorVector) { |
9609 size_t index = m_floatingSelectorVectors.reverseFind(selectorVector); | 9609 size_t index = m_floatingSelectorVectors.reverseFind(selectorVector); |
9610 ASSERT(index != kNotFound); | 9610 ASSERT(index != kNotFound); |
9611 m_floatingSelectorVectors.remove(index); | 9611 m_floatingSelectorVectors.remove(index); |
9612 } | 9612 } |
9613 return adoptPtr(selectorVector); | 9613 return adoptPtr(selectorVector); |
9614 } | 9614 } |
9615 | 9615 |
9616 CSSParserValueList* CSSParser::createFloatingValueList() | 9616 CSSParserValueList* BisonCSSParser::createFloatingValueList() |
9617 { | 9617 { |
9618 CSSParserValueList* list = new CSSParserValueList; | 9618 CSSParserValueList* list = new CSSParserValueList; |
9619 m_floatingValueLists.append(list); | 9619 m_floatingValueLists.append(list); |
9620 return list; | 9620 return list; |
9621 } | 9621 } |
9622 | 9622 |
9623 PassOwnPtr<CSSParserValueList> CSSParser::sinkFloatingValueList(CSSParserValueLi
st* list) | 9623 PassOwnPtr<CSSParserValueList> BisonCSSParser::sinkFloatingValueList(CSSParserVa
lueList* list) |
9624 { | 9624 { |
9625 if (list) { | 9625 if (list) { |
9626 size_t index = m_floatingValueLists.reverseFind(list); | 9626 size_t index = m_floatingValueLists.reverseFind(list); |
9627 ASSERT(index != kNotFound); | 9627 ASSERT(index != kNotFound); |
9628 m_floatingValueLists.remove(index); | 9628 m_floatingValueLists.remove(index); |
9629 } | 9629 } |
9630 return adoptPtr(list); | 9630 return adoptPtr(list); |
9631 } | 9631 } |
9632 | 9632 |
9633 CSSParserFunction* CSSParser::createFloatingFunction() | 9633 CSSParserFunction* BisonCSSParser::createFloatingFunction() |
9634 { | 9634 { |
9635 CSSParserFunction* function = new CSSParserFunction; | 9635 CSSParserFunction* function = new CSSParserFunction; |
9636 m_floatingFunctions.append(function); | 9636 m_floatingFunctions.append(function); |
9637 return function; | 9637 return function; |
9638 } | 9638 } |
9639 | 9639 |
9640 CSSParserFunction* CSSParser::createFloatingFunction(const CSSParserString& name
, PassOwnPtr<CSSParserValueList> args) | 9640 CSSParserFunction* BisonCSSParser::createFloatingFunction(const CSSParserString&
name, PassOwnPtr<CSSParserValueList> args) |
9641 { | 9641 { |
9642 CSSParserFunction* function = createFloatingFunction(); | 9642 CSSParserFunction* function = createFloatingFunction(); |
9643 function->name = name; | 9643 function->name = name; |
9644 function->args = args; | 9644 function->args = args; |
9645 return function; | 9645 return function; |
9646 } | 9646 } |
9647 | 9647 |
9648 PassOwnPtr<CSSParserFunction> CSSParser::sinkFloatingFunction(CSSParserFunction*
function) | 9648 PassOwnPtr<CSSParserFunction> BisonCSSParser::sinkFloatingFunction(CSSParserFunc
tion* function) |
9649 { | 9649 { |
9650 if (function) { | 9650 if (function) { |
9651 size_t index = m_floatingFunctions.reverseFind(function); | 9651 size_t index = m_floatingFunctions.reverseFind(function); |
9652 ASSERT(index != kNotFound); | 9652 ASSERT(index != kNotFound); |
9653 m_floatingFunctions.remove(index); | 9653 m_floatingFunctions.remove(index); |
9654 } | 9654 } |
9655 return adoptPtr(function); | 9655 return adoptPtr(function); |
9656 } | 9656 } |
9657 | 9657 |
9658 CSSParserValue& CSSParser::sinkFloatingValue(CSSParserValue& value) | 9658 CSSParserValue& BisonCSSParser::sinkFloatingValue(CSSParserValue& value) |
9659 { | 9659 { |
9660 if (value.unit == CSSParserValue::Function) { | 9660 if (value.unit == CSSParserValue::Function) { |
9661 size_t index = m_floatingFunctions.reverseFind(value.function); | 9661 size_t index = m_floatingFunctions.reverseFind(value.function); |
9662 ASSERT(index != kNotFound); | 9662 ASSERT(index != kNotFound); |
9663 m_floatingFunctions.remove(index); | 9663 m_floatingFunctions.remove(index); |
9664 } | 9664 } |
9665 return value; | 9665 return value; |
9666 } | 9666 } |
9667 | 9667 |
9668 MediaQueryExp* CSSParser::createFloatingMediaQueryExp(const AtomicString& mediaF
eature, CSSParserValueList* values) | 9668 MediaQueryExp* BisonCSSParser::createFloatingMediaQueryExp(const AtomicString& m
ediaFeature, CSSParserValueList* values) |
9669 { | 9669 { |
9670 m_floatingMediaQueryExp = MediaQueryExp::create(mediaFeature, values); | 9670 m_floatingMediaQueryExp = MediaQueryExp::create(mediaFeature, values); |
9671 return m_floatingMediaQueryExp.get(); | 9671 return m_floatingMediaQueryExp.get(); |
9672 } | 9672 } |
9673 | 9673 |
9674 PassOwnPtr<MediaQueryExp> CSSParser::sinkFloatingMediaQueryExp(MediaQueryExp* ex
pression) | 9674 PassOwnPtr<MediaQueryExp> BisonCSSParser::sinkFloatingMediaQueryExp(MediaQueryEx
p* expression) |
9675 { | 9675 { |
9676 ASSERT_UNUSED(expression, expression == m_floatingMediaQueryExp); | 9676 ASSERT_UNUSED(expression, expression == m_floatingMediaQueryExp); |
9677 return m_floatingMediaQueryExp.release(); | 9677 return m_floatingMediaQueryExp.release(); |
9678 } | 9678 } |
9679 | 9679 |
9680 Vector<OwnPtr<MediaQueryExp> >* CSSParser::createFloatingMediaQueryExpList() | 9680 Vector<OwnPtr<MediaQueryExp> >* BisonCSSParser::createFloatingMediaQueryExpList(
) |
9681 { | 9681 { |
9682 m_floatingMediaQueryExpList = adoptPtr(new Vector<OwnPtr<MediaQueryExp> >); | 9682 m_floatingMediaQueryExpList = adoptPtr(new Vector<OwnPtr<MediaQueryExp> >); |
9683 return m_floatingMediaQueryExpList.get(); | 9683 return m_floatingMediaQueryExpList.get(); |
9684 } | 9684 } |
9685 | 9685 |
9686 PassOwnPtr<Vector<OwnPtr<MediaQueryExp> > > CSSParser::sinkFloatingMediaQueryExp
List(Vector<OwnPtr<MediaQueryExp> >* list) | 9686 PassOwnPtr<Vector<OwnPtr<MediaQueryExp> > > BisonCSSParser::sinkFloatingMediaQue
ryExpList(Vector<OwnPtr<MediaQueryExp> >* list) |
9687 { | 9687 { |
9688 ASSERT_UNUSED(list, list == m_floatingMediaQueryExpList); | 9688 ASSERT_UNUSED(list, list == m_floatingMediaQueryExpList); |
9689 return m_floatingMediaQueryExpList.release(); | 9689 return m_floatingMediaQueryExpList.release(); |
9690 } | 9690 } |
9691 | 9691 |
9692 MediaQuery* CSSParser::createFloatingMediaQuery(MediaQuery::Restrictor restricto
r, const AtomicString& mediaType, PassOwnPtr<Vector<OwnPtr<MediaQueryExp> > > ex
pressions) | 9692 MediaQuery* BisonCSSParser::createFloatingMediaQuery(MediaQuery::Restrictor rest
rictor, const AtomicString& mediaType, PassOwnPtr<Vector<OwnPtr<MediaQueryExp> >
> expressions) |
9693 { | 9693 { |
9694 m_floatingMediaQuery = adoptPtr(new MediaQuery(restrictor, mediaType, expres
sions)); | 9694 m_floatingMediaQuery = adoptPtr(new MediaQuery(restrictor, mediaType, expres
sions)); |
9695 return m_floatingMediaQuery.get(); | 9695 return m_floatingMediaQuery.get(); |
9696 } | 9696 } |
9697 | 9697 |
9698 MediaQuery* CSSParser::createFloatingMediaQuery(PassOwnPtr<Vector<OwnPtr<MediaQu
eryExp> > > expressions) | 9698 MediaQuery* BisonCSSParser::createFloatingMediaQuery(PassOwnPtr<Vector<OwnPtr<Me
diaQueryExp> > > expressions) |
9699 { | 9699 { |
9700 return createFloatingMediaQuery(MediaQuery::None, AtomicString("all", Atomic
String::ConstructFromLiteral), expressions); | 9700 return createFloatingMediaQuery(MediaQuery::None, AtomicString("all", Atomic
String::ConstructFromLiteral), expressions); |
9701 } | 9701 } |
9702 | 9702 |
9703 MediaQuery* CSSParser::createFloatingNotAllQuery() | 9703 MediaQuery* BisonCSSParser::createFloatingNotAllQuery() |
9704 { | 9704 { |
9705 return createFloatingMediaQuery(MediaQuery::Not, AtomicString("all", AtomicS
tring::ConstructFromLiteral), sinkFloatingMediaQueryExpList(createFloatingMediaQ
ueryExpList())); | 9705 return createFloatingMediaQuery(MediaQuery::Not, AtomicString("all", AtomicS
tring::ConstructFromLiteral), sinkFloatingMediaQueryExpList(createFloatingMediaQ
ueryExpList())); |
9706 } | 9706 } |
9707 | 9707 |
9708 PassOwnPtr<MediaQuery> CSSParser::sinkFloatingMediaQuery(MediaQuery* query) | 9708 PassOwnPtr<MediaQuery> BisonCSSParser::sinkFloatingMediaQuery(MediaQuery* query) |
9709 { | 9709 { |
9710 ASSERT_UNUSED(query, query == m_floatingMediaQuery); | 9710 ASSERT_UNUSED(query, query == m_floatingMediaQuery); |
9711 return m_floatingMediaQuery.release(); | 9711 return m_floatingMediaQuery.release(); |
9712 } | 9712 } |
9713 | 9713 |
9714 Vector<RefPtr<StyleKeyframe> >* CSSParser::createFloatingKeyframeVector() | 9714 Vector<RefPtr<StyleKeyframe> >* BisonCSSParser::createFloatingKeyframeVector() |
9715 { | 9715 { |
9716 m_floatingKeyframeVector = adoptPtr(new Vector<RefPtr<StyleKeyframe> >()); | 9716 m_floatingKeyframeVector = adoptPtr(new Vector<RefPtr<StyleKeyframe> >()); |
9717 return m_floatingKeyframeVector.get(); | 9717 return m_floatingKeyframeVector.get(); |
9718 } | 9718 } |
9719 | 9719 |
9720 PassOwnPtr<Vector<RefPtr<StyleKeyframe> > > CSSParser::sinkFloatingKeyframeVecto
r(Vector<RefPtr<StyleKeyframe> >* keyframeVector) | 9720 PassOwnPtr<Vector<RefPtr<StyleKeyframe> > > BisonCSSParser::sinkFloatingKeyframe
Vector(Vector<RefPtr<StyleKeyframe> >* keyframeVector) |
9721 { | 9721 { |
9722 ASSERT_UNUSED(keyframeVector, m_floatingKeyframeVector == keyframeVector); | 9722 ASSERT_UNUSED(keyframeVector, m_floatingKeyframeVector == keyframeVector); |
9723 return m_floatingKeyframeVector.release(); | 9723 return m_floatingKeyframeVector.release(); |
9724 } | 9724 } |
9725 | 9725 |
9726 MediaQuerySet* CSSParser::createMediaQuerySet() | 9726 MediaQuerySet* BisonCSSParser::createMediaQuerySet() |
9727 { | 9727 { |
9728 RefPtr<MediaQuerySet> queries = MediaQuerySet::create(); | 9728 RefPtr<MediaQuerySet> queries = MediaQuerySet::create(); |
9729 MediaQuerySet* result = queries.get(); | 9729 MediaQuerySet* result = queries.get(); |
9730 m_parsedMediaQuerySets.append(queries.release()); | 9730 m_parsedMediaQuerySets.append(queries.release()); |
9731 return result; | 9731 return result; |
9732 } | 9732 } |
9733 | 9733 |
9734 StyleRuleBase* CSSParser::createImportRule(const CSSParserString& url, MediaQuer
ySet* media) | 9734 StyleRuleBase* BisonCSSParser::createImportRule(const CSSParserString& url, Medi
aQuerySet* media) |
9735 { | 9735 { |
9736 if (!media || !m_allowImportRules) | 9736 if (!media || !m_allowImportRules) |
9737 return 0; | 9737 return 0; |
9738 RefPtr<StyleRuleImport> rule = StyleRuleImport::create(url, media); | 9738 RefPtr<StyleRuleImport> rule = StyleRuleImport::create(url, media); |
9739 StyleRuleImport* result = rule.get(); | 9739 StyleRuleImport* result = rule.get(); |
9740 m_parsedRules.append(rule.release()); | 9740 m_parsedRules.append(rule.release()); |
9741 return result; | 9741 return result; |
9742 } | 9742 } |
9743 | 9743 |
9744 StyleRuleBase* CSSParser::createMediaRule(MediaQuerySet* media, RuleList* rules) | 9744 StyleRuleBase* BisonCSSParser::createMediaRule(MediaQuerySet* media, RuleList* r
ules) |
9745 { | 9745 { |
9746 m_allowImportRules = m_allowNamespaceDeclarations = false; | 9746 m_allowImportRules = m_allowNamespaceDeclarations = false; |
9747 RefPtr<StyleRuleMedia> rule; | 9747 RefPtr<StyleRuleMedia> rule; |
9748 if (rules) { | 9748 if (rules) { |
9749 rule = StyleRuleMedia::create(media ? media : MediaQuerySet::create(), *
rules); | 9749 rule = StyleRuleMedia::create(media ? media : MediaQuerySet::create(), *
rules); |
9750 } else { | 9750 } else { |
9751 RuleList emptyRules; | 9751 RuleList emptyRules; |
9752 rule = StyleRuleMedia::create(media ? media : MediaQuerySet::create(), e
mptyRules); | 9752 rule = StyleRuleMedia::create(media ? media : MediaQuerySet::create(), e
mptyRules); |
9753 } | 9753 } |
9754 StyleRuleMedia* result = rule.get(); | 9754 StyleRuleMedia* result = rule.get(); |
9755 m_parsedRules.append(rule.release()); | 9755 m_parsedRules.append(rule.release()); |
9756 return result; | 9756 return result; |
9757 } | 9757 } |
9758 | 9758 |
9759 StyleRuleBase* CSSParser::createSupportsRule(bool conditionIsSupported, RuleList
* rules) | 9759 StyleRuleBase* BisonCSSParser::createSupportsRule(bool conditionIsSupported, Rul
eList* rules) |
9760 { | 9760 { |
9761 m_allowImportRules = m_allowNamespaceDeclarations = false; | 9761 m_allowImportRules = m_allowNamespaceDeclarations = false; |
9762 | 9762 |
9763 RefPtr<CSSRuleSourceData> data = popSupportsRuleData(); | 9763 RefPtr<CSSRuleSourceData> data = popSupportsRuleData(); |
9764 RefPtr<StyleRuleSupports> rule; | 9764 RefPtr<StyleRuleSupports> rule; |
9765 String conditionText; | 9765 String conditionText; |
9766 unsigned conditionOffset = data->ruleHeaderRange.start + 9; | 9766 unsigned conditionOffset = data->ruleHeaderRange.start + 9; |
9767 unsigned conditionLength = data->ruleHeaderRange.length() - 9; | 9767 unsigned conditionLength = data->ruleHeaderRange.length() - 9; |
9768 | 9768 |
9769 if (m_tokenizer.is8BitSource()) | 9769 if (m_tokenizer.is8BitSource()) |
9770 conditionText = String(m_tokenizer.m_dataStart8.get() + conditionOffset,
conditionLength).stripWhiteSpace(); | 9770 conditionText = String(m_tokenizer.m_dataStart8.get() + conditionOffset,
conditionLength).stripWhiteSpace(); |
9771 else | 9771 else |
9772 conditionText = String(m_tokenizer.m_dataStart16.get() + conditionOffset
, conditionLength).stripWhiteSpace(); | 9772 conditionText = String(m_tokenizer.m_dataStart16.get() + conditionOffset
, conditionLength).stripWhiteSpace(); |
9773 | 9773 |
9774 if (rules) { | 9774 if (rules) { |
9775 rule = StyleRuleSupports::create(conditionText, conditionIsSupported, *r
ules); | 9775 rule = StyleRuleSupports::create(conditionText, conditionIsSupported, *r
ules); |
9776 } else { | 9776 } else { |
9777 RuleList emptyRules; | 9777 RuleList emptyRules; |
9778 rule = StyleRuleSupports::create(conditionText, conditionIsSupported, em
ptyRules); | 9778 rule = StyleRuleSupports::create(conditionText, conditionIsSupported, em
ptyRules); |
9779 } | 9779 } |
9780 | 9780 |
9781 StyleRuleSupports* result = rule.get(); | 9781 StyleRuleSupports* result = rule.get(); |
9782 m_parsedRules.append(rule.release()); | 9782 m_parsedRules.append(rule.release()); |
9783 | 9783 |
9784 return result; | 9784 return result; |
9785 } | 9785 } |
9786 | 9786 |
9787 void CSSParser::markSupportsRuleHeaderStart() | 9787 void BisonCSSParser::markSupportsRuleHeaderStart() |
9788 { | 9788 { |
9789 if (!m_supportsRuleDataStack) | 9789 if (!m_supportsRuleDataStack) |
9790 m_supportsRuleDataStack = adoptPtr(new RuleSourceDataList()); | 9790 m_supportsRuleDataStack = adoptPtr(new RuleSourceDataList()); |
9791 | 9791 |
9792 RefPtr<CSSRuleSourceData> data = CSSRuleSourceData::create(CSSRuleSourceData
::SUPPORTS_RULE); | 9792 RefPtr<CSSRuleSourceData> data = CSSRuleSourceData::create(CSSRuleSourceData
::SUPPORTS_RULE); |
9793 data->ruleHeaderRange.start = m_tokenizer.tokenStartOffset(); | 9793 data->ruleHeaderRange.start = m_tokenizer.tokenStartOffset(); |
9794 m_supportsRuleDataStack->append(data); | 9794 m_supportsRuleDataStack->append(data); |
9795 } | 9795 } |
9796 | 9796 |
9797 void CSSParser::markSupportsRuleHeaderEnd() | 9797 void BisonCSSParser::markSupportsRuleHeaderEnd() |
9798 { | 9798 { |
9799 ASSERT(m_supportsRuleDataStack && !m_supportsRuleDataStack->isEmpty()); | 9799 ASSERT(m_supportsRuleDataStack && !m_supportsRuleDataStack->isEmpty()); |
9800 | 9800 |
9801 if (m_tokenizer.is8BitSource()) | 9801 if (m_tokenizer.is8BitSource()) |
9802 m_supportsRuleDataStack->last()->ruleHeaderRange.end = m_tokenizer.token
Start<LChar>() - m_tokenizer.m_dataStart8.get(); | 9802 m_supportsRuleDataStack->last()->ruleHeaderRange.end = m_tokenizer.token
Start<LChar>() - m_tokenizer.m_dataStart8.get(); |
9803 else | 9803 else |
9804 m_supportsRuleDataStack->last()->ruleHeaderRange.end = m_tokenizer.token
Start<UChar>() - m_tokenizer.m_dataStart16.get(); | 9804 m_supportsRuleDataStack->last()->ruleHeaderRange.end = m_tokenizer.token
Start<UChar>() - m_tokenizer.m_dataStart16.get(); |
9805 } | 9805 } |
9806 | 9806 |
9807 PassRefPtr<CSSRuleSourceData> CSSParser::popSupportsRuleData() | 9807 PassRefPtr<CSSRuleSourceData> BisonCSSParser::popSupportsRuleData() |
9808 { | 9808 { |
9809 ASSERT(m_supportsRuleDataStack && !m_supportsRuleDataStack->isEmpty()); | 9809 ASSERT(m_supportsRuleDataStack && !m_supportsRuleDataStack->isEmpty()); |
9810 RefPtr<CSSRuleSourceData> data = m_supportsRuleDataStack->last(); | 9810 RefPtr<CSSRuleSourceData> data = m_supportsRuleDataStack->last(); |
9811 m_supportsRuleDataStack->removeLast(); | 9811 m_supportsRuleDataStack->removeLast(); |
9812 return data.release(); | 9812 return data.release(); |
9813 } | 9813 } |
9814 | 9814 |
9815 CSSParser::RuleList* CSSParser::createRuleList() | 9815 BisonCSSParser::RuleList* BisonCSSParser::createRuleList() |
9816 { | 9816 { |
9817 OwnPtr<RuleList> list = adoptPtr(new RuleList); | 9817 OwnPtr<RuleList> list = adoptPtr(new RuleList); |
9818 RuleList* listPtr = list.get(); | 9818 RuleList* listPtr = list.get(); |
9819 | 9819 |
9820 m_parsedRuleLists.append(list.release()); | 9820 m_parsedRuleLists.append(list.release()); |
9821 return listPtr; | 9821 return listPtr; |
9822 } | 9822 } |
9823 | 9823 |
9824 CSSParser::RuleList* CSSParser::appendRule(RuleList* ruleList, StyleRuleBase* ru
le) | 9824 BisonCSSParser::RuleList* BisonCSSParser::appendRule(RuleList* ruleList, StyleRu
leBase* rule) |
9825 { | 9825 { |
9826 if (rule) { | 9826 if (rule) { |
9827 if (!ruleList) | 9827 if (!ruleList) |
9828 ruleList = createRuleList(); | 9828 ruleList = createRuleList(); |
9829 ruleList->append(rule); | 9829 ruleList->append(rule); |
9830 } | 9830 } |
9831 return ruleList; | 9831 return ruleList; |
9832 } | 9832 } |
9833 | 9833 |
9834 template <typename CharacterType> | 9834 template <typename CharacterType> |
9835 ALWAYS_INLINE static void makeLower(const CharacterType* input, CharacterType* o
utput, unsigned length) | 9835 ALWAYS_INLINE static void makeLower(const CharacterType* input, CharacterType* o
utput, unsigned length) |
9836 { | 9836 { |
9837 // FIXME: If we need Unicode lowercasing here, then we probably want the rea
l kind | 9837 // FIXME: If we need Unicode lowercasing here, then we probably want the rea
l kind |
9838 // that can potentially change the length of the string rather than the char
acter | 9838 // that can potentially change the length of the string rather than the char
acter |
9839 // by character kind. If we don't need Unicode lowercasing, it would be good
to | 9839 // by character kind. If we don't need Unicode lowercasing, it would be good
to |
9840 // simplify this function. | 9840 // simplify this function. |
9841 | 9841 |
9842 if (charactersAreAllASCII(input, length)) { | 9842 if (charactersAreAllASCII(input, length)) { |
9843 // Fast case for all-ASCII. | 9843 // Fast case for all-ASCII. |
9844 for (unsigned i = 0; i < length; i++) | 9844 for (unsigned i = 0; i < length; i++) |
9845 output[i] = toASCIILower(input[i]); | 9845 output[i] = toASCIILower(input[i]); |
9846 } else { | 9846 } else { |
9847 for (unsigned i = 0; i < length; i++) | 9847 for (unsigned i = 0; i < length; i++) |
9848 output[i] = Unicode::toLower(input[i]); | 9848 output[i] = Unicode::toLower(input[i]); |
9849 } | 9849 } |
9850 } | 9850 } |
9851 | 9851 |
9852 void CSSParser::tokenToLowerCase(const CSSParserString& token) | 9852 void BisonCSSParser::tokenToLowerCase(const CSSParserString& token) |
9853 { | 9853 { |
9854 size_t length = token.length(); | 9854 size_t length = token.length(); |
9855 if (m_tokenizer.is8BitSource()) { | 9855 if (m_tokenizer.is8BitSource()) { |
9856 size_t offset = token.characters8() - m_tokenizer.m_dataStart8.get(); | 9856 size_t offset = token.characters8() - m_tokenizer.m_dataStart8.get(); |
9857 makeLower(token.characters8(), m_tokenizer.m_dataStart8.get() + offset,
length); | 9857 makeLower(token.characters8(), m_tokenizer.m_dataStart8.get() + offset,
length); |
9858 } else { | 9858 } else { |
9859 size_t offset = token.characters16() - m_tokenizer.m_dataStart16.get(); | 9859 size_t offset = token.characters16() - m_tokenizer.m_dataStart16.get(); |
9860 makeLower(token.characters16(), m_tokenizer.m_dataStart16.get() + offset
, length); | 9860 makeLower(token.characters16(), m_tokenizer.m_dataStart16.get() + offset
, length); |
9861 } | 9861 } |
9862 } | 9862 } |
9863 | 9863 |
9864 void CSSParser::endInvalidRuleHeader() | 9864 void BisonCSSParser::endInvalidRuleHeader() |
9865 { | 9865 { |
9866 if (m_ruleHeaderType == CSSRuleSourceData::UNKNOWN_RULE) | 9866 if (m_ruleHeaderType == CSSRuleSourceData::UNKNOWN_RULE) |
9867 return; | 9867 return; |
9868 | 9868 |
9869 CSSParserLocation location; | 9869 CSSParserLocation location; |
9870 location.lineNumber = m_tokenizer.m_lineNumber; | 9870 location.lineNumber = m_tokenizer.m_lineNumber; |
9871 location.offset = m_ruleHeaderStartOffset; | 9871 location.offset = m_ruleHeaderStartOffset; |
9872 if (m_tokenizer.is8BitSource()) | 9872 if (m_tokenizer.is8BitSource()) |
9873 location.token.init(m_tokenizer.m_dataStart8.get() + m_ruleHeaderStartOf
fset, 0); | 9873 location.token.init(m_tokenizer.m_dataStart8.get() + m_ruleHeaderStartOf
fset, 0); |
9874 else | 9874 else |
9875 location.token.init(m_tokenizer.m_dataStart16.get() + m_ruleHeaderStartO
ffset, 0); | 9875 location.token.init(m_tokenizer.m_dataStart16.get() + m_ruleHeaderStartO
ffset, 0); |
9876 | 9876 |
9877 reportError(location, m_ruleHeaderType == CSSRuleSourceData::STYLE_RULE ? In
validSelectorCSSError : InvalidRuleCSSError); | 9877 reportError(location, m_ruleHeaderType == CSSRuleSourceData::STYLE_RULE ? In
validSelectorCSSError : InvalidRuleCSSError); |
9878 | 9878 |
9879 endRuleHeader(); | 9879 endRuleHeader(); |
9880 } | 9880 } |
9881 | 9881 |
9882 void CSSParser::reportError(const CSSParserLocation&, CSSParserError) | 9882 void BisonCSSParser::reportError(const CSSParserLocation&, CSSParserError) |
9883 { | 9883 { |
9884 // FIXME: error reporting temporatily disabled. | 9884 // FIXME: error reporting temporatily disabled. |
9885 } | 9885 } |
9886 | 9886 |
9887 bool CSSParser::isLoggingErrors() | 9887 bool BisonCSSParser::isLoggingErrors() |
9888 { | 9888 { |
9889 return m_logErrors && !m_ignoreErrors; | 9889 return m_logErrors && !m_ignoreErrors; |
9890 } | 9890 } |
9891 | 9891 |
9892 void CSSParser::logError(const String& message, const CSSParserLocation& locatio
n) | 9892 void BisonCSSParser::logError(const String& message, const CSSParserLocation& lo
cation) |
9893 { | 9893 { |
9894 unsigned lineNumberInStyleSheet; | 9894 unsigned lineNumberInStyleSheet; |
9895 unsigned columnNumber = 0; | 9895 unsigned columnNumber = 0; |
9896 if (InspectorInstrumentation::hasFrontends()) { | 9896 if (InspectorInstrumentation::hasFrontends()) { |
9897 ensureLineEndings(); | 9897 ensureLineEndings(); |
9898 TextPosition tokenPosition = TextPosition::fromOffsetAndLineEndings(loca
tion.offset, *m_lineEndings); | 9898 TextPosition tokenPosition = TextPosition::fromOffsetAndLineEndings(loca
tion.offset, *m_lineEndings); |
9899 lineNumberInStyleSheet = tokenPosition.m_line.zeroBasedInt(); | 9899 lineNumberInStyleSheet = tokenPosition.m_line.zeroBasedInt(); |
9900 columnNumber = (lineNumberInStyleSheet ? 0 : m_startPosition.m_column.ze
roBasedInt()) + tokenPosition.m_column.zeroBasedInt(); | 9900 columnNumber = (lineNumberInStyleSheet ? 0 : m_startPosition.m_column.ze
roBasedInt()) + tokenPosition.m_column.zeroBasedInt(); |
9901 } else { | 9901 } else { |
9902 lineNumberInStyleSheet = location.lineNumber; | 9902 lineNumberInStyleSheet = location.lineNumber; |
9903 } | 9903 } |
9904 PageConsole& console = m_styleSheet->singleOwnerDocument()->frameHost()->con
sole(); | 9904 PageConsole& console = m_styleSheet->singleOwnerDocument()->frameHost()->con
sole(); |
9905 console.addMessage(CSSMessageSource, WarningMessageLevel, message, m_styleSh
eet->baseURL().string(), lineNumberInStyleSheet + m_startPosition.m_line.zeroBas
edInt() + 1, columnNumber + 1); | 9905 console.addMessage(CSSMessageSource, WarningMessageLevel, message, m_styleSh
eet->baseURL().string(), lineNumberInStyleSheet + m_startPosition.m_line.zeroBas
edInt() + 1, columnNumber + 1); |
9906 } | 9906 } |
9907 | 9907 |
9908 StyleRuleKeyframes* CSSParser::createKeyframesRule(const String& name, PassOwnPt
r<Vector<RefPtr<StyleKeyframe> > > popKeyframes, bool isPrefixed) | 9908 StyleRuleKeyframes* BisonCSSParser::createKeyframesRule(const String& name, Pass
OwnPtr<Vector<RefPtr<StyleKeyframe> > > popKeyframes, bool isPrefixed) |
9909 { | 9909 { |
9910 OwnPtr<Vector<RefPtr<StyleKeyframe> > > keyframes = popKeyframes; | 9910 OwnPtr<Vector<RefPtr<StyleKeyframe> > > keyframes = popKeyframes; |
9911 m_allowImportRules = m_allowNamespaceDeclarations = false; | 9911 m_allowImportRules = m_allowNamespaceDeclarations = false; |
9912 RefPtr<StyleRuleKeyframes> rule = StyleRuleKeyframes::create(); | 9912 RefPtr<StyleRuleKeyframes> rule = StyleRuleKeyframes::create(); |
9913 for (size_t i = 0; i < keyframes->size(); ++i) | 9913 for (size_t i = 0; i < keyframes->size(); ++i) |
9914 rule->parserAppendKeyframe(keyframes->at(i)); | 9914 rule->parserAppendKeyframe(keyframes->at(i)); |
9915 rule->setName(name); | 9915 rule->setName(name); |
9916 rule->setVendorPrefixed(isPrefixed); | 9916 rule->setVendorPrefixed(isPrefixed); |
9917 StyleRuleKeyframes* rulePtr = rule.get(); | 9917 StyleRuleKeyframes* rulePtr = rule.get(); |
9918 m_parsedRules.append(rule.release()); | 9918 m_parsedRules.append(rule.release()); |
9919 return rulePtr; | 9919 return rulePtr; |
9920 } | 9920 } |
9921 | 9921 |
9922 StyleRuleBase* CSSParser::createStyleRule(Vector<OwnPtr<CSSParserSelector> >* se
lectors) | 9922 StyleRuleBase* BisonCSSParser::createStyleRule(Vector<OwnPtr<CSSParserSelector>
>* selectors) |
9923 { | 9923 { |
9924 StyleRule* result = 0; | 9924 StyleRule* result = 0; |
9925 if (selectors) { | 9925 if (selectors) { |
9926 m_allowImportRules = m_allowNamespaceDeclarations = false; | 9926 m_allowImportRules = m_allowNamespaceDeclarations = false; |
9927 RefPtr<StyleRule> rule = StyleRule::create(); | 9927 RefPtr<StyleRule> rule = StyleRule::create(); |
9928 rule->parserAdoptSelectorVector(*selectors); | 9928 rule->parserAdoptSelectorVector(*selectors); |
9929 if (m_hasFontFaceOnlyValues) | 9929 if (m_hasFontFaceOnlyValues) |
9930 deleteFontFaceOnlyValues(); | 9930 deleteFontFaceOnlyValues(); |
9931 rule->setProperties(createStylePropertySet()); | 9931 rule->setProperties(createStylePropertySet()); |
9932 result = rule.get(); | 9932 result = rule.get(); |
9933 m_parsedRules.append(rule.release()); | 9933 m_parsedRules.append(rule.release()); |
9934 } | 9934 } |
9935 clearProperties(); | 9935 clearProperties(); |
9936 return result; | 9936 return result; |
9937 } | 9937 } |
9938 | 9938 |
9939 StyleRuleBase* CSSParser::createFontFaceRule() | 9939 StyleRuleBase* BisonCSSParser::createFontFaceRule() |
9940 { | 9940 { |
9941 m_allowImportRules = m_allowNamespaceDeclarations = false; | 9941 m_allowImportRules = m_allowNamespaceDeclarations = false; |
9942 for (unsigned i = 0; i < m_parsedProperties.size(); ++i) { | 9942 for (unsigned i = 0; i < m_parsedProperties.size(); ++i) { |
9943 CSSProperty& property = m_parsedProperties[i]; | 9943 CSSProperty& property = m_parsedProperties[i]; |
9944 if (property.id() == CSSPropertyFontVariant && property.value()->isPrimi
tiveValue()) | 9944 if (property.id() == CSSPropertyFontVariant && property.value()->isPrimi
tiveValue()) |
9945 property.wrapValueInCommaSeparatedList(); | 9945 property.wrapValueInCommaSeparatedList(); |
9946 else if (property.id() == CSSPropertyFontFamily && (!property.value()->i
sValueList() || toCSSValueList(property.value())->length() != 1)) { | 9946 else if (property.id() == CSSPropertyFontFamily && (!property.value()->i
sValueList() || toCSSValueList(property.value())->length() != 1)) { |
9947 // Unlike font-family property, font-family descriptor in @font-face
rule | 9947 // Unlike font-family property, font-family descriptor in @font-face
rule |
9948 // has to be a value list with exactly one family name. It cannot ha
ve a | 9948 // has to be a value list with exactly one family name. It cannot ha
ve a |
9949 // have 'initial' value and cannot 'inherit' from parent. | 9949 // have 'initial' value and cannot 'inherit' from parent. |
9950 // See http://dev.w3.org/csswg/css3-fonts/#font-family-desc | 9950 // See http://dev.w3.org/csswg/css3-fonts/#font-family-desc |
9951 clearProperties(); | 9951 clearProperties(); |
9952 return 0; | 9952 return 0; |
9953 } | 9953 } |
9954 } | 9954 } |
9955 RefPtr<StyleRuleFontFace> rule = StyleRuleFontFace::create(); | 9955 RefPtr<StyleRuleFontFace> rule = StyleRuleFontFace::create(); |
9956 rule->setProperties(createStylePropertySet()); | 9956 rule->setProperties(createStylePropertySet()); |
9957 clearProperties(); | 9957 clearProperties(); |
9958 StyleRuleFontFace* result = rule.get(); | 9958 StyleRuleFontFace* result = rule.get(); |
9959 m_parsedRules.append(rule.release()); | 9959 m_parsedRules.append(rule.release()); |
9960 if (m_styleSheet) | 9960 if (m_styleSheet) |
9961 m_styleSheet->setHasFontFaceRule(true); | 9961 m_styleSheet->setHasFontFaceRule(true); |
9962 return result; | 9962 return result; |
9963 } | 9963 } |
9964 | 9964 |
9965 void CSSParser::addNamespace(const AtomicString& prefix, const AtomicString& uri
) | 9965 void BisonCSSParser::addNamespace(const AtomicString& prefix, const AtomicString
& uri) |
9966 { | 9966 { |
9967 if (!m_styleSheet || !m_allowNamespaceDeclarations) | 9967 if (!m_styleSheet || !m_allowNamespaceDeclarations) |
9968 return; | 9968 return; |
9969 m_allowImportRules = false; | 9969 m_allowImportRules = false; |
9970 m_styleSheet->parserAddNamespace(prefix, uri); | 9970 m_styleSheet->parserAddNamespace(prefix, uri); |
9971 if (prefix.isEmpty() && !uri.isNull()) | 9971 if (prefix.isEmpty() && !uri.isNull()) |
9972 m_defaultNamespace = uri; | 9972 m_defaultNamespace = uri; |
9973 } | 9973 } |
9974 | 9974 |
9975 QualifiedName CSSParser::determineNameInNamespace(const AtomicString& prefix, co
nst AtomicString& localName) | 9975 QualifiedName BisonCSSParser::determineNameInNamespace(const AtomicString& prefi
x, const AtomicString& localName) |
9976 { | 9976 { |
9977 if (!m_styleSheet) | 9977 if (!m_styleSheet) |
9978 return QualifiedName(prefix, localName, m_defaultNamespace); | 9978 return QualifiedName(prefix, localName, m_defaultNamespace); |
9979 return QualifiedName(prefix, localName, m_styleSheet->determineNamespace(pre
fix)); | 9979 return QualifiedName(prefix, localName, m_styleSheet->determineNamespace(pre
fix)); |
9980 } | 9980 } |
9981 | 9981 |
9982 CSSParserSelector* CSSParser::rewriteSpecifiersWithNamespaceIfNeeded(CSSParserSe
lector* specifiers) | 9982 CSSParserSelector* BisonCSSParser::rewriteSpecifiersWithNamespaceIfNeeded(CSSPar
serSelector* specifiers) |
9983 { | 9983 { |
9984 if (m_defaultNamespace != starAtom || specifiers->needsCrossingTreeScopeBoun
dary()) | 9984 if (m_defaultNamespace != starAtom || specifiers->needsCrossingTreeScopeBoun
dary()) |
9985 return rewriteSpecifiersWithElementName(nullAtom, starAtom, specifiers,
/*tagIsForNamespaceRule*/true); | 9985 return rewriteSpecifiersWithElementName(nullAtom, starAtom, specifiers,
/*tagIsForNamespaceRule*/true); |
9986 if (CSSParserSelector* distributedPseudoElementSelector = specifiers->findDi
stributedPseudoElementSelector()) { | 9986 if (CSSParserSelector* distributedPseudoElementSelector = specifiers->findDi
stributedPseudoElementSelector()) { |
9987 specifiers->prependTagSelector(QualifiedName(nullAtom, starAtom, m_defau
ltNamespace), /*tagIsForNamespaceRule*/true); | 9987 specifiers->prependTagSelector(QualifiedName(nullAtom, starAtom, m_defau
ltNamespace), /*tagIsForNamespaceRule*/true); |
9988 return rewriteSpecifiersForShadowDistributed(specifiers, distributedPseu
doElementSelector); | 9988 return rewriteSpecifiersForShadowDistributed(specifiers, distributedPseu
doElementSelector); |
9989 } | 9989 } |
9990 return specifiers; | 9990 return specifiers; |
9991 } | 9991 } |
9992 | 9992 |
9993 CSSParserSelector* CSSParser::rewriteSpecifiersWithElementName(const AtomicStrin
g& namespacePrefix, const AtomicString& elementName, CSSParserSelector* specifie
rs, bool tagIsForNamespaceRule) | 9993 CSSParserSelector* BisonCSSParser::rewriteSpecifiersWithElementName(const Atomic
String& namespacePrefix, const AtomicString& elementName, CSSParserSelector* spe
cifiers, bool tagIsForNamespaceRule) |
9994 { | 9994 { |
9995 AtomicString determinedNamespace = namespacePrefix != nullAtom && m_styleShe
et ? m_styleSheet->determineNamespace(namespacePrefix) : m_defaultNamespace; | 9995 AtomicString determinedNamespace = namespacePrefix != nullAtom && m_styleShe
et ? m_styleSheet->determineNamespace(namespacePrefix) : m_defaultNamespace; |
9996 QualifiedName tag(namespacePrefix, elementName, determinedNamespace); | 9996 QualifiedName tag(namespacePrefix, elementName, determinedNamespace); |
9997 | 9997 |
9998 if (CSSParserSelector* distributedPseudoElementSelector = specifiers->findDi
stributedPseudoElementSelector()) { | 9998 if (CSSParserSelector* distributedPseudoElementSelector = specifiers->findDi
stributedPseudoElementSelector()) { |
9999 specifiers->prependTagSelector(tag, tagIsForNamespaceRule); | 9999 specifiers->prependTagSelector(tag, tagIsForNamespaceRule); |
10000 return rewriteSpecifiersForShadowDistributed(specifiers, distributedPseu
doElementSelector); | 10000 return rewriteSpecifiersForShadowDistributed(specifiers, distributedPseu
doElementSelector); |
10001 } | 10001 } |
10002 | 10002 |
10003 if (specifiers->needsCrossingTreeScopeBoundary()) | 10003 if (specifiers->needsCrossingTreeScopeBoundary()) |
10004 return rewriteSpecifiersWithElementNameForCustomPseudoElement(tag, eleme
ntName, specifiers, tagIsForNamespaceRule); | 10004 return rewriteSpecifiersWithElementNameForCustomPseudoElement(tag, eleme
ntName, specifiers, tagIsForNamespaceRule); |
10005 | 10005 |
10006 if (specifiers->isContentPseudoElement()) | 10006 if (specifiers->isContentPseudoElement()) |
10007 return rewriteSpecifiersWithElementNameForContentPseudoElement(tag, elem
entName, specifiers, tagIsForNamespaceRule); | 10007 return rewriteSpecifiersWithElementNameForContentPseudoElement(tag, elem
entName, specifiers, tagIsForNamespaceRule); |
10008 | 10008 |
10009 if (tag == anyQName()) | 10009 if (tag == anyQName()) |
10010 return specifiers; | 10010 return specifiers; |
10011 if (!(specifiers->pseudoType() == CSSSelector::PseudoCue)) | 10011 if (!(specifiers->pseudoType() == CSSSelector::PseudoCue)) |
10012 specifiers->prependTagSelector(tag, tagIsForNamespaceRule); | 10012 specifiers->prependTagSelector(tag, tagIsForNamespaceRule); |
10013 return specifiers; | 10013 return specifiers; |
10014 } | 10014 } |
10015 | 10015 |
10016 CSSParserSelector* CSSParser::rewriteSpecifiersWithElementNameForCustomPseudoEle
ment(const QualifiedName& tag, const AtomicString& elementName, CSSParserSelecto
r* specifiers, bool tagIsForNamespaceRule) | 10016 CSSParserSelector* BisonCSSParser::rewriteSpecifiersWithElementNameForCustomPseu
doElement(const QualifiedName& tag, const AtomicString& elementName, CSSParserSe
lector* specifiers, bool tagIsForNamespaceRule) |
10017 { | 10017 { |
10018 if (m_useCounter && specifiers->pseudoType() == CSSSelector::PseudoUserAgent
CustomElement) | 10018 if (m_useCounter && specifiers->pseudoType() == CSSSelector::PseudoUserAgent
CustomElement) |
10019 m_useCounter->count(UseCounter::CSSPseudoElementUserAgentCustomPseudo); | 10019 m_useCounter->count(UseCounter::CSSPseudoElementUserAgentCustomPseudo); |
10020 | 10020 |
10021 CSSParserSelector* lastShadowPseudo = specifiers; | 10021 CSSParserSelector* lastShadowPseudo = specifiers; |
10022 CSSParserSelector* history = specifiers; | 10022 CSSParserSelector* history = specifiers; |
10023 while (history->tagHistory()) { | 10023 while (history->tagHistory()) { |
10024 history = history->tagHistory(); | 10024 history = history->tagHistory(); |
10025 if (history->needsCrossingTreeScopeBoundary() || history->hasShadowPseud
o()) | 10025 if (history->needsCrossingTreeScopeBoundary() || history->hasShadowPseud
o()) |
10026 lastShadowPseudo = history; | 10026 lastShadowPseudo = history; |
10027 } | 10027 } |
10028 | 10028 |
10029 if (lastShadowPseudo->tagHistory()) { | 10029 if (lastShadowPseudo->tagHistory()) { |
10030 if (tag != anyQName()) | 10030 if (tag != anyQName()) |
10031 lastShadowPseudo->tagHistory()->prependTagSelector(tag, tagIsForName
spaceRule); | 10031 lastShadowPseudo->tagHistory()->prependTagSelector(tag, tagIsForName
spaceRule); |
10032 return specifiers; | 10032 return specifiers; |
10033 } | 10033 } |
10034 | 10034 |
10035 // For shadow-ID pseudo-elements to be correctly matched, the ShadowPseudo c
ombinator has to be used. | 10035 // For shadow-ID pseudo-elements to be correctly matched, the ShadowPseudo c
ombinator has to be used. |
10036 // We therefore create a new Selector with that combinator here in any case,
even if matching any (host) element in any namespace (i.e. '*'). | 10036 // We therefore create a new Selector with that combinator here in any case,
even if matching any (host) element in any namespace (i.e. '*'). |
10037 OwnPtr<CSSParserSelector> elementNameSelector = adoptPtr(new CSSParserSelect
or(tag)); | 10037 OwnPtr<CSSParserSelector> elementNameSelector = adoptPtr(new CSSParserSelect
or(tag)); |
10038 lastShadowPseudo->setTagHistory(elementNameSelector.release()); | 10038 lastShadowPseudo->setTagHistory(elementNameSelector.release()); |
10039 lastShadowPseudo->setRelation(CSSSelector::ShadowPseudo); | 10039 lastShadowPseudo->setRelation(CSSSelector::ShadowPseudo); |
10040 return specifiers; | 10040 return specifiers; |
10041 } | 10041 } |
10042 | 10042 |
10043 CSSParserSelector* CSSParser::rewriteSpecifiersWithElementNameForContentPseudoEl
ement(const QualifiedName& tag, const AtomicString& elementName, CSSParserSelect
or* specifiers, bool tagIsForNamespaceRule) | 10043 CSSParserSelector* BisonCSSParser::rewriteSpecifiersWithElementNameForContentPse
udoElement(const QualifiedName& tag, const AtomicString& elementName, CSSParserS
elector* specifiers, bool tagIsForNamespaceRule) |
10044 { | 10044 { |
10045 CSSParserSelector* last = specifiers; | 10045 CSSParserSelector* last = specifiers; |
10046 CSSParserSelector* history = specifiers; | 10046 CSSParserSelector* history = specifiers; |
10047 while (history->tagHistory()) { | 10047 while (history->tagHistory()) { |
10048 history = history->tagHistory(); | 10048 history = history->tagHistory(); |
10049 if (history->isContentPseudoElement() || history->relationIsAffectedByPs
eudoContent()) | 10049 if (history->isContentPseudoElement() || history->relationIsAffectedByPs
eudoContent()) |
10050 last = history; | 10050 last = history; |
10051 } | 10051 } |
10052 | 10052 |
10053 if (last->tagHistory()) { | 10053 if (last->tagHistory()) { |
10054 if (tag != anyQName()) | 10054 if (tag != anyQName()) |
10055 last->tagHistory()->prependTagSelector(tag, tagIsForNamespaceRule); | 10055 last->tagHistory()->prependTagSelector(tag, tagIsForNamespaceRule); |
10056 return specifiers; | 10056 return specifiers; |
10057 } | 10057 } |
10058 | 10058 |
10059 // For shadow-ID pseudo-elements to be correctly matched, the ShadowPseudo c
ombinator has to be used. | 10059 // For shadow-ID pseudo-elements to be correctly matched, the ShadowPseudo c
ombinator has to be used. |
10060 // We therefore create a new Selector with that combinator here in any case,
even if matching any (host) element in any namespace (i.e. '*'). | 10060 // We therefore create a new Selector with that combinator here in any case,
even if matching any (host) element in any namespace (i.e. '*'). |
10061 OwnPtr<CSSParserSelector> elementNameSelector = adoptPtr(new CSSParserSelect
or(tag)); | 10061 OwnPtr<CSSParserSelector> elementNameSelector = adoptPtr(new CSSParserSelect
or(tag)); |
10062 last->setTagHistory(elementNameSelector.release()); | 10062 last->setTagHistory(elementNameSelector.release()); |
10063 last->setRelation(CSSSelector::SubSelector); | 10063 last->setRelation(CSSSelector::SubSelector); |
10064 return specifiers; | 10064 return specifiers; |
10065 } | 10065 } |
10066 | 10066 |
10067 CSSParserSelector* CSSParser::rewriteSpecifiersForShadowDistributed(CSSParserSel
ector* specifiers, CSSParserSelector* distributedPseudoElementSelector) | 10067 CSSParserSelector* BisonCSSParser::rewriteSpecifiersForShadowDistributed(CSSPars
erSelector* specifiers, CSSParserSelector* distributedPseudoElementSelector) |
10068 { | 10068 { |
10069 if (m_useCounter) | 10069 if (m_useCounter) |
10070 m_useCounter->count(UseCounter::CSSPseudoElementPrefixedDistributed); | 10070 m_useCounter->count(UseCounter::CSSPseudoElementPrefixedDistributed); |
10071 CSSParserSelector* argumentSelector = distributedPseudoElementSelector->func
tionArgumentSelector(); | 10071 CSSParserSelector* argumentSelector = distributedPseudoElementSelector->func
tionArgumentSelector(); |
10072 ASSERT(argumentSelector); | 10072 ASSERT(argumentSelector); |
10073 ASSERT(!specifiers->isDistributedPseudoElement()); | 10073 ASSERT(!specifiers->isDistributedPseudoElement()); |
10074 for (CSSParserSelector* end = specifiers; end->tagHistory(); end = end->tagH
istory()) { | 10074 for (CSSParserSelector* end = specifiers; end->tagHistory(); end = end->tagH
istory()) { |
10075 if (end->tagHistory()->isDistributedPseudoElement()) { | 10075 if (end->tagHistory()->isDistributedPseudoElement()) { |
10076 end->clearTagHistory(); | 10076 end->clearTagHistory(); |
10077 break; | 10077 break; |
10078 } | 10078 } |
10079 } | 10079 } |
10080 CSSParserSelector* end = argumentSelector; | 10080 CSSParserSelector* end = argumentSelector; |
10081 while (end->tagHistory()) | 10081 while (end->tagHistory()) |
10082 end = end->tagHistory(); | 10082 end = end->tagHistory(); |
10083 | 10083 |
10084 switch (end->relation()) { | 10084 switch (end->relation()) { |
10085 case CSSSelector::Child: | 10085 case CSSSelector::Child: |
10086 case CSSSelector::Descendant: | 10086 case CSSSelector::Descendant: |
10087 end->setTagHistory(sinkFloatingSelector(specifiers)); | 10087 end->setTagHistory(sinkFloatingSelector(specifiers)); |
10088 end->setRelationIsAffectedByPseudoContent(); | 10088 end->setRelationIsAffectedByPseudoContent(); |
10089 return argumentSelector; | 10089 return argumentSelector; |
10090 default: | 10090 default: |
10091 return 0; | 10091 return 0; |
10092 } | 10092 } |
10093 } | 10093 } |
10094 | 10094 |
10095 CSSParserSelector* CSSParser::rewriteSpecifiers(CSSParserSelector* specifiers, C
SSParserSelector* newSpecifier) | 10095 CSSParserSelector* BisonCSSParser::rewriteSpecifiers(CSSParserSelector* specifie
rs, CSSParserSelector* newSpecifier) |
10096 { | 10096 { |
10097 if (newSpecifier->needsCrossingTreeScopeBoundary()) { | 10097 if (newSpecifier->needsCrossingTreeScopeBoundary()) { |
10098 // Unknown pseudo element always goes at the top of selector chain. | 10098 // Unknown pseudo element always goes at the top of selector chain. |
10099 newSpecifier->appendTagHistory(CSSSelector::ShadowPseudo, sinkFloatingSe
lector(specifiers)); | 10099 newSpecifier->appendTagHistory(CSSSelector::ShadowPseudo, sinkFloatingSe
lector(specifiers)); |
10100 return newSpecifier; | 10100 return newSpecifier; |
10101 } | 10101 } |
10102 if (newSpecifier->isContentPseudoElement()) { | 10102 if (newSpecifier->isContentPseudoElement()) { |
10103 newSpecifier->appendTagHistory(CSSSelector::SubSelector, sinkFloatingSel
ector(specifiers)); | 10103 newSpecifier->appendTagHistory(CSSSelector::SubSelector, sinkFloatingSel
ector(specifiers)); |
10104 return newSpecifier; | 10104 return newSpecifier; |
10105 } | 10105 } |
10106 if (specifiers->needsCrossingTreeScopeBoundary()) { | 10106 if (specifiers->needsCrossingTreeScopeBoundary()) { |
10107 // Specifiers for unknown pseudo element go right behind it in the chain
. | 10107 // Specifiers for unknown pseudo element go right behind it in the chain
. |
10108 specifiers->insertTagHistory(CSSSelector::SubSelector, sinkFloatingSelec
tor(newSpecifier), CSSSelector::ShadowPseudo); | 10108 specifiers->insertTagHistory(CSSSelector::SubSelector, sinkFloatingSelec
tor(newSpecifier), CSSSelector::ShadowPseudo); |
10109 return specifiers; | 10109 return specifiers; |
10110 } | 10110 } |
10111 if (specifiers->isContentPseudoElement()) { | 10111 if (specifiers->isContentPseudoElement()) { |
10112 specifiers->insertTagHistory(CSSSelector::SubSelector, sinkFloatingSelec
tor(newSpecifier), CSSSelector::SubSelector); | 10112 specifiers->insertTagHistory(CSSSelector::SubSelector, sinkFloatingSelec
tor(newSpecifier), CSSSelector::SubSelector); |
10113 return specifiers; | 10113 return specifiers; |
10114 } | 10114 } |
10115 specifiers->appendTagHistory(CSSSelector::SubSelector, sinkFloatingSelector(
newSpecifier)); | 10115 specifiers->appendTagHistory(CSSSelector::SubSelector, sinkFloatingSelector(
newSpecifier)); |
10116 return specifiers; | 10116 return specifiers; |
10117 } | 10117 } |
10118 | 10118 |
10119 StyleRuleBase* CSSParser::createPageRule(PassOwnPtr<CSSParserSelector> pageSelec
tor) | 10119 StyleRuleBase* BisonCSSParser::createPageRule(PassOwnPtr<CSSParserSelector> page
Selector) |
10120 { | 10120 { |
10121 // FIXME: Margin at-rules are ignored. | 10121 // FIXME: Margin at-rules are ignored. |
10122 m_allowImportRules = m_allowNamespaceDeclarations = false; | 10122 m_allowImportRules = m_allowNamespaceDeclarations = false; |
10123 StyleRulePage* pageRule = 0; | 10123 StyleRulePage* pageRule = 0; |
10124 if (pageSelector) { | 10124 if (pageSelector) { |
10125 RefPtr<StyleRulePage> rule = StyleRulePage::create(); | 10125 RefPtr<StyleRulePage> rule = StyleRulePage::create(); |
10126 Vector<OwnPtr<CSSParserSelector> > selectorVector; | 10126 Vector<OwnPtr<CSSParserSelector> > selectorVector; |
10127 selectorVector.append(pageSelector); | 10127 selectorVector.append(pageSelector); |
10128 rule->parserAdoptSelectorVector(selectorVector); | 10128 rule->parserAdoptSelectorVector(selectorVector); |
10129 rule->setProperties(createStylePropertySet()); | 10129 rule->setProperties(createStylePropertySet()); |
10130 pageRule = rule.get(); | 10130 pageRule = rule.get(); |
10131 m_parsedRules.append(rule.release()); | 10131 m_parsedRules.append(rule.release()); |
10132 } | 10132 } |
10133 clearProperties(); | 10133 clearProperties(); |
10134 return pageRule; | 10134 return pageRule; |
10135 } | 10135 } |
10136 | 10136 |
10137 void CSSParser::setReusableRegionSelectorVector(Vector<OwnPtr<CSSParserSelector>
>* selectors) | 10137 void BisonCSSParser::setReusableRegionSelectorVector(Vector<OwnPtr<CSSParserSele
ctor> >* selectors) |
10138 { | 10138 { |
10139 if (selectors) | 10139 if (selectors) |
10140 m_reusableRegionSelectorVector.swap(*selectors); | 10140 m_reusableRegionSelectorVector.swap(*selectors); |
10141 } | 10141 } |
10142 | 10142 |
10143 StyleRuleBase* CSSParser::createRegionRule(Vector<OwnPtr<CSSParserSelector> >* r
egionSelector, RuleList* rules) | 10143 StyleRuleBase* BisonCSSParser::createRegionRule(Vector<OwnPtr<CSSParserSelector>
>* regionSelector, RuleList* rules) |
10144 { | 10144 { |
10145 if (m_useCounter) | 10145 if (m_useCounter) |
10146 m_useCounter->count(UseCounter::CSSWebkitRegionAtRule); | 10146 m_useCounter->count(UseCounter::CSSWebkitRegionAtRule); |
10147 | 10147 |
10148 if (!RuntimeEnabledFeatures::cssRegionsEnabled() || !regionSelector || !rule
s) | 10148 if (!RuntimeEnabledFeatures::cssRegionsEnabled() || !regionSelector || !rule
s) |
10149 return 0; | 10149 return 0; |
10150 | 10150 |
10151 m_allowImportRules = m_allowNamespaceDeclarations = false; | 10151 m_allowImportRules = m_allowNamespaceDeclarations = false; |
10152 | 10152 |
10153 RefPtr<StyleRuleRegion> regionRule = StyleRuleRegion::create(regionSelector,
*rules); | 10153 RefPtr<StyleRuleRegion> regionRule = StyleRuleRegion::create(regionSelector,
*rules); |
10154 | 10154 |
10155 StyleRuleRegion* result = regionRule.get(); | 10155 StyleRuleRegion* result = regionRule.get(); |
10156 m_parsedRules.append(regionRule.release()); | 10156 m_parsedRules.append(regionRule.release()); |
10157 if (m_observer) | 10157 if (m_observer) |
10158 m_observer->startEndUnknownRule(); | 10158 m_observer->startEndUnknownRule(); |
10159 | 10159 |
10160 return result; | 10160 return result; |
10161 } | 10161 } |
10162 | 10162 |
10163 StyleRuleBase* CSSParser::createMarginAtRule(CSSSelector::MarginBoxType /* margi
nBox */) | 10163 StyleRuleBase* BisonCSSParser::createMarginAtRule(CSSSelector::MarginBoxType /*
marginBox */) |
10164 { | 10164 { |
10165 // FIXME: Implement margin at-rule here, using: | 10165 // FIXME: Implement margin at-rule here, using: |
10166 // - marginBox: margin box | 10166 // - marginBox: margin box |
10167 // - m_parsedProperties: properties at [m_numParsedPropertiesBeforeMa
rginBox, m_parsedProperties.size()] are for this at-rule. | 10167 // - m_parsedProperties: properties at [m_numParsedPropertiesBeforeMa
rginBox, m_parsedProperties.size()] are for this at-rule. |
10168 // Don't forget to also update the action for page symbol in CSSGrammar.y su
ch that margin at-rule data is cleared if page_selector is invalid. | 10168 // Don't forget to also update the action for page symbol in CSSGrammar.y su
ch that margin at-rule data is cleared if page_selector is invalid. |
10169 | 10169 |
10170 endDeclarationsForMarginBox(); | 10170 endDeclarationsForMarginBox(); |
10171 return 0; // until this method is implemented. | 10171 return 0; // until this method is implemented. |
10172 } | 10172 } |
10173 | 10173 |
10174 void CSSParser::startDeclarationsForMarginBox() | 10174 void BisonCSSParser::startDeclarationsForMarginBox() |
10175 { | 10175 { |
10176 m_numParsedPropertiesBeforeMarginBox = m_parsedProperties.size(); | 10176 m_numParsedPropertiesBeforeMarginBox = m_parsedProperties.size(); |
10177 } | 10177 } |
10178 | 10178 |
10179 void CSSParser::endDeclarationsForMarginBox() | 10179 void BisonCSSParser::endDeclarationsForMarginBox() |
10180 { | 10180 { |
10181 rollbackLastProperties(m_parsedProperties.size() - m_numParsedPropertiesBefo
reMarginBox); | 10181 rollbackLastProperties(m_parsedProperties.size() - m_numParsedPropertiesBefo
reMarginBox); |
10182 m_numParsedPropertiesBeforeMarginBox = INVALID_NUM_PARSED_PROPERTIES; | 10182 m_numParsedPropertiesBeforeMarginBox = INVALID_NUM_PARSED_PROPERTIES; |
10183 } | 10183 } |
10184 | 10184 |
10185 void CSSParser::deleteFontFaceOnlyValues() | 10185 void BisonCSSParser::deleteFontFaceOnlyValues() |
10186 { | 10186 { |
10187 ASSERT(m_hasFontFaceOnlyValues); | 10187 ASSERT(m_hasFontFaceOnlyValues); |
10188 for (unsigned i = 0; i < m_parsedProperties.size();) { | 10188 for (unsigned i = 0; i < m_parsedProperties.size();) { |
10189 CSSProperty& property = m_parsedProperties[i]; | 10189 CSSProperty& property = m_parsedProperties[i]; |
10190 if (property.id() == CSSPropertyFontVariant && property.value()->isValue
List()) { | 10190 if (property.id() == CSSPropertyFontVariant && property.value()->isValue
List()) { |
10191 m_parsedProperties.remove(i); | 10191 m_parsedProperties.remove(i); |
10192 continue; | 10192 continue; |
10193 } | 10193 } |
10194 ++i; | 10194 ++i; |
10195 } | 10195 } |
10196 } | 10196 } |
10197 | 10197 |
10198 StyleKeyframe* CSSParser::createKeyframe(CSSParserValueList* keys) | 10198 StyleKeyframe* BisonCSSParser::createKeyframe(CSSParserValueList* keys) |
10199 { | 10199 { |
10200 OwnPtr<Vector<double> > keyVector = StyleKeyframe::createKeyList(keys); | 10200 OwnPtr<Vector<double> > keyVector = StyleKeyframe::createKeyList(keys); |
10201 if (keyVector->isEmpty()) | 10201 if (keyVector->isEmpty()) |
10202 return 0; | 10202 return 0; |
10203 | 10203 |
10204 RefPtr<StyleKeyframe> keyframe = StyleKeyframe::create(); | 10204 RefPtr<StyleKeyframe> keyframe = StyleKeyframe::create(); |
10205 keyframe->setKeys(keyVector.release()); | 10205 keyframe->setKeys(keyVector.release()); |
10206 keyframe->setProperties(createStylePropertySet()); | 10206 keyframe->setProperties(createStylePropertySet()); |
10207 | 10207 |
10208 clearProperties(); | 10208 clearProperties(); |
10209 | 10209 |
10210 StyleKeyframe* keyframePtr = keyframe.get(); | 10210 StyleKeyframe* keyframePtr = keyframe.get(); |
10211 m_parsedKeyframes.append(keyframe.release()); | 10211 m_parsedKeyframes.append(keyframe.release()); |
10212 return keyframePtr; | 10212 return keyframePtr; |
10213 } | 10213 } |
10214 | 10214 |
10215 void CSSParser::invalidBlockHit() | 10215 void BisonCSSParser::invalidBlockHit() |
10216 { | 10216 { |
10217 if (m_styleSheet && !m_hadSyntacticallyValidCSSRule) | 10217 if (m_styleSheet && !m_hadSyntacticallyValidCSSRule) |
10218 m_styleSheet->setHasSyntacticallyValidCSSHeader(false); | 10218 m_styleSheet->setHasSyntacticallyValidCSSHeader(false); |
10219 } | 10219 } |
10220 | 10220 |
10221 void CSSParser::startRule() | 10221 void BisonCSSParser::startRule() |
10222 { | 10222 { |
10223 if (!m_observer) | 10223 if (!m_observer) |
10224 return; | 10224 return; |
10225 | 10225 |
10226 ASSERT(m_ruleHasHeader); | 10226 ASSERT(m_ruleHasHeader); |
10227 m_ruleHasHeader = false; | 10227 m_ruleHasHeader = false; |
10228 } | 10228 } |
10229 | 10229 |
10230 void CSSParser::endRule(bool valid) | 10230 void BisonCSSParser::endRule(bool valid) |
10231 { | 10231 { |
10232 if (!m_observer) | 10232 if (!m_observer) |
10233 return; | 10233 return; |
10234 | 10234 |
10235 if (m_ruleHasHeader) | 10235 if (m_ruleHasHeader) |
10236 m_observer->endRuleBody(m_tokenizer.safeUserStringTokenOffset(), !valid)
; | 10236 m_observer->endRuleBody(m_tokenizer.safeUserStringTokenOffset(), !valid)
; |
10237 m_ruleHasHeader = true; | 10237 m_ruleHasHeader = true; |
10238 } | 10238 } |
10239 | 10239 |
10240 void CSSParser::startRuleHeader(CSSRuleSourceData::Type ruleType) | 10240 void BisonCSSParser::startRuleHeader(CSSRuleSourceData::Type ruleType) |
10241 { | 10241 { |
10242 resumeErrorLogging(); | 10242 resumeErrorLogging(); |
10243 m_ruleHeaderType = ruleType; | 10243 m_ruleHeaderType = ruleType; |
10244 m_ruleHeaderStartOffset = m_tokenizer.safeUserStringTokenOffset(); | 10244 m_ruleHeaderStartOffset = m_tokenizer.safeUserStringTokenOffset(); |
10245 m_ruleHeaderStartLineNumber = m_tokenizer.m_tokenStartLineNumber; | 10245 m_ruleHeaderStartLineNumber = m_tokenizer.m_tokenStartLineNumber; |
10246 if (m_observer) { | 10246 if (m_observer) { |
10247 ASSERT(!m_ruleHasHeader); | 10247 ASSERT(!m_ruleHasHeader); |
10248 m_observer->startRuleHeader(ruleType, m_ruleHeaderStartOffset); | 10248 m_observer->startRuleHeader(ruleType, m_ruleHeaderStartOffset); |
10249 m_ruleHasHeader = true; | 10249 m_ruleHasHeader = true; |
10250 } | 10250 } |
10251 } | 10251 } |
10252 | 10252 |
10253 void CSSParser::endRuleHeader() | 10253 void BisonCSSParser::endRuleHeader() |
10254 { | 10254 { |
10255 ASSERT(m_ruleHeaderType != CSSRuleSourceData::UNKNOWN_RULE); | 10255 ASSERT(m_ruleHeaderType != CSSRuleSourceData::UNKNOWN_RULE); |
10256 m_ruleHeaderType = CSSRuleSourceData::UNKNOWN_RULE; | 10256 m_ruleHeaderType = CSSRuleSourceData::UNKNOWN_RULE; |
10257 if (m_observer) { | 10257 if (m_observer) { |
10258 ASSERT(m_ruleHasHeader); | 10258 ASSERT(m_ruleHasHeader); |
10259 m_observer->endRuleHeader(m_tokenizer.safeUserStringTokenOffset()); | 10259 m_observer->endRuleHeader(m_tokenizer.safeUserStringTokenOffset()); |
10260 } | 10260 } |
10261 } | 10261 } |
10262 | 10262 |
10263 void CSSParser::startSelector() | 10263 void BisonCSSParser::startSelector() |
10264 { | 10264 { |
10265 if (m_observer) | 10265 if (m_observer) |
10266 m_observer->startSelector(m_tokenizer.safeUserStringTokenOffset()); | 10266 m_observer->startSelector(m_tokenizer.safeUserStringTokenOffset()); |
10267 } | 10267 } |
10268 | 10268 |
10269 void CSSParser::endSelector() | 10269 void BisonCSSParser::endSelector() |
10270 { | 10270 { |
10271 if (m_observer) | 10271 if (m_observer) |
10272 m_observer->endSelector(m_tokenizer.safeUserStringTokenOffset()); | 10272 m_observer->endSelector(m_tokenizer.safeUserStringTokenOffset()); |
10273 } | 10273 } |
10274 | 10274 |
10275 void CSSParser::startRuleBody() | 10275 void BisonCSSParser::startRuleBody() |
10276 { | 10276 { |
10277 if (m_observer) | 10277 if (m_observer) |
10278 m_observer->startRuleBody(m_tokenizer.safeUserStringTokenOffset()); | 10278 m_observer->startRuleBody(m_tokenizer.safeUserStringTokenOffset()); |
10279 } | 10279 } |
10280 | 10280 |
10281 void CSSParser::startProperty() | 10281 void BisonCSSParser::startProperty() |
10282 { | 10282 { |
10283 resumeErrorLogging(); | 10283 resumeErrorLogging(); |
10284 if (m_observer) | 10284 if (m_observer) |
10285 m_observer->startProperty(m_tokenizer.safeUserStringTokenOffset()); | 10285 m_observer->startProperty(m_tokenizer.safeUserStringTokenOffset()); |
10286 } | 10286 } |
10287 | 10287 |
10288 void CSSParser::endProperty(bool isImportantFound, bool isPropertyParsed, CSSPar
serError errorType) | 10288 void BisonCSSParser::endProperty(bool isImportantFound, bool isPropertyParsed, C
SSParserError errorType) |
10289 { | 10289 { |
10290 m_id = CSSPropertyInvalid; | 10290 m_id = CSSPropertyInvalid; |
10291 if (m_observer) | 10291 if (m_observer) |
10292 m_observer->endProperty(isImportantFound, isPropertyParsed, m_tokenizer.
safeUserStringTokenOffset(), errorType); | 10292 m_observer->endProperty(isImportantFound, isPropertyParsed, m_tokenizer.
safeUserStringTokenOffset(), errorType); |
10293 } | 10293 } |
10294 | 10294 |
10295 void CSSParser::startEndUnknownRule() | 10295 void BisonCSSParser::startEndUnknownRule() |
10296 { | 10296 { |
10297 if (m_observer) | 10297 if (m_observer) |
10298 m_observer->startEndUnknownRule(); | 10298 m_observer->startEndUnknownRule(); |
10299 } | 10299 } |
10300 | 10300 |
10301 StyleRuleBase* CSSParser::createViewportRule() | 10301 StyleRuleBase* BisonCSSParser::createViewportRule() |
10302 { | 10302 { |
10303 // Allow @viewport rules from UA stylesheets even if the feature is disabled
. | 10303 // Allow @viewport rules from UA stylesheets even if the feature is disabled
. |
10304 if (!RuntimeEnabledFeatures::cssViewportEnabled() && !isUASheetBehavior(m_co
ntext.mode())) | 10304 if (!RuntimeEnabledFeatures::cssViewportEnabled() && !isUASheetBehavior(m_co
ntext.mode())) |
10305 return 0; | 10305 return 0; |
10306 | 10306 |
10307 m_allowImportRules = m_allowNamespaceDeclarations = false; | 10307 m_allowImportRules = m_allowNamespaceDeclarations = false; |
10308 | 10308 |
10309 RefPtr<StyleRuleViewport> rule = StyleRuleViewport::create(); | 10309 RefPtr<StyleRuleViewport> rule = StyleRuleViewport::create(); |
10310 | 10310 |
10311 rule->setProperties(createStylePropertySet()); | 10311 rule->setProperties(createStylePropertySet()); |
10312 clearProperties(); | 10312 clearProperties(); |
10313 | 10313 |
10314 StyleRuleViewport* result = rule.get(); | 10314 StyleRuleViewport* result = rule.get(); |
10315 m_parsedRules.append(rule.release()); | 10315 m_parsedRules.append(rule.release()); |
10316 | 10316 |
10317 return result; | 10317 return result; |
10318 } | 10318 } |
10319 | 10319 |
10320 bool CSSParser::parseViewportProperty(CSSPropertyID propId, bool important) | 10320 bool BisonCSSParser::parseViewportProperty(CSSPropertyID propId, bool important) |
10321 { | 10321 { |
10322 ASSERT(RuntimeEnabledFeatures::cssViewportEnabled() || isUASheetBehavior(m_c
ontext.mode())); | 10322 ASSERT(RuntimeEnabledFeatures::cssViewportEnabled() || isUASheetBehavior(m_c
ontext.mode())); |
10323 | 10323 |
10324 CSSParserValue* value = m_valueList->current(); | 10324 CSSParserValue* value = m_valueList->current(); |
10325 if (!value) | 10325 if (!value) |
10326 return false; | 10326 return false; |
10327 | 10327 |
10328 CSSValueID id = value->id; | 10328 CSSValueID id = value->id; |
10329 bool validPrimitive = false; | 10329 bool validPrimitive = false; |
10330 | 10330 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10370 if (parsedValue) { | 10370 if (parsedValue) { |
10371 if (!m_valueList->current() || inShorthand()) { | 10371 if (!m_valueList->current() || inShorthand()) { |
10372 addProperty(propId, parsedValue.release(), important); | 10372 addProperty(propId, parsedValue.release(), important); |
10373 return true; | 10373 return true; |
10374 } | 10374 } |
10375 } | 10375 } |
10376 | 10376 |
10377 return false; | 10377 return false; |
10378 } | 10378 } |
10379 | 10379 |
10380 bool CSSParser::parseViewportShorthand(CSSPropertyID propId, CSSPropertyID first
, CSSPropertyID second, bool important) | 10380 bool BisonCSSParser::parseViewportShorthand(CSSPropertyID propId, CSSPropertyID
first, CSSPropertyID second, bool important) |
10381 { | 10381 { |
10382 ASSERT(RuntimeEnabledFeatures::cssViewportEnabled() || isUASheetBehavior(m_c
ontext.mode())); | 10382 ASSERT(RuntimeEnabledFeatures::cssViewportEnabled() || isUASheetBehavior(m_c
ontext.mode())); |
10383 unsigned numValues = m_valueList->size(); | 10383 unsigned numValues = m_valueList->size(); |
10384 | 10384 |
10385 if (numValues > 2) | 10385 if (numValues > 2) |
10386 return false; | 10386 return false; |
10387 | 10387 |
10388 ShorthandScope scope(this, propId); | 10388 ShorthandScope scope(this, propId); |
10389 | 10389 |
10390 if (!parseViewportProperty(first, important)) | 10390 if (!parseViewportProperty(first, important)) |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10472 { | 10472 { |
10473 // The tokenizer checks for the construct of an+b. | 10473 // The tokenizer checks for the construct of an+b. |
10474 // However, since the {ident} rule precedes the {nth} rule, some of those | 10474 // However, since the {ident} rule precedes the {nth} rule, some of those |
10475 // tokens are identified as string literal. Furthermore we need to accept | 10475 // tokens are identified as string literal. Furthermore we need to accept |
10476 // "odd" and "even" which does not match to an+b. | 10476 // "odd" and "even" which does not match to an+b. |
10477 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even") | 10477 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even") |
10478 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n"); | 10478 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n"); |
10479 } | 10479 } |
10480 | 10480 |
10481 } | 10481 } |
OLD | NEW |