2 * Copyright (C) 2003 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com)
4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved.
5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com>
6 * Copyright (C) 2008 Eric Seidel <eric@webkit.org>
7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
8 * Copyright (C) 2012, 2013 Adobe Systems Incorporated. All rights reserved.
9 * Copyright (C) 2012 Intel Corporation. All rights reserved.
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Library General Public
13 * License as published by the Free Software Foundation; either
14 * version 2 of the License, or (at your option) any later version.
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Library General Public License for more details.
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
23 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 * Boston, MA 02110-1301, USA.
28 #include "CSSParser.h"
30 #include "CSSAspectRatioValue.h"
31 #include "CSSBasicShapes.h"
32 #include "CSSBorderImage.h"
33 #include "CSSCanvasValue.h"
34 #include "CSSCrossfadeValue.h"
35 #include "CSSCursorImageValue.h"
36 #include "CSSFilterImageValue.h"
37 #include "CSSFontFaceRule.h"
38 #include "CSSFontFaceSrcValue.h"
39 #include "CSSFontFeatureValue.h"
40 #include "CSSFontValue.h"
41 #include "CSSFunctionValue.h"
42 #include "CSSGradientValue.h"
43 #include "CSSGridTemplateValue.h"
44 #include "CSSImageValue.h"
45 #include "CSSInheritedValue.h"
46 #include "CSSInitialValue.h"
47 #include "CSSLineBoxContainValue.h"
48 #include "CSSMediaRule.h"
49 #include "CSSPageRule.h"
50 #include "CSSPrimitiveValue.h"
51 #include "CSSPropertySourceData.h"
52 #include "CSSReflectValue.h"
53 #include "CSSSelector.h"
54 #include "CSSShadowValue.h"
55 #include "CSSStyleSheet.h"
56 #include "CSSTimingFunctionValue.h"
57 #include "CSSUnicodeRangeValue.h"
58 #include "CSSValueKeywords.h"
59 #include "CSSValueList.h"
60 #include "CSSValuePool.h"
63 #include "FloatConversion.h"
64 #include "HTMLParserIdioms.h"
65 #include "HashTools.h"
66 #include "HistogramSupport.h"
67 #include "MediaList.h"
68 #include "MediaQueryExp.h"
70 #include "PageConsole.h"
73 #include "RenderTheme.h"
74 #include "RuntimeEnabledFeatures.h"
75 #include "SVGParserUtilities.h"
77 #include "StyleProperties.h"
78 #include "StylePropertyShorthand.h"
79 #include "StyleRule.h"
80 #include "StyleRuleImport.h"
81 #include "StyleSheetContents.h"
82 #include "TextEncoding.h"
83 #include "WebKitCSSKeyframeRule.h"
84 #include "WebKitCSSKeyframesRule.h"
85 #include "WebKitCSSRegionRule.h"
86 #include "WebKitCSSTransformValue.h"
89 #include <wtf/HexNumber.h>
90 #include <wtf/StdLibExtras.h>
92 #include <wtf/text/StringBuffer.h>
93 #include <wtf/text/StringBuilder.h>
94 #include <wtf/text/StringImpl.h>
96 #if ENABLE(CSS_IMAGE_SET)
97 #include "CSSImageSetValue.h"
100 #if ENABLE(CSS_FILTERS)
101 #include "WebKitCSSFilterValue.h"
103 #include "WebKitCSSSVGDocumentValue.h"
107 #if ENABLE(CSS_SHADERS)
108 #include "WebKitCSSArrayFunctionValue.h"
109 #include "WebKitCSSMatFunctionValue.h"
110 #include "WebKitCSSMixFunctionValue.h"
111 #include "WebKitCSSShaderValue.h"
114 #if ENABLE(DASHBOARD_SUPPORT)
115 #include "DashboardRegion.h"
121 extern int cssyydebug;
124 extern int cssyyparse(WebCore::CSSParser*);
135 class ImplicitScope {
136 WTF_MAKE_NONCOPYABLE(ImplicitScope);
138 ImplicitScope(WebCore::CSSParser* parser, PropertyType propertyType)
141 m_parser->m_implicitShorthand = propertyType == PropertyImplicit;
146 m_parser->m_implicitShorthand = false;
150 WebCore::CSSParser* m_parser;
157 static const unsigned INVALID_NUM_PARSED_PROPERTIES = UINT_MAX;
158 static const double MAX_SCALE = 1000000;
160 template <unsigned N>
161 static bool equal(const CSSParserString& a, const char (&b)[N])
163 unsigned length = N - 1; // Ignore the trailing null character
164 if (a.length() != length)
167 return a.is8Bit() ? WTF::equal(a.characters8(), reinterpret_cast<const LChar*>(b), length) : WTF::equal(a.characters16(), reinterpret_cast<const LChar*>(b), length);
170 template <unsigned N>
171 static bool equalIgnoringCase(const CSSParserString& a, const char (&b)[N])
173 unsigned length = N - 1; // Ignore the trailing null character
174 if (a.length() != length)
177 return a.is8Bit() ? WTF::equalIgnoringCase(b, a.characters8(), length) : WTF::equalIgnoringCase(b, a.characters16(), length);
180 template <unsigned N>
181 static bool equalIgnoringCase(CSSParserValue* value, const char (&b)[N])
183 ASSERT(value->unit == CSSPrimitiveValue::CSS_IDENT || value->unit == CSSPrimitiveValue::CSS_STRING);
184 return equalIgnoringCase(value->string, b);
187 static bool hasPrefix(const char* string, unsigned length, const char* prefix)
189 for (unsigned i = 0; i < length; ++i) {
192 if (string[i] != prefix[i])
198 static PassRefPtr<CSSPrimitiveValue> createPrimitiveValuePair(PassRefPtr<CSSPrimitiveValue> first, PassRefPtr<CSSPrimitiveValue> second)
200 return cssValuePool().createValue(Pair::create(first, second));
203 class AnimationParseContext {
205 AnimationParseContext()
206 : m_animationPropertyKeywordAllowed(true)
207 , m_firstAnimationCommitted(false)
208 , m_hasSeenAnimationPropertyKeyword(false)
212 void commitFirstAnimation()
214 m_firstAnimationCommitted = true;
217 bool hasCommittedFirstAnimation() const
219 return m_firstAnimationCommitted;
222 void commitAnimationPropertyKeyword()
224 m_animationPropertyKeywordAllowed = false;
227 bool animationPropertyKeywordAllowed() const
229 return m_animationPropertyKeywordAllowed;
232 bool hasSeenAnimationPropertyKeyword() const
234 return m_hasSeenAnimationPropertyKeyword;
237 void sawAnimationPropertyKeyword()
239 m_hasSeenAnimationPropertyKeyword = true;
243 bool m_animationPropertyKeywordAllowed;
244 bool m_firstAnimationCommitted;
245 bool m_hasSeenAnimationPropertyKeyword;
248 const CSSParserContext& strictCSSParserContext()
250 DEFINE_STATIC_LOCAL(CSSParserContext, strictContext, (CSSStrictMode));
251 return strictContext;
254 CSSParserContext::CSSParserContext(CSSParserMode mode, const URL& baseURL)
257 , isHTMLDocument(false)
258 , isCSSCustomFilterEnabled(false)
259 , isCSSStickyPositionEnabled(false)
260 , isCSSRegionsEnabled(false)
261 , isCSSCompositingEnabled(false)
262 , isCSSGridLayoutEnabled(false)
263 , needsSiteSpecificQuirks(false)
264 , enforcesCSSMIMETypeInNoQuirksMode(true)
265 , useLegacyBackgroundSizeShorthandBehavior(false)
269 CSSParserContext::CSSParserContext(Document& document, const URL& baseURL, const String& charset)
270 : baseURL(baseURL.isNull() ? document.baseURL() : baseURL)
272 , mode(document.inQuirksMode() ? CSSQuirksMode : CSSStrictMode)
273 , isHTMLDocument(document.isHTMLDocument())
274 , isCSSCustomFilterEnabled(document.settings() ? document.settings()->isCSSCustomFilterEnabled() : false)
275 , isCSSStickyPositionEnabled(document.cssStickyPositionEnabled())
276 , isCSSRegionsEnabled(document.cssRegionsEnabled())
277 , isCSSCompositingEnabled(document.cssCompositingEnabled())
278 , isCSSGridLayoutEnabled(document.cssGridLayoutEnabled())
279 , needsSiteSpecificQuirks(document.settings() ? document.settings()->needsSiteSpecificQuirks() : false)
280 , enforcesCSSMIMETypeInNoQuirksMode(!document.settings() || document.settings()->enforceCSSMIMETypeInNoQuirksMode())
281 , useLegacyBackgroundSizeShorthandBehavior(document.settings() ? document.settings()->useLegacyBackgroundSizeShorthandBehavior() : false)
285 bool operator==(const CSSParserContext& a, const CSSParserContext& b)
287 return a.baseURL == b.baseURL
288 && a.charset == b.charset
290 && a.isHTMLDocument == b.isHTMLDocument
291 && a.isCSSCustomFilterEnabled == b.isCSSCustomFilterEnabled
292 && a.isCSSStickyPositionEnabled == b.isCSSStickyPositionEnabled
293 && a.isCSSRegionsEnabled == b.isCSSRegionsEnabled
294 && a.isCSSCompositingEnabled == b.isCSSCompositingEnabled
295 && a.isCSSGridLayoutEnabled == b.isCSSGridLayoutEnabled
296 && a.needsSiteSpecificQuirks == b.needsSiteSpecificQuirks
297 && a.enforcesCSSMIMETypeInNoQuirksMode == b.enforcesCSSMIMETypeInNoQuirksMode
298 && a.useLegacyBackgroundSizeShorthandBehavior == b.useLegacyBackgroundSizeShorthandBehavior;
301 CSSParser::CSSParser(const CSSParserContext& context)
304 , m_id(CSSPropertyInvalid)
306 #if ENABLE(CSS3_CONDITIONAL_RULES)
307 , m_supportsCondition(false)
309 , m_selectorListForParseSelector(0)
310 , m_numParsedPropertiesBeforeMarginBox(INVALID_NUM_PARSED_PROPERTIES)
311 , m_inParseShorthand(0)
312 , m_currentShorthand(CSSPropertyInvalid)
313 , m_implicitShorthand(false)
314 , m_hasFontFaceOnlyValues(false)
315 , m_hadSyntacticallyValidCSSRule(false)
317 , m_ignoreErrorsInDeclaration(false)
318 #if ENABLE(CSS_SHADERS)
319 , m_inFilterRule(false)
321 , m_defaultNamespace(starAtom)
322 , m_parsedTextPrefixLength(0)
323 , m_propertyRange(UINT_MAX, UINT_MAX)
324 , m_ruleSourceDataResult(0)
325 , m_parsingMode(NormalMode)
326 , m_is8BitSource(false)
327 , m_currentCharacter8(0)
328 , m_currentCharacter16(0)
332 , m_tokenStartLineNumber(0)
333 , m_lastSelectorLineNumber(0)
334 , m_allowImportRules(true)
335 , m_allowNamespaceDeclarations(true)
336 #if ENABLE(CSS_DEVICE_ADAPTATION)
337 , m_inViewport(false)
343 m_tokenStart.ptr8 = 0;
346 CSSParser::~CSSParser()
351 template <typename CharacterType>
352 ALWAYS_INLINE static void makeLower(const CharacterType* input, CharacterType* output, unsigned length)
354 // FIXME: If we need Unicode lowercasing here, then we probably want the real kind
355 // that can potentially change the length of the string rather than the character
356 // by character kind. If we don't need Unicode lowercasing, it would be good to
357 // simplify this function.
359 if (charactersAreAllASCII(input, length)) {
360 // Fast case for all-ASCII.
361 for (unsigned i = 0; i < length; i++)
362 output[i] = toASCIILower(input[i]);
364 for (unsigned i = 0; i < length; i++) {
365 ASSERT(u_tolower(input[i]) <= 0xFFFF);
366 output[i] = u_tolower(input[i]);
371 void CSSParserString::lower()
374 makeLower(characters8(), characters8(), length());
378 makeLower(characters16(), characters16(), length());
381 void CSSParser::setupParser(const char* prefix, unsigned prefixLength, const String& string, const char* suffix, unsigned suffixLength)
383 m_parsedTextPrefixLength = prefixLength;
384 unsigned stringLength = string.length();
385 unsigned length = stringLength + m_parsedTextPrefixLength + suffixLength + 1;
388 if (!stringLength || string.is8Bit()) {
389 m_dataStart8 = std::make_unique<LChar[]>(length);
390 for (unsigned i = 0; i < m_parsedTextPrefixLength; i++)
391 m_dataStart8[i] = prefix[i];
394 memcpy(m_dataStart8.get() + m_parsedTextPrefixLength, string.characters8(), stringLength * sizeof(LChar));
396 unsigned start = m_parsedTextPrefixLength + stringLength;
397 unsigned end = start + suffixLength;
398 for (unsigned i = start; i < end; i++)
399 m_dataStart8[i] = suffix[i - start];
401 m_dataStart8[length - 1] = 0;
403 m_is8BitSource = true;
404 m_currentCharacter8 = m_dataStart8.get();
405 m_currentCharacter16 = 0;
406 setTokenStart<LChar>(m_currentCharacter8);
407 m_lexFunc = &CSSParser::realLex<LChar>;
411 m_dataStart16 = std::make_unique<UChar[]>(length);
412 for (unsigned i = 0; i < m_parsedTextPrefixLength; i++)
413 m_dataStart16[i] = prefix[i];
415 ASSERT(stringLength);
416 memcpy(m_dataStart16.get() + m_parsedTextPrefixLength, string.characters16(), stringLength * sizeof(UChar));
418 unsigned start = m_parsedTextPrefixLength + stringLength;
419 unsigned end = start + suffixLength;
420 for (unsigned i = start; i < end; i++)
421 m_dataStart16[i] = suffix[i - start];
423 m_dataStart16[length - 1] = 0;
425 m_is8BitSource = false;
426 m_currentCharacter8 = 0;
427 m_currentCharacter16 = m_dataStart16.get();
428 setTokenStart<UChar>(m_currentCharacter16);
429 m_lexFunc = &CSSParser::realLex<UChar>;
432 void CSSParser::parseSheet(StyleSheetContents* sheet, const String& string, int startLineNumber, RuleSourceDataList* ruleSourceDataResult, bool logErrors)
434 setStyleSheet(sheet);
435 m_defaultNamespace = starAtom; // Reset the default namespace.
436 if (ruleSourceDataResult)
437 m_currentRuleDataStack = adoptPtr(new RuleSourceDataList());
438 m_ruleSourceDataResult = ruleSourceDataResult;
440 m_logErrors = logErrors && sheet->singleOwnerDocument() && !sheet->baseURL().isEmpty() && sheet->singleOwnerDocument()->page();
441 m_ignoreErrorsInDeclaration = false;
442 m_lineNumber = startLineNumber;
443 setupParser("", string, "");
445 sheet->shrinkToFit();
446 m_currentRuleDataStack.clear();
447 m_ruleSourceDataResult = 0;
449 m_ignoreErrorsInDeclaration = false;
453 PassRefPtr<StyleRuleBase> CSSParser::parseRule(StyleSheetContents* sheet, const String& string)
455 setStyleSheet(sheet);
456 m_allowNamespaceDeclarations = false;
457 setupParser("@-webkit-rule{", string, "} ");
459 return m_rule.release();
462 PassRefPtr<StyleKeyframe> CSSParser::parseKeyframeRule(StyleSheetContents* sheet, const String& string)
464 setStyleSheet(sheet);
465 setupParser("@-webkit-keyframe-rule{ ", string, "} ");
467 return m_keyframe.release();
470 #if ENABLE(CSS3_CONDITIONAL_RULES)
471 bool CSSParser::parseSupportsCondition(const String& string)
473 m_supportsCondition = false;
474 setupParser("@-webkit-supports-condition{ ", string, "} ");
476 return m_supportsCondition;
480 static inline bool isColorPropertyID(CSSPropertyID propertyId)
482 switch (propertyId) {
483 case CSSPropertyColor:
484 case CSSPropertyBackgroundColor:
485 case CSSPropertyBorderBottomColor:
486 case CSSPropertyBorderLeftColor:
487 case CSSPropertyBorderRightColor:
488 case CSSPropertyBorderTopColor:
489 case CSSPropertyOutlineColor:
490 case CSSPropertyTextLineThroughColor:
491 case CSSPropertyTextOverlineColor:
492 case CSSPropertyTextUnderlineColor:
493 case CSSPropertyWebkitBorderAfterColor:
494 case CSSPropertyWebkitBorderBeforeColor:
495 case CSSPropertyWebkitBorderEndColor:
496 case CSSPropertyWebkitBorderStartColor:
497 case CSSPropertyWebkitColumnRuleColor:
498 #if ENABLE(CSS3_TEXT_DECORATION)
499 case CSSPropertyWebkitTextDecorationColor:
501 case CSSPropertyWebkitTextEmphasisColor:
502 case CSSPropertyWebkitTextFillColor:
503 case CSSPropertyWebkitTextStrokeColor:
510 static bool parseColorValue(MutableStyleProperties* declaration, CSSPropertyID propertyId, const String& string, bool important, CSSParserMode cssParserMode)
512 ASSERT(!string.isEmpty());
513 bool strict = isStrictParserMode(cssParserMode);
514 if (!isColorPropertyID(propertyId))
516 CSSParserString cssString;
517 cssString.init(string);
518 CSSValueID valueID = cssValueKeywordID(cssString);
519 bool validPrimitive = false;
520 if (valueID == CSSValueWebkitText)
521 validPrimitive = true;
522 else if (valueID == CSSValueCurrentcolor)
523 validPrimitive = true;
524 else if ((valueID >= CSSValueAqua && valueID <= CSSValueWindowtext) || valueID == CSSValueMenu
525 || (valueID >= CSSValueWebkitFocusRingColor && valueID < CSSValueWebkitText && !strict)) {
526 validPrimitive = true;
529 if (validPrimitive) {
530 RefPtr<CSSValue> value = cssValuePool().createIdentifierValue(valueID);
531 declaration->addParsedProperty(CSSProperty(propertyId, value.release(), important));
535 if (!CSSParser::fastParseColor(color, string, strict && string[0] != '#'))
537 RefPtr<CSSValue> value = cssValuePool().createColorValue(color);
538 declaration->addParsedProperty(CSSProperty(propertyId, value.release(), important));
542 static inline bool isSimpleLengthPropertyID(CSSPropertyID propertyId, bool& acceptsNegativeNumbers)
544 switch (propertyId) {
545 case CSSPropertyFontSize:
546 case CSSPropertyHeight:
547 case CSSPropertyWidth:
548 case CSSPropertyMinHeight:
549 case CSSPropertyMinWidth:
550 case CSSPropertyPaddingBottom:
551 case CSSPropertyPaddingLeft:
552 case CSSPropertyPaddingRight:
553 case CSSPropertyPaddingTop:
554 case CSSPropertyWebkitLogicalWidth:
555 case CSSPropertyWebkitLogicalHeight:
556 case CSSPropertyWebkitMinLogicalWidth:
557 case CSSPropertyWebkitMinLogicalHeight:
558 case CSSPropertyWebkitPaddingAfter:
559 case CSSPropertyWebkitPaddingBefore:
560 case CSSPropertyWebkitPaddingEnd:
561 case CSSPropertyWebkitPaddingStart:
562 acceptsNegativeNumbers = false;
564 #if ENABLE(CSS_SHAPES)
565 case CSSPropertyWebkitShapeMargin:
566 case CSSPropertyWebkitShapePadding:
567 acceptsNegativeNumbers = false;
568 return RuntimeEnabledFeatures::sharedFeatures().cssShapesEnabled();
570 case CSSPropertyBottom:
571 case CSSPropertyLeft:
572 case CSSPropertyMarginBottom:
573 case CSSPropertyMarginLeft:
574 case CSSPropertyMarginRight:
575 case CSSPropertyMarginTop:
576 case CSSPropertyRight:
578 case CSSPropertyWebkitMarginAfter:
579 case CSSPropertyWebkitMarginBefore:
580 case CSSPropertyWebkitMarginEnd:
581 case CSSPropertyWebkitMarginStart:
582 acceptsNegativeNumbers = true;
589 template <typename CharacterType>
590 static inline bool parseSimpleLength(const CharacterType* characters, unsigned& length, CSSPrimitiveValue::UnitTypes& unit, double& number)
592 if (length > 2 && (characters[length - 2] | 0x20) == 'p' && (characters[length - 1] | 0x20) == 'x') {
594 unit = CSSPrimitiveValue::CSS_PX;
595 } else if (length > 1 && characters[length - 1] == '%') {
597 unit = CSSPrimitiveValue::CSS_PERCENTAGE;
600 // We rely on charactersToDouble for validation as well. The function
601 // will set "ok" to "false" if the entire passed-in character range does
602 // not represent a double.
604 number = charactersToDouble(characters, length, &ok);
608 static bool parseSimpleLengthValue(MutableStyleProperties* declaration, CSSPropertyID propertyId, const String& string, bool important, CSSParserMode cssParserMode)
610 ASSERT(!string.isEmpty());
611 bool acceptsNegativeNumbers;
612 if (!isSimpleLengthPropertyID(propertyId, acceptsNegativeNumbers))
615 unsigned length = string.length();
617 CSSPrimitiveValue::UnitTypes unit = CSSPrimitiveValue::CSS_NUMBER;
619 if (string.is8Bit()) {
620 if (!parseSimpleLength(string.characters8(), length, unit, number))
623 if (!parseSimpleLength(string.characters16(), length, unit, number))
627 if (unit == CSSPrimitiveValue::CSS_NUMBER) {
628 if (number && isStrictParserMode(cssParserMode))
630 unit = CSSPrimitiveValue::CSS_PX;
632 if (number < 0 && !acceptsNegativeNumbers)
635 RefPtr<CSSValue> value = cssValuePool().createValue(number, unit);
636 declaration->addParsedProperty(CSSProperty(propertyId, value.release(), important));
640 static inline bool isValidKeywordPropertyAndValue(CSSPropertyID propertyId, int valueID, const CSSParserContext& parserContext)
645 switch (propertyId) {
646 case CSSPropertyBorderCollapse: // collapse | separate | inherit
647 if (valueID == CSSValueCollapse || valueID == CSSValueSeparate)
650 case CSSPropertyBorderTopStyle: // <border-style> | inherit
651 case CSSPropertyBorderRightStyle: // Defined as: none | hidden | dotted | dashed |
652 case CSSPropertyBorderBottomStyle: // solid | double | groove | ridge | inset | outset
653 case CSSPropertyBorderLeftStyle:
654 case CSSPropertyWebkitBorderAfterStyle:
655 case CSSPropertyWebkitBorderBeforeStyle:
656 case CSSPropertyWebkitBorderEndStyle:
657 case CSSPropertyWebkitBorderStartStyle:
658 case CSSPropertyWebkitColumnRuleStyle:
659 if (valueID >= CSSValueNone && valueID <= CSSValueDouble)
662 case CSSPropertyBoxSizing:
663 if (valueID == CSSValueBorderBox || valueID == CSSValueContentBox)
666 case CSSPropertyCaptionSide: // top | bottom | left | right | inherit
667 if (valueID == CSSValueLeft || valueID == CSSValueRight || valueID == CSSValueTop || valueID == CSSValueBottom)
670 case CSSPropertyClear: // none | left | right | both | inherit
671 if (valueID == CSSValueNone || valueID == CSSValueLeft || valueID == CSSValueRight || valueID == CSSValueBoth)
674 case CSSPropertyDirection: // ltr | rtl | inherit
675 if (valueID == CSSValueLtr || valueID == CSSValueRtl)
678 case CSSPropertyDisplay:
679 // inline | block | list-item | run-in | inline-block | table |
680 // inline-table | table-row-group | table-header-group | table-footer-group | table-row |
681 // table-column-group | table-column | table-cell | table-caption | -webkit-box | -webkit-inline-box | none | inherit
682 // -webkit-flex | -webkit-inline-flex | -webkit-grid | -webkit-inline-grid
683 if ((valueID >= CSSValueInline && valueID <= CSSValueWebkitInlineFlex) || valueID == CSSValueNone)
685 if (parserContext.isCSSGridLayoutEnabled && (valueID == CSSValueWebkitGrid || valueID == CSSValueWebkitInlineGrid))
689 case CSSPropertyEmptyCells: // show | hide | inherit
690 if (valueID == CSSValueShow || valueID == CSSValueHide)
693 case CSSPropertyFloat: // left | right | none | center (for buggy CSS, maps to none)
694 if (valueID == CSSValueLeft || valueID == CSSValueRight || valueID == CSSValueNone || valueID == CSSValueCenter)
697 case CSSPropertyFontStyle: // normal | italic | oblique | inherit
698 if (valueID == CSSValueNormal || valueID == CSSValueItalic || valueID == CSSValueOblique)
701 case CSSPropertyImageRendering: // auto | optimizeSpeed | optimizeQuality | -webkit-crisp-edges | -webkit-optimize-contrast
702 if (valueID == CSSValueAuto || valueID == CSSValueOptimizespeed || valueID == CSSValueOptimizequality
703 || valueID == CSSValueWebkitCrispEdges || valueID == CSSValueWebkitOptimizeContrast)
706 case CSSPropertyListStylePosition: // inside | outside | inherit
707 if (valueID == CSSValueInside || valueID == CSSValueOutside)
710 case CSSPropertyListStyleType:
711 // See section CSS_PROP_LIST_STYLE_TYPE of file CSSValueKeywords.in
712 // for the list of supported list-style-types.
713 if ((valueID >= CSSValueDisc && valueID <= CSSValueKatakanaIroha) || valueID == CSSValueNone)
716 case CSSPropertyObjectFit:
717 if (valueID == CSSValueFill || valueID == CSSValueContain || valueID == CSSValueCover || valueID == CSSValueNone || valueID == CSSValueScaleDown)
720 case CSSPropertyOutlineStyle: // (<border-style> except hidden) | auto | inherit
721 if (valueID == CSSValueAuto || valueID == CSSValueNone || (valueID >= CSSValueInset && valueID <= CSSValueDouble))
724 case CSSPropertyOverflowWrap: // normal | break-word
725 case CSSPropertyWordWrap:
726 if (valueID == CSSValueNormal || valueID == CSSValueBreakWord)
729 case CSSPropertyOverflowX: // visible | hidden | scroll | auto | marquee | overlay | inherit
730 if (valueID == CSSValueVisible || valueID == CSSValueHidden || valueID == CSSValueScroll || valueID == CSSValueAuto || valueID == CSSValueOverlay || valueID == CSSValueWebkitMarquee)
733 case CSSPropertyOverflowY: // visible | hidden | scroll | auto | marquee | overlay | inherit | -webkit-paged-x | -webkit-paged-y
734 if (valueID == CSSValueVisible || valueID == CSSValueHidden || valueID == CSSValueScroll || valueID == CSSValueAuto || valueID == CSSValueOverlay || valueID == CSSValueWebkitMarquee || valueID == CSSValueWebkitPagedX || valueID == CSSValueWebkitPagedY)
737 case CSSPropertyPageBreakAfter: // auto | always | avoid | left | right | inherit
738 case CSSPropertyPageBreakBefore:
739 case CSSPropertyWebkitColumnBreakAfter:
740 case CSSPropertyWebkitColumnBreakBefore:
741 if (valueID == CSSValueAuto || valueID == CSSValueAlways || valueID == CSSValueAvoid || valueID == CSSValueLeft || valueID == CSSValueRight)
744 case CSSPropertyPageBreakInside: // avoid | auto | inherit
745 case CSSPropertyWebkitColumnBreakInside:
746 if (valueID == CSSValueAuto || valueID == CSSValueAvoid)
749 case CSSPropertyPointerEvents:
750 // none | visiblePainted | visibleFill | visibleStroke | visible |
751 // painted | fill | stroke | auto | all | inherit
752 if (valueID == CSSValueVisible || valueID == CSSValueNone || valueID == CSSValueAll || valueID == CSSValueAuto || (valueID >= CSSValueVisiblepainted && valueID <= CSSValueStroke))
755 case CSSPropertyPosition: // static | relative | absolute | fixed | sticky | inherit
756 if (valueID == CSSValueStatic || valueID == CSSValueRelative || valueID == CSSValueAbsolute || valueID == CSSValueFixed
757 #if ENABLE(CSS_STICKY_POSITION)
758 || (parserContext.isCSSStickyPositionEnabled && valueID == CSSValueWebkitSticky)
763 case CSSPropertyResize: // none | both | horizontal | vertical | auto
764 if (valueID == CSSValueNone || valueID == CSSValueBoth || valueID == CSSValueHorizontal || valueID == CSSValueVertical || valueID == CSSValueAuto)
767 case CSSPropertySpeak: // none | normal | spell-out | digits | literal-punctuation | no-punctuation | inherit
768 if (valueID == CSSValueNone || valueID == CSSValueNormal || valueID == CSSValueSpellOut || valueID == CSSValueDigits || valueID == CSSValueLiteralPunctuation || valueID == CSSValueNoPunctuation)
771 case CSSPropertyTableLayout: // auto | fixed | inherit
772 if (valueID == CSSValueAuto || valueID == CSSValueFixed)
775 case CSSPropertyTextLineThroughMode:
776 case CSSPropertyTextOverlineMode:
777 case CSSPropertyTextUnderlineMode:
778 if (valueID == CSSValueContinuous || valueID == CSSValueSkipWhiteSpace)
781 case CSSPropertyTextLineThroughStyle:
782 case CSSPropertyTextOverlineStyle:
783 case CSSPropertyTextUnderlineStyle:
784 if (valueID == CSSValueNone || valueID == CSSValueSolid || valueID == CSSValueDouble || valueID == CSSValueDashed || valueID == CSSValueDotDash || valueID == CSSValueDotDotDash || valueID == CSSValueWave)
787 case CSSPropertyTextOverflow: // clip | ellipsis
788 if (valueID == CSSValueClip || valueID == CSSValueEllipsis)
791 case CSSPropertyTextRendering: // auto | optimizeSpeed | optimizeLegibility | geometricPrecision
792 if (valueID == CSSValueAuto || valueID == CSSValueOptimizespeed || valueID == CSSValueOptimizelegibility || valueID == CSSValueGeometricprecision)
795 case CSSPropertyTextTransform: // capitalize | uppercase | lowercase | none | inherit
796 if ((valueID >= CSSValueCapitalize && valueID <= CSSValueLowercase) || valueID == CSSValueNone)
799 case CSSPropertyVisibility: // visible | hidden | collapse | inherit
800 if (valueID == CSSValueVisible || valueID == CSSValueHidden || valueID == CSSValueCollapse)
803 case CSSPropertyWebkitAppearance:
804 if ((valueID >= CSSValueCheckbox && valueID <= CSSValueTextarea) || valueID == CSSValueNone)
807 case CSSPropertyWebkitBackfaceVisibility:
808 if (valueID == CSSValueVisible || valueID == CSSValueHidden)
811 #if ENABLE(CSS_COMPOSITING)
812 case CSSPropertyWebkitBlendMode:
813 if (parserContext.isCSSCompositingEnabled && (valueID == CSSValueNormal || valueID == CSSValueMultiply || valueID == CSSValueScreen
814 || valueID == CSSValueOverlay || valueID == CSSValueDarken || valueID == CSSValueLighten || valueID == CSSValueColorDodge
815 || valueID == CSSValueColorBurn || valueID == CSSValueHardLight || valueID == CSSValueSoftLight || valueID == CSSValueDifference
816 || valueID == CSSValueExclusion || valueID == CSSValueHue || valueID == CSSValueSaturation || valueID == CSSValueColor
817 || valueID == CSSValueLuminosity))
821 case CSSPropertyWebkitBorderFit:
822 if (valueID == CSSValueBorder || valueID == CSSValueLines)
825 case CSSPropertyWebkitBoxAlign:
826 if (valueID == CSSValueStretch || valueID == CSSValueStart || valueID == CSSValueEnd || valueID == CSSValueCenter || valueID == CSSValueBaseline)
829 #if ENABLE(CSS_BOX_DECORATION_BREAK)
830 case CSSPropertyWebkitBoxDecorationBreak:
831 if (valueID == CSSValueClone || valueID == CSSValueSlice)
835 case CSSPropertyWebkitBoxDirection:
836 if (valueID == CSSValueNormal || valueID == CSSValueReverse)
839 case CSSPropertyWebkitBoxLines:
840 if (valueID == CSSValueSingle || valueID == CSSValueMultiple)
843 case CSSPropertyWebkitBoxOrient:
844 if (valueID == CSSValueHorizontal || valueID == CSSValueVertical || valueID == CSSValueInlineAxis || valueID == CSSValueBlockAxis)
847 case CSSPropertyWebkitBoxPack:
848 if (valueID == CSSValueStart || valueID == CSSValueEnd || valueID == CSSValueCenter || valueID == CSSValueJustify)
851 case CSSPropertyWebkitColorCorrection:
852 if (valueID == CSSValueSrgb || valueID == CSSValueDefault)
855 case CSSPropertyWebkitColumnFill:
856 if (valueID == CSSValueAuto || valueID == CSSValueBalance)
859 case CSSPropertyWebkitAlignContent:
860 if (valueID == CSSValueFlexStart || valueID == CSSValueFlexEnd || valueID == CSSValueCenter || valueID == CSSValueSpaceBetween || valueID == CSSValueSpaceAround || valueID == CSSValueStretch)
863 case CSSPropertyWebkitAlignItems:
864 if (valueID == CSSValueFlexStart || valueID == CSSValueFlexEnd || valueID == CSSValueCenter || valueID == CSSValueBaseline || valueID == CSSValueStretch)
867 case CSSPropertyWebkitAlignSelf:
868 if (valueID == CSSValueAuto || valueID == CSSValueFlexStart || valueID == CSSValueFlexEnd || valueID == CSSValueCenter || valueID == CSSValueBaseline || valueID == CSSValueStretch)
871 case CSSPropertyWebkitFlexDirection:
872 if (valueID == CSSValueRow || valueID == CSSValueRowReverse || valueID == CSSValueColumn || valueID == CSSValueColumnReverse)
875 case CSSPropertyWebkitFlexWrap:
876 if (valueID == CSSValueNowrap || valueID == CSSValueWrap || valueID == CSSValueWrapReverse)
879 case CSSPropertyWebkitJustifyContent:
880 if (valueID == CSSValueFlexStart || valueID == CSSValueFlexEnd || valueID == CSSValueCenter || valueID == CSSValueSpaceBetween || valueID == CSSValueSpaceAround)
883 case CSSPropertyWebkitFontKerning:
884 if (valueID == CSSValueAuto || valueID == CSSValueNormal || valueID == CSSValueNone)
887 case CSSPropertyWebkitFontSmoothing:
888 if (valueID == CSSValueAuto || valueID == CSSValueNone || valueID == CSSValueAntialiased || valueID == CSSValueSubpixelAntialiased)
891 case CSSPropertyWebkitHyphens:
892 if (valueID == CSSValueNone || valueID == CSSValueManual || valueID == CSSValueAuto)
895 case CSSPropertyWebkitGridAutoFlow:
896 if (valueID == CSSValueNone || valueID == CSSValueRow || valueID == CSSValueColumn)
899 case CSSPropertyWebkitLineAlign:
900 if (valueID == CSSValueNone || valueID == CSSValueEdges)
903 case CSSPropertyWebkitLineBreak: // auto | loose | normal | strict | after-white-space
904 if (valueID == CSSValueAuto || valueID == CSSValueLoose || valueID == CSSValueNormal || valueID == CSSValueStrict || valueID == CSSValueAfterWhiteSpace)
907 case CSSPropertyWebkitLineSnap:
908 if (valueID == CSSValueNone || valueID == CSSValueBaseline || valueID == CSSValueContain)
911 case CSSPropertyWebkitMarginAfterCollapse:
912 case CSSPropertyWebkitMarginBeforeCollapse:
913 case CSSPropertyWebkitMarginBottomCollapse:
914 case CSSPropertyWebkitMarginTopCollapse:
915 if (valueID == CSSValueCollapse || valueID == CSSValueSeparate || valueID == CSSValueDiscard)
918 case CSSPropertyWebkitMarqueeDirection:
919 if (valueID == CSSValueForwards || valueID == CSSValueBackwards || valueID == CSSValueAhead || valueID == CSSValueReverse || valueID == CSSValueLeft || valueID == CSSValueRight || valueID == CSSValueDown
920 || valueID == CSSValueUp || valueID == CSSValueAuto)
923 case CSSPropertyWebkitMarqueeStyle:
924 if (valueID == CSSValueNone || valueID == CSSValueSlide || valueID == CSSValueScroll || valueID == CSSValueAlternate)
927 case CSSPropertyWebkitNbspMode: // normal | space
928 if (valueID == CSSValueNormal || valueID == CSSValueSpace)
931 #if ENABLE(ACCELERATED_OVERFLOW_SCROLLING)
932 case CSSPropertyWebkitOverflowScrolling:
933 if (valueID == CSSValueAuto || valueID == CSSValueTouch)
937 case CSSPropertyWebkitPrintColorAdjust:
938 if (valueID == CSSValueExact || valueID == CSSValueEconomy)
941 #if ENABLE(CSS_REGIONS)
942 case CSSPropertyWebkitRegionBreakAfter:
943 case CSSPropertyWebkitRegionBreakBefore:
944 if (parserContext.isCSSRegionsEnabled && (valueID == CSSValueAuto || valueID == CSSValueAlways || valueID == CSSValueAvoid || valueID == CSSValueLeft || valueID == CSSValueRight))
947 case CSSPropertyWebkitRegionBreakInside:
948 if (parserContext.isCSSRegionsEnabled && (valueID == CSSValueAuto || valueID == CSSValueAvoid))
951 case CSSPropertyWebkitRegionFragment:
952 if (parserContext.isCSSRegionsEnabled && (valueID == CSSValueAuto || valueID == CSSValueBreak))
956 case CSSPropertyWebkitRtlOrdering:
957 if (valueID == CSSValueLogical || valueID == CSSValueVisual)
961 case CSSPropertyWebkitRubyPosition:
962 if (valueID == CSSValueBefore || valueID == CSSValueAfter)
966 #if ENABLE(CSS3_TEXT)
967 case CSSPropertyWebkitTextAlignLast:
968 // auto | start | end | left | right | center | justify
969 if ((valueID >= CSSValueLeft && valueID <= CSSValueJustify) || valueID == CSSValueStart || valueID == CSSValueEnd || valueID == CSSValueAuto)
973 case CSSPropertyWebkitTextCombine:
974 if (valueID == CSSValueNone || valueID == CSSValueHorizontal)
977 case CSSPropertyWebkitTextEmphasisPosition:
978 if (valueID == CSSValueOver || valueID == CSSValueUnder)
981 #if ENABLE(CSS3_TEXT)
982 case CSSPropertyWebkitTextJustify:
983 // auto | none | inter-word | inter-ideograph | inter-cluster | distribute | kashida
984 if ((valueID >= CSSValueInterWord && valueID <= CSSValueKashida) || valueID == CSSValueAuto || valueID == CSSValueNone)
988 case CSSPropertyWebkitTextSecurity:
989 // disc | circle | square | none | inherit
990 if (valueID == CSSValueDisc || valueID == CSSValueCircle || valueID == CSSValueSquare || valueID == CSSValueNone)
993 #if ENABLE(IOS_TEXT_AUTOSIZING)
994 case CSSPropertyWebkitTextSizeAdjust:
995 if (valueID == CSSValueAuto || valueID == CSSValueNone)
999 case CSSPropertyWebkitTransformStyle:
1000 if (valueID == CSSValueFlat || valueID == CSSValuePreserve3d)
1003 case CSSPropertyWebkitUserDrag: // auto | none | element
1004 if (valueID == CSSValueAuto || valueID == CSSValueNone || valueID == CSSValueElement)
1007 case CSSPropertyWebkitUserModify: // read-only | read-write
1008 if (valueID == CSSValueReadOnly || valueID == CSSValueReadWrite || valueID == CSSValueReadWritePlaintextOnly)
1011 case CSSPropertyWebkitUserSelect: // auto | none | text | all
1012 if (valueID == CSSValueAuto || valueID == CSSValueNone || valueID == CSSValueText || valueID == CSSValueAll)
1015 #if ENABLE(CSS_EXCLUSIONS)
1016 case CSSPropertyWebkitWrapFlow:
1017 if (!RuntimeEnabledFeatures::sharedFeatures().cssExclusionsEnabled())
1019 if (valueID == CSSValueAuto || valueID == CSSValueBoth || valueID == CSSValueStart || valueID == CSSValueEnd || valueID == CSSValueMaximum || valueID == CSSValueClear)
1022 case CSSPropertyWebkitWrapThrough:
1023 if (!RuntimeEnabledFeatures::sharedFeatures().cssExclusionsEnabled())
1025 if (valueID == CSSValueWrap || valueID == CSSValueNone)
1029 case CSSPropertyWebkitWritingMode:
1030 if (valueID >= CSSValueHorizontalTb && valueID <= CSSValueHorizontalBt)
1033 case CSSPropertyWhiteSpace: // normal | pre | nowrap | inherit
1034 if (valueID == CSSValueNormal || valueID == CSSValuePre || valueID == CSSValuePreWrap || valueID == CSSValuePreLine || valueID == CSSValueNowrap)
1037 case CSSPropertyWordBreak: // normal | break-all | break-word (this is a custom extension)
1038 if (valueID == CSSValueNormal || valueID == CSSValueBreakAll || valueID == CSSValueBreakWord)
1042 ASSERT_NOT_REACHED();
1048 static inline bool isKeywordPropertyID(CSSPropertyID propertyId)
1050 switch (propertyId) {
1051 case CSSPropertyBorderBottomStyle:
1052 case CSSPropertyBorderCollapse:
1053 case CSSPropertyBorderLeftStyle:
1054 case CSSPropertyBorderRightStyle:
1055 case CSSPropertyBorderTopStyle:
1056 case CSSPropertyBoxSizing:
1057 case CSSPropertyCaptionSide:
1058 case CSSPropertyClear:
1059 case CSSPropertyDirection:
1060 case CSSPropertyDisplay:
1061 case CSSPropertyEmptyCells:
1062 case CSSPropertyFloat:
1063 case CSSPropertyFontStyle:
1064 case CSSPropertyImageRendering:
1065 case CSSPropertyListStylePosition:
1066 case CSSPropertyListStyleType:
1067 case CSSPropertyObjectFit:
1068 case CSSPropertyOutlineStyle:
1069 case CSSPropertyOverflowWrap:
1070 case CSSPropertyOverflowX:
1071 case CSSPropertyOverflowY:
1072 case CSSPropertyPageBreakAfter:
1073 case CSSPropertyPageBreakBefore:
1074 case CSSPropertyPageBreakInside:
1075 case CSSPropertyPointerEvents:
1076 case CSSPropertyPosition:
1077 case CSSPropertyResize:
1078 case CSSPropertySpeak:
1079 case CSSPropertyTableLayout:
1080 case CSSPropertyTextLineThroughMode:
1081 case CSSPropertyTextLineThroughStyle:
1082 case CSSPropertyTextOverflow:
1083 case CSSPropertyTextOverlineMode:
1084 case CSSPropertyTextOverlineStyle:
1085 case CSSPropertyTextRendering:
1086 case CSSPropertyTextTransform:
1087 case CSSPropertyTextUnderlineMode:
1088 case CSSPropertyTextUnderlineStyle:
1089 case CSSPropertyVisibility:
1090 case CSSPropertyWebkitAppearance:
1091 #if ENABLE(CSS_COMPOSITING)
1092 case CSSPropertyWebkitBlendMode:
1094 case CSSPropertyWebkitBackfaceVisibility:
1095 case CSSPropertyWebkitBorderAfterStyle:
1096 case CSSPropertyWebkitBorderBeforeStyle:
1097 case CSSPropertyWebkitBorderEndStyle:
1098 case CSSPropertyWebkitBorderFit:
1099 case CSSPropertyWebkitBorderStartStyle:
1100 case CSSPropertyWebkitBoxAlign:
1101 #if ENABLE(CSS_BOX_DECORATION_BREAK)
1102 case CSSPropertyWebkitBoxDecorationBreak:
1104 case CSSPropertyWebkitBoxDirection:
1105 case CSSPropertyWebkitBoxLines:
1106 case CSSPropertyWebkitBoxOrient:
1107 case CSSPropertyWebkitBoxPack:
1108 case CSSPropertyWebkitColorCorrection:
1109 case CSSPropertyWebkitColumnBreakAfter:
1110 case CSSPropertyWebkitColumnBreakBefore:
1111 case CSSPropertyWebkitColumnBreakInside:
1112 case CSSPropertyWebkitColumnFill:
1113 case CSSPropertyWebkitColumnRuleStyle:
1114 case CSSPropertyWebkitAlignContent:
1115 case CSSPropertyWebkitAlignItems:
1116 case CSSPropertyWebkitAlignSelf:
1117 case CSSPropertyWebkitFlexDirection:
1118 case CSSPropertyWebkitFlexWrap:
1119 case CSSPropertyWebkitJustifyContent:
1120 case CSSPropertyWebkitFontKerning:
1121 case CSSPropertyWebkitFontSmoothing:
1122 case CSSPropertyWebkitHyphens:
1123 case CSSPropertyWebkitGridAutoFlow:
1124 case CSSPropertyWebkitLineAlign:
1125 case CSSPropertyWebkitLineBreak:
1126 case CSSPropertyWebkitLineSnap:
1127 case CSSPropertyWebkitMarginAfterCollapse:
1128 case CSSPropertyWebkitMarginBeforeCollapse:
1129 case CSSPropertyWebkitMarginBottomCollapse:
1130 case CSSPropertyWebkitMarginTopCollapse:
1131 case CSSPropertyWebkitMarqueeDirection:
1132 case CSSPropertyWebkitMarqueeStyle:
1133 case CSSPropertyWebkitNbspMode:
1134 #if ENABLE(ACCELERATED_OVERFLOW_SCROLLING)
1135 case CSSPropertyWebkitOverflowScrolling:
1137 case CSSPropertyWebkitPrintColorAdjust:
1138 #if ENABLE(CSS_REGIONS)
1139 case CSSPropertyWebkitRegionBreakAfter:
1140 case CSSPropertyWebkitRegionBreakBefore:
1141 case CSSPropertyWebkitRegionBreakInside:
1142 case CSSPropertyWebkitRegionFragment:
1144 case CSSPropertyWebkitRtlOrdering:
1145 case CSSPropertyWebkitRubyPosition:
1146 #if ENABLE(CSS3_TEXT)
1147 case CSSPropertyWebkitTextAlignLast:
1149 case CSSPropertyWebkitTextCombine:
1150 case CSSPropertyWebkitTextEmphasisPosition:
1151 #if ENABLE(CSS3_TEXT)
1152 case CSSPropertyWebkitTextJustify:
1154 case CSSPropertyWebkitTextSecurity:
1155 case CSSPropertyWebkitTransformStyle:
1156 case CSSPropertyWebkitUserDrag:
1157 case CSSPropertyWebkitUserModify:
1158 case CSSPropertyWebkitUserSelect:
1159 #if ENABLE(CSS_EXCLUSIONS)
1160 case CSSPropertyWebkitWrapFlow:
1161 case CSSPropertyWebkitWrapThrough:
1163 case CSSPropertyWebkitWritingMode:
1164 case CSSPropertyWhiteSpace:
1165 case CSSPropertyWordBreak:
1166 case CSSPropertyWordWrap:
1173 static bool parseKeywordValue(MutableStyleProperties* declaration, CSSPropertyID propertyId, const String& string, bool important, const CSSParserContext& parserContext)
1175 ASSERT(!string.isEmpty());
1177 if (!isKeywordPropertyID(propertyId)) {
1178 // All properties accept the values of "initial" and "inherit".
1179 String lowerCaseString = string.lower();
1180 if (lowerCaseString != "initial" && lowerCaseString != "inherit")
1183 // Parse initial/inherit shorthands using the CSSParser.
1184 if (shorthandForProperty(propertyId).length())
1188 CSSParserString cssString;
1189 cssString.init(string);
1190 CSSValueID valueID = cssValueKeywordID(cssString);
1195 RefPtr<CSSValue> value;
1196 if (valueID == CSSValueInherit)
1197 value = cssValuePool().createInheritedValue();
1198 else if (valueID == CSSValueInitial)
1199 value = cssValuePool().createExplicitInitialValue();
1200 else if (isValidKeywordPropertyAndValue(propertyId, valueID, parserContext))
1201 value = cssValuePool().createIdentifierValue(valueID);
1205 declaration->addParsedProperty(CSSProperty(propertyId, value.release(), important));
1209 template <typename CharacterType>
1210 static bool parseTransformArguments(WebKitCSSTransformValue* transformValue, CharacterType* characters, unsigned length, unsigned start, unsigned expectedCount)
1212 while (expectedCount) {
1213 size_t end = WTF::find(characters, length, expectedCount == 1 ? ')' : ',', start);
1214 if (end == notFound || (expectedCount == 1 && end != length - 1))
1216 unsigned argumentLength = end - start;
1217 CSSPrimitiveValue::UnitTypes unit = CSSPrimitiveValue::CSS_NUMBER;
1219 if (!parseSimpleLength(characters + start, argumentLength, unit, number))
1221 if (unit != CSSPrimitiveValue::CSS_PX && (number || unit != CSSPrimitiveValue::CSS_NUMBER))
1223 transformValue->append(cssValuePool().createValue(number, unit));
1230 static bool parseTranslateTransformValue(MutableStyleProperties* properties, CSSPropertyID propertyID, const String& string, bool important)
1232 if (propertyID != CSSPropertyWebkitTransform)
1234 static const unsigned shortestValidTransformStringLength = 12;
1235 static const unsigned likelyMultipartTransformStringLengthCutoff = 32;
1236 if (string.length() < shortestValidTransformStringLength || string.length() > likelyMultipartTransformStringLengthCutoff)
1238 if (!string.startsWith("translate", false))
1240 UChar c9 = toASCIILower(string[9]);
1241 UChar c10 = toASCIILower(string[10]);
1243 WebKitCSSTransformValue::TransformOperationType transformType;
1244 unsigned expectedArgumentCount = 1;
1245 unsigned argumentStart = 11;
1246 if (c9 == 'x' && c10 == '(')
1247 transformType = WebKitCSSTransformValue::TranslateXTransformOperation;
1248 else if (c9 == 'y' && c10 == '(')
1249 transformType = WebKitCSSTransformValue::TranslateYTransformOperation;
1250 else if (c9 == 'z' && c10 == '(')
1251 transformType = WebKitCSSTransformValue::TranslateZTransformOperation;
1252 else if (c9 == '(') {
1253 transformType = WebKitCSSTransformValue::TranslateTransformOperation;
1254 expectedArgumentCount = 2;
1256 } else if (c9 == '3' && c10 == 'd' && string[11] == '(') {
1257 transformType = WebKitCSSTransformValue::Translate3DTransformOperation;
1258 expectedArgumentCount = 3;
1263 RefPtr<WebKitCSSTransformValue> transformValue = WebKitCSSTransformValue::create(transformType);
1265 if (string.is8Bit())
1266 success = parseTransformArguments(transformValue.get(), string.characters8(), string.length(), argumentStart, expectedArgumentCount);
1268 success = parseTransformArguments(transformValue.get(), string.characters16(), string.length(), argumentStart, expectedArgumentCount);
1271 RefPtr<CSSValueList> result = CSSValueList::createSpaceSeparated();
1272 result->append(transformValue.release());
1273 properties->addParsedProperty(CSSProperty(CSSPropertyWebkitTransform, result.release(), important));
1277 PassRefPtr<CSSValueList> CSSParser::parseFontFaceValue(const AtomicString& string)
1279 if (string.isEmpty())
1281 RefPtr<MutableStyleProperties> dummyStyle = MutableStyleProperties::create();
1282 if (!parseValue(dummyStyle.get(), CSSPropertyFontFamily, string, false, CSSQuirksMode, 0))
1285 RefPtr<CSSValue> fontFamily = dummyStyle->getPropertyCSSValue(CSSPropertyFontFamily);
1286 if (!fontFamily->isValueList())
1287 return 0; // FIXME: "initial" and "inherit" should be parsed as font names in the face attribute.
1288 return static_pointer_cast<CSSValueList>(fontFamily.release());
1291 bool CSSParser::parseValue(MutableStyleProperties* declaration, CSSPropertyID propertyID, const String& string, bool important, CSSParserMode cssParserMode, StyleSheetContents* contextStyleSheet)
1293 ASSERT(!string.isEmpty());
1294 if (parseSimpleLengthValue(declaration, propertyID, string, important, cssParserMode))
1296 if (parseColorValue(declaration, propertyID, string, important, cssParserMode))
1299 CSSParserContext context(cssParserMode);
1300 if (contextStyleSheet) {
1301 context = contextStyleSheet->parserContext();
1302 context.mode = cssParserMode;
1305 if (parseKeywordValue(declaration, propertyID, string, important, context))
1307 if (parseTranslateTransformValue(declaration, propertyID, string, important))
1310 CSSParser parser(context);
1311 return parser.parseValue(declaration, propertyID, string, important, contextStyleSheet);
1314 bool CSSParser::parseValue(MutableStyleProperties* declaration, CSSPropertyID propertyID, const String& string, bool important, StyleSheetContents* contextStyleSheet)
1316 setStyleSheet(contextStyleSheet);
1318 setupParser("@-webkit-value{", string, "} ");
1321 m_important = important;
1328 if (m_hasFontFaceOnlyValues)
1329 deleteFontFaceOnlyValues();
1330 if (!m_parsedProperties.isEmpty()) {
1332 declaration->addParsedProperties(m_parsedProperties);
1339 // The color will only be changed when string contains a valid CSS color, so callers
1340 // can set it to a default color and ignore the boolean result.
1341 bool CSSParser::parseColor(RGBA32& color, const String& string, bool strict)
1343 // First try creating a color specified by name, rgba(), rgb() or "#" syntax.
1344 if (fastParseColor(color, string, strict))
1347 CSSParser parser(CSSStrictMode);
1349 // In case the fast-path parser didn't understand the color, try the full parser.
1350 if (!parser.parseColor(string))
1353 CSSValue* value = parser.m_parsedProperties.first().value();
1354 if (!value->isPrimitiveValue())
1357 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
1358 if (!primitiveValue->isRGBColor())
1361 color = primitiveValue->getRGBA32Value();
1365 bool CSSParser::parseColor(const String& string)
1367 setupParser("@-webkit-decls{color:", string, "} ");
1371 return !m_parsedProperties.isEmpty() && m_parsedProperties.first().id() == CSSPropertyColor;
1374 bool CSSParser::parseSystemColor(RGBA32& color, const String& string, Document* document)
1376 if (!document || !document->page())
1379 CSSParserString cssColor;
1380 cssColor.init(string);
1381 CSSValueID id = cssValueKeywordID(cssColor);
1385 color = document->page()->theme()->systemColor(id).rgb();
1389 void CSSParser::parseSelector(const String& string, CSSSelectorList& selectorList)
1391 m_selectorListForParseSelector = &selectorList;
1393 setupParser("@-webkit-selector{", string, "}");
1397 m_selectorListForParseSelector = 0;
1400 PassRef<ImmutableStyleProperties> CSSParser::parseInlineStyleDeclaration(const String& string, Element* element)
1402 CSSParserContext context = element->document().elementSheet().contents().parserContext();
1403 context.mode = strictToCSSParserMode(element->isHTMLElement() && !element->document().inQuirksMode());
1404 return CSSParser(context).parseDeclaration(string, &element->document().elementSheet().contents());
1407 PassRef<ImmutableStyleProperties> CSSParser::parseDeclaration(const String& string, StyleSheetContents* contextStyleSheet)
1409 setStyleSheet(contextStyleSheet);
1411 setupParser("@-webkit-decls{", string, "} ");
1415 if (m_hasFontFaceOnlyValues)
1416 deleteFontFaceOnlyValues();
1418 PassRef<ImmutableStyleProperties> style = createStyleProperties();
1424 bool CSSParser::parseDeclaration(MutableStyleProperties* declaration, const String& string, PassRefPtr<CSSRuleSourceData> prpRuleSourceData, StyleSheetContents* contextStyleSheet)
1426 // Length of the "@-webkit-decls{" prefix.
1427 static const unsigned prefixLength = 15;
1429 setStyleSheet(contextStyleSheet);
1431 RefPtr<CSSRuleSourceData> ruleSourceData = prpRuleSourceData;
1432 if (ruleSourceData) {
1433 m_currentRuleDataStack = adoptPtr(new RuleSourceDataList());
1434 m_currentRuleDataStack->append(ruleSourceData);
1437 setupParser("@-webkit-decls{", string, "} ");
1442 if (m_hasFontFaceOnlyValues)
1443 deleteFontFaceOnlyValues();
1444 if (!m_parsedProperties.isEmpty()) {
1446 declaration->addParsedProperties(m_parsedProperties);
1450 if (ruleSourceData) {
1451 ASSERT(m_currentRuleDataStack->size() == 1);
1452 ruleSourceData->ruleBodyRange.start = 0;
1453 ruleSourceData->ruleBodyRange.end = string.length();
1454 for (size_t i = 0, size = ruleSourceData->styleSourceData->propertyData.size(); i < size; ++i) {
1455 CSSPropertySourceData& propertyData = ruleSourceData->styleSourceData->propertyData.at(i);
1456 propertyData.range.start -= prefixLength;
1457 propertyData.range.end -= prefixLength;
1460 fixUnparsedPropertyRanges(ruleSourceData.get());
1461 m_currentRuleDataStack.clear();
1467 PassOwnPtr<MediaQuery> CSSParser::parseMediaQuery(const String& string)
1469 if (string.isEmpty())
1472 ASSERT(!m_mediaQuery);
1474 // can't use { because tokenizer state switches from mediaquery to initial state when it sees { token.
1475 // instead insert one " " (which is WHITESPACE in CSSGrammar.y)
1476 setupParser("@-webkit-mediaquery ", string, "} ");
1479 return m_mediaQuery.release();
1482 static inline void filterProperties(bool important, const CSSParser::ParsedPropertyVector& input, Vector<CSSProperty, 256>& output, size_t& unusedEntries, std::bitset<numCSSProperties>& seenProperties)
1484 // Add properties in reverse order so that highest priority definitions are reached first. Duplicate definitions can then be ignored when found.
1485 for (int i = input.size() - 1; i >= 0; --i) {
1486 const CSSProperty& property = input[i];
1487 if (property.isImportant() != important)
1489 const unsigned propertyIDIndex = property.id() - firstCSSProperty;
1490 if (seenProperties.test(propertyIDIndex))
1492 seenProperties.set(propertyIDIndex);
1493 output[--unusedEntries] = property;
1497 PassRef<ImmutableStyleProperties> CSSParser::createStyleProperties()
1499 std::bitset<numCSSProperties> seenProperties;
1500 size_t unusedEntries = m_parsedProperties.size();
1501 Vector<CSSProperty, 256> results(unusedEntries);
1503 // Important properties have higher priority, so add them first. Duplicate definitions can then be ignored when found.
1504 filterProperties(true, m_parsedProperties, results, unusedEntries, seenProperties);
1505 filterProperties(false, m_parsedProperties, results, unusedEntries, seenProperties);
1507 results.remove(0, unusedEntries);
1509 return ImmutableStyleProperties::create(results.data(), results.size(), m_context.mode);
1512 void CSSParser::addPropertyWithPrefixingVariant(CSSPropertyID propId, PassRefPtr<CSSValue> value, bool important, bool implicit)
1514 RefPtr<CSSValue> val = value.get();
1515 addProperty(propId, value, important, implicit);
1517 CSSPropertyID prefixingVariant = prefixingVariantForPropertyId(propId);
1518 if (prefixingVariant == propId)
1521 if (m_currentShorthand) {
1522 // We can't use ShorthandScope here as we can already be inside one (e.g we are parsing CSSTransition).
1523 m_currentShorthand = prefixingVariantForPropertyId(m_currentShorthand);
1524 addProperty(prefixingVariant, val.release(), important, implicit);
1525 m_currentShorthand = prefixingVariantForPropertyId(m_currentShorthand);
1527 addProperty(prefixingVariant, val.release(), important, implicit);
1530 void CSSParser::addProperty(CSSPropertyID propId, PassRefPtr<CSSValue> value, bool important, bool implicit)
1532 // This property doesn't belong to a shorthand or is a CSS variable (which will be resolved later).
1533 if (!m_currentShorthand) {
1534 m_parsedProperties.append(CSSProperty(propId, value, important, false, CSSPropertyInvalid, m_implicitShorthand || implicit));
1538 Vector<StylePropertyShorthand> shorthands = matchingShorthandsForLonghand(propId);
1539 if (shorthands.size() == 1)
1540 m_parsedProperties.append(CSSProperty(propId, value, important, true, CSSPropertyInvalid, m_implicitShorthand || implicit));
1542 m_parsedProperties.append(CSSProperty(propId, value, important, true, indexOfShorthandForLonghand(m_currentShorthand, shorthands), m_implicitShorthand || implicit));
1545 void CSSParser::rollbackLastProperties(int num)
1548 ASSERT(m_parsedProperties.size() >= static_cast<unsigned>(num));
1549 m_parsedProperties.shrink(m_parsedProperties.size() - num);
1552 void CSSParser::clearProperties()
1554 m_parsedProperties.clear();
1555 m_numParsedPropertiesBeforeMarginBox = INVALID_NUM_PARSED_PROPERTIES;
1556 m_hasFontFaceOnlyValues = false;
1559 URL CSSParser::completeURL(const CSSParserContext& context, const String& url)
1563 if (context.charset.isEmpty())
1564 return URL(context.baseURL, url);
1565 return URL(context.baseURL, url, context.charset);
1568 URL CSSParser::completeURL(const String& url) const
1570 return completeURL(m_context, url);
1573 bool CSSParser::validCalculationUnit(CSSParserValue* value, Units unitflags, ReleaseParsedCalcValueCondition releaseCalc)
1575 bool mustBeNonNegative = unitflags & FNonNeg;
1577 if (!parseCalculation(value, mustBeNonNegative ? CalculationRangeNonNegative : CalculationRangeAll))
1581 switch (m_parsedCalculation->category()) {
1583 b = (unitflags & FLength);
1586 b = (unitflags & FPercent);
1587 if (b && mustBeNonNegative && m_parsedCalculation->isNegative())
1591 b = (unitflags & FNumber);
1592 if (!b && (unitflags & FInteger) && m_parsedCalculation->isInt())
1594 if (b && mustBeNonNegative && m_parsedCalculation->isNegative())
1597 case CalcPercentLength:
1598 b = (unitflags & FPercent) && (unitflags & FLength);
1600 case CalcPercentNumber:
1601 b = (unitflags & FPercent) && (unitflags & FNumber);
1606 if (!b || releaseCalc == ReleaseParsedCalcValue)
1607 m_parsedCalculation.release();
1611 inline bool CSSParser::shouldAcceptUnitLessValues(CSSParserValue* value, Units unitflags, CSSParserMode cssParserMode)
1613 // Qirks mode and svg presentation attributes accept unit less values.
1614 return (unitflags & (FLength | FAngle | FTime)) && (!value->fValue || cssParserMode == CSSQuirksMode || cssParserMode == SVGAttributeMode);
1617 bool CSSParser::validUnit(CSSParserValue* value, Units unitflags, CSSParserMode cssParserMode, ReleaseParsedCalcValueCondition releaseCalc)
1619 if (isCalculation(value))
1620 return validCalculationUnit(value, unitflags, releaseCalc);
1623 switch (value->unit) {
1624 case CSSPrimitiveValue::CSS_NUMBER:
1625 b = (unitflags & FNumber);
1626 if (!b && shouldAcceptUnitLessValues(value, unitflags, cssParserMode)) {
1627 value->unit = (unitflags & FLength) ? CSSPrimitiveValue::CSS_PX :
1628 ((unitflags & FAngle) ? CSSPrimitiveValue::CSS_DEG : CSSPrimitiveValue::CSS_MS);
1631 if (!b && (unitflags & FInteger) && value->isInt)
1633 if (!b && (unitflags & FPositiveInteger) && value->isInt && value->fValue > 0)
1636 case CSSPrimitiveValue::CSS_PERCENTAGE:
1637 b = (unitflags & FPercent);
1639 case CSSParserValue::Q_EMS:
1640 case CSSPrimitiveValue::CSS_EMS:
1641 case CSSPrimitiveValue::CSS_REMS:
1642 case CSSPrimitiveValue::CSS_CHS:
1643 case CSSPrimitiveValue::CSS_EXS:
1644 case CSSPrimitiveValue::CSS_PX:
1645 case CSSPrimitiveValue::CSS_CM:
1646 case CSSPrimitiveValue::CSS_MM:
1647 case CSSPrimitiveValue::CSS_IN:
1648 case CSSPrimitiveValue::CSS_PT:
1649 case CSSPrimitiveValue::CSS_PC:
1650 case CSSPrimitiveValue::CSS_VW:
1651 case CSSPrimitiveValue::CSS_VH:
1652 case CSSPrimitiveValue::CSS_VMIN:
1653 case CSSPrimitiveValue::CSS_VMAX:
1654 b = (unitflags & FLength);
1656 case CSSPrimitiveValue::CSS_MS:
1657 case CSSPrimitiveValue::CSS_S:
1658 b = (unitflags & FTime);
1660 case CSSPrimitiveValue::CSS_DEG:
1661 case CSSPrimitiveValue::CSS_RAD:
1662 case CSSPrimitiveValue::CSS_GRAD:
1663 case CSSPrimitiveValue::CSS_TURN:
1664 b = (unitflags & FAngle);
1666 #if ENABLE(CSS_IMAGE_RESOLUTION) || ENABLE(RESOLUTION_MEDIA_QUERY)
1667 case CSSPrimitiveValue::CSS_DPPX:
1668 case CSSPrimitiveValue::CSS_DPI:
1669 case CSSPrimitiveValue::CSS_DPCM:
1670 b = (unitflags & FResolution);
1673 case CSSPrimitiveValue::CSS_HZ:
1674 case CSSPrimitiveValue::CSS_KHZ:
1675 case CSSPrimitiveValue::CSS_DIMENSION:
1679 if (b && unitflags & FNonNeg && value->fValue < 0)
1684 inline PassRefPtr<CSSPrimitiveValue> CSSParser::createPrimitiveNumericValue(CSSParserValue* value)
1686 if (m_parsedCalculation) {
1687 ASSERT(isCalculation(value));
1688 return CSSPrimitiveValue::create(m_parsedCalculation.release());
1691 #if ENABLE(CSS_IMAGE_RESOLUTION) || ENABLE(RESOLUTION_MEDIA_QUERY)
1692 ASSERT((value->unit >= CSSPrimitiveValue::CSS_NUMBER && value->unit <= CSSPrimitiveValue::CSS_KHZ)
1693 || (value->unit >= CSSPrimitiveValue::CSS_TURN && value->unit <= CSSPrimitiveValue::CSS_CHS)
1694 || (value->unit >= CSSPrimitiveValue::CSS_VW && value->unit <= CSSPrimitiveValue::CSS_VMAX)
1695 || (value->unit >= CSSPrimitiveValue::CSS_DPPX && value->unit <= CSSPrimitiveValue::CSS_DPCM));
1697 ASSERT((value->unit >= CSSPrimitiveValue::CSS_NUMBER && value->unit <= CSSPrimitiveValue::CSS_KHZ)
1698 || (value->unit >= CSSPrimitiveValue::CSS_TURN && value->unit <= CSSPrimitiveValue::CSS_CHS)
1699 || (value->unit >= CSSPrimitiveValue::CSS_VW && value->unit <= CSSPrimitiveValue::CSS_VMAX));
1701 return cssValuePool().createValue(value->fValue, static_cast<CSSPrimitiveValue::UnitTypes>(value->unit));
1704 inline PassRefPtr<CSSPrimitiveValue> CSSParser::createPrimitiveStringValue(CSSParserValue* value)
1706 ASSERT(value->unit == CSSPrimitiveValue::CSS_STRING || value->unit == CSSPrimitiveValue::CSS_IDENT);
1707 return cssValuePool().createValue(value->string, CSSPrimitiveValue::CSS_STRING);
1710 static inline bool isComma(CSSParserValue* value)
1712 return value && value->unit == CSSParserValue::Operator && value->iValue == ',';
1715 static inline bool isForwardSlashOperator(CSSParserValue* value)
1718 return value->unit == CSSParserValue::Operator && value->iValue == '/';
1721 bool CSSParser::validWidth(CSSParserValue* value)
1724 if (id == CSSValueIntrinsic || id == CSSValueMinIntrinsic || id == CSSValueWebkitMinContent || id == CSSValueWebkitMaxContent || id == CSSValueWebkitFillAvailable || id == CSSValueWebkitFitContent)
1726 return !id && validUnit(value, FLength | FPercent | FNonNeg);
1729 // FIXME: Combine this with validWidth when we support fit-content, et al, for heights.
1730 bool CSSParser::validHeight(CSSParserValue* value)
1733 if (id == CSSValueIntrinsic || id == CSSValueMinIntrinsic)
1735 return !id && validUnit(value, FLength | FPercent | FNonNeg);
1738 inline PassRefPtr<CSSPrimitiveValue> CSSParser::parseValidPrimitive(CSSValueID identifier, CSSParserValue* value)
1741 return cssValuePool().createIdentifierValue(identifier);
1742 if (value->unit == CSSPrimitiveValue::CSS_STRING)
1743 return createPrimitiveStringValue(value);
1744 if (value->unit >= CSSPrimitiveValue::CSS_NUMBER && value->unit <= CSSPrimitiveValue::CSS_KHZ)
1745 return createPrimitiveNumericValue(value);
1746 if (value->unit >= CSSPrimitiveValue::CSS_TURN && value->unit <= CSSPrimitiveValue::CSS_CHS)
1747 return createPrimitiveNumericValue(value);
1748 if (value->unit >= CSSPrimitiveValue::CSS_VW && value->unit <= CSSPrimitiveValue::CSS_VMAX)
1749 return createPrimitiveNumericValue(value);
1750 #if ENABLE(CSS_IMAGE_RESOLUTION) || ENABLE(RESOLUTION_MEDIA_QUERY)
1751 if (value->unit >= CSSPrimitiveValue::CSS_DPPX && value->unit <= CSSPrimitiveValue::CSS_DPCM)
1752 return createPrimitiveNumericValue(value);
1754 if (value->unit >= CSSParserValue::Q_EMS)
1755 return CSSPrimitiveValue::createAllowingMarginQuirk(value->fValue, CSSPrimitiveValue::CSS_EMS);
1756 if (isCalculation(value))
1757 return CSSPrimitiveValue::create(m_parsedCalculation.release());
1762 void CSSParser::addExpandedPropertyForValue(CSSPropertyID propId, PassRefPtr<CSSValue> prpValue, bool important)
1764 const StylePropertyShorthand& shorthand = shorthandForProperty(propId);
1765 unsigned shorthandLength = shorthand.length();
1766 if (!shorthandLength) {
1767 addProperty(propId, prpValue, important);
1771 RefPtr<CSSValue> value = prpValue;
1772 ShorthandScope scope(this, propId);
1773 const CSSPropertyID* longhands = shorthand.properties();
1774 for (unsigned i = 0; i < shorthandLength; ++i)
1775 addProperty(longhands[i], value, important);
1778 bool CSSParser::parseValue(CSSPropertyID propId, bool important)
1783 CSSParserValue* value = m_valueList->current();
1788 // Note: m_parsedCalculation is used to pass the calc value to validUnit and then cleared at the end of this function.
1789 // FIXME: This is to avoid having to pass parsedCalc to all validUnit callers.
1790 ASSERT(!m_parsedCalculation);
1792 CSSValueID id = value->id;
1794 int num = inShorthand() ? 1 : m_valueList->size();
1796 if (id == CSSValueInherit) {
1799 addExpandedPropertyForValue(propId, cssValuePool().createInheritedValue(), important);
1802 else if (id == CSSValueInitial) {
1805 addExpandedPropertyForValue(propId, cssValuePool().createExplicitInitialValue(), important);
1809 if (isKeywordPropertyID(propId)) {
1810 if (!isValidKeywordPropertyAndValue(propId, id, m_context))
1812 if (m_valueList->next() && !inShorthand())
1814 addProperty(propId, cssValuePool().createIdentifierValue(id), important);
1818 #if ENABLE(CSS_DEVICE_ADAPTATION)
1820 return parseViewportProperty(propId, important);
1823 bool validPrimitive = false;
1824 RefPtr<CSSValue> parsedValue;
1827 case CSSPropertySize: // <length>{1,2} | auto | [ <page-size> || [ portrait | landscape] ]
1828 return parseSize(propId, important);
1830 case CSSPropertyQuotes: // [<string> <string>]+ | none | inherit
1832 validPrimitive = true;
1834 return parseQuotes(propId, important);
1836 case CSSPropertyUnicodeBidi: // normal | embed | bidi-override | isolate | isolate-override | plaintext | inherit
1837 if (id == CSSValueNormal
1838 || id == CSSValueEmbed
1839 || id == CSSValueBidiOverride
1840 || id == CSSValueWebkitIsolate
1841 || id == CSSValueWebkitIsolateOverride
1842 || id == CSSValueWebkitPlaintext)
1843 validPrimitive = true;
1846 case CSSPropertyContent: // [ <string> | <uri> | <counter> | attr(X) | open-quote |
1847 // close-quote | no-open-quote | no-close-quote ]+ | inherit
1848 return parseContent(propId, important);
1850 case CSSPropertyWebkitAlt: // [ <string> | attr(X) ]
1851 return parseAlt(propId, important);
1853 case CSSPropertyClip: // <shape> | auto | inherit
1854 if (id == CSSValueAuto)
1855 validPrimitive = true;
1856 else if (value->unit == CSSParserValue::Function)
1857 return parseClipShape(propId, important);
1860 /* Start of supported CSS properties with validation. This is needed for parseShorthand to work
1861 * correctly and allows optimization in WebCore::applyRule(..)
1863 case CSSPropertyOverflow: {
1864 ShorthandScope scope(this, propId);
1865 if (num != 1 || !parseValue(CSSPropertyOverflowY, important))
1868 RefPtr<CSSValue> overflowXValue;
1870 // FIXME: -webkit-paged-x or -webkit-paged-y only apply to overflow-y. If this value has been
1871 // set using the shorthand, then for now overflow-x will default to auto, but once we implement
1872 // pagination controls, it should default to hidden. If the overflow-y value is anything but
1873 // paged-x or paged-y, then overflow-x and overflow-y should have the same value.
1874 if (id == CSSValueWebkitPagedX || id == CSSValueWebkitPagedY)
1875 overflowXValue = cssValuePool().createIdentifierValue(CSSValueAuto);
1877 overflowXValue = m_parsedProperties.last().value();
1878 addProperty(CSSPropertyOverflowX, overflowXValue.release(), important);
1882 case CSSPropertyTextAlign:
1883 // left | right | center | justify | -webkit-left | -webkit-right | -webkit-center | -webkit-match-parent
1884 // | start | end | inherit | -webkit-auto (converted to start)
1885 // NOTE: <string> is not supported.
1886 if ((id >= CSSValueWebkitAuto && id <= CSSValueWebkitMatchParent) || id == CSSValueStart || id == CSSValueEnd)
1887 validPrimitive = true;
1890 case CSSPropertyFontWeight: { // normal | bold | bolder | lighter | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | inherit
1891 if (m_valueList->size() != 1)
1893 return parseFontWeight(important);
1895 case CSSPropertyBorderSpacing: {
1897 ShorthandScope scope(this, CSSPropertyBorderSpacing);
1898 if (!parseValue(CSSPropertyWebkitBorderHorizontalSpacing, important))
1900 CSSValue* value = m_parsedProperties.last().value();
1901 addProperty(CSSPropertyWebkitBorderVerticalSpacing, value, important);
1904 else if (num == 2) {
1905 ShorthandScope scope(this, CSSPropertyBorderSpacing);
1906 if (!parseValue(CSSPropertyWebkitBorderHorizontalSpacing, important) || !parseValue(CSSPropertyWebkitBorderVerticalSpacing, important))
1912 case CSSPropertyWebkitBorderHorizontalSpacing:
1913 case CSSPropertyWebkitBorderVerticalSpacing:
1914 validPrimitive = validUnit(value, FLength | FNonNeg);
1916 case CSSPropertyOutlineColor: // <color> | invert | inherit
1917 // Outline color has "invert" as additional keyword.
1918 // Also, we want to allow the special focus color even in strict parsing mode.
1919 if (id == CSSValueInvert || id == CSSValueWebkitFocusRingColor) {
1920 validPrimitive = true;
1924 case CSSPropertyBackgroundColor: // <color> | inherit
1925 case CSSPropertyBorderTopColor: // <color> | inherit
1926 case CSSPropertyBorderRightColor:
1927 case CSSPropertyBorderBottomColor:
1928 case CSSPropertyBorderLeftColor:
1929 case CSSPropertyWebkitBorderStartColor:
1930 case CSSPropertyWebkitBorderEndColor:
1931 case CSSPropertyWebkitBorderBeforeColor:
1932 case CSSPropertyWebkitBorderAfterColor:
1933 case CSSPropertyColor: // <color> | inherit
1934 case CSSPropertyTextLineThroughColor: // CSS3 text decoration colors
1935 case CSSPropertyTextUnderlineColor:
1936 case CSSPropertyTextOverlineColor:
1937 case CSSPropertyWebkitColumnRuleColor:
1938 #if ENABLE(CSS3_TEXT_DECORATION)
1939 case CSSPropertyWebkitTextDecorationColor:
1941 case CSSPropertyWebkitTextEmphasisColor:
1942 case CSSPropertyWebkitTextFillColor:
1943 case CSSPropertyWebkitTextStrokeColor:
1944 if (id == CSSValueWebkitText)
1945 validPrimitive = true; // Always allow this, even when strict parsing is on,
1946 // since we use this in our UA sheets.
1947 else if (id == CSSValueCurrentcolor)
1948 validPrimitive = true;
1949 else if ((id >= CSSValueAqua && id <= CSSValueWindowtext) || id == CSSValueMenu ||
1950 (id >= CSSValueWebkitFocusRingColor && id < CSSValueWebkitText && inQuirksMode())) {
1951 validPrimitive = true;
1953 parsedValue = parseColor();
1955 m_valueList->next();
1959 case CSSPropertyCursor: {
1960 // Grammar defined by CSS3 UI and modified by CSS4 images:
1961 // [ [<image> [<x> <y>]?,]*
1962 // [ auto | crosshair | default | pointer | progress | move | e-resize | ne-resize |
1963 // nw-resize | n-resize | se-resize | sw-resize | s-resize | w-resize | ew-resize |
1964 // ns-resize | nesw-resize | nwse-resize | col-resize | row-resize | text | wait | help |
1965 // vertical-text | cell | context-menu | alias | copy | no-drop | not-allowed | -webkit-zoom-in
1966 // -webkit-zoom-out | all-scroll | -webkit-grab | -webkit-grabbing ] ] | inherit
1967 RefPtr<CSSValueList> list;
1969 RefPtr<CSSValue> image = 0;
1970 if (value->unit == CSSPrimitiveValue::CSS_URI) {
1971 String uri = value->string;
1973 image = CSSImageValue::create(completeURL(uri));
1974 #if ENABLE(CSS_IMAGE_SET) && ENABLE(MOUSE_CURSOR_SCALE)
1975 } else if (value->unit == CSSParserValue::Function && equalIgnoringCase(value->function->name, "-webkit-image-set(")) {
1976 image = parseImageSet();
1984 value = m_valueList->next();
1985 while (value && value->unit == CSSPrimitiveValue::CSS_NUMBER) {
1986 coords.append(int(value->fValue));
1987 value = m_valueList->next();
1989 bool hasHotSpot = false;
1990 IntPoint hotSpot(-1, -1);
1991 int nrcoords = coords.size();
1992 if (nrcoords > 0 && nrcoords != 2)
1994 if (nrcoords == 2) {
1996 hotSpot = IntPoint(coords[0], coords[1]);
2000 list = CSSValueList::createCommaSeparated();
2003 list->append(CSSCursorImageValue::create(image.releaseNonNull(), hasHotSpot, hotSpot));
2005 if ((inStrictMode() && !value) || (value && !(value->unit == CSSParserValue::Operator && value->iValue == ',')))
2007 value = m_valueList->next(); // comma
2010 if (!value) { // no value after url list (MSIE 5 compatibility)
2011 if (list->length() != 1)
2013 } else if (inQuirksMode() && value->id == CSSValueHand) // MSIE 5 compatibility :/
2014 list->append(cssValuePool().createIdentifierValue(CSSValuePointer));
2015 else if ((value->id >= CSSValueAuto && value->id <= CSSValueWebkitGrabbing) || value->id == CSSValueCopy || value->id == CSSValueNone)
2016 list->append(cssValuePool().createIdentifierValue(value->id));
2017 m_valueList->next();
2018 parsedValue = list.release();
2022 if (inQuirksMode() && value->id == CSSValueHand) { // MSIE 5 compatibility :/
2023 id = CSSValuePointer;
2024 validPrimitive = true;
2025 } else if ((value->id >= CSSValueAuto && value->id <= CSSValueWebkitGrabbing) || value->id == CSSValueCopy || value->id == CSSValueNone)
2026 validPrimitive = true;
2028 ASSERT_NOT_REACHED();
2034 #if ENABLE(CURSOR_VISIBILITY)
2035 case CSSPropertyWebkitCursorVisibility:
2036 if (id == CSSValueAuto || id == CSSValueAutoHide)
2037 validPrimitive = true;
2041 case CSSPropertyBackgroundAttachment:
2042 case CSSPropertyWebkitBackgroundBlendMode:
2043 case CSSPropertyBackgroundClip:
2044 case CSSPropertyWebkitBackgroundClip:
2045 case CSSPropertyWebkitBackgroundComposite:
2046 case CSSPropertyBackgroundImage:
2047 case CSSPropertyBackgroundOrigin:
2048 case CSSPropertyWebkitBackgroundOrigin:
2049 case CSSPropertyBackgroundPosition:
2050 case CSSPropertyBackgroundPositionX:
2051 case CSSPropertyBackgroundPositionY:
2052 case CSSPropertyBackgroundSize:
2053 case CSSPropertyWebkitBackgroundSize:
2054 case CSSPropertyBackgroundRepeat:
2055 case CSSPropertyBackgroundRepeatX:
2056 case CSSPropertyBackgroundRepeatY:
2057 case CSSPropertyWebkitMaskClip:
2058 case CSSPropertyWebkitMaskComposite:
2059 case CSSPropertyWebkitMaskImage:
2060 case CSSPropertyWebkitMaskOrigin:
2061 case CSSPropertyWebkitMaskPosition:
2062 case CSSPropertyWebkitMaskPositionX:
2063 case CSSPropertyWebkitMaskPositionY:
2064 case CSSPropertyWebkitMaskSize:
2065 case CSSPropertyWebkitMaskSourceType:
2066 case CSSPropertyWebkitMaskRepeat:
2067 case CSSPropertyWebkitMaskRepeatX:
2068 case CSSPropertyWebkitMaskRepeatY:
2070 RefPtr<CSSValue> val1;
2071 RefPtr<CSSValue> val2;
2072 CSSPropertyID propId1, propId2;
2073 bool result = false;
2074 if (parseFillProperty(propId, propId1, propId2, val1, val2)) {
2075 OwnPtr<ShorthandScope> shorthandScope;
2076 if (propId == CSSPropertyBackgroundPosition ||
2077 propId == CSSPropertyBackgroundRepeat ||
2078 propId == CSSPropertyWebkitMaskPosition ||
2079 propId == CSSPropertyWebkitMaskRepeat) {
2080 shorthandScope = adoptPtr(new ShorthandScope(this, propId));
2082 addProperty(propId1, val1.release(), important);
2084 addProperty(propId2, val2.release(), important);
2087 m_implicitShorthand = false;
2090 case CSSPropertyListStyleImage: // <uri> | none | inherit
2091 case CSSPropertyBorderImageSource:
2092 case CSSPropertyWebkitMaskBoxImageSource:
2093 if (id == CSSValueNone) {
2094 parsedValue = cssValuePool().createIdentifierValue(CSSValueNone);
2095 m_valueList->next();
2096 } else if (value->unit == CSSPrimitiveValue::CSS_URI) {
2097 parsedValue = CSSImageValue::create(completeURL(value->string));
2098 m_valueList->next();
2099 } else if (isGeneratedImageValue(value)) {
2100 if (parseGeneratedImage(m_valueList.get(), parsedValue))
2101 m_valueList->next();
2105 #if ENABLE(CSS_IMAGE_SET)
2106 else if (value->unit == CSSParserValue::Function && equalIgnoringCase(value->function->name, "-webkit-image-set(")) {
2107 parsedValue = parseImageSet();
2110 m_valueList->next();
2115 case CSSPropertyWebkitTextStrokeWidth:
2116 case CSSPropertyOutlineWidth: // <border-width> | inherit
2117 case CSSPropertyBorderTopWidth: //// <border-width> | inherit
2118 case CSSPropertyBorderRightWidth: // Which is defined as
2119 case CSSPropertyBorderBottomWidth: // thin | medium | thick | <length>
2120 case CSSPropertyBorderLeftWidth:
2121 case CSSPropertyWebkitBorderStartWidth:
2122 case CSSPropertyWebkitBorderEndWidth:
2123 case CSSPropertyWebkitBorderBeforeWidth:
2124 case CSSPropertyWebkitBorderAfterWidth:
2125 case CSSPropertyWebkitColumnRuleWidth:
2126 if (id == CSSValueThin || id == CSSValueMedium || id == CSSValueThick)
2127 validPrimitive = true;
2129 validPrimitive = validUnit(value, FLength | FNonNeg);
2132 case CSSPropertyLetterSpacing: // normal | <length> | inherit
2133 case CSSPropertyWordSpacing: // normal | <length> | inherit
2134 if (id == CSSValueNormal)
2135 validPrimitive = true;
2137 validPrimitive = validUnit(value, FLength);
2140 case CSSPropertyTextIndent:
2141 parsedValue = parseTextIndent();
2144 case CSSPropertyPaddingTop: //// <padding-width> | inherit
2145 case CSSPropertyPaddingRight: // Which is defined as
2146 case CSSPropertyPaddingBottom: // <length> | <percentage>
2147 case CSSPropertyPaddingLeft: ////
2148 case CSSPropertyWebkitPaddingStart:
2149 case CSSPropertyWebkitPaddingEnd:
2150 case CSSPropertyWebkitPaddingBefore:
2151 case CSSPropertyWebkitPaddingAfter:
2152 validPrimitive = (!id && validUnit(value, FLength | FPercent | FNonNeg));
2155 case CSSPropertyMaxWidth:
2156 case CSSPropertyWebkitMaxLogicalWidth:
2157 validPrimitive = (id == CSSValueNone || validWidth(value));
2160 case CSSPropertyMinWidth:
2161 case CSSPropertyWebkitMinLogicalWidth:
2162 validPrimitive = validWidth(value);
2165 case CSSPropertyWidth:
2166 case CSSPropertyWebkitLogicalWidth:
2167 validPrimitive = (id == CSSValueAuto || validWidth(value));
2170 case CSSPropertyMaxHeight:
2171 case CSSPropertyWebkitMaxLogicalHeight:
2172 validPrimitive = (id == CSSValueNone || validHeight(value));
2175 case CSSPropertyMinHeight:
2176 case CSSPropertyWebkitMinLogicalHeight:
2177 validPrimitive = validHeight(value);
2180 case CSSPropertyHeight:
2181 case CSSPropertyWebkitLogicalHeight:
2182 validPrimitive = (id == CSSValueAuto || validHeight(value));
2185 case CSSPropertyFontSize:
2186 return parseFontSize(important);
2188 case CSSPropertyFontVariant: // normal | small-caps | inherit
2189 return parseFontVariant(important);
2191 case CSSPropertyVerticalAlign:
2192 // baseline | sub | super | top | text-top | middle | bottom | text-bottom |
2193 // <percentage> | <length> | inherit
2195 if (id >= CSSValueBaseline && id <= CSSValueWebkitBaselineMiddle)
2196 validPrimitive = true;
2198 validPrimitive = (!id && validUnit(value, FLength | FPercent));
2201 case CSSPropertyBottom: // <length> | <percentage> | auto | inherit
2202 case CSSPropertyLeft: // <length> | <percentage> | auto | inherit
2203 case CSSPropertyRight: // <length> | <percentage> | auto | inherit
2204 case CSSPropertyTop: // <length> | <percentage> | auto | inherit
2205 case CSSPropertyMarginTop: //// <margin-width> | inherit
2206 case CSSPropertyMarginRight: // Which is defined as
2207 case CSSPropertyMarginBottom: // <length> | <percentage> | auto | inherit
2208 case CSSPropertyMarginLeft: ////
2209 case CSSPropertyWebkitMarginStart:
2210 case CSSPropertyWebkitMarginEnd:
2211 case CSSPropertyWebkitMarginBefore:
2212 case CSSPropertyWebkitMarginAfter:
2213 if (id == CSSValueAuto)
2214 validPrimitive = true;
2216 validPrimitive = (!id && validUnit(value, FLength | FPercent));
2219 case CSSPropertyZIndex: // auto | <integer> | inherit
2220 if (id == CSSValueAuto) {
2221 validPrimitive = true;
2225 case CSSPropertyOrphans: // <integer> | inherit | auto (We've added support for auto for backwards compatibility)
2226 case CSSPropertyWidows: // <integer> | inherit | auto (Ditto)
2227 if (id == CSSValueAuto)
2228 validPrimitive = true;
2230 validPrimitive = (!id && validUnit(value, FInteger, CSSQuirksMode));
2233 case CSSPropertyLineHeight:
2234 return parseLineHeight(important);
2235 case CSSPropertyCounterIncrement: // [ <identifier> <integer>? ]+ | none | inherit
2236 if (id != CSSValueNone)
2237 return parseCounter(propId, 1, important);
2238 validPrimitive = true;
2240 case CSSPropertyCounterReset: // [ <identifier> <integer>? ]+ | none | inherit
2241 if (id != CSSValueNone)
2242 return parseCounter(propId, 0, important);
2243 validPrimitive = true;
2245 case CSSPropertyFontFamily:
2246 // [[ <family-name> | <generic-family> ],]* [<family-name> | <generic-family>] | inherit
2248 parsedValue = parseFontFamily();
2252 #if ENABLE(CSS3_TEXT_DECORATION)
2253 case CSSPropertyWebkitTextDecoration:
2254 // [ <text-decoration-line> || <text-decoration-style> || <text-decoration-color> ] | inherit
2255 return parseShorthand(CSSPropertyWebkitTextDecoration, webkitTextDecorationShorthand(), important);
2258 case CSSPropertyTextDecoration:
2259 case CSSPropertyWebkitTextDecorationsInEffect:
2260 #if ENABLE(CSS3_TEXT_DECORATION)
2261 case CSSPropertyWebkitTextDecorationLine:
2263 // none | [ underline || overline || line-through || blink ] | inherit
2264 return parseTextDecoration(propId, important);
2266 #if ENABLE(CSS3_TEXT_DECORATION)
2267 case CSSPropertyWebkitTextDecorationStyle:
2268 // solid | double | dotted | dashed | wavy
2269 if (id == CSSValueSolid || id == CSSValueDouble || id == CSSValueDotted || id == CSSValueDashed || id == CSSValueWavy)
2270 validPrimitive = true;
2273 case CSSPropertyWebkitTextDecorationSkip:
2274 // none | [ objects || spaces || ink || edges || box-decoration ]
2275 return parseTextDecorationSkip(important);
2277 case CSSPropertyWebkitTextUnderlinePosition:
2278 // auto | alphabetic | under
2279 return parseTextUnderlinePosition(important);
2282 case CSSPropertyZoom: // normal | reset | document | <number> | <percentage> | inherit
2283 if (id == CSSValueNormal || id == CSSValueReset || id == CSSValueDocument)
2284 validPrimitive = true;
2286 validPrimitive = (!id && validUnit(value, FNumber | FPercent | FNonNeg, CSSStrictMode));
2289 case CSSPropertySrc: // Only used within @font-face and @-webkit-filter, so cannot use inherit | initial or be !important. This is a list of urls or local references.
2290 #if ENABLE(CSS_SHADERS)
2292 return parseFilterRuleSrc();
2294 return parseFontFaceSrc();
2296 #if ENABLE(CSS_SHADERS)
2297 case CSSPropertyMix:
2298 // The mix property is just supported inside of an @filter rule.
2299 if (!m_inFilterRule)
2301 return parseFilterRuleMix();
2302 case CSSPropertyParameters:
2303 // The parameters property is just supported inside of an @filter rule.
2304 if (!m_inFilterRule)
2306 return parseFilterRuleParameters();
2309 case CSSPropertyUnicodeRange:
2310 return parseFontFaceUnicodeRange();
2312 /* CSS3 properties */
2314 case CSSPropertyBorderImage: {
2315 RefPtr<CSSValue> result;
2316 return parseBorderImage(propId, result, important);
2318 case CSSPropertyWebkitBorderImage:
2319 case CSSPropertyWebkitMaskBoxImage: {
2320 RefPtr<CSSValue> result;
2321 if (parseBorderImage(propId, result)) {
2322 addProperty(propId, result, important);
2327 case CSSPropertyBorderImageOutset:
2328 case CSSPropertyWebkitMaskBoxImageOutset: {
2329 RefPtr<CSSPrimitiveValue> result;
2330 if (parseBorderImageOutset(result)) {
2331 addProperty(propId, result, important);
2336 case CSSPropertyBorderImageRepeat:
2337 case CSSPropertyWebkitMaskBoxImageRepeat: {
2338 RefPtr<CSSValue> result;
2339 if (parseBorderImageRepeat(result)) {
2340 addProperty(propId, result, important);
2345 case CSSPropertyBorderImageSlice:
2346 case CSSPropertyWebkitMaskBoxImageSlice: {
2347 RefPtr<CSSBorderImageSliceValue> result;
2348 if (parseBorderImageSlice(propId, result)) {
2349 addProperty(propId, result, important);
2354 case CSSPropertyBorderImageWidth:
2355 case CSSPropertyWebkitMaskBoxImageWidth: {
2356 RefPtr<CSSPrimitiveValue> result;
2357 if (parseBorderImageWidth(result)) {
2358 addProperty(propId, result, important);
2363 case CSSPropertyBorderTopRightRadius:
2364 case CSSPropertyBorderTopLeftRadius:
2365 case CSSPropertyBorderBottomLeftRadius:
2366 case CSSPropertyBorderBottomRightRadius: {
2367 if (num != 1 && num != 2)
2369 validPrimitive = validUnit(value, FLength | FPercent | FNonNeg);
2370 if (!validPrimitive)
2372 RefPtr<CSSPrimitiveValue> parsedValue1 = createPrimitiveNumericValue(value);
2373 RefPtr<CSSPrimitiveValue> parsedValue2;
2375 value = m_valueList->next();
2376 validPrimitive = validUnit(value, FLength | FPercent | FNonNeg);
2377 if (!validPrimitive)
2379 parsedValue2 = createPrimitiveNumericValue(value);
2381 parsedValue2 = parsedValue1;
2383 addProperty(propId, createPrimitiveValuePair(parsedValue1.release(), parsedValue2.release()), important);
2386 case CSSPropertyTabSize:
2387 validPrimitive = validUnit(value, FInteger | FNonNeg);
2389 case CSSPropertyWebkitAspectRatio:
2390 return parseAspectRatio(important);
2391 case CSSPropertyBorderRadius:
2392 case CSSPropertyWebkitBorderRadius:
2393 return parseBorderRadius(propId, important);
2394 case CSSPropertyOutlineOffset:
2395 validPrimitive = validUnit(value, FLength);
2397 case CSSPropertyTextShadow: // CSS2 property, dropped in CSS2.1, back in CSS3, so treat as CSS3
2398 case CSSPropertyBoxShadow:
2399 case CSSPropertyWebkitBoxShadow:
2400 if (id == CSSValueNone)
2401 validPrimitive = true;
2403 RefPtr<CSSValueList> shadowValueList = parseShadow(m_valueList.get(), propId);
2404 if (shadowValueList) {
2405 addProperty(propId, shadowValueList.release(), important);
2406 m_valueList->next();
2412 case CSSPropertyWebkitBoxReflect:
2413 if (id == CSSValueNone)
2414 validPrimitive = true;
2416 return parseReflect(propId, important);
2418 case CSSPropertyOpacity:
2419 validPrimitive = validUnit(value, FNumber);
2421 case CSSPropertyWebkitBoxFlex:
2422 validPrimitive = validUnit(value, FNumber);
2424 case CSSPropertyWebkitBoxFlexGroup:
2425 validPrimitive = validUnit(value, FInteger | FNonNeg, CSSStrictMode);
2427 case CSSPropertyWebkitBoxOrdinalGroup:
2428 validPrimitive = validUnit(value, FInteger | FNonNeg, CSSStrictMode) && value->fValue;
2430 #if ENABLE(CSS_FILTERS)
2431 case CSSPropertyWebkitFilter:
2432 if (id == CSSValueNone)
2433 validPrimitive = true;
2435 RefPtr<CSSValue> currValue;
2436 if (!parseFilter(m_valueList.get(), currValue))
2438 // m_valueList->next();
2439 addProperty(propId, currValue, important);
2444 #if ENABLE(CSS_COMPOSITING)
2445 case CSSPropertyWebkitBlendMode:
2446 if (cssCompositingEnabled())
2447 validPrimitive = true;
2450 case CSSPropertyWebkitFlex: {
2451 ShorthandScope scope(this, propId);
2452 if (id == CSSValueNone) {
2453 addProperty(CSSPropertyWebkitFlexGrow, cssValuePool().createValue(0, CSSPrimitiveValue::CSS_NUMBER), important);
2454 addProperty(CSSPropertyWebkitFlexShrink, cssValuePool().createValue(0, CSSPrimitiveValue::CSS_NUMBER), important);
2455 addProperty(CSSPropertyWebkitFlexBasis, cssValuePool().createIdentifierValue(CSSValueAuto), important);
2458 return parseFlex(m_valueList.get(), important);
2460 case CSSPropertyWebkitFlexBasis:
2461 // FIXME: Support intrinsic dimensions too.
2462 if (id == CSSValueAuto)
2463 validPrimitive = true;
2465 validPrimitive = (!id && validUnit(value, FLength | FPercent | FNonNeg));
2467 case CSSPropertyWebkitFlexGrow:
2468 case CSSPropertyWebkitFlexShrink:
2469 validPrimitive = validUnit(value, FNumber | FNonNeg);
2471 case CSSPropertyWebkitOrder:
2472 if (validUnit(value, FInteger, CSSStrictMode)) {
2473 // We restrict the smallest value to int min + 2 because we use int min and int min + 1 as special values in a hash set.
2474 parsedValue = cssValuePool().createValue(std::max<double>(std::numeric_limits<int>::min() + 2, value->fValue), static_cast<CSSPrimitiveValue::UnitTypes>(value->unit));
2475 m_valueList->next();
2478 case CSSPropertyWebkitMarquee:
2479 return parseShorthand(propId, webkitMarqueeShorthand(), important);
2480 case CSSPropertyWebkitMarqueeIncrement:
2481 if (id == CSSValueSmall || id == CSSValueLarge || id == CSSValueMedium)
2482 validPrimitive = true;
2484 validPrimitive = validUnit(value, FLength | FPercent);
2486 case CSSPropertyWebkitMarqueeRepetition:
2487 if (id == CSSValueInfinite)
2488 validPrimitive = true;
2490 validPrimitive = validUnit(value, FInteger | FNonNeg);
2492 case CSSPropertyWebkitMarqueeSpeed:
2493 if (id == CSSValueNormal || id == CSSValueSlow || id == CSSValueFast)
2494 validPrimitive = true;
2496 validPrimitive = validUnit(value, FTime | FInteger | FNonNeg);
2498 #if ENABLE(CSS_REGIONS)
2499 case CSSPropertyWebkitFlowInto:
2500 if (!cssRegionsEnabled())
2502 return parseFlowThread(propId, important);
2503 case CSSPropertyWebkitFlowFrom:
2504 if (!cssRegionsEnabled())
2506 return parseRegionThread(propId, important);
2508 case CSSPropertyWebkitTransform:
2509 if (id == CSSValueNone)
2510 validPrimitive = true;
2512 RefPtr<CSSValue> transformValue = parseTransform();
2513 if (transformValue) {
2514 addProperty(propId, transformValue.release(), important);
2520 case CSSPropertyWebkitTransformOrigin:
2521 case CSSPropertyWebkitTransformOriginX:
2522 case CSSPropertyWebkitTransformOriginY:
2523 case CSSPropertyWebkitTransformOriginZ: {
2524 RefPtr<CSSValue> val1;
2525 RefPtr<CSSValue> val2;
2526 RefPtr<CSSValue> val3;
2527 CSSPropertyID propId1, propId2, propId3;
2528 if (parseTransformOrigin(propId, propId1, propId2, propId3, val1, val2, val3)) {
2529 addProperty(propId1, val1.release(), important);
2531 addProperty(propId2, val2.release(), important);
2533 addProperty(propId3, val3.release(), important);
2538 case CSSPropertyWebkitPerspective:
2539 if (id == CSSValueNone)
2540 validPrimitive = true;
2542 // Accepting valueless numbers is a quirk of the -webkit prefixed version of the property.
2543 if (validUnit(value, FNumber | FLength | FNonNeg)) {
2544 RefPtr<CSSValue> val = createPrimitiveNumericValue(value);
2546 addProperty(propId, val.release(), important);
2553 case CSSPropertyWebkitPerspectiveOrigin:
2554 case CSSPropertyWebkitPerspectiveOriginX:
2555 case CSSPropertyWebkitPerspectiveOriginY: {
2556 RefPtr<CSSValue> val1;
2557 RefPtr<CSSValue> val2;
2558 CSSPropertyID propId1, propId2;
2559 if (parsePerspectiveOrigin(propId, propId1, propId2, val1, val2)) {
2560 addProperty(propId1, val1.release(), important);
2562 addProperty(propId2, val2.release(), important);
2567 case CSSPropertyWebkitAnimationDelay:
2568 case CSSPropertyWebkitAnimationDirection:
2569 case CSSPropertyWebkitAnimationDuration:
2570 case CSSPropertyWebkitAnimationFillMode:
2571 case CSSPropertyWebkitAnimationName:
2572 case CSSPropertyWebkitAnimationPlayState:
2573 case CSSPropertyWebkitAnimationIterationCount:
2574 case CSSPropertyWebkitAnimationTimingFunction:
2575 case CSSPropertyTransitionDelay:
2576 case CSSPropertyTransitionDuration:
2577 case CSSPropertyTransitionTimingFunction:
2578 case CSSPropertyTransitionProperty:
2579 case CSSPropertyWebkitTransitionDelay:
2580 case CSSPropertyWebkitTransitionDuration:
2581 case CSSPropertyWebkitTransitionTimingFunction:
2582 case CSSPropertyWebkitTransitionProperty: {
2583 RefPtr<CSSValue> val;
2584 AnimationParseContext context;
2585 if (parseAnimationProperty(propId, val, context)) {
2586 addPropertyWithPrefixingVariant(propId, val.release(), important);
2592 case CSSPropertyWebkitGridAutoColumns:
2593 case CSSPropertyWebkitGridAutoRows:
2594 if (!cssGridLayoutEnabled())
2596 parsedValue = parseGridTrackSize(*m_valueList);
2599 case CSSPropertyWebkitGridDefinitionColumns:
2600 case CSSPropertyWebkitGridDefinitionRows:
2601 if (!cssGridLayoutEnabled())
2603 return parseGridTrackList(propId, important);
2605 case CSSPropertyWebkitGridColumnStart:
2606 case CSSPropertyWebkitGridColumnEnd:
2607 case CSSPropertyWebkitGridRowStart:
2608 case CSSPropertyWebkitGridRowEnd:
2609 if (!cssGridLayoutEnabled())
2612 parsedValue = parseGridPosition();
2615 case CSSPropertyWebkitGridColumn:
2616 case CSSPropertyWebkitGridRow: {
2617 if (!cssGridLayoutEnabled())
2620 return parseGridItemPositionShorthand(propId, important);
2623 case CSSPropertyWebkitGridArea:
2624 if (!cssGridLayoutEnabled())
2626 return parseGridAreaShorthand(important);
2628 case CSSPropertyWebkitGridTemplate:
2629 if (!cssGridLayoutEnabled())
2632 parsedValue = parseGridTemplate();
2635 case CSSPropertyWebkitMarginCollapse: {
2637 ShorthandScope scope(this, CSSPropertyWebkitMarginCollapse);
2638 if (!parseValue(webkitMarginCollapseShorthand().properties()[0], important))
2640 CSSValue* value = m_parsedProperties.last().value();
2641 addProperty(webkitMarginCollapseShorthand().properties()[1], value, important);
2644 else if (num == 2) {
2645 ShorthandScope scope(this, CSSPropertyWebkitMarginCollapse);
2646 if (!parseValue(webkitMarginCollapseShorthand().properties()[0], important) || !parseValue(webkitMarginCollapseShorthand().properties()[1], important))
2652 case CSSPropertyTextLineThroughWidth:
2653 case CSSPropertyTextOverlineWidth:
2654 case CSSPropertyTextUnderlineWidth:
2655 if (id == CSSValueAuto || id == CSSValueNormal || id == CSSValueThin ||
2656 id == CSSValueMedium || id == CSSValueThick)
2657 validPrimitive = true;
2659 validPrimitive = !id && validUnit(value, FNumber | FLength | FPercent);
2661 case CSSPropertyWebkitColumnCount:
2662 if (id == CSSValueAuto)
2663 validPrimitive = true;
2665 validPrimitive = !id && validUnit(value, FPositiveInteger, CSSQuirksMode);
2667 case CSSPropertyWebkitColumnGap: // normal | <length>
2668 if (id == CSSValueNormal)
2669 validPrimitive = true;
2671 validPrimitive = validUnit(value, FLength | FNonNeg);
2673 case CSSPropertyWebkitColumnAxis:
2674 if (id == CSSValueHorizontal || id == CSSValueVertical || id == CSSValueAuto)
2675 validPrimitive = true;
2677 case CSSPropertyWebkitColumnProgression:
2678 if (id == CSSValueNormal || id == CSSValueReverse)
2679 validPrimitive = true;
2681 case CSSPropertyWebkitColumnSpan: // none | all | 1 (will be dropped in the unprefixed property)
2682 if (id == CSSValueAll || id == CSSValueNone)
2683 validPrimitive = true;
2685 validPrimitive = validUnit(value, FNumber | FNonNeg) && value->fValue == 1;
2687 case CSSPropertyWebkitColumnWidth: // auto | <length>
2688 if (id == CSSValueAuto)
2689 validPrimitive = true;
2690 else // Always parse this property in strict mode, since it would be ambiguous otherwise when used in the 'columns' shorthand property.
2691 validPrimitive = validUnit(value, FLength | FNonNeg, CSSStrictMode) && value->fValue;
2693 // End of CSS3 properties
2695 // Apple specific properties. These will never be standardized and are purely to
2696 // support custom WebKit-based Apple applications.
2697 case CSSPropertyWebkitLineClamp:
2698 // When specifying number of lines, don't allow 0 as a valid value
2699 // When specifying either type of unit, require non-negative integers
2700 validPrimitive = (!id && (value->unit == CSSPrimitiveValue::CSS_PERCENTAGE || value->fValue) && validUnit(value, FInteger | FPercent | FNonNeg, CSSQuirksMode));
2702 #if ENABLE(IOS_TEXT_AUTOSIZING)
2703 case CSSPropertyWebkitTextSizeAdjust:
2704 if (id == CSSValueAuto || id == CSSValueNone)
2705 validPrimitive = true;
2707 // FIXME: Handle multilength case where we allow relative units.
2708 validPrimitive = (!id && validUnit(value, FPercent | FNonNeg, CSSStrictMode));
2713 case CSSPropertyWebkitFontSizeDelta: // <length>
2714 validPrimitive = validUnit(value, FLength);
2717 case CSSPropertyWebkitHighlight:
2718 if (id == CSSValueNone || value->unit == CSSPrimitiveValue::CSS_STRING)
2719 validPrimitive = true;
2722 case CSSPropertyWebkitHyphenateCharacter:
2723 if (id == CSSValueAuto || value->unit == CSSPrimitiveValue::CSS_STRING)
2724 validPrimitive = true;
2727 case CSSPropertyWebkitHyphenateLimitBefore:
2728 case CSSPropertyWebkitHyphenateLimitAfter:
2729 if (id == CSSValueAuto || validUnit(value, FInteger | FNonNeg, CSSStrictMode))
2730 validPrimitive = true;
2733 case CSSPropertyWebkitHyphenateLimitLines:
2734 if (id == CSSValueNoLimit || validUnit(value, FInteger | FNonNeg, CSSStrictMode))
2735 validPrimitive = true;
2738 case CSSPropertyWebkitLineGrid:
2739 if (id == CSSValueNone)
2740 validPrimitive = true;
2741 else if (value->unit == CSSPrimitiveValue::CSS_IDENT) {
2742 String lineGridValue = String(value->string);
2743 if (!lineGridValue.isEmpty()) {
2744 addProperty(propId, cssValuePool().createValue(lineGridValue, CSSPrimitiveValue::CSS_STRING), important);
2749 case CSSPropertyWebkitLocale:
2750 if (id == CSSValueAuto || value->unit == CSSPrimitiveValue::CSS_STRING)
2751 validPrimitive = true;
2754 #if ENABLE(DASHBOARD_SUPPORT)
2755 case CSSPropertyWebkitDashboardRegion: // <dashboard-region> | <dashboard-region>
2756 if (value->unit == CSSParserValue::Function || id == CSSValueNone)
2757 return parseDashboardRegions(propId, important);
2762 case CSSPropertyWebkitTouchCallout:
2763 if (id == CSSValueDefault || id == CSSValueNone)
2764 validPrimitive = true;
2767 // End Apple-specific properties
2769 #if ENABLE(DRAGGABLE_REGION)
2770 case CSSPropertyWebkitAppRegion:
2771 if (id >= CSSValueDrag && id <= CSSValueNoDrag)
2772 validPrimitive = true;
2776 #if ENABLE(TOUCH_EVENTS)
2777 case CSSPropertyWebkitTapHighlightColor:
2778 if ((id >= CSSValueAqua && id <= CSSValueWindowtext) || id == CSSValueMenu
2779 || (id >= CSSValueWebkitFocusRingColor && id < CSSValueWebkitText && inQuirksMode())) {
2780 validPrimitive = true;
2782 parsedValue = parseColor();
2784 m_valueList->next();
2789 /* shorthand properties */
2790 case CSSPropertyBackground: {
2791 // Position must come before color in this array because a plain old "0" is a legal color
2792 // in quirks mode but it's usually the X coordinate of a position.
2793 const CSSPropertyID properties[] = { CSSPropertyBackgroundImage, CSSPropertyBackgroundRepeat,
2794 CSSPropertyBackgroundAttachment, CSSPropertyBackgroundPosition, CSSPropertyBackgroundOrigin,
2795 CSSPropertyBackgroundClip, CSSPropertyBackgroundColor, CSSPropertyBackgroundSize };
2796 return parseFillShorthand(propId, properties, WTF_ARRAY_LENGTH(properties), important);
2798 case CSSPropertyWebkitMask: {
2799 const CSSPropertyID properties[] = { CSSPropertyWebkitMaskImage, CSSPropertyWebkitMaskSourceType, CSSPropertyWebkitMaskRepeat,
2800 CSSPropertyWebkitMaskPosition, CSSPropertyWebkitMaskOrigin, CSSPropertyWebkitMaskClip, CSSPropertyWebkitMaskSize };
2801 return parseFillShorthand(propId, properties, WTF_ARRAY_LENGTH(properties), important);
2803 case CSSPropertyBorder:
2804 // [ 'border-width' || 'border-style' || <color> ] | inherit
2806 if (parseShorthand(propId, borderAbridgedShorthand(), important)) {
2807 // The CSS3 Borders and Backgrounds specification says that border also resets border-image. It's as
2808 // though a value of none was specified for the image.
2809 addExpandedPropertyForValue(CSSPropertyBorderImage, cssValuePool().createImplicitInitialValue(), important);
2814 case CSSPropertyBorderTop:
2815 // [ 'border-top-width' || 'border-style' || <color> ] | inherit
2816 return parseShorthand(propId, borderTopShorthand(), important);
2817 case CSSPropertyBorderRight:
2818 // [ 'border-right-width' || 'border-style' || <color> ] | inherit
2819 return parseShorthand(propId, borderRightShorthand(), important);
2820 case CSSPropertyBorderBottom:
2821 // [ 'border-bottom-width' || 'border-style' || <color> ] | inherit
2822 return parseShorthand(propId, borderBottomShorthand(), important);
2823 case CSSPropertyBorderLeft:
2824 // [ 'border-left-width' || 'border-style' || <color> ] | inherit
2825 return parseShorthand(propId, borderLeftShorthand(), important);
2826 case CSSPropertyWebkitBorderStart:
2827 return parseShorthand(propId, webkitBorderStartShorthand(), important);
2828 case CSSPropertyWebkitBorderEnd:
2829 return parseShorthand(propId, webkitBorderEndShorthand(), important);
2830 case CSSPropertyWebkitBorderBefore:
2831 return parseShorthand(propId, webkitBorderBeforeShorthand(), important);
2832 case CSSPropertyWebkitBorderAfter:
2833 return parseShorthand(propId, webkitBorderAfterShorthand(), important);
2834 case CSSPropertyOutline:
2835 // [ 'outline-color' || 'outline-style' || 'outline-width' ] | inherit
2836 return parseShorthand(propId, outlineShorthand(), important);
2837 case CSSPropertyBorderColor:
2838 // <color>{1,4} | inherit
2839 return parse4Values(propId, borderColorShorthand().properties(), important);
2840 case CSSPropertyBorderWidth:
2841 // <border-width>{1,4} | inherit
2842 return parse4Values(propId, borderWidthShorthand().properties(), important);
2843 case CSSPropertyBorderStyle:
2844 // <border-style>{1,4} | inherit
2845 return parse4Values(propId, borderStyleShorthand().properties(), important);
2846 case CSSPropertyMargin:
2847 // <margin-width>{1,4} | inherit
2848 return parse4Values(propId, marginShorthand().properties(), important);
2849 case CSSPropertyPadding:
2850 // <padding-width>{1,4} | inherit
2851 return parse4Values(propId, paddingShorthand().properties(), important);
2852 case CSSPropertyWebkitFlexFlow:
2853 return parseShorthand(propId, webkitFlexFlowShorthand(), important);
2854 case CSSPropertyFont:
2855 // [ [ 'font-style' || 'font-variant' || 'font-weight' ]? 'font-size' [ / 'line-height' ]?
2856 // 'font-family' ] | caption | icon | menu | message-box | small-caption | status-bar | inherit
2857 if (id >= CSSValueCaption && id <= CSSValueStatusBar)
2858 validPrimitive = true;
2860 return parseFont(important);
2862 case CSSPropertyListStyle:
2863 return parseShorthand(propId, listStyleShorthand(), important);
2864 case CSSPropertyWebkitColumns:
2865 return parseShorthand(propId, webkitColumnsShorthand(), important);
2866 case CSSPropertyWebkitColumnRule:
2867 return parseShorthand(propId, webkitColumnRuleShorthand(), important);
2868 case CSSPropertyWebkitTextStroke:
2869 return parseShorthand(propId, webkitTextStrokeShorthand(), important);
2870 case CSSPropertyWebkitAnimation:
2871 return parseAnimationShorthand(important);
2872 case CSSPropertyTransition:
2873 case CSSPropertyWebkitTransition:
2874 return parseTransitionShorthand(propId, important);
2875 case CSSPropertyInvalid:
2877 case CSSPropertyPage:
2878 return parsePage(propId, important);
2879 #if ENABLE(CSS_SHADERS)
2880 case CSSPropertyGeometry:
2881 return m_inFilterRule ? parseGeometry(propId, value, important) : false;
2883 case CSSPropertyFontStretch:
2884 case CSSPropertyTextLineThrough:
2885 case CSSPropertyTextOverline:
2886 case CSSPropertyTextUnderline:
2888 // CSS Text Layout Module Level 3: Vertical writing support
2889 case CSSPropertyWebkitTextEmphasis:
2890 return parseShorthand(propId, webkitTextEmphasisShorthand(), important);
2892 case CSSPropertyWebkitTextEmphasisStyle:
2893 return parseTextEmphasisStyle(important);
2895 case CSSPropertyWebkitTextOrientation:
2896 // FIXME: For now just support sideways, sideways-right, upright and vertical-right.
2897 if (id == CSSValueSideways || id == CSSValueSidewaysRight || id == CSSValueVerticalRight || id == CSSValueUpright)
2898 validPrimitive = true;
2901 case CSSPropertyWebkitLineBoxContain:
2902 if (id == CSSValueNone)
2903 validPrimitive = true;
2905 return parseLineBoxContain(important);
2907 case CSSPropertyWebkitFontFeatureSettings:
2908 if (id == CSSValueNormal)
2909 validPrimitive = true;
2911 return parseFontFeatureSettings(important);
2914 case CSSPropertyWebkitFontVariantLigatures:
2915 if (id == CSSValueNormal)
2916 validPrimitive = true;
2918 return parseFontVariantLigatures(important);
2920 case CSSPropertyWebkitClipPath:
2921 if (id == CSSValueNone)
2922 validPrimitive = true;
2923 else if (value->unit == CSSParserValue::Function) {
2924 RefPtr<CSSBasicShape> shapeValue = parseBasicShape();
2926 parsedValue = cssValuePool().createValue(shapeValue.release());
2929 else if (value->unit == CSSPrimitiveValue::CSS_URI) {
2930 parsedValue = CSSPrimitiveValue::create(value->string, CSSPrimitiveValue::CSS_URI);
2931 addProperty(propId, parsedValue.release(), important);
2936 #if ENABLE(CSS_SHAPES)
2937 case CSSPropertyWebkitShapeInside:
2938 case CSSPropertyWebkitShapeOutside:
2939 parsedValue = parseShapeProperty(propId);
2941 case CSSPropertyWebkitShapeMargin:
2942 case CSSPropertyWebkitShapePadding:
2943 validPrimitive = (RuntimeEnabledFeatures::sharedFeatures().cssShapesEnabled() && !id && validUnit(value, FLength | FNonNeg));
2945 case CSSPropertyWebkitShapeImageThreshold:
2946 validPrimitive = (RuntimeEnabledFeatures::sharedFeatures().cssShapesEnabled() && !id && validUnit(value, FNumber));
2949 #if ENABLE(CSS_IMAGE_ORIENTATION)
2950 case CSSPropertyImageOrientation:
2951 validPrimitive = !id && validUnit(value, FAngle);
2954 #if ENABLE(CSS_IMAGE_RESOLUTION)
2955 case CSSPropertyImageResolution:
2956 parsedValue = parseImageResolution();
2959 case CSSPropertyBorderBottomStyle:
2960 case CSSPropertyBorderCollapse:
2961 case CSSPropertyBorderLeftStyle:
2962 case CSSPropertyBorderRightStyle:
2963 case CSSPropertyBorderTopStyle:
2964 case CSSPropertyBoxSizing:
2965 case CSSPropertyCaptionSide:
2966 case CSSPropertyClear:
2967 case CSSPropertyDirection:
2968 case CSSPropertyDisplay:
2969 case CSSPropertyEmptyCells:
2970 case CSSPropertyFloat:
2971 case CSSPropertyFontStyle:
2972 case CSSPropertyImageRendering:
2973 case CSSPropertyListStylePosition:
2974 case CSSPropertyListStyleType:
2975 case CSSPropertyObjectFit:
2976 case CSSPropertyOutlineStyle:
2977 case CSSPropertyOverflowWrap:
2978 case CSSPropertyOverflowX:
2979 case CSSPropertyOverflowY:
2980 case CSSPropertyPageBreakAfter:
2981 case CSSPropertyPageBreakBefore:
2982 case CSSPropertyPageBreakInside:
2983 case CSSPropertyPointerEvents:
2984 case CSSPropertyPosition:
2985 case CSSPropertyResize:
2986 case CSSPropertySpeak:
2987 case CSSPropertyTableLayout:
2988 case CSSPropertyTextLineThroughMode:
2989 case CSSPropertyTextLineThroughStyle:
2990 case CSSPropertyTextOverflow:
2991 case CSSPropertyTextOverlineMode:
2992 case CSSPropertyTextOverlineStyle:
2993 case CSSPropertyTextRendering:
2994 case CSSPropertyTextTransform:
2995 case CSSPropertyTextUnderlineMode:
2996 case CSSPropertyTextUnderlineStyle:
2997 case CSSPropertyVisibility:
2998 case CSSPropertyWebkitAppearance:
2999 case CSSPropertyWebkitBackfaceVisibility:
3000 case CSSPropertyWebkitBorderAfterStyle:
3001 case CSSPropertyWebkitBorderBeforeStyle:
3002 case CSSPropertyWebkitBorderEndStyle:
3003 case CSSPropertyWebkitBorderFit:
3004 case CSSPropertyWebkitBorderStartStyle:
3005 case CSSPropertyWebkitBoxAlign:
3006 #if ENABLE(CSS_BOX_DECORATION_BREAK)
3007 case CSSPropertyWebkitBoxDecorationBreak:
3009 case CSSPropertyWebkitBoxDirection:
3010 case CSSPropertyWebkitBoxLines:
3011 case CSSPropertyWebkitBoxOrient:
3012 case CSSPropertyWebkitBoxPack:
3013 case CSSPropertyWebkitColorCorrection:
3014 case CSSPropertyWebkitColumnBreakAfter:
3015 case CSSPropertyWebkitColumnBreakBefore:
3016 case CSSPropertyWebkitColumnBreakInside:
3017 case CSSPropertyWebkitColumnFill:
3018 case CSSPropertyWebkitColumnRuleStyle:
3019 case CSSPropertyWebkitAlignContent:
3020 case CSSPropertyWebkitAlignItems:
3021 case CSSPropertyWebkitAlignSelf:
3022 case CSSPropertyWebkitFlexDirection:
3023 case CSSPropertyWebkitFlexWrap:
3024 case CSSPropertyWebkitJustifyContent:
3025 case CSSPropertyWebkitFontKerning:
3026 case CSSPropertyWebkitFontSmoothing:
3027 case CSSPropertyWebkitHyphens:
3028 case CSSPropertyWebkitGridAutoFlow:
3029 case CSSPropertyWebkitLineAlign:
3030 case CSSPropertyWebkitLineBreak:
3031 case CSSPropertyWebkitLineSnap:
3032 case CSSPropertyWebkitMarginAfterCollapse:
3033 case CSSPropertyWebkitMarginBeforeCollapse:
3034 case CSSPropertyWebkitMarginBottomCollapse:
3035 case CSSPropertyWebkitMarginTopCollapse:
3036 case CSSPropertyWebkitMarqueeDirection:
3037 case CSSPropertyWebkitMarqueeStyle:
3038 case CSSPropertyWebkitNbspMode:
3039 #if ENABLE(ACCELERATED_OVERFLOW_SCROLLING)
3040 case CSSPropertyWebkitOverflowScrolling:
3042 case CSSPropertyWebkitPrintColorAdjust:
3043 #if ENABLE(CSS_REGIONS)
3044 case CSSPropertyWebkitRegionBreakAfter:
3045 case CSSPropertyWebkitRegionBreakBefore:
3046 case CSSPropertyWebkitRegionBreakInside:
3047 case CSSPropertyWebkitRegionFragment:
3049 case CSSPropertyWebkitRtlOrdering:
3050 case CSSPropertyWebkitRubyPosition:
3051 #if ENABLE(CSS3_TEXT)
3052 case CSSPropertyWebkitTextAlignLast:
3054 case CSSPropertyWebkitTextCombine:
3055 case CSSPropertyWebkitTextEmphasisPosition:
3056 #if ENABLE(CSS3_TEXT)
3057 case CSSPropertyWebkitTextJustify:
3059 case CSSPropertyWebkitTextSecurity:
3060 case CSSPropertyWebkitTransformStyle:
3061 case CSSPropertyWebkitUserDrag:
3062 case CSSPropertyWebkitUserModify:
3063 case CSSPropertyWebkitUserSelect:
3064 #if ENABLE(CSS_EXCLUSIONS)
3065 case CSSPropertyWebkitWrapFlow:
3066 case CSSPropertyWebkitWrapThrough:
3068 case CSSPropertyWebkitWritingMode:
3069 case CSSPropertyWhiteSpace:
3070 case CSSPropertyWordBreak:
3071 case CSSPropertyWordWrap:
3072 // These properties should be handled before in isValidKeywordPropertyAndValue().
3073 ASSERT_NOT_REACHED();
3075 #if ENABLE(CSS_DEVICE_ADAPTATION)
3076 // Properties bellow are validated inside parseViewportProperty, because we
3077 // check for parser state inViewportScope. We need to invalidate if someone
3078 // adds them outside a @viewport rule.
3079 case CSSPropertyMaxZoom:
3080 case CSSPropertyMinZoom:
3081 case CSSPropertyOrientation:
3082 case CSSPropertyUserZoom:
3083 validPrimitive = false;
3088 return parseSVGValue(propId, important);
3092 if (validPrimitive) {
3093 parsedValue = parseValidPrimitive(id, value);
3094 m_valueList->next();
3096 ASSERT(!m_parsedCalculation);
3098 if (!m_valueList->current() || inShorthand()) {
3099 addProperty(propId, parsedValue.release(), important);
3106 void CSSParser::addFillValue(RefPtr<CSSValue>& lval, PassRefPtr<CSSValue> rval)
3109 if (lval->isBaseValueList())
3110 toCSSValueList(lval.get())->append(rval);
3112 PassRefPtr<CSSValue> oldlVal(lval.release());
3113 PassRefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
3114 list->append(oldlVal);
3123 static bool parseBackgroundClip(CSSParserValue* parserValue, RefPtr<CSSValue>& cssValue)
3125 if (parserValue->id == CSSValueBorderBox || parserValue->id == CSSValuePaddingBox
3126 || parserValue->id == CSSValueContentBox || parserValue->id == CSSValueWebkitText) {
3127 cssValue = cssValuePool().createIdentifierValue(parserValue->id);
3133 bool CSSParser::useLegacyBackgroundSizeShorthandBehavior() const
3135 return m_context.useLegacyBackgroundSizeShorthandBehavior;
3138 const int cMaxFillProperties = 9;
3140 bool CSSParser::parseFillShorthand(CSSPropertyID propId, const CSSPropertyID* properties, int numProperties, bool important)
3142 ASSERT(numProperties <= cMaxFillProperties);
3143 if (numProperties > cMaxFillProperties)
3146 ShorthandScope scope(this, propId);
3148 bool parsedProperty[cMaxFillProperties] = { false };
3149 RefPtr<CSSValue> values[cMaxFillProperties];
3150 RefPtr<CSSValue> clipValue;
3151 RefPtr<CSSValue> positionYValue;
3152 RefPtr<CSSValue> repeatYValue;
3153 bool foundClip = false;
3155 bool foundPositionCSSProperty = false;
3157 while (m_valueList->current()) {
3158 CSSParserValue* val = m_valueList->current();
3159 if (val->unit == CSSParserValue::Operator && val->iValue == ',') {
3160 // We hit the end. Fill in all remaining values with the initial value.
3161 m_valueList->next();
3162 for (i = 0; i < numProperties; ++i) {
3163 if (properties[i] == CSSPropertyBackgroundColor && parsedProperty[i])
3164 // Color is not allowed except as the last item in a list for backgrounds.
3165 // Reject the entire property.
3168 if (!parsedProperty[i] && properties[i] != CSSPropertyBackgroundColor) {
3169 addFillValue(values[i], cssValuePool().createImplicitInitialValue());
3170 if (properties[i] == CSSPropertyBackgroundPosition || properties[i] == CSSPropertyWebkitMaskPosition)
3171 addFillValue(positionYValue, cssValuePool().createImplicitInitialValue());
3172 if (properties[i] == CSSPropertyBackgroundRepeat || properties[i] == CSSPropertyWebkitMaskRepeat)
3173 addFillValue(repeatYValue, cssValuePool().createImplicitInitialValue());
3174 if ((properties[i] == CSSPropertyBackgroundOrigin || properties[i] == CSSPropertyWebkitMaskOrigin) && !parsedProperty[i]) {
3175 // If background-origin wasn't present, then reset background-clip also.
3176 addFillValue(clipValue, cssValuePool().createImplicitInitialValue());
3179 parsedProperty[i] = false;
3181 if (!m_valueList->current())
3185 bool sizeCSSPropertyExpected = false;
3186 if (isForwardSlashOperator(val) && foundPositionCSSProperty) {
3187 sizeCSSPropertyExpected = true;
3188 m_valueList->next();
3191 foundPositionCSSProperty = false;
3193 for (i = 0; !found && i < numProperties; ++i) {
3195 if (sizeCSSPropertyExpected && (properties[i] != CSSPropertyBackgroundSize && properties[i] != CSSPropertyWebkitMaskSize))
3197 if (!sizeCSSPropertyExpected && (properties[i] == CSSPropertyBackgroundSize || properties[i] == CSSPropertyWebkitMaskSize))
3200 if (!parsedProperty[i]) {
3201 RefPtr<CSSValue> val1;
3202 RefPtr<CSSValue> val2;
3203 CSSPropertyID propId1, propId2;
3204 CSSParserValue* parserValue = m_valueList->current();
3205 if (parseFillProperty(properties[i], propId1, propId2, val1, val2)) {
3206 parsedProperty[i] = found = true;
3207 addFillValue(values[i], val1.release());
3208 if (properties[i] == CSSPropertyBackgroundPosition || properties[i] == CSSPropertyWebkitMaskPosition)
3209 addFillValue(positionYValue, val2.release());
3210 if (properties[i] == CSSPropertyBackgroundRepeat || properties[i] == CSSPropertyWebkitMaskRepeat)
3211 addFillValue(repeatYValue, val2.release());
3212 if (properties[i] == CSSPropertyBackgroundOrigin || properties[i] == CSSPropertyWebkitMaskOrigin) {
3213 // Reparse the value as a clip, and see if we succeed.
3214 if (parseBackgroundClip(parserValue, val1))
3215 addFillValue(clipValue, val1.release()); // The property parsed successfully.
3217 addFillValue(clipValue, cssValuePool().createImplicitInitialValue()); // Some value was used for origin that is not supported by clip. Just reset clip instead.
3219 if (properties[i] == CSSPropertyBackgroundClip || properties[i] == CSSPropertyWebkitMaskClip) {
3221 addFillValue(clipValue, val1.release());
3224 if (properties[i] == CSSPropertyBackgroundPosition || properties[i] == CSSPropertyWebkitMaskPosition)
3225 foundPositionCSSProperty = true;
3230 // if we didn't find at least one match, this is an
3231 // invalid shorthand and we have to ignore it
3236 // Now add all of the properties we found.
3237 for (i = 0; i < numProperties; i++) {
3238 // Fill in any remaining properties with the initial value.
3239 if (!parsedProperty[i]) {
3240 addFillValue(values[i], cssValuePool().createImplicitInitialValue());
3241 if (properties[i] == CSSPropertyBackgroundPosition || properties[i] == CSSPropertyWebkitMaskPosition)
3242 addFillValue(positionYValue, cssValuePool().createImplicitInitialValue());
3243 if (properties[i] == CSSPropertyBackgroundRepeat || properties[i] == CSSPropertyWebkitMaskRepeat)
3244 addFillValue(repeatYValue, cssValuePool().createImplicitInitialValue());
3245 if (properties[i] == CSSPropertyBackgroundOrigin || properties[i] == CSSPropertyWebkitMaskOrigin) {
3246 // If background-origin wasn't present, then reset background-clip also.
3247 addFillValue(clipValue, cssValuePool().createImplicitInitialValue());
3250 if (properties[i] == CSSPropertyBackgroundPosition) {
3251 addProperty(CSSPropertyBackgroundPositionX, values[i].release(), important);
3252 // it's OK to call positionYValue.release() since we only see CSSPropertyBackgroundPosition once
3253 addProperty(CSSPropertyBackgroundPositionY, positionYValue.release(), important);
3254 } else if (properties[i] == CSSPropertyWebkitMaskPosition) {
3255 addProperty(CSSPropertyWebkitMaskPositionX, values[i].release(), important);
3256 // it's OK to call positionYValue.release() since we only see CSSPropertyWebkitMaskPosition once
3257 addProperty(CSSPropertyWebkitMaskPositionY, positionYValue.release(), important);
3258 } else if (properties[i] == CSSPropertyBackgroundRepeat) {
3259 addProperty(CSSPropertyBackgroundRepeatX, values[i].release(), important);
3260 // it's OK to call repeatYValue.release() since we only see CSSPropertyBackgroundPosition once
3261 addProperty(CSSPropertyBackgroundRepeatY, repeatYValue.release(), important);
3262 } else if (properties[i] == CSSPropertyWebkitMaskRepeat) {
3263 addProperty(CSSPropertyWebkitMaskRepeatX, values[i].release(), important);
3264 // it's OK to call repeatYValue.release() since we only see CSSPropertyBackgroundPosition once
3265 addProperty(CSSPropertyWebkitMaskRepeatY, repeatYValue.release(), important);
3266 } else if ((properties[i] == CSSPropertyBackgroundClip || properties[i] == CSSPropertyWebkitMaskClip) && !foundClip)
3267 // Value is already set while updating origin
3269 else if (properties[i] == CSSPropertyBackgroundSize && !parsedProperty[i] && useLegacyBackgroundSizeShorthandBehavior())
3272 addProperty(properties[i], values[i].release(), important);
3274 // Add in clip values when we hit the corresponding origin property.
3275 if (properties[i] == CSSPropertyBackgroundOrigin && !foundClip)
3276 addProperty(CSSPropertyBackgroundClip, clipValue.release(), important);
3277 else if (properties[i] == CSSPropertyWebkitMaskOrigin && !foundClip)
3278 addProperty(CSSPropertyWebkitMaskClip, clipValue.release(), important);
3284 void CSSParser::addAnimationValue(RefPtr<CSSValue>& lval, PassRefPtr<CSSValue> rval)
3287 if (lval->isValueList())
3288 toCSSValueList(lval.get())->append(rval);
3290 PassRefPtr<CSSValue> oldVal(lval.release());
3291 PassRefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
3292 list->append(oldVal);
3301 bool CSSParser::parseAnimationShorthand(bool important)
3303 const StylePropertyShorthand& animationProperties = webkitAnimationShorthandForParsing();
3304 const unsigned numProperties = 7;
3306 // The list of properties in the shorthand should be the same
3307 // length as the list with animation name in last position, even though they are
3308 // in a different order.
3309 ASSERT(numProperties == webkitAnimationShorthandForParsing().length());
3310 ASSERT(numProperties == webkitAnimationShorthand().length());
3312 ShorthandScope scope(this, CSSPropertyWebkitAnimation);
3314 bool parsedProperty[numProperties] = { false };
3315 AnimationParseContext context;
3316 RefPtr<CSSValue> values[numProperties];
3319 while (m_valueList->current()) {
3320 CSSParserValue* val = m_valueList->current();
3321 if (val->unit == CSSParserValue::Operator && val->iValue == ',') {
3322 // We hit the end. Fill in all remaining values with the initial value.
3323 m_valueList->next();
3324 for (i = 0; i < numProperties; ++i) {
3325 if (!parsedProperty[i])
3326 addAnimationValue(values[i], cssValuePool().createImplicitInitialValue());
3327 parsedProperty[i] = false;
3329 if (!m_valueList->current())
3331 context.commitFirstAnimation();
3335 for (i = 0; i < numProperties; ++i) {
3336 if (!parsedProperty[i]) {
3337 RefPtr<CSSValue> val;
3338 if (parseAnimationProperty(animationProperties.properties()[i], val, context)) {
3339 parsedProperty[i] = found = true;
3340 addAnimationValue(values[i], val.release());
3345 // There are more values to process but 'none' or 'all' were already defined as the animation property, the declaration becomes invalid.
3346 if (!context.animationPropertyKeywordAllowed() && context.hasCommittedFirstAnimation())
3350 // if we didn't find at least one match, this is an
3351 // invalid shorthand and we have to ignore it
3356 for (i = 0; i < numProperties; ++i) {
3357 // If we didn't find the property, set an intial value.
3358 if (!parsedProperty[i])
3359 addAnimationValue(values[i], cssValuePool().createImplicitInitialValue());
3361 addProperty(animationProperties.properties()[i], values[i].release(), important);
3367 bool CSSParser::parseTransitionShorthand(CSSPropertyID propId, bool important)
3369 const unsigned numProperties = 4;
3370 const StylePropertyShorthand& shorthand = shorthandForProperty(propId);
3371 ASSERT(numProperties == shorthand.length());
3373 ShorthandScope scope(this, propId);
3375 bool parsedProperty[numProperties] = { false };
3376 AnimationParseContext context;
3377 RefPtr<CSSValue> values[numProperties];
3380 while (m_valueList->current()) {
3381 CSSParserValue* val = m_valueList->current();
3382 if (val->unit == CSSParserValue::Operator && val->iValue == ',') {
3383 // We hit the end. Fill in all remaining values with the initial value.
3384 m_valueList->next();
3385 for (i = 0; i < numProperties; ++i) {
3386 if (!parsedProperty[i])
3387 addAnimationValue(values[i], cssValuePool().createImplicitInitialValue());
3388 parsedProperty[i] = false;
3390 if (!m_valueList->current())
3392 context.commitFirstAnimation();
3396 for (i = 0; !found && i < numProperties; ++i) {
3397 if (!parsedProperty[i]) {
3398 RefPtr<CSSValue> val;
3399 if (parseAnimationProperty(shorthand.properties()[i], val, context)) {
3400 parsedProperty[i] = found = true;
3401 addAnimationValue(values[i], val.release());
3404 // There are more values to process but 'none' or 'all' were already defined as the animation property, the declaration becomes invalid.
3405 if (!context.animationPropertyKeywordAllowed() && context.hasCommittedFirstAnimation())