/WebCore/css/CSSParser.cpp
http://github.com/CyanogenMod/android_external_webkit · C++ · 1670 lines · 1411 code · 149 blank · 110 comment · 673 complexity · 777351b62f087173c71955797a2ed02b MD5 · raw file
Large files are truncated click here to view the full file
- /*
- * Copyright (C) 2003 Lars Knoll (knoll@kde.org)
- * Copyright (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com)
- * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
- * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com>
- * Copyright (C) 2008 Eric Seidel <eric@webkit.org>
- * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
- #include "config.h"
- #include "CSSParser.h"
- #include "CString.h"
- #include "CSSTimingFunctionValue.h"
- #include "CSSBorderImageValue.h"
- #include "CSSCanvasValue.h"
- #include "CSSCharsetRule.h"
- #include "CSSCursorImageValue.h"
- #include "CSSHelper.h"
- #include "CSSImageValue.h"
- #include "CSSFontFaceRule.h"
- #include "CSSFontFaceSrcValue.h"
- #include "CSSGradientValue.h"
- #include "CSSImportRule.h"
- #include "CSSInheritedValue.h"
- #include "CSSInitialValue.h"
- #include "CSSMediaRule.h"
- #include "CSSMutableStyleDeclaration.h"
- #include "CSSPrimitiveValue.h"
- #include "CSSProperty.h"
- #include "CSSPropertyNames.h"
- #include "CSSQuirkPrimitiveValue.h"
- #include "CSSReflectValue.h"
- #include "CSSRuleList.h"
- #include "CSSSelector.h"
- #include "CSSStyleRule.h"
- #include "CSSStyleSheet.h"
- #include "CSSUnicodeRangeValue.h"
- #include "CSSValueKeywords.h"
- #include "CSSValueList.h"
- #include "CSSVariableDependentValue.h"
- #include "CSSVariablesDeclaration.h"
- #include "CSSVariablesRule.h"
- #include "Counter.h"
- #include "Document.h"
- #include "FloatConversion.h"
- #include "FontFamilyValue.h"
- #include "FontValue.h"
- #include "MediaList.h"
- #include "MediaQueryExp.h"
- #include "Pair.h"
- #include "Rect.h"
- #include "ShadowValue.h"
- #include "WebKitCSSKeyframeRule.h"
- #include "WebKitCSSKeyframesRule.h"
- #include "WebKitCSSTransformValue.h"
- #include <wtf/dtoa.h>
- #if ENABLE(DASHBOARD_SUPPORT)
- #include "DashboardRegion.h"
- #endif
- #define YYDEBUG 0
- #if YYDEBUG > 0
- extern int cssyydebug;
- #endif
- extern int cssyyparse(void* parser);
- using namespace std;
- using namespace WTF;
- #include "CSSPropertyNames.cpp"
- #include "CSSValueKeywords.c"
- #ifdef ANDROID_INSTRUMENT
- #include "TimeCounter.h"
- #endif
- namespace WebCore {
- static bool equal(const CSSParserString& a, const char* b)
- {
- for (int i = 0; i < a.length; ++i) {
- if (!b[i])
- return false;
- if (a.characters[i] != b[i])
- return false;
- }
- return !b[a.length];
- }
- static bool equalIgnoringCase(const CSSParserString& a, const char* b)
- {
- for (int i = 0; i < a.length; ++i) {
- if (!b[i])
- return false;
- ASSERT(!isASCIIUpper(b[i]));
- if (toASCIILower(a.characters[i]) != b[i])
- return false;
- }
- return !b[a.length];
- }
- static bool hasPrefix(const char* string, unsigned length, const char* prefix)
- {
- for (unsigned i = 0; i < length; ++i) {
- if (!prefix[i])
- return true;
- if (string[i] != prefix[i])
- return false;
- }
- return false;
- }
- CSSParser::CSSParser(bool strictParsing)
- : m_strict(strictParsing)
- , m_important(false)
- , m_id(0)
- , m_styleSheet(0)
- , m_mediaQuery(0)
- , m_valueList(0)
- , m_parsedProperties(static_cast<CSSProperty**>(fastMalloc(32 * sizeof(CSSProperty*))))
- , m_numParsedProperties(0)
- , m_maxParsedProperties(32)
- , m_inParseShorthand(0)
- , m_currentShorthand(0)
- , m_implicitShorthand(false)
- , m_hasFontFaceOnlyValues(false)
- , m_hadSyntacticallyValidCSSRule(false)
- , m_defaultNamespace(starAtom)
- , m_data(0)
- , yy_start(1)
- , m_allowImportRules(true)
- , m_allowVariablesRules(true)
- , m_allowNamespaceDeclarations(true)
- , m_floatingMediaQuery(0)
- , m_floatingMediaQueryExp(0)
- , m_floatingMediaQueryExpList(0)
- {
- #if YYDEBUG > 0
- cssyydebug = 1;
- #endif
- }
- CSSParser::~CSSParser()
- {
- clearProperties();
- fastFree(m_parsedProperties);
- clearVariables();
-
- delete m_valueList;
- fastFree(m_data);
- if (m_floatingMediaQueryExpList) {
- deleteAllValues(*m_floatingMediaQueryExpList);
- delete m_floatingMediaQueryExpList;
- }
- delete m_floatingMediaQueryExp;
- delete m_floatingMediaQuery;
- fastDeleteAllValues(m_floatingSelectors);
- deleteAllValues(m_floatingValueLists);
- deleteAllValues(m_floatingFunctions);
- deleteAllValues(m_reusableSelectorVector);
- }
- void CSSParserString::lower()
- {
- // FIXME: If we need Unicode lowercasing here, then we probably want the real kind
- // that can potentially change the length of the string rather than the character
- // by character kind. If we don't need Unicode lowercasing, it would be good to
- // simplify this function.
- if (charactersAreAllASCII(characters, length)) {
- // Fast case for all-ASCII.
- for (int i = 0; i < length; i++)
- characters[i] = toASCIILower(characters[i]);
- } else {
- for (int i = 0; i < length; i++)
- characters[i] = Unicode::toLower(characters[i]);
- }
- }
- void CSSParser::setupParser(const char* prefix, const String& string, const char* suffix)
- {
- int length = string.length() + strlen(prefix) + strlen(suffix) + 2;
- fastFree(m_data);
- m_data = static_cast<UChar*>(fastMalloc(length * sizeof(UChar)));
- for (unsigned i = 0; i < strlen(prefix); i++)
- m_data[i] = prefix[i];
-
- memcpy(m_data + strlen(prefix), string.characters(), string.length() * sizeof(UChar));
- unsigned start = strlen(prefix) + string.length();
- unsigned end = start + strlen(suffix);
- for (unsigned i = start; i < end; i++)
- m_data[i] = suffix[i - start];
- m_data[length - 1] = 0;
- m_data[length - 2] = 0;
- yy_hold_char = 0;
- yyleng = 0;
- yytext = yy_c_buf_p = m_data;
- yy_hold_char = *yy_c_buf_p;
- }
- void CSSParser::parseSheet(CSSStyleSheet* sheet, const String& string)
- {
- #ifdef ANDROID_INSTRUMENT
- android::TimeCounter::start(android::TimeCounter::CSSParseTimeCounter);
- #endif
- m_styleSheet = sheet;
- m_defaultNamespace = starAtom; // Reset the default namespace.
-
- setupParser("", string, "");
- cssyyparse(this);
- m_rule = 0;
- #ifdef ANDROID_INSTRUMENT
- android::TimeCounter::record(android::TimeCounter::CSSParseTimeCounter, __FUNCTION__);
- #endif
- }
- PassRefPtr<CSSRule> CSSParser::parseRule(CSSStyleSheet* sheet, const String& string)
- {
- #ifdef ANDROID_INSTRUMENT
- android::TimeCounter::start(android::TimeCounter::CSSParseTimeCounter);
- #endif
- m_styleSheet = sheet;
- m_allowNamespaceDeclarations = false;
- setupParser("@-webkit-rule{", string, "} ");
- cssyyparse(this);
- #ifdef ANDROID_INSTRUMENT
- android::TimeCounter::record(android::TimeCounter::CSSParseTimeCounter, __FUNCTION__);
- #endif
- return m_rule.release();
- }
- PassRefPtr<CSSRule> CSSParser::parseKeyframeRule(CSSStyleSheet *sheet, const String &string)
- {
- #ifdef ANDROID_INSTRUMENT
- android::TimeCounter::start(android::TimeCounter::CSSParseTimeCounter);
- #endif
- m_styleSheet = sheet;
- setupParser("@-webkit-keyframe-rule{ ", string, "} ");
- cssyyparse(this);
- #ifdef ANDROID_INSTRUMENT
- android::TimeCounter::record(android::TimeCounter::CSSParseTimeCounter, __FUNCTION__);
- #endif
- return m_keyframe.release();
- }
- bool CSSParser::parseValue(CSSMutableStyleDeclaration* declaration, int id, const String& string, bool important)
- {
- #ifdef ANDROID_INSTRUMENT
- android::TimeCounter::start(android::TimeCounter::CSSParseTimeCounter);
- #endif
- ASSERT(!declaration->stylesheet() || declaration->stylesheet()->isCSSStyleSheet());
- m_styleSheet = static_cast<CSSStyleSheet*>(declaration->stylesheet());
- setupParser("@-webkit-value{", string, "} ");
- m_id = id;
- m_important = important;
-
- cssyyparse(this);
-
- m_rule = 0;
- bool ok = false;
- if (m_hasFontFaceOnlyValues)
- deleteFontFaceOnlyValues();
- if (m_numParsedProperties) {
- ok = true;
- declaration->addParsedProperties(m_parsedProperties, m_numParsedProperties);
- clearProperties();
- }
- #ifdef ANDROID_INSTRUMENT
- android::TimeCounter::record(android::TimeCounter::CSSParseTimeCounter, __FUNCTION__);
- #endif
- return ok;
- }
- // color will only be changed when string contains a valid css color, making it
- // possible to set up a default color.
- bool CSSParser::parseColor(RGBA32& color, const String& string, bool strict)
- {
- color = 0;
- CSSParser parser(true);
- // First try creating a color specified by name or the "#" syntax.
- if (!parser.parseColor(string, color, strict)) {
- RefPtr<CSSMutableStyleDeclaration> dummyStyleDeclaration = CSSMutableStyleDeclaration::create();
- // Now try to create a color from the rgb() or rgba() syntax.
- if (parser.parseColor(dummyStyleDeclaration.get(), string)) {
- CSSValue* value = parser.m_parsedProperties[0]->value();
- if (value->cssValueType() == CSSValue::CSS_PRIMITIVE_VALUE) {
- CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
- color = primitiveValue->getRGBA32Value();
- }
- } else
- return false;
- }
- return true;
- }
- bool CSSParser::parseColor(CSSMutableStyleDeclaration* declaration, const String& string)
- {
- #ifdef ANDROID_INSTRUMENT
- android::TimeCounter::start(android::TimeCounter::CSSParseTimeCounter);
- #endif
- ASSERT(!declaration->stylesheet() || declaration->stylesheet()->isCSSStyleSheet());
- m_styleSheet = static_cast<CSSStyleSheet*>(declaration->stylesheet());
- setupParser("@-webkit-decls{color:", string, "} ");
- cssyyparse(this);
- m_rule = 0;
- #ifdef ANDROID_INSTRUMENT
- android::TimeCounter::record(android::TimeCounter::CSSParseTimeCounter, __FUNCTION__);
- #endif
- return (m_numParsedProperties && m_parsedProperties[0]->m_id == CSSPropertyColor);
- }
- void CSSParser::parseSelector(const String& string, Document* doc, CSSSelectorList& selectorList)
- {
- #ifdef ANDROID_INSTRUMENT
- android::TimeCounter::start(android::TimeCounter::CSSParseTimeCounter);
- #endif
- RefPtr<CSSStyleSheet> dummyStyleSheet = CSSStyleSheet::create(doc);
- m_styleSheet = dummyStyleSheet.get();
- m_selectorListForParseSelector = &selectorList;
- setupParser("@-webkit-selector{", string, "}");
- cssyyparse(this);
- m_selectorListForParseSelector = 0;
- #ifdef ANDROID_INSTRUMENT
- android::TimeCounter::record(android::TimeCounter::CSSParseTimeCounter, __FUNCTION__);
- #endif
- }
- bool CSSParser::parseDeclaration(CSSMutableStyleDeclaration* declaration, const String& string)
- {
- #ifdef ANDROID_INSTRUMENT
- android::TimeCounter::start(android::TimeCounter::CSSParseTimeCounter);
- #endif
- ASSERT(!declaration->stylesheet() || declaration->stylesheet()->isCSSStyleSheet());
- m_styleSheet = static_cast<CSSStyleSheet*>(declaration->stylesheet());
- setupParser("@-webkit-decls{", string, "} ");
- cssyyparse(this);
- m_rule = 0;
- bool ok = false;
- if (m_hasFontFaceOnlyValues)
- deleteFontFaceOnlyValues();
- if (m_numParsedProperties) {
- ok = true;
- declaration->addParsedProperties(m_parsedProperties, m_numParsedProperties);
- clearProperties();
- }
- #ifdef ANDROID_INSTRUMENT
- android::TimeCounter::record(android::TimeCounter::CSSParseTimeCounter, __FUNCTION__);
- #endif
- return ok;
- }
- bool CSSParser::parseMediaQuery(MediaList* queries, const String& string)
- {
- if (string.isEmpty())
- return true;
- #ifdef ANDROID_INSTRUMENT
- android::TimeCounter::start(android::TimeCounter::CSSParseTimeCounter);
- #endif
- m_mediaQuery = 0;
- // can't use { because tokenizer state switches from mediaquery to initial state when it sees { token.
- // instead insert one " " (which is WHITESPACE in CSSGrammar.y)
- setupParser("@-webkit-mediaquery ", string, "} ");
- cssyyparse(this);
- bool ok = false;
- if (m_mediaQuery) {
- ok = true;
- queries->appendMediaQuery(m_mediaQuery);
- m_mediaQuery = 0;
- }
- #ifdef ANDROID_INSTRUMENT
- android::TimeCounter::record(android::TimeCounter::CSSParseTimeCounter, __FUNCTION__);
- #endif
- return ok;
- }
- void CSSParser::addProperty(int propId, PassRefPtr<CSSValue> value, bool important)
- {
- auto_ptr<CSSProperty> prop(new CSSProperty(propId, value, important, m_currentShorthand, m_implicitShorthand));
- if (m_numParsedProperties >= m_maxParsedProperties) {
- m_maxParsedProperties += 32;
- if (m_maxParsedProperties > UINT_MAX / sizeof(CSSProperty*))
- return;
- m_parsedProperties = static_cast<CSSProperty**>(fastRealloc(m_parsedProperties,
- m_maxParsedProperties * sizeof(CSSProperty*)));
- }
- m_parsedProperties[m_numParsedProperties++] = prop.release();
- }
- void CSSParser::rollbackLastProperties(int num)
- {
- ASSERT(num >= 0);
- ASSERT(m_numParsedProperties >= static_cast<unsigned>(num));
- for (int i = 0; i < num; ++i)
- delete m_parsedProperties[--m_numParsedProperties];
- }
- void CSSParser::clearProperties()
- {
- for (unsigned i = 0; i < m_numParsedProperties; i++)
- delete m_parsedProperties[i];
- m_numParsedProperties = 0;
- m_hasFontFaceOnlyValues = false;
- }
- Document* CSSParser::document() const
- {
- StyleBase* root = m_styleSheet;
- Document* doc = 0;
- while (root && root->parent())
- root = root->parent();
- if (root && root->isCSSStyleSheet())
- doc = static_cast<CSSStyleSheet*>(root)->doc();
- return doc;
- }
- bool CSSParser::validUnit(CSSParserValue* value, Units unitflags, bool strict)
- {
- bool b = false;
- switch (value->unit) {
- case CSSPrimitiveValue::CSS_NUMBER:
- b = (unitflags & FNumber);
- if (!b && ((unitflags & (FLength | FAngle | FTime)) && (value->fValue == 0 || !strict))) {
- value->unit = (unitflags & FLength) ? CSSPrimitiveValue::CSS_PX :
- ((unitflags & FAngle) ? CSSPrimitiveValue::CSS_DEG : CSSPrimitiveValue::CSS_MS);
- b = true;
- }
- if (!b && (unitflags & FInteger) && value->isInt)
- b = true;
- break;
- case CSSPrimitiveValue::CSS_PERCENTAGE:
- b = (unitflags & FPercent);
- break;
- case CSSParserValue::Q_EMS:
- case CSSPrimitiveValue::CSS_EMS:
- case CSSPrimitiveValue::CSS_REMS:
- case CSSPrimitiveValue::CSS_EXS:
- case CSSPrimitiveValue::CSS_PX:
- case CSSPrimitiveValue::CSS_CM:
- case CSSPrimitiveValue::CSS_MM:
- case CSSPrimitiveValue::CSS_IN:
- case CSSPrimitiveValue::CSS_PT:
- case CSSPrimitiveValue::CSS_PC:
- b = (unitflags & FLength);
- break;
- case CSSPrimitiveValue::CSS_MS:
- case CSSPrimitiveValue::CSS_S:
- b = (unitflags & FTime);
- break;
- case CSSPrimitiveValue::CSS_DEG:
- case CSSPrimitiveValue::CSS_RAD:
- case CSSPrimitiveValue::CSS_GRAD:
- case CSSPrimitiveValue::CSS_TURN:
- b = (unitflags & FAngle);
- break;
- case CSSPrimitiveValue::CSS_HZ:
- case CSSPrimitiveValue::CSS_KHZ:
- case CSSPrimitiveValue::CSS_DIMENSION:
- default:
- break;
- }
- if (b && unitflags & FNonNeg && value->fValue < 0)
- b = false;
- return b;
- }
- static int unitFromString(CSSParserValue* value)
- {
- if (value->unit != CSSPrimitiveValue::CSS_IDENT || value->id)
- return 0;
- if (equal(value->string, "em"))
- return CSSPrimitiveValue::CSS_EMS;
- if (equal(value->string, "rem"))
- return CSSPrimitiveValue::CSS_REMS;
- if (equal(value->string, "ex"))
- return CSSPrimitiveValue::CSS_EXS;
- if (equal(value->string, "px"))
- return CSSPrimitiveValue::CSS_PX;
- if (equal(value->string, "cm"))
- return CSSPrimitiveValue::CSS_CM;
- if (equal(value->string, "mm"))
- return CSSPrimitiveValue::CSS_MM;
- if (equal(value->string, "in"))
- return CSSPrimitiveValue::CSS_IN;
- if (equal(value->string, "pt"))
- return CSSPrimitiveValue::CSS_PT;
- if (equal(value->string, "pc"))
- return CSSPrimitiveValue::CSS_PC;
- if (equal(value->string, "deg"))
- return CSSPrimitiveValue::CSS_DEG;
- if (equal(value->string, "rad"))
- return CSSPrimitiveValue::CSS_RAD;
- if (equal(value->string, "grad"))
- return CSSPrimitiveValue::CSS_GRAD;
- if (equal(value->string, "turn"))
- return CSSPrimitiveValue::CSS_TURN;
- if (equal(value->string, "ms"))
- return CSSPrimitiveValue::CSS_MS;
- if (equal(value->string, "s"))
- return CSSPrimitiveValue::CSS_S;
- if (equal(value->string, "Hz"))
- return CSSPrimitiveValue::CSS_HZ;
- if (equal(value->string, "kHz"))
- return CSSPrimitiveValue::CSS_KHZ;
-
- return 0;
- }
- void CSSParser::checkForOrphanedUnits()
- {
- if (m_strict || inShorthand())
- return;
-
- // The purpose of this code is to implement the WinIE quirk that allows unit types to be separated from their numeric values
- // by whitespace, so e.g., width: 20 px instead of width:20px. This is invalid CSS, so we don't do this in strict mode.
- CSSParserValue* numericVal = 0;
- unsigned size = m_valueList->size();
- for (unsigned i = 0; i < size; i++) {
- CSSParserValue* value = m_valueList->valueAt(i);
- if (numericVal) {
- // Change the unit type of the numeric val to match.
- int unit = unitFromString(value);
- if (unit) {
- numericVal->unit = unit;
- numericVal = 0;
- // Now delete the bogus unit value.
- m_valueList->deleteValueAt(i);
- i--; // We're safe even though |i| is unsigned, since we only hit this code if we had a previous numeric value (so |i| is always > 0 here).
- size--;
- continue;
- }
- }
-
- numericVal = (value->unit == CSSPrimitiveValue::CSS_NUMBER) ? value : 0;
- }
- }
- bool CSSParser::parseValue(int propId, bool important)
- {
- if (!m_valueList)
- return false;
- CSSParserValue *value = m_valueList->current();
- if (!value)
- return false;
- int id = value->id;
- // In quirks mode, we will look for units that have been incorrectly separated from the number they belong to
- // by a space. We go ahead and associate the unit with the number even though it is invalid CSS.
- checkForOrphanedUnits();
-
- int num = inShorthand() ? 1 : m_valueList->size();
- if (id == CSSValueInherit) {
- if (num != 1)
- return false;
- addProperty(propId, CSSInheritedValue::create(), important);
- return true;
- }
- else if (id == CSSValueInitial) {
- if (num != 1)
- return false;
- addProperty(propId, CSSInitialValue::createExplicit(), important);
- return true;
- }
- // If we have any variables, then we don't parse the list of values yet. We add them to the declaration
- // as unresolved, and allow them to be parsed later. The parse is considered "successful" for now, even though
- // it might ultimately fail once the variable has been resolved.
- if (!inShorthand() && checkForVariables(m_valueList)) {
- addUnresolvedProperty(propId, important);
- return true;
- }
- bool validPrimitive = false;
- RefPtr<CSSValue> parsedValue;
- switch (static_cast<CSSPropertyID>(propId)) {
- /* The comment to the left defines all valid value of this properties as defined
- * in CSS 2, Appendix F. Property index
- */
- /* All the CSS properties are not supported by the renderer at the moment.
- * Note that all the CSS2 Aural properties are only checked, if CSS_AURAL is defined
- * (see parseAuralValues). As we don't support them at all this seems reasonable.
- */
- case CSSPropertySize: // <length>{1,2} | auto | portrait | landscape | inherit
- case CSSPropertyQuotes: // [<string> <string>]+ | none | inherit
- if (id)
- validPrimitive = true;
- break;
- case CSSPropertyUnicodeBidi: // normal | embed | bidi-override | inherit
- if (id == CSSValueNormal ||
- id == CSSValueEmbed ||
- id == CSSValueBidiOverride)
- validPrimitive = true;
- break;
- case CSSPropertyPosition: // static | relative | absolute | fixed | inherit
- if (id == CSSValueStatic ||
- id == CSSValueRelative ||
- id == CSSValueAbsolute ||
- id == CSSValueFixed)
- validPrimitive = true;
- break;
- case CSSPropertyPageBreakAfter: // auto | always | avoid | left | right | inherit
- case CSSPropertyPageBreakBefore:
- case CSSPropertyWebkitColumnBreakAfter:
- case CSSPropertyWebkitColumnBreakBefore:
- if (id == CSSValueAuto ||
- id == CSSValueAlways ||
- id == CSSValueAvoid ||
- id == CSSValueLeft ||
- id == CSSValueRight)
- validPrimitive = true;
- break;
- case CSSPropertyPageBreakInside: // avoid | auto | inherit
- case CSSPropertyWebkitColumnBreakInside:
- if (id == CSSValueAuto || id == CSSValueAvoid)
- validPrimitive = true;
- break;
- case CSSPropertyEmptyCells: // show | hide | inherit
- if (id == CSSValueShow ||
- id == CSSValueHide)
- validPrimitive = true;
- break;
- case CSSPropertyContent: // [ <string> | <uri> | <counter> | attr(X) | open-quote |
- // close-quote | no-open-quote | no-close-quote ]+ | inherit
- return parseContent(propId, important);
- case CSSPropertyWhiteSpace: // normal | pre | nowrap | inherit
- if (id == CSSValueNormal ||
- id == CSSValuePre ||
- id == CSSValuePreWrap ||
- id == CSSValuePreLine ||
- id == CSSValueNowrap)
- validPrimitive = true;
- break;
- case CSSPropertyClip: // <shape> | auto | inherit
- if (id == CSSValueAuto)
- validPrimitive = true;
- else if (value->unit == CSSParserValue::Function)
- return parseShape(propId, important);
- break;
- /* Start of supported CSS properties with validation. This is needed for parseShorthand to work
- * correctly and allows optimization in WebCore::applyRule(..)
- */
- case CSSPropertyCaptionSide: // top | bottom | left | right | inherit
- if (id == CSSValueLeft || id == CSSValueRight ||
- id == CSSValueTop || id == CSSValueBottom)
- validPrimitive = true;
- break;
- case CSSPropertyBorderCollapse: // collapse | separate | inherit
- if (id == CSSValueCollapse || id == CSSValueSeparate)
- validPrimitive = true;
- break;
- case CSSPropertyVisibility: // visible | hidden | collapse | inherit
- if (id == CSSValueVisible || id == CSSValueHidden || id == CSSValueCollapse)
- validPrimitive = true;
- break;
- case CSSPropertyOverflow: {
- ShorthandScope scope(this, propId);
- if (num != 1 || !parseValue(CSSPropertyOverflowX, important))
- return false;
- CSSValue* value = m_parsedProperties[m_numParsedProperties - 1]->value();
- addProperty(CSSPropertyOverflowY, value, important);
- return true;
- }
- case CSSPropertyOverflowX:
- case CSSPropertyOverflowY: // visible | hidden | scroll | auto | marquee | overlay | inherit
- if (id == CSSValueVisible || id == CSSValueHidden || id == CSSValueScroll || id == CSSValueAuto ||
- id == CSSValueOverlay || id == CSSValueWebkitMarquee)
- validPrimitive = true;
- break;
- case CSSPropertyListStylePosition: // inside | outside | inherit
- if (id == CSSValueInside || id == CSSValueOutside)
- validPrimitive = true;
- break;
- case CSSPropertyListStyleType:
- // See section CSS_PROP_LIST_STYLE_TYPE of file CSSValueKeywords.in
- // for the list of supported list-style-types.
- if ((id >= CSSValueDisc && id <= CSSValueKatakanaIroha) || id == CSSValueNone)
- validPrimitive = true;
- break;
- case CSSPropertyDisplay:
- // inline | block | list-item | run-in | inline-block | table |
- // inline-table | table-row-group | table-header-group | table-footer-group | table-row |
- // table-column-group | table-column | table-cell | table-caption | box | inline-box | none | inherit
- #if ENABLE(WCSS)
- if ((id >= CSSValueInline && id <= CSSValueWapMarquee) || id == CSSValueNone)
- #else
- if ((id >= CSSValueInline && id <= CSSValueWebkitInlineBox) || id == CSSValueNone)
- #endif
- validPrimitive = true;
- break;
- case CSSPropertyDirection: // ltr | rtl | inherit
- if (id == CSSValueLtr || id == CSSValueRtl)
- validPrimitive = true;
- break;
- case CSSPropertyTextTransform: // capitalize | uppercase | lowercase | none | inherit
- if ((id >= CSSValueCapitalize && id <= CSSValueLowercase) || id == CSSValueNone)
- validPrimitive = true;
- break;
- case CSSPropertyFloat: // left | right | none | inherit + center for buggy CSS
- if (id == CSSValueLeft || id == CSSValueRight ||
- id == CSSValueNone || id == CSSValueCenter)
- validPrimitive = true;
- break;
- case CSSPropertyClear: // none | left | right | both | inherit
- if (id == CSSValueNone || id == CSSValueLeft ||
- id == CSSValueRight|| id == CSSValueBoth)
- validPrimitive = true;
- break;
- case CSSPropertyTextAlign:
- // left | right | center | justify | webkit_left | webkit_right | webkit_center | start | end | <string> | inherit
- if ((id >= CSSValueWebkitAuto && id <= CSSValueWebkitCenter) || id == CSSValueStart || id == CSSValueEnd ||
- value->unit == CSSPrimitiveValue::CSS_STRING)
- validPrimitive = true;
- break;
- case CSSPropertyOutlineStyle: // (<border-style> except hidden) | auto | inherit
- if (id == CSSValueAuto || id == CSSValueNone || (id >= CSSValueInset && id <= CSSValueDouble))
- validPrimitive = true;
- break;
-
- case CSSPropertyBorderTopStyle: //// <border-style> | inherit
- case CSSPropertyBorderRightStyle: // Defined as: none | hidden | dotted | dashed |
- case CSSPropertyBorderBottomStyle: // solid | double | groove | ridge | inset | outset
- case CSSPropertyBorderLeftStyle:
- case CSSPropertyWebkitColumnRuleStyle:
- if (id >= CSSValueNone && id <= CSSValueDouble)
- validPrimitive = true;
- break;
- case CSSPropertyFontWeight: // normal | bold | bolder | lighter | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | inherit
- return parseFontWeight(important);
- case CSSPropertyBorderSpacing: {
- const int properties[2] = { CSSPropertyWebkitBorderHorizontalSpacing,
- CSSPropertyWebkitBorderVerticalSpacing };
- if (num == 1) {
- ShorthandScope scope(this, CSSPropertyBorderSpacing);
- if (!parseValue(properties[0], important))
- return false;
- CSSValue* value = m_parsedProperties[m_numParsedProperties-1]->value();
- addProperty(properties[1], value, important);
- return true;
- }
- else if (num == 2) {
- ShorthandScope scope(this, CSSPropertyBorderSpacing);
- if (!parseValue(properties[0], important) || !parseValue(properties[1], important))
- return false;
- return true;
- }
- return false;
- }
- case CSSPropertyWebkitBorderHorizontalSpacing:
- case CSSPropertyWebkitBorderVerticalSpacing:
- validPrimitive = validUnit(value, FLength | FNonNeg, m_strict);
- break;
- case CSSPropertyOutlineColor: // <color> | invert | inherit
- // Outline color has "invert" as additional keyword.
- // Also, we want to allow the special focus color even in strict parsing mode.
- if (propId == CSSPropertyOutlineColor && (id == CSSValueInvert || id == CSSValueWebkitFocusRingColor)) {
- validPrimitive = true;
- break;
- }
- /* nobreak */
- case CSSPropertyBackgroundColor: // <color> | inherit
- case CSSPropertyBorderTopColor: // <color> | inherit
- case CSSPropertyBorderRightColor: // <color> | inherit
- case CSSPropertyBorderBottomColor: // <color> | inherit
- case CSSPropertyBorderLeftColor: // <color> | inherit
- case CSSPropertyColor: // <color> | inherit
- case CSSPropertyTextLineThroughColor: // CSS3 text decoration colors
- case CSSPropertyTextUnderlineColor:
- case CSSPropertyTextOverlineColor:
- case CSSPropertyWebkitColumnRuleColor:
- case CSSPropertyWebkitTextFillColor:
- case CSSPropertyWebkitTextStrokeColor:
- if (id == CSSValueWebkitText)
- validPrimitive = true; // Always allow this, even when strict parsing is on,
- // since we use this in our UA sheets.
- else if (id == CSSValueCurrentcolor)
- validPrimitive = true;
- else if ((id >= CSSValueAqua && id <= CSSValueWindowtext) || id == CSSValueMenu ||
- (id >= CSSValueWebkitFocusRingColor && id < CSSValueWebkitText && !m_strict)) {
- validPrimitive = true;
- } else {
- parsedValue = parseColor();
- if (parsedValue)
- m_valueList->next();
- }
- break;
- case CSSPropertyCursor: {
- // [<uri>,]* [ auto | crosshair | default | pointer | progress | move | e-resize | ne-resize |
- // nw-resize | n-resize | se-resize | sw-resize | s-resize | w-resize | ew-resize |
- // ns-resize | nesw-resize | nwse-resize | col-resize | row-resize | text | wait | help |
- // vertical-text | cell | context-menu | alias | copy | no-drop | not-allowed | -webkit-zoom-in
- // -webkit-zoom-in | -webkit-zoom-out | all-scroll | -webkit-grab | -webkit-grabbing ] ] | inherit
- RefPtr<CSSValueList> list;
- while (value && value->unit == CSSPrimitiveValue::CSS_URI) {
- if (!list)
- list = CSSValueList::createCommaSeparated();
- String uri = value->string;
- Vector<int> coords;
- value = m_valueList->next();
- while (value && value->unit == CSSPrimitiveValue::CSS_NUMBER) {
- coords.append(int(value->fValue));
- value = m_valueList->next();
- }
- IntPoint hotspot;
- int nrcoords = coords.size();
- if (nrcoords > 0 && nrcoords != 2)
- return false;
- if (nrcoords == 2)
- hotspot = IntPoint(coords[0], coords[1]);
-
- if (!uri.isNull() && m_styleSheet) {
- // FIXME: The completeURL call should be done when using the CSSCursorImageValue,
- // not when creating it.
- list->append(CSSCursorImageValue::create(m_styleSheet->completeURL(uri), hotspot));
- }
- if ((m_strict && !value) || (value && !(value->unit == CSSParserValue::Operator && value->iValue == ',')))
- return false;
- value = m_valueList->next(); // comma
- }
- if (list) {
- if (!value) { // no value after url list (MSIE 5 compatibility)
- if (list->length() != 1)
- return false;
- } else if (!m_strict && value->id == CSSValueHand) // MSIE 5 compatibility :/
- list->append(CSSPrimitiveValue::createIdentifier(CSSValuePointer));
- else if (value && ((value->id >= CSSValueAuto && value->id <= CSSValueWebkitGrabbing) || value->id == CSSValueCopy || value->id == CSSValueNone))
- list->append(CSSPrimitiveValue::createIdentifier(value->id));
- m_valueList->next();
- parsedValue = list.release();
- break;
- }
- id = value->id;
- if (!m_strict && value->id == CSSValueHand) { // MSIE 5 compatibility :/
- id = CSSValuePointer;
- validPrimitive = true;
- } else if ((value->id >= CSSValueAuto && value->id <= CSSValueWebkitGrabbing) || value->id == CSSValueCopy || value->id == CSSValueNone)
- validPrimitive = true;
- break;
- }
- case CSSPropertyBackgroundAttachment:
- case CSSPropertyBackgroundClip:
- case CSSPropertyWebkitBackgroundClip:
- case CSSPropertyWebkitBackgroundComposite:
- case CSSPropertyBackgroundImage:
- case CSSPropertyBackgroundOrigin:
- case CSSPropertyWebkitBackgroundOrigin:
- case CSSPropertyBackgroundPosition:
- case CSSPropertyBackgroundPositionX:
- case CSSPropertyBackgroundPositionY:
- case CSSPropertyBackgroundSize:
- case CSSPropertyWebkitBackgroundSize:
- case CSSPropertyBackgroundRepeat:
- case CSSPropertyBackgroundRepeatX:
- case CSSPropertyBackgroundRepeatY:
- case CSSPropertyWebkitMaskAttachment:
- case CSSPropertyWebkitMaskClip:
- case CSSPropertyWebkitMaskComposite:
- case CSSPropertyWebkitMaskImage:
- case CSSPropertyWebkitMaskOrigin:
- case CSSPropertyWebkitMaskPosition:
- case CSSPropertyWebkitMaskPositionX:
- case CSSPropertyWebkitMaskPositionY:
- case CSSPropertyWebkitMaskSize:
- case CSSPropertyWebkitMaskRepeat:
- case CSSPropertyWebkitMaskRepeatX:
- case CSSPropertyWebkitMaskRepeatY: {
- RefPtr<CSSValue> val1;
- RefPtr<CSSValue> val2;
- int propId1, propId2;
- bool result = false;
- if (parseFillProperty(propId, propId1, propId2, val1, val2)) {
- OwnPtr<ShorthandScope> shorthandScope;
- if (propId == CSSPropertyBackgroundPosition ||
- propId == CSSPropertyBackgroundRepeat ||
- propId == CSSPropertyWebkitMaskPosition ||
- propId == CSSPropertyWebkitMaskRepeat) {
- shorthandScope.set(new ShorthandScope(this, propId));
- }
- addProperty(propId1, val1.release(), important);
- if (val2)
- addProperty(propId2, val2.release(), important);
- result = true;
- }
- m_implicitShorthand = false;
- return result;
- }
- case CSSPropertyListStyleImage: // <uri> | none | inherit
- if (id == CSSValueNone) {
- parsedValue = CSSImageValue::create();
- m_valueList->next();
- } else if (value->unit == CSSPrimitiveValue::CSS_URI) {
- if (m_styleSheet) {
- // FIXME: The completeURL call should be done when using the CSSImageValue,
- // not when creating it.
- parsedValue = CSSImageValue::create(m_styleSheet->completeURL(value->string));
- m_valueList->next();
- }
- } else if (value->unit == CSSParserValue::Function && equalIgnoringCase(value->function->name, "-webkit-gradient(")) {
- if (parseGradient(parsedValue))
- m_valueList->next();
- else
- return false;
- }
- break;
- case CSSPropertyWebkitTextStrokeWidth:
- case CSSPropertyOutlineWidth: // <border-width> | inherit
- case CSSPropertyBorderTopWidth: //// <border-width> | inherit
- case CSSPropertyBorderRightWidth: // Which is defined as
- case CSSPropertyBorderBottomWidth: // thin | medium | thick | <length>
- case CSSPropertyBorderLeftWidth:
- case CSSPropertyWebkitColumnRuleWidth:
- if (id == CSSValueThin || id == CSSValueMedium || id == CSSValueThick)
- validPrimitive = true;
- else
- validPrimitive = validUnit(value, FLength, m_strict);
- break;
- case CSSPropertyLetterSpacing: // normal | <length> | inherit
- case CSSPropertyWordSpacing: // normal | <length> | inherit
- if (id == CSSValueNormal)
- validPrimitive = true;
- else
- validPrimitive = validUnit(value, FLength, m_strict);
- break;
- case CSSPropertyWordBreak: // normal | break-all | break-word (this is a custom extension)
- if (id == CSSValueNormal || id == CSSValueBreakAll || id == CSSValueBreakWord)
- validPrimitive = true;
- break;
- case CSSPropertyWordWrap: // normal | break-word
- if (id == CSSValueNormal || id == CSSValueBreakWord)
- validPrimitive = true;
- break;
- case CSSPropertyTextIndent: // <length> | <percentage> | inherit
- case CSSPropertyPaddingTop: //// <padding-width> | inherit
- case CSSPropertyPaddingRight: // Which is defined as
- case CSSPropertyPaddingBottom: // <length> | <percentage>
- case CSSPropertyPaddingLeft: ////
- case CSSPropertyWebkitPaddingStart:
- validPrimitive = (!id && validUnit(value, FLength | FPercent, m_strict));
- break;
- case CSSPropertyMaxHeight: // <length> | <percentage> | none | inherit
- case CSSPropertyMaxWidth: // <length> | <percentage> | none | inherit
- if (id == CSSValueNone || id == CSSValueIntrinsic || id == CSSValueMinIntrinsic) {
- validPrimitive = true;
- break;
- }
- /* nobreak */
- case CSSPropertyMinHeight: // <length> | <percentage> | inherit
- case CSSPropertyMinWidth: // <length> | <percentage> | inherit
- if (id == CSSValueIntrinsic || id == CSSValueMinIntrinsic)
- validPrimitive = true;
- else
- validPrimitive = (!id && validUnit(value, FLength | FPercent | FNonNeg, m_strict));
- break;
- case CSSPropertyFontSize:
- // <absolute-size> | <relative-size> | <length> | <percentage> | inherit
- if (id >= CSSValueXxSmall && id <= CSSValueLarger)
- validPrimitive = true;
- else
- validPrimitive = (validUnit(value, FLength | FPercent | FNonNeg, m_strict));
- break;
- case CSSPropertyFontStyle: // normal | italic | oblique | inherit
- return parseFontStyle(important);
- case CSSPropertyFontVariant: // normal | small-caps | inherit
- return parseFontVariant(important);
- case CSSPropertyVerticalAlign:
- // baseline | sub | super | top | text-top | middle | bottom | text-bottom |
- // <percentage> | <length> | inherit
- if (id >= CSSValueBaseline && id <= CSSValueWebkitBaselineMiddle)
- validPrimitive = true;
- else
- validPrimitive = (!id && validUnit(value, FLength | FPercent, m_strict));
- break;
- case CSSPropertyHeight: // <length> | <percentage> | auto | inherit
- case CSSPropertyWidth: // <length> | <percentage> | auto | inherit
- if (id == CSSValueAuto || id == CSSValueIntrinsic || id == CSSValueMinIntrinsic)
- validPrimitive = true;
- else
- // ### handle multilength case where we allow relative units
- validPrimitive = (!id && validUnit(value, FLength | FPercent | FNonNeg, m_strict));
- break;
- case CSSPropertyBottom: // <length> | <percentage> | auto | inherit
- case CSSPropertyLeft: // <length> | <percentage> | auto | inherit
- case CSSPropertyRight: // <length> | <percentage> | auto | inherit
- case CSSPropertyTop: // <length> | <percentage> | auto | inherit
- case CSSPropertyMarginTop: //// <margin-width> | inherit
- case CSSPropertyMarginRight: // Which is defined as
- case CSSPropertyMarginBottom: // <length> | <percentage> | auto | inherit
- case CSSPropertyMarginLeft: ////
- case CSSPropertyWebkitMarginStart:
- if (id == CSSValueAuto)
- validPrimitive = true;
- else
- validPrimitive = (!id && validUnit(value, FLength | FPercent, m_strict));
- break;
- case CSSPropertyZIndex: // auto | <integer> | inherit
- if (id == CSSValueAuto) {
- validPrimitive = true;
- break;
- }
- /* nobreak */
- case CSSPropertyOrphans: // <integer> | inherit
- case CSSPropertyWidows: // <integer> | inherit
- // ### not supported later on
- validPrimitive = (!id && validUnit(value, FInteger, false));
- break;
- case CSSPropertyLineHeight: // normal | <number> | <length> | <percentage> | inherit
- if (id == CSSValueNormal)
- validPrimitive = true;
- else
- validPrimitive = (!id && validUnit(value, FNumber | FLength | FPercent | FNonNeg, m_strict));
- break;
- case CSSPropertyCounterIncrement: // [ <identifier> <integer>? ]+ | none | inherit
- if (id != CSSValueNone)
- return parseCounter(propId, 1, important);
- validPrimitive = true;
- break;
- case CSSPropertyCounterReset: // [ <identifier> <integer>? ]+ | none | inherit
- if (id != CSSValueNone)
- return parseCounter(propId, 0, important);
- validPrimitive = true;
- break;
- case CSSPropertyFontFamily:
- // [[ <family-name> | <generic-family> ],]* [<family-name> | <generic-family>] | inherit
- {
- parsedValue = parseFontFamily();
- break;
- }
- case CSSPropertyTextDecoration:
- case CSSPropertyWebkitTextDecorationsInEffect:
- // none | [ underline || overline || line-through || blink ] | inherit
- if (id == CSSValueNone) {
- validPrimitive = true;
- } else {
- RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
- bool isValid = true;
- while (isValid && value) {
- switch (value->id) {
- case CSSValueBlink:
- break;
- case CSSValueUnderline:
- case CSSValueOverline:
- case CSSValueLineThrough:
- list->append(CSSPrimitiveValue::createIdentifier(value->id));
- break;
- default:
- isValid = false;
- }
- value = m_valueList->next();
- }
- if (list->length() && isValid) {
- parsedValue = list.release();
- m_valueList->next();
- }
- }
- break;
- case CSSPropertyZoom: // normal | reset | document | <number> | <percentage> | inherit
- if (id == CSSValueNormal || id == CSSValueReset || id == CSSValueDocument)
- validPrimitive = true;
- else
- validPrimitive = (!id && validUnit(value, FNumber | FPercent | FNonNeg, true));
- break;
-
- case CSSPropertyTableLayout: // auto | fixed | inherit
- if (id == CSSValueAuto || id == CSSValueFixed)
- validPrimitive = true;
- break;
- case CSSPropertySrc: // Only used within @font-face, so cannot use inherit | initial or be !important. This is a list of urls or local references.
- return parseFontFaceSrc();
- case CSSPropertyUnicodeRange:
- return parseFontFaceUnicodeRange();
- /* CSS3 properties */
- case CSSPropertyWebkitAppearance:
- if ((id >= CSSValueCheckbox && id <= CSSValueTextarea) || id == CSSValueNone)
- validPrimitive = true;
- break;
- case CSSPropertyWebkitBinding:
- #if ENABLE(XBL)
- if (id == CSSValueNone)
- validPrimitive = true;
- else {
- RefPtr<CSSValueList> values = CSSValueList::createCommaSeparated();
- CSSParserValue* val;
- RefPtr<CSSValue> parsedValue;
- while ((val = m_valueList->current())) {
- if (val->unit == CSSPrimitiveValue::CSS_URI && m_styleSheet) {
- // FIXME: The completeURL call should be done when using the CSSPrimitiveValue,
- // not when creating it.
- parsedValue = CSSPrimitiveValue::create(m_styleSheet->completeURL(val->string), CSSPrimitiveValue::CSS_URI);
- }
- if (!parsedValue)
- break;
-
- // FIXME: We can't use release() here since we might hit this path twice
- // but that logic seems wrong to me to begin with, we convert all non-uri values
- // into the last seen URI value!?
- // -webkit-binding: url(foo.xml), 1, 2; (if that were valid) is treated as:
- // -webkit-binding: url(foo.xml), url(foo.xml), url(foo.xml); !?
- values->append(parsedValue.get());
- m_valueList->next();
- }
- if (!values->length())
- return false;
-
- addProperty(propId, values.release(), important);
- m_valueList->next();
- return true;
- }
- #endif
- break;
- case CSSPropertyWebkitBorderImage:
- case CSSPropertyWebkitMaskBoxImage:
- if (id == CSSValueNone)
- validPrimitive = true;
- else {
- RefPtr<CSSValue> result;
- if (parseBorderImage(propId, important, result)) {
- addProperty(propId, result, important);
- return true;
- }
- }
- break;
- case CSSPropertyBorderTopRightRadius:
- case CSSPropertyBorderTopLeftRadius:
- case CSSPropertyBorderBottomLeftRadius:
- case CSSPropertyBorderBottomRightRadius: {
- if (num != 1 && num != 2)
- return false;
- validPrimitive = validUnit(value, FLength, m_strict);
- if (!validPrimitive)
- return false;
- RefPtr<CSSPrimitiveValue> parsedValue1 = CSSPrimitiveValue::create(value->fValue, (CSSPrimitiveValue::UnitTypes)value->unit);
- RefPtr<CSSPrimitiveValue> parsedValue2;
- if (num == 2) {
- value = m_valueList->next();
- validPrimitive = validUnit(value, FLength, m_strict);
- if (!validPrimitive)
- return false;
- parsedValue2 = CSSPrimitiveValue::create(value->fValue, (CSSPrimitiveValue::UnitTypes)value->unit);
- } else
- parsedValue2 = parsedValue1;
- RefPtr<Pair> pair = Pair::create(parsedValue1.release(), parsedValue2.release());
- RefPtr<CSSPrimitiveValue> val = CSSPrimitiveValue::create(pair.release());
- addProperty(propId, val.release(), important);
- return true;
- }
- case CSSPropertyBorderRadius:
- case CSSPropertyWebkitBorderRadius:
- return parseBorderRadius(propId, important);
- case CSSPropertyOutlineOffset:
- validPrimitive = validUnit(value, FLength, m_strict);
- break;
- case CSSPropertyTextShadow: // CSS2 property, dropped in CSS2.1, back in CSS3, so treat as CSS3
- case CSSPropertyWebkitBoxShadow:
- if (id == CSSValueNone)
- validPrimitive = true;
- else
- return parseShadow(propId, important);
- break;
- case CSSPropertyWebkitBoxReflect:
- if (id == CSSValueNone)
- validPrimitive = true;
- else
- return parseReflect(propId, important);
- break;
- case CSSPropertyOpacity:
- validPrimitive = validUnit(value, FNumber, m_strict);
- break;
- case CSSPropertyWebkitBoxAlign:
- if (id == CSSValueStretch || id == CSSValueStart || id == CSSValueEnd ||
- id == CSSValueCenter || id == CSSValueBaseline)
- validPrimitive = true;
- break;
- case CSSPropertyWebkitBoxDirection:
- if (id == CSSValueNormal || id == CSSValueReverse)
- validPrimitive = true;
- break;
- case CSSPropertyWebkitBoxLines:
- if (id == CSSValueSingle || id == CSSValueMultiple)
- validPrimitive = true;
- break;
- case CSSPropertyWebkitBoxOrient:
- if (id == CSSValueHorizontal || id == CSSValueVertical ||
- id == CSSValueInlineAxis || id == CSSValueBlockAxis)
- validPrimitive = true;
- break;
- case CSSPropertyWebkitBoxPack:
- if (id == CSSValueStart || id == CSSValueEnd ||
- id == CSSValueCenter || id == CSSValueJustify)
- validPrimitive = true;
- break;
- case CSSPropertyWebkitBoxFlex:
- validPrimitive = validUnit(value, FNumber, m_strict);
- break;
- case CSSPropertyWebkitBoxFlexGroup:
- case CSSPropertyWebkitBoxOrdinalGroup:
- validPrimitive = validUnit(value, FInteger | FNonNeg, true);
- break;
- case CSSPropertyWebkitBoxSizing:
- validPrimitive = id == CSSValueBorderBox || id == CSSValueContentBox;
- break;
- case CSSPropertyWebkitColorCorrection:
- validPrimitive = id == CSSValueSrgb || id == CSSValueDefault;
- break;
- case CSSPropertyWebkitMarquee: {
- const int properties[5] = { CSSPropertyWebkitMarqueeDirection, CSSPropertyWebkitMarqueeIncrement,
- CSSPropertyWebkitMarqueeRepetition,
- CSSPropertyWebkitMarqueeStyle, CSSPropertyWebkitMarqueeSpeed };
- return parseShorthand(propId, properties, 5, important);
- }
- case CSSPropertyWebkitMarqueeDirection:
- if (id == CSSValueForwards || id == CSSValueBackwards || id == CSSValueAhead ||…