#include "core/css/CSSKeyframesRule.h"
#include "core/css/CSSLineBoxContainValue.h"
#include "core/css/CSSPrimitiveValue.h"
+#include "core/css/CSSPropertyMetadata.h"
#include "core/css/CSSPropertySourceData.h"
#include "core/css/CSSReflectValue.h"
#include "core/css/CSSSVGDocumentValue.h"
#include "core/css/HashTools.h"
#include "core/css/Pair.h"
#include "core/css/Rect.h"
-#include "core/css/RuntimeCSSEnabled.h"
-#include "core/css/parser/BisonCSSParser.h"
#include "core/css/parser/CSSParserIdioms.h"
#include "core/css/parser/CSSParserValues.h"
#include "core/frame/UseCounter.h"
static const double MAX_SCALE = 1000000;
template <unsigned N>
-static bool equal(const CSSParserString& a, const char (&b)[N])
-{
- unsigned length = N - 1; // Ignore the trailing null character
- if (a.length() != length)
- return false;
-
- return a.is8Bit() ? WTF::equal(a.characters8(), reinterpret_cast<const LChar*>(b), length) : WTF::equal(a.characters16(), reinterpret_cast<const LChar*>(b), length);
-}
-
-template <unsigned N>
static bool equalIgnoringCase(const CSSParserString& a, const char (&b)[N])
{
unsigned length = N - 1; // Ignore the trailing null character
return cssValuePool().createValue(Pair::create(first, second, identicalValuesPolicy));
}
-CSSPropertyParser::CSSPropertyParser(OwnPtr<CSSParserValueList>& valueList,
- const CSSParserContext& context, bool inViewport, bool savedImportant,
+CSSPropertyParser::CSSPropertyParser(CSSParserValueList* valueList,
+ const CSSParserContext& context, bool inViewport,
WillBeHeapVector<CSSProperty, 256>& parsedProperties,
CSSRuleSourceData::Type ruleType)
: m_valueList(valueList)
, m_context(context)
, m_inViewport(inViewport)
- , m_important(savedImportant) // See comment in header, should be removed.
, m_parsedProperties(parsedProperties)
, m_ruleType(ruleType)
, m_inParseShorthand(0)
{
}
-CSSPropertyParser::~CSSPropertyParser()
+bool CSSPropertyParser::parseValue(CSSPropertyID property, bool important,
+ CSSParserValueList* valueList, const CSSParserContext& context, bool inViewport,
+ WillBeHeapVector<CSSProperty, 256>& parsedProperties, CSSRuleSourceData::Type ruleType)
{
+ CSSPropertyParser parser(valueList, context, inViewport, parsedProperties, ruleType);
+ return parser.parseValue(property, important);
}
void CSSPropertyParser::addPropertyWithPrefixingVariant(CSSPropertyID propId, PassRefPtrWillBeRawPtr<CSSValue> value, bool important, bool implicit)
return value && value->unit == CSSParserValue::Operator && value->iValue == ',';
}
+static bool consumeComma(CSSParserValueList* valueList)
+{
+ if (!isComma(valueList->current()))
+ return false;
+ valueList->next();
+ return true;
+}
+
static inline bool isForwardSlashOperator(CSSParserValue* value)
{
ASSERT(value);
if (val->unit != CSSParserValue::Function)
return false;
- return equalIgnoringCase(val->function->name, "-webkit-gradient(")
- || equalIgnoringCase(val->function->name, "-webkit-linear-gradient(")
- || equalIgnoringCase(val->function->name, "linear-gradient(")
- || equalIgnoringCase(val->function->name, "-webkit-repeating-linear-gradient(")
- || equalIgnoringCase(val->function->name, "repeating-linear-gradient(")
- || equalIgnoringCase(val->function->name, "-webkit-radial-gradient(")
- || equalIgnoringCase(val->function->name, "radial-gradient(")
- || equalIgnoringCase(val->function->name, "-webkit-repeating-radial-gradient(")
- || equalIgnoringCase(val->function->name, "repeating-radial-gradient(")
- || equalIgnoringCase(val->function->name, "-webkit-canvas(")
- || equalIgnoringCase(val->function->name, "-webkit-cross-fade(");
+ return equalIgnoringCase(val->function->name, "-webkit-gradient")
+ || equalIgnoringCase(val->function->name, "-webkit-linear-gradient")
+ || equalIgnoringCase(val->function->name, "linear-gradient")
+ || equalIgnoringCase(val->function->name, "-webkit-repeating-linear-gradient")
+ || equalIgnoringCase(val->function->name, "repeating-linear-gradient")
+ || equalIgnoringCase(val->function->name, "-webkit-radial-gradient")
+ || equalIgnoringCase(val->function->name, "radial-gradient")
+ || equalIgnoringCase(val->function->name, "-webkit-repeating-radial-gradient")
+ || equalIgnoringCase(val->function->name, "repeating-radial-gradient")
+ || equalIgnoringCase(val->function->name, "-webkit-canvas")
+ || equalIgnoringCase(val->function->name, "-webkit-cross-fade");
}
bool CSSPropertyParser::validWidthOrHeight(CSSParserValue* value)
case CSSPropertySize: // <length>{1,2} | auto | [ <page-size> || [ portrait | landscape] ]
return parseSize(propId, important);
- case CSSPropertyQuotes: // [<string> <string>]+ | none | inherit
- if (id)
+ case CSSPropertyQuotes: // [<string> <string>]+ | none
+ if (id == CSSValueNone)
validPrimitive = true;
else
- return parseQuotes(propId, important);
- break;
- case CSSPropertyUnicodeBidi: // normal | embed | bidi-override | isolate | isolate-override | plaintext | inherit
- if (id == CSSValueNormal
- || id == CSSValueEmbed
- || id == CSSValueBidiOverride
- || id == CSSValueWebkitIsolate
- || id == CSSValueWebkitIsolateOverride
- || id == CSSValueWebkitPlaintext)
- validPrimitive = true;
+ parsedValue = parseQuotes();
break;
case CSSPropertyContent: // [ <string> | <uri> | <counter> | attr(X) | open-quote |
return parseFontWeight(important);
}
- case CSSPropertyFontStretch: { // normal | ultra-condensed | extra-condensed | condensed | semi-condensed | semi-expanded | expanded | extra-expanded | ultra-expanded
- if (m_valueList->size() != 1)
- return false;
- return parseFontStretch(important);
- }
-
case CSSPropertyBorderSpacing: {
if (num == 1) {
ShorthandScope scope(this, CSSPropertyBorderSpacing);
case CSSPropertyWebkitTextEmphasisColor:
case CSSPropertyWebkitTextFillColor:
case CSSPropertyWebkitTextStrokeColor:
- if (propId == CSSPropertyTextDecorationColor
- && !RuntimeEnabledFeatures::css3TextDecorationsEnabled())
- return false;
+ ASSERT(propId != CSSPropertyTextDecorationColor || RuntimeEnabledFeatures::css3TextDecorationsEnabled());
if ((id >= CSSValueAqua && id <= CSSValueWebkitText) || id == CSSValueMenu) {
validPrimitive = isValueAllowedInMode(id, m_context.mode());
String uri = value->string;
if (!uri.isNull())
image = createCSSImageValueWithReferrer(uri, completeURL(uri));
- } else if (value->unit == CSSParserValue::Function && equalIgnoringCase(value->function->name, "-webkit-image-set(")) {
- image = parseImageSet(m_valueList.get());
+ } else if (value->unit == CSSParserValue::Function && equalIgnoringCase(value->function->name, "-webkit-image-set")) {
+ image = parseImageSet(m_valueList);
if (!image)
break;
} else
if (image)
list->append(CSSCursorImageValue::create(image, hasHotSpot, hotSpot));
- if (!value || !(value->unit == CSSParserValue::Operator && value->iValue == ','))
+ if (!consumeComma(m_valueList))
return false;
- value = m_valueList->next(); // comma
+ value = m_valueList->current();
}
if (value && m_context.useCounter()) {
if (value->id == CSSValueWebkitZoomIn)
case CSSPropertyBackgroundSize:
case CSSPropertyWebkitBackgroundSize:
case CSSPropertyBackgroundRepeat:
- case CSSPropertyBackgroundRepeatX:
- case CSSPropertyBackgroundRepeatY:
case CSSPropertyWebkitMaskClip:
case CSSPropertyWebkitMaskComposite:
case CSSPropertyWebkitMaskImage:
return result;
}
case CSSPropertyObjectPosition:
- return RuntimeEnabledFeatures::objectFitPositionEnabled() && parseObjectPosition(important);
+ parsedValue = parseObjectPosition();
+ break;
case CSSPropertyListStyleImage: // <uri> | none | inherit
case CSSPropertyBorderImageSource:
case CSSPropertyWebkitMaskBoxImageSource:
parsedValue = createCSSImageValueWithReferrer(value->string, completeURL(value->string));
m_valueList->next();
} else if (isGeneratedImageValue(value)) {
- if (parseGeneratedImage(m_valueList.get(), parsedValue))
+ if (parseGeneratedImage(m_valueList, parsedValue))
m_valueList->next();
else
return false;
}
- else if (value->unit == CSSParserValue::Function && equalIgnoringCase(value->function->name, "-webkit-image-set(")) {
- parsedValue = parseImageSet(m_valueList.get());
+ else if (value->unit == CSSParserValue::Function && equalIgnoringCase(value->function->name, "-webkit-image-set")) {
+ parsedValue = parseImageSet(m_valueList);
if (!parsedValue)
return false;
m_valueList->next();
if (id == CSSValueAuto)
validPrimitive = true;
else
- validPrimitive = (!id && validUnit(value, FPositiveInteger, HTMLQuirksMode));
+ validPrimitive = (!id && validUnit(value, FPositiveInteger));
break;
case CSSPropertyZIndex: // auto | <integer> | inherit
if (id == CSSValueAuto)
validPrimitive = true;
else
- validPrimitive = (!id && validUnit(value, FInteger, HTMLQuirksMode));
+ validPrimitive = (!id && validUnit(value, FInteger));
break;
case CSSPropertyLineHeight:
return parseLineHeight(important);
- case CSSPropertyCounterIncrement: // [ <identifier> <integer>? ]+ | none | inherit
- if (id != CSSValueNone)
- return parseCounter(propId, 1, important);
- validPrimitive = true;
+ case CSSPropertyCounterIncrement:
+ if (id == CSSValueNone)
+ validPrimitive = true;
+ else
+ parsedValue = parseCounter(1);
break;
- case CSSPropertyCounterReset: // [ <identifier> <integer>? ]+ | none | inherit
- if (id != CSSValueNone)
- return parseCounter(propId, 0, important);
- validPrimitive = true;
+ case CSSPropertyCounterReset:
+ if (id == CSSValueNone)
+ validPrimitive = true;
+ else
+ parsedValue = parseCounter(0);
break;
case CSSPropertyFontFamily:
// [[ <family-name> | <generic-family> ],]* [<family-name> | <generic-family>] | inherit
// none | [ underline || overline || line-through || blink ] | inherit
return parseTextDecoration(propId, important);
- case CSSPropertyTextDecorationStyle:
- // solid | double | dotted | dashed | wavy
- if (RuntimeEnabledFeatures::css3TextDecorationsEnabled()
- && (id == CSSValueSolid || id == CSSValueDouble || id == CSSValueDotted || id == CSSValueDashed || id == CSSValueWavy))
- validPrimitive = true;
- break;
-
case CSSPropertyTextUnderlinePosition:
// auto | under | inherit
- if (RuntimeEnabledFeatures::css3TextDecorationsEnabled())
- return parseTextUnderlinePosition(important);
- return false;
+ ASSERT(RuntimeEnabledFeatures::css3TextDecorationsEnabled());
+ return parseTextUnderlinePosition(important);
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, HTMLStandardMode));
+ validPrimitive = (!id && validUnit(value, FNumber | FPercent | FNonNeg));
break;
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.
- return parseFontFaceSrc();
+ parsedValue = parseFontFaceSrc();
+ break;
case CSSPropertyUnicodeRange:
- return parseFontFaceUnicodeRange();
+ parsedValue = parseFontFaceUnicodeRange();
+ break;
/* CSS3 properties */
validPrimitive = validUnit(value, FInteger | FNonNeg);
break;
case CSSPropertyWebkitAspectRatio:
- return parseAspectRatio(important);
+ parsedValue = parseAspectRatio();
+ break;
case CSSPropertyBorderRadius:
case CSSPropertyWebkitBorderRadius:
return parseBorderRadius(propId, important);
if (id == CSSValueNone)
validPrimitive = true;
else {
- RefPtrWillBeRawPtr<CSSValueList> shadowValueList = parseShadow(m_valueList.get(), propId);
+ RefPtrWillBeRawPtr<CSSValueList> shadowValueList = parseShadow(m_valueList, propId);
if (shadowValueList) {
addProperty(propId, shadowValueList.release(), important);
m_valueList->next();
if (id == CSSValueNone)
validPrimitive = true;
else
- return parseReflect(propId, important);
+ parsedValue = parseReflect();
break;
case CSSPropertyOpacity:
validPrimitive = validUnit(value, FNumber);
validPrimitive = validUnit(value, FNumber);
break;
case CSSPropertyWebkitBoxFlexGroup:
- validPrimitive = validUnit(value, FInteger | FNonNeg, HTMLStandardMode);
+ validPrimitive = validUnit(value, FInteger | FNonNeg);
break;
case CSSPropertyWebkitBoxOrdinalGroup:
- validPrimitive = validUnit(value, FInteger | FNonNeg, HTMLStandardMode) && value->fValue;
+ validPrimitive = validUnit(value, FInteger | FNonNeg) && value->fValue;
break;
case CSSPropertyWebkitFilter:
if (id == CSSValueNone)
addProperty(CSSPropertyFlexBasis, cssValuePool().createIdentifierValue(CSSValueAuto), important);
return true;
}
- return parseFlex(m_valueList.get(), important);
+ return parseFlex(m_valueList, important);
}
case CSSPropertyFlexBasis:
// FIXME: Support intrinsic dimensions too.
validPrimitive = validUnit(value, FNumber | FNonNeg);
break;
case CSSPropertyOrder:
- validPrimitive = validUnit(value, FInteger, HTMLStandardMode);
+ validPrimitive = validUnit(value, FInteger);
break;
case CSSPropertyInternalMarqueeIncrement:
validPrimitive = validUnit(value, FLength | FPercent);
addProperty(propId, list.release(), important);
return true;
}
+ case CSSPropertyWebkitPerspectiveOriginX:
case CSSPropertyWebkitTransformOriginX:
- parsedValue = parseFillPositionX(m_valueList.get());
+ parsedValue = parseFillPositionX(m_valueList);
if (parsedValue)
m_valueList->next();
break;
+ case CSSPropertyWebkitPerspectiveOriginY:
case CSSPropertyWebkitTransformOriginY:
- parsedValue = parseFillPositionY(m_valueList.get());
+ parsedValue = parseFillPositionY(m_valueList);
if (parsedValue)
m_valueList->next();
break;
return true;
}
break;
- case CSSPropertyPerspectiveOrigin: {
+ case CSSPropertyPerspectiveOrigin:
+ case CSSPropertyWebkitPerspectiveOrigin: {
RefPtrWillBeRawPtr<CSSValueList> list = parseTransformOrigin();
if (!list || list->length() == 3)
return false;
addProperty(propId, list.release(), important);
return true;
}
- case CSSPropertyWebkitPerspectiveOrigin:
- case CSSPropertyWebkitPerspectiveOriginX:
- case CSSPropertyWebkitPerspectiveOriginY: {
- RefPtrWillBeRawPtr<CSSValue> val1 = nullptr;
- RefPtrWillBeRawPtr<CSSValue> val2 = nullptr;
- CSSPropertyID propId1, propId2;
- if (parseWebkitPerspectiveOrigin(propId, propId1, propId2, val1, val2)) {
- addProperty(propId1, val1.release(), important);
- if (val2)
- addProperty(propId2, val2.release(), important);
- return true;
- }
- return false;
- }
case CSSPropertyAnimationDelay:
case CSSPropertyAnimationDirection:
case CSSPropertyAnimationDuration:
case CSSPropertyAnimationPlayState:
case CSSPropertyAnimationIterationCount:
case CSSPropertyAnimationTimingFunction:
- if (!RuntimeEnabledFeatures::cssAnimationUnprefixedEnabled())
- break;
+ ASSERT(RuntimeEnabledFeatures::cssAnimationUnprefixedEnabled());
case CSSPropertyWebkitAnimationDelay:
case CSSPropertyWebkitAnimationDirection:
case CSSPropertyWebkitAnimationDuration:
}
case CSSPropertyJustifySelf:
- if (!RuntimeEnabledFeatures::cssGridLayoutEnabled())
- return false;
-
+ ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
return parseItemPositionOverflowPosition(propId, important);
case CSSPropertyJustifyItems:
- if (!RuntimeEnabledFeatures::cssGridLayoutEnabled())
- return false;
+ ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
if (parseLegacyPosition(propId, important))
return true;
m_valueList->setCurrentIndex(0);
return parseItemPositionOverflowPosition(propId, important);
case CSSPropertyGridAutoFlow:
- if (!RuntimeEnabledFeatures::cssGridLayoutEnabled())
- return false;
+ ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
parsedValue = parseGridAutoFlow(*m_valueList);
break;
case CSSPropertyGridAutoColumns:
case CSSPropertyGridAutoRows:
- if (!RuntimeEnabledFeatures::cssGridLayoutEnabled())
- return false;
+ ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
parsedValue = parseGridTrackSize(*m_valueList);
break;
case CSSPropertyGridTemplateColumns:
case CSSPropertyGridTemplateRows:
- if (!RuntimeEnabledFeatures::cssGridLayoutEnabled())
- return false;
- parsedValue = parseGridTrackList(important);
+ ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
+ parsedValue = parseGridTrackList();
break;
case CSSPropertyGridColumnEnd:
case CSSPropertyGridColumnStart:
case CSSPropertyGridRowEnd:
case CSSPropertyGridRowStart:
- if (!RuntimeEnabledFeatures::cssGridLayoutEnabled())
- return false;
+ ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
parsedValue = parseGridPosition();
break;
case CSSPropertyGridColumn:
case CSSPropertyGridRow:
- if (!RuntimeEnabledFeatures::cssGridLayoutEnabled())
- return false;
+ ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
return parseGridItemPositionShorthand(propId, important);
case CSSPropertyGridArea:
- if (!RuntimeEnabledFeatures::cssGridLayoutEnabled())
- return false;
+ ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
return parseGridAreaShorthand(important);
case CSSPropertyGridTemplateAreas:
- if (!RuntimeEnabledFeatures::cssGridLayoutEnabled())
- return false;
+ ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
parsedValue = parseGridTemplateAreas();
break;
case CSSPropertyGridTemplate:
- if (!RuntimeEnabledFeatures::cssGridLayoutEnabled())
- return false;
+ ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
return parseGridTemplateShorthand(important);
case CSSPropertyGrid:
- if (!RuntimeEnabledFeatures::cssGridLayoutEnabled())
- return false;
+ ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
return parseGridShorthand(important);
case CSSPropertyWebkitMarginCollapse: {
parsedValue = parseColumnWidth();
break;
case CSSPropertyWillChange:
- if (!RuntimeEnabledFeatures::cssWillChangeEnabled())
- return false;
- return parseWillChange(important);
+ parsedValue = parseWillChange();
+ break;
// End of CSS3 properties
// Apple specific properties. These will never be standardized and are purely to
case CSSPropertyWebkitLineClamp:
// When specifying number of lines, don't allow 0 as a valid value
// When specifying either type of unit, require non-negative integers
- validPrimitive = (!id && (value->unit == CSSPrimitiveValue::CSS_PERCENTAGE || value->fValue) && validUnit(value, FInteger | FPercent | FNonNeg, HTMLQuirksMode));
+ validPrimitive = (!id && (value->unit == CSSPrimitiveValue::CSS_PERCENTAGE || value->fValue) && validUnit(value, FInteger | FPercent | FNonNeg));
break;
case CSSPropertyWebkitFontSizeDelta: // <length>
case CSSPropertyWebkitTextStroke:
return parseShorthand(propId, webkitTextStrokeShorthand(), important);
case CSSPropertyAnimation:
- if (!RuntimeEnabledFeatures::cssAnimationUnprefixedEnabled())
- break;
+ ASSERT(RuntimeEnabledFeatures::cssAnimationUnprefixedEnabled());
case CSSPropertyWebkitAnimation:
return parseAnimationShorthand(propId, important);
case CSSPropertyTransition:
break;
case CSSPropertyTouchAction:
- // auto | none | [pan-x || pan-y] | manipulation
- return parseTouchAction(important);
+ parsedValue = parseTouchAction();
+ break;
case CSSPropertyAlignSelf:
ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
return parseItemPositionOverflowPosition(propId, important);
- case CSSPropertyBorderBottomStyle:
- case CSSPropertyBorderCollapse:
- case CSSPropertyBorderLeftStyle:
- case CSSPropertyBorderRightStyle:
- case CSSPropertyBorderTopStyle:
- case CSSPropertyBoxSizing:
- case CSSPropertyCaptionSide:
- case CSSPropertyClear:
- case CSSPropertyDirection:
- case CSSPropertyDisplay:
- case CSSPropertyEmptyCells:
- case CSSPropertyFloat:
- case CSSPropertyFontStyle:
- case CSSPropertyImageRendering:
- case CSSPropertyListStylePosition:
- case CSSPropertyListStyleType:
- case CSSPropertyObjectFit:
- case CSSPropertyOutlineStyle:
- case CSSPropertyOverflowWrap:
- case CSSPropertyOverflowX:
- case CSSPropertyOverflowY:
- case CSSPropertyPageBreakAfter:
- case CSSPropertyPageBreakBefore:
- case CSSPropertyPageBreakInside:
- case CSSPropertyPointerEvents:
- case CSSPropertyPosition:
- case CSSPropertyResize:
- case CSSPropertySpeak:
- case CSSPropertyTableLayout:
- case CSSPropertyTextAlignLast:
- case CSSPropertyTextJustify:
- case CSSPropertyTextOverflow:
- case CSSPropertyTextRendering:
- case CSSPropertyTextTransform:
- case CSSPropertyTouchActionDelay:
- case CSSPropertyVisibility:
- case CSSPropertyWebkitAppearance:
- case CSSPropertyBackfaceVisibility:
- case CSSPropertyWebkitBackfaceVisibility:
- case CSSPropertyWebkitBorderAfterStyle:
- case CSSPropertyWebkitBorderBeforeStyle:
- case CSSPropertyWebkitBorderEndStyle:
- case CSSPropertyWebkitBorderFit:
- case CSSPropertyWebkitBorderStartStyle:
- case CSSPropertyWebkitBoxAlign:
- case CSSPropertyWebkitBoxDecorationBreak:
- case CSSPropertyWebkitBoxDirection:
- case CSSPropertyWebkitBoxLines:
- case CSSPropertyWebkitBoxOrient:
- case CSSPropertyWebkitBoxPack:
- case CSSPropertyInternalCallback:
- case CSSPropertyWebkitColumnBreakAfter:
- case CSSPropertyWebkitColumnBreakBefore:
- case CSSPropertyWebkitColumnBreakInside:
- case CSSPropertyColumnFill:
- case CSSPropertyWebkitColumnRuleStyle:
- case CSSPropertyAlignContent:
- case CSSPropertyFlexDirection:
- case CSSPropertyFlexWrap:
- case CSSPropertyJustifyContent:
- case CSSPropertyFontKerning:
- case CSSPropertyWebkitFontSmoothing:
- case CSSPropertyWebkitLineBreak:
- case CSSPropertyWebkitMarginAfterCollapse:
- case CSSPropertyWebkitMarginBeforeCollapse:
- case CSSPropertyWebkitMarginBottomCollapse:
- case CSSPropertyWebkitMarginTopCollapse:
- case CSSPropertyInternalMarqueeDirection:
- case CSSPropertyInternalMarqueeStyle:
- case CSSPropertyWebkitPrintColorAdjust:
- case CSSPropertyWebkitRtlOrdering:
- case CSSPropertyWebkitRubyPosition:
- case CSSPropertyWebkitTextCombine:
- case CSSPropertyWebkitTextEmphasisPosition:
- case CSSPropertyWebkitTextSecurity:
- case CSSPropertyTransformStyle:
- case CSSPropertyWebkitTransformStyle:
- case CSSPropertyWebkitUserDrag:
- case CSSPropertyWebkitUserModify:
- case CSSPropertyWebkitUserSelect:
- case CSSPropertyWebkitWritingMode:
- case CSSPropertyWhiteSpace:
- case CSSPropertyWordBreak:
- case CSSPropertyWordWrap:
- case CSSPropertyMixBlendMode:
- case CSSPropertyIsolation:
- // These properties should be handled before in isValidKeywordPropertyAndValue().
- ASSERT_NOT_REACHED();
- return false;
// Properties below are validated inside parseViewportProperty, because we
// check for parser state. We need to invalidate if someone adds them outside
// a @viewport rule.
validPrimitive = false;
break;
- case CSSPropertyAll:
- if (id == CSSValueInitial || id == CSSValueInherit || id == CSSValueUnset) {
- validPrimitive = true;
- break;
- }
- return false;
-
default:
return parseSVGValue(propId, important);
}
values[i] = CSSValueList::createCommaSeparated();
while (m_valueList->current()) {
- CSSParserValue* val = m_valueList->current();
- if (val->unit == CSSParserValue::Operator && val->iValue == ',') {
+ if (consumeComma(m_valueList)) {
// We hit the end. Fill in all remaining values with the initial value.
- m_valueList->next();
for (size_t i = 0; i < numProperties; ++i) {
if (!parsedProperty[i])
values[i]->append(cssValuePool().createImplicitInitialValue());
values[i] = CSSValueList::createCommaSeparated();
while (m_valueList->current()) {
- CSSParserValue* val = m_valueList->current();
- if (val->unit == CSSParserValue::Operator && val->iValue == ',') {
+ if (consumeComma(m_valueList)) {
// We hit the end. Fill in all remaining values with the initial value.
- m_valueList->next();
for (size_t i = 0; i < numProperties; ++i) {
if (!parsedProperty[i])
values[i]->append(cssValuePool().createImplicitInitialValue());
{
CSSParserValue* value = m_valueList->current();
if (value->id == CSSValueAuto
- || (!value->id && validUnit(value, FPositiveInteger, HTMLQuirksMode))) {
+ || (!value->id && validUnit(value, FPositiveInteger))) {
RefPtrWillBeRawPtr<CSSValue> parsedValue = parseValidPrimitive(value->id, value);
m_valueList->next();
return parsedValue;
return true;
// Fill in any remaining properties with the initial value.
- ImplicitScope implicitScope(this, PropertyImplicit);
+ ImplicitScope implicitScope(this);
const StylePropertyShorthand* const* const propertiesForInitialization = shorthand.propertiesForInitialization();
for (unsigned i = 0; i < shorthand.length(); ++i) {
if (propertyFound[i])
if (!parseValue(properties[0], important))
return false;
CSSValue* value = m_parsedProperties.last().value();
- ImplicitScope implicitScope(this, PropertyImplicit);
+ ImplicitScope implicitScope(this);
addProperty(properties[1], value, important);
addProperty(properties[2], value, important);
addProperty(properties[3], value, important);
if (!parseValue(properties[0], important) || !parseValue(properties[1], important))
return false;
CSSValue* value = m_parsedProperties[m_parsedProperties.size() - 2].value();
- ImplicitScope implicitScope(this, PropertyImplicit);
+ ImplicitScope implicitScope(this);
addProperty(properties[2], value, important);
value = m_parsedProperties[m_parsedProperties.size() - 2].value();
addProperty(properties[3], value, important);
if (!parseValue(properties[0], important) || !parseValue(properties[1], important) || !parseValue(properties[2], important))
return false;
CSSValue* value = m_parsedProperties[m_parsedProperties.size() - 2].value();
- ImplicitScope implicitScope(this, PropertyImplicit);
+ ImplicitScope implicitScope(this);
addProperty(properties[3], value, important);
break;
}
}
}
-// [ <string> <string> ]+ | inherit | none
-// inherit and none are handled in parseValue.
-bool CSSPropertyParser::parseQuotes(CSSPropertyID propId, bool important)
+// [ <string> <string> ]+ | none, but none is handled in parseValue
+PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseQuotes()
{
RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createCommaSeparated();
while (CSSParserValue* val = m_valueList->current()) {
RefPtrWillBeRawPtr<CSSValue> parsedValue = nullptr;
- if (val->unit == CSSPrimitiveValue::CSS_STRING)
- parsedValue = CSSPrimitiveValue::create(val->string, CSSPrimitiveValue::CSS_STRING);
- else
- break;
+ if (val->unit != CSSPrimitiveValue::CSS_STRING)
+ return nullptr;
+ parsedValue = CSSPrimitiveValue::create(val->string, CSSPrimitiveValue::CSS_STRING);
values->append(parsedValue.release());
m_valueList->next();
}
- if (values->length() && values->length() % 2 == 0) {
- addProperty(propId, values.release(), important);
- m_valueList->next();
- return true;
- }
- return false;
+ if (values->length() && values->length() % 2 == 0)
+ return values.release();
+ return nullptr;
}
// [ <string> | <uri> | <counter> | attr(X) | open-quote | close-quote | no-open-quote | no-close-quote ]+ | inherit
CSSParserValueList* args = val->function->args.get();
if (!args)
return false;
- if (equalIgnoringCase(val->function->name, "attr(")) {
+ if (equalIgnoringCase(val->function->name, "attr")) {
parsedValue = parseAttr(args);
if (!parsedValue)
return false;
- } else if (equalIgnoringCase(val->function->name, "counter(")) {
+ } else if (equalIgnoringCase(val->function->name, "counter")) {
parsedValue = parseCounterContent(args, false);
if (!parsedValue)
return false;
- } else if (equalIgnoringCase(val->function->name, "counters(")) {
+ } else if (equalIgnoringCase(val->function->name, "counters")) {
parsedValue = parseCounterContent(args, true);
if (!parsedValue)
return false;
- } else if (equalIgnoringCase(val->function->name, "-webkit-image-set(")) {
- parsedValue = parseImageSet(m_valueList.get());
+ } else if (equalIgnoringCase(val->function->name, "-webkit-image-set")) {
+ parsedValue = parseImageSet(m_valueList);
if (!parsedValue)
return false;
} else if (isGeneratedImageValue(val)) {
- if (!parseGeneratedImage(m_valueList.get(), parsedValue))
+ if (!parseGeneratedImage(m_valueList, parsedValue))
return false;
} else
return false;
} else if (val->unit == CSSPrimitiveValue::CSS_IDENT) {
- // open-quote
- // close-quote
- // no-open-quote
- // no-close-quote
- // inherit
- // FIXME: These are not yet implemented (http://bugs.webkit.org/show_bug.cgi?id=6503).
- // none
- // normal
switch (val->id) {
case CSSValueOpenQuote:
case CSSValueCloseQuote:
if (isGeneratedImageValue(valueList->current()))
return parseGeneratedImage(valueList, value);
- if (valueList->current()->unit == CSSParserValue::Function && equalIgnoringCase(valueList->current()->function->name, "-webkit-image-set(")) {
- value = parseImageSet(m_valueList.get());
+ if (valueList->current()->unit == CSSParserValue::Function && equalIgnoringCase(valueList->current()->function->name, "-webkit-image-set")) {
+ value = parseImageSet(m_valueList);
if (value)
return true;
}
break;
case CSSPropertyBackgroundImage:
case CSSPropertyWebkitMaskImage:
- if (parseFillImage(m_valueList.get(), currValue))
+ if (parseFillImage(m_valueList, currValue))
m_valueList->next();
break;
case CSSPropertyWebkitBackgroundClip:
break;
case CSSPropertyBackgroundPosition:
case CSSPropertyWebkitMaskPosition:
- parseFillPosition(m_valueList.get(), currValue, currValue2);
+ parseFillPosition(m_valueList, currValue, currValue2);
// parseFillPosition advances the m_valueList pointer.
break;
case CSSPropertyBackgroundPositionX:
case CSSPropertyWebkitMaskPositionX: {
- currValue = parseFillPositionX(m_valueList.get());
+ currValue = parseFillPositionX(m_valueList);
if (currValue)
m_valueList->next();
break;
}
case CSSPropertyBackgroundPositionY:
case CSSPropertyWebkitMaskPositionY: {
- currValue = parseFillPositionY(m_valueList.get());
+ currValue = parseFillPositionY(m_valueList);
if (currValue)
m_valueList->next();
break;
break;
}
case CSSPropertyMaskSourceType: {
- if (RuntimeEnabledFeatures::cssMaskSourceTypeEnabled()) {
- if (val->id == CSSValueAuto || val->id == CSSValueAlpha || val->id == CSSValueLuminance) {
- currValue = cssValuePool().createIdentifierValue(val->id);
- m_valueList->next();
- } else {
- currValue = nullptr;
- }
+ ASSERT(RuntimeEnabledFeatures::cssMaskSourceTypeEnabled());
+ if (val->id == CSSValueAuto || val->id == CSSValueAlpha || val->id == CSSValueLuminance) {
+ currValue = cssValuePool().createIdentifierValue(val->id);
+ m_valueList->next();
+ } else {
+ currValue = nullptr;
}
break;
}
// Since all is valid css property keyword, cssPropertyID for all
// returns non-null value. We need to check "all" before
// cssPropertyID check.
- if (equalIgnoringCase(value, "all"))
+ if (value->id == CSSValueAll)
return cssValuePool().createIdentifierValue(CSSValueAll);
- CSSPropertyID result = cssPropertyID(value->string);
- if (result && RuntimeCSSEnabled::isCSSPropertyEnabled(result))
- return cssValuePool().createIdentifierValue(result);
- if (equalIgnoringCase(value, "none"))
+ CSSPropertyID property = cssPropertyID(value->string);
+ if (property) {
+ ASSERT(CSSPropertyMetadata::isEnabledProperty(property));
+ return cssValuePool().createIdentifierValue(property);
+ }
+ if (value->id == CSSValueNone)
return cssValuePool().createIdentifierValue(CSSValueNone);
- if (equalIgnoringCase(value, "inherit") || equalIgnoringCase(value, "initial"))
+ if (value->id == CSSValueInitial || value->id == CSSValueInherit)
return nullptr;
return createPrimitiveStringValue(value);
}
RefPtrWillBeRawPtr<CSSValue> originY = nullptr;
RefPtrWillBeRawPtr<CSSValue> originZ = nullptr;
- parse2ValuesFillPosition(m_valueList.get(), originX, originY);
+ parse2ValuesFillPosition(m_valueList, originX, originY);
if (m_valueList->current()) {
if (!validUnit(m_valueList->current(), FLength))
if (!v)
// The last number in the function has no comma after it, so we're done.
return true;
- if (!isComma(v))
- return false;
- args->next();
- return true;
+ return consumeComma(args);
}
PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAnimationTimingFunction()
CSSParserValue* value = m_valueList->current();
if (value->id == CSSValueEase || value->id == CSSValueLinear || value->id == CSSValueEaseIn || value->id == CSSValueEaseOut
|| value->id == CSSValueEaseInOut || value->id == CSSValueStepStart || value->id == CSSValueStepEnd
- || (value->id == CSSValueStepMiddle && RuntimeEnabledFeatures::webAnimationsElementAnimateEnabled()))
+ || value->id == CSSValueStepMiddle)
return cssValuePool().createIdentifierValue(value->id);
// We must be a function.
CSSParserValueList* args = value->function->args.get();
- if (equalIgnoringCase(value->function->name, "steps(")) {
+ if (equalIgnoringCase(value->function->name, "steps")) {
// For steps, 1 or 2 params must be specified (comma-separated)
if (!args || (args->size() != 1 && args->size() != 3))
return nullptr;
// There are two values.
int numSteps;
- StepsTimingFunction::StepAtPosition stepAtPosition = StepsTimingFunction::StepAtEnd;
+ StepsTimingFunction::StepAtPosition stepAtPosition = StepsTimingFunction::End;
CSSParserValue* v = args->current();
if (!validUnit(v, FInteger))
numSteps = clampToInteger(v->fValue);
if (numSteps < 1)
return nullptr;
- v = args->next();
- if (v) {
+ if (args->next()) {
// There is a comma so we need to parse the second value
- if (!isComma(v))
+ if (!consumeComma(args))
return nullptr;
- v = args->next();
- switch (v->id) {
+ switch (args->current()->id) {
case CSSValueMiddle:
if (!RuntimeEnabledFeatures::webAnimationsAPIEnabled())
return nullptr;
- stepAtPosition = StepsTimingFunction::StepAtMiddle;
+ stepAtPosition = StepsTimingFunction::Middle;
break;
case CSSValueStart:
- stepAtPosition = StepsTimingFunction::StepAtStart;
+ stepAtPosition = StepsTimingFunction::Start;
break;
case CSSValueEnd:
- stepAtPosition = StepsTimingFunction::StepAtEnd;
+ stepAtPosition = StepsTimingFunction::End;
break;
default:
return nullptr;
return CSSStepsTimingFunctionValue::create(numSteps, stepAtPosition);
}
- if (equalIgnoringCase(value->function->name, "cubic-bezier(")) {
+ if (equalIgnoringCase(value->function->name, "cubic-bezier")) {
// For cubic bezier, 4 values must be specified.
if (!args || args->size() != 7)
return nullptr;
// This will handle the trailing/leading <custom-ident>* in the grammar.
trailingIdentWasAdded = false;
- if (m_valueList->current() && m_valueList->current()->unit == CSSParserValue::ValueList) {
- parseGridLineNames(*m_valueList, *templateRows);
- trailingIdentWasAdded = true;
- }
+ if (m_valueList->current() && m_valueList->current()->unit == CSSParserValue::ValueList)
+ trailingIdentWasAdded = parseGridLineNames(*m_valueList, *templateRows);
}
// [<track-list> /]?
if (firstValueIsNone) {
columnsValue = cssValuePool().createIdentifierValue(CSSValueNone);
} else {
- columnsValue = parseGridTrackList(important);
+ columnsValue = parseGridTrackList();
}
// 2- <grid-template-columns> / <grid-template-columns> syntax.
if (!(m_valueList->current() && isForwardSlashOperator(m_valueList->current()) && m_valueList->next()))
return false;
index = m_valueList->currentIndex();
- if (RefPtrWillBeRawPtr<CSSValue> rowsValue = parseGridTrackList(important)) {
+ if (RefPtrWillBeRawPtr<CSSValue> rowsValue = parseGridTrackList()) {
if (m_valueList->current())
return false;
addProperty(CSSPropertyGridTemplateColumns, columnsValue, important);
bool CSSPropertyParser::parseGridShorthand(bool important)
{
ShorthandScope scope(this, CSSPropertyGrid);
- ASSERT(shorthandForProperty(CSSPropertyGrid).length() == 4);
+ ASSERT(shorthandForProperty(CSSPropertyGrid).length() == 6);
// 1- <grid-template>
if (parseGridTemplateShorthand(important)) {
return true;
}
-void CSSPropertyParser::parseGridLineNames(CSSParserValueList& inputList, CSSValueList& valueList, CSSGridLineNamesValue* previousNamedAreaTrailingLineNames)
+bool CSSPropertyParser::parseGridLineNames(CSSParserValueList& inputList, CSSValueList& valueList, CSSGridLineNamesValue* previousNamedAreaTrailingLineNames)
{
ASSERT(inputList.current() && inputList.current()->unit == CSSParserValue::ValueList);
CSSParserValueList* identList = inputList.current()->valueList;
if (!identList->size()) {
inputList.next();
- return;
+ return false;
}
// Need to ensure the identList is at the heading index, since the parserList might have been rewound.
valueList.append(lineNames.release());
inputList.next();
+ return true;
}
-PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseGridTrackList(bool important)
+PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseGridTrackList()
{
ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
while (CSSParserValue* currentValue = m_valueList->current()) {
if (isForwardSlashOperator(currentValue))
break;
- if (currentValue->unit == CSSParserValue::Function && equalIgnoringCase(currentValue->function->name, "repeat(")) {
+ if (currentValue->unit == CSSParserValue::Function && equalIgnoringCase(currentValue->function->name, "repeat")) {
if (!parseGridTrackRepeatFunction(*values))
return nullptr;
seenTrackSizeOrRepeatFunction = true;
if (currentValue && currentValue->unit == CSSParserValue::ValueList)
parseGridLineNames(*arguments, *repeatedValues);
+ bool seenTrackSize = false;
while (arguments->current()) {
RefPtrWillBeRawPtr<CSSValue> trackSize = parseGridTrackSize(*arguments);
if (!trackSize)
return false;
repeatedValues->append(trackSize);
+ seenTrackSize = true;
// This takes care of any trailing <ident>* in the grammar.
currentValue = arguments->current();
parseGridLineNames(*arguments, *repeatedValues);
}
+ // We should have found at least one <track-size> or else it is not a valid <track-list>.
+ if (!seenTrackSize)
+ return false;
+
for (size_t i = 0; i < repetitions; ++i) {
for (size_t j = 0; j < repeatedValues->length(); ++j)
list.append(repeatedValues->item(j));
if (currentValue->id == CSSValueAuto)
return cssValuePool().createIdentifierValue(CSSValueAuto);
- if (currentValue->unit == CSSParserValue::Function && equalIgnoringCase(currentValue->function->name, "minmax(")) {
+ if (currentValue->unit == CSSParserValue::Function && equalIgnoringCase(currentValue->function->name, "minmax")) {
// The spec defines the following grammar: minmax( <track-breadth> , <track-breadth> )
CSSParserValueList* arguments = currentValue->function->args.get();
if (!arguments || arguments->size() != 3 || !isComma(arguments->valueAt(1)))
return false;
String gridRowNames = currentValue->string;
- if (!gridRowNames.length())
+ if (gridRowNames.isEmpty() || gridRowNames.containsOnlyWhitespace())
return false;
Vector<String> columnNames;
if (!counters)
separator = cssValuePool().createValue(String(), CSSPrimitiveValue::CSS_STRING);
else {
- i = args->next();
- if (i->unit != CSSParserValue::Operator || i->iValue != ',')
+ args->next();
+ if (!consumeComma(args))
return nullptr;
- i = args->next();
+ i = args->current();
if (i->unit != CSSPrimitiveValue::CSS_STRING)
return nullptr;
if (!i) // Make the list style default decimal
listStyle = cssValuePool().createIdentifierValue(CSSValueDecimal);
else {
- if (i->unit != CSSParserValue::Operator || i->iValue != ',')
+ if (!consumeComma(args))
return nullptr;
- i = args->next();
+ i = args->current();
if (i->unit != CSSPrimitiveValue::CSS_IDENT)
return nullptr;
CSSParserValue* value = m_valueList->current();
CSSParserValueList* args = value->function->args.get();
- if (!equalIgnoringCase(value->function->name, "rect(") || !args)
+ if (!equalIgnoringCase(value->function->name, "rect") || !args)
return false;
// rect(t, r, b, l) || rect(t r b l)
if (args->size() != 4 && args->size() != 7)
return false;
RefPtrWillBeRawPtr<Rect> rect = Rect::create();
- bool valid = true;
int i = 0;
CSSParserValue* a = args->current();
while (a) {
- valid = a->id == CSSValueAuto || validUnit(a, FLength);
- if (!valid)
- break;
+ if (a->id != CSSValueAuto && !validUnit(a, FLength))
+ return false;
RefPtrWillBeRawPtr<CSSPrimitiveValue> length = a->id == CSSValueAuto ?
cssValuePool().createIdentifierValue(CSSValueAuto) :
createPrimitiveNumericValue(a);
rect->setLeft(length);
a = args->next();
if (a && args->size() == 7) {
- if (a->unit == CSSParserValue::Operator && a->iValue == ',') {
- a = args->next();
- } else {
- valid = false;
- break;
- }
+ if (!consumeComma(args))
+ return false;
+ a = args->current();
}
i++;
}
- if (valid) {
- addProperty(propId, cssValuePool().createValue(rect.release()), important);
- m_valueList->next();
- return true;
- }
- return false;
+ addProperty(propId, cssValuePool().createValue(rect.release()), important);
+ m_valueList->next();
+ return true;
}
static void completeBorderRadii(RefPtrWillBeRawPtr<CSSPrimitiveValue> radii[4])
radii[3] = radii[1];
}
-// FIXME: This should be refactored with CSSParser::parseBorderRadius.
-// CSSParser::parseBorderRadius contains support for some legacy radius construction.
+// FIXME: This should be refactored with parseBorderRadius.
+// parseBorderRadius contains support for some legacy radius construction.
PassRefPtrWillBeRawPtr<CSSBasicShape> CSSPropertyParser::parseInsetRoundedCorners(PassRefPtrWillBeRawPtr<CSSBasicShapeInset> shape, CSSParserValueList* args)
{
CSSParserValue* argument = args->next();
bool hasRoundedInset = false;
while (argument) {
- if (argument->unit == CSSPrimitiveValue::CSS_IDENT && equalIgnoringCase(argument->string, "round")) {
+ if (argument->unit == CSSPrimitiveValue::CSS_IDENT && argument->id == CSSValueRound) {
hasRoundedInset = true;
break;
}
CSSParserValue* argument = args->current();
if (argument->id == CSSValueEvenodd || argument->id == CSSValueNonzero) {
shape->setWindRule(argument->id == CSSValueEvenodd ? RULE_EVENODD : RULE_NONZERO);
+ args->next();
- if (!isComma(args->next()))
+ if (!consumeComma(args))
return nullptr;
- argument = args->next();
size -= 2;
}
if (!size || (size % 3) - 2)
return nullptr;
- CSSParserValue* argumentX = argument;
- while (argumentX) {
-
- if (!validUnit(argumentX, FLength | FPercent))
+ while (true) {
+ CSSParserValue* argumentX = args->current();
+ if (!argumentX || !validUnit(argumentX, FLength | FPercent))
return nullptr;
RefPtrWillBeRawPtr<CSSPrimitiveValue> xLength = createPrimitiveNumericValue(argumentX);
CSSParserValue* argumentY = args->next();
if (!argumentY || !validUnit(argumentY, FLength | FPercent))
return nullptr;
-
RefPtrWillBeRawPtr<CSSPrimitiveValue> yLength = createPrimitiveNumericValue(argumentY);
shape->appendPoint(xLength.release(), yLength.release());
- CSSParserValue* commaOrNull = args->next();
- if (!commaOrNull)
- argumentX = 0;
- else if (!isComma(commaOrNull))
+ if (!args->next())
+ break;
+ if (!consumeComma(args))
return nullptr;
- else
- argumentX = args->next();
}
return shape;
}
RefPtrWillBeRawPtr<CSSValue> imageValue = nullptr;
- if (valueId != CSSValueNone && parseFillImage(m_valueList.get(), imageValue)) {
+ if (valueId != CSSValueNone && parseFillImage(m_valueList, imageValue)) {
m_valueList->next();
return imageValue.release();
}
return nullptr;
RefPtrWillBeRawPtr<CSSBasicShape> shape = nullptr;
- if (equalIgnoringCase(value->function->name, "circle("))
+ if (equalIgnoringCase(value->function->name, "circle"))
shape = parseBasicShapeCircle(args);
- else if (equalIgnoringCase(value->function->name, "ellipse("))
+ else if (equalIgnoringCase(value->function->name, "ellipse"))
shape = parseBasicShapeEllipse(args);
- else if (equalIgnoringCase(value->function->name, "polygon("))
+ else if (equalIgnoringCase(value->function->name, "polygon"))
shape = parseBasicShapePolygon(args);
- else if (equalIgnoringCase(value->function->name, "inset("))
+ else if (equalIgnoringCase(value->function->name, "inset"))
shape = parseBasicShapeInset(args);
if (!shape)
fontVariantParsed = true;
} else if (!fontWeightParsed && parseFontWeight(important)) {
fontWeightParsed = true;
- } else if (!fontStretchParsed && parseFontStretch(important)) {
+ } else if (!fontStretchParsed && isValidKeywordPropertyAndValue(CSSPropertyFontStretch, value->id, m_context)) {
+ addProperty(CSSPropertyFontStretch, cssValuePool().createIdentifierValue(value->id), important);
fontStretchParsed = true;
} else {
break;
values = CSSValueList::createCommaSeparated();
parsedValue = cssValuePool().createIdentifierValue(val->id);
}
- } else if (val->unit == CSSParserValue::Operator && val->iValue == ',') {
+ } else if (consumeComma(m_valueList)) {
expectComma = false;
- m_valueList->next();
continue;
}
return false;
}
-bool CSSPropertyParser::parseFontStretch(bool important)
-{
- CSSParserValue* value = m_valueList->current();
- if (value->id == CSSValueNormal || (value->id >= CSSValueUltraCondensed && value->id <= CSSValueUltraExpanded)) {
- addProperty(CSSPropertyFontStretch, cssValuePool().createIdentifierValue(value->id), important);
- return true;
- }
- return false;
-}
-
bool CSSPropertyParser::parseFontFaceSrcURI(CSSValueList* valueList)
{
RefPtrWillBeRawPtr<CSSFontFaceSrcValue> uriValue(CSSFontFaceSrcValue::create(completeURL(m_valueList->current()->string)));
return true;
}
- if (value->unit != CSSParserValue::Function || !equalIgnoringCase(value->function->name, "format("))
+ if (value->unit != CSSParserValue::Function || !equalIgnoringCase(value->function->name, "format"))
return false;
// FIXME: http://www.w3.org/TR/2011/WD-css3-fonts-20111004/ says that format() contains a comma-separated list of strings,
return true;
}
-bool CSSPropertyParser::parseFontFaceSrc()
+PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseFontFaceSrc()
{
RefPtrWillBeRawPtr<CSSValueList> values(CSSValueList::createCommaSeparated());
while (CSSParserValue* value = m_valueList->current()) {
if (value->unit == CSSPrimitiveValue::CSS_URI) {
if (!parseFontFaceSrcURI(values.get()))
- return false;
- } else if (value->unit == CSSParserValue::Function && equalIgnoringCase(value->function->name, "local(")) {
+ return nullptr;
+ } else if (value->unit == CSSParserValue::Function && equalIgnoringCase(value->function->name, "local")) {
if (!parseFontFaceSrcLocal(values.get()))
- return false;
- } else
- return false;
+ return nullptr;
+ } else {
+ return nullptr;
+ }
}
if (!values->length())
- return false;
+ return nullptr;
- addProperty(CSSPropertySrc, values.release(), m_important);
m_valueList->next();
- return true;
+ return values.release();
}
-bool CSSPropertyParser::parseFontFaceUnicodeRange()
+PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseFontFaceUnicodeRange()
{
RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createCommaSeparated();
- bool failed = false;
- bool operatorExpected = false;
- for (; m_valueList->current(); m_valueList->next(), operatorExpected = !operatorExpected) {
- if (operatorExpected) {
- if (m_valueList->current()->unit == CSSParserValue::Operator && m_valueList->current()->iValue == ',')
- continue;
- failed = true;
- break;
- }
- if (m_valueList->current()->unit != CSSPrimitiveValue::CSS_UNICODE_RANGE) {
- failed = true;
- break;
- }
- String rangeString = m_valueList->current()->string;
+ do {
+ CSSParserValue* current = m_valueList->current();
+ if (!current || current->unit != CSSPrimitiveValue::CSS_UNICODE_RANGE)
+ return nullptr;
+
+ String rangeString = current->string;
UChar32 from = 0;
UChar32 to = 0;
unsigned length = rangeString.length();
- if (length < 3) {
- failed = true;
- break;
- }
+ if (length < 3)
+ return nullptr;
unsigned i = 2;
while (i < length) {
from += 10 + c - 'A';
else if (c >= 'a' && c <= 'f')
from += 10 + c - 'a';
- else {
- failed = true;
- break;
- }
+ else
+ return nullptr;
i++;
}
- if (failed)
- break;
if (i == length)
to = from;
i++;
}
if (i < length)
- failed = true;
+ return nullptr;
to = from + span - 1;
} else {
- if (length < i + 2) {
- failed = true;
- break;
- }
+ if (length < i + 2)
+ return nullptr;
i++;
while (i < length) {
UChar c = rangeString[i];
to += 10 + c - 'A';
else if (c >= 'a' && c <= 'f')
to += 10 + c - 'a';
- else {
- failed = true;
- break;
- }
+ else
+ return nullptr;
i++;
}
- if (failed)
- break;
}
if (from <= to)
values->append(CSSUnicodeRangeValue::create(from, to));
- }
- if (failed || !values->length())
- return false;
- addProperty(CSSPropertyUnicodeRange, values.release(), m_important);
- return true;
+ m_valueList->next();
+ } while (consumeComma(m_valueList));
+
+ return values.release();
}
// Returns the number of characters which form a valid double
bool CSSPropertyParser::isCalculation(CSSParserValue* value)
{
return (value->unit == CSSParserValue::Function)
- && (equalIgnoringCase(value->function->name, "calc(")
- || equalIgnoringCase(value->function->name, "-webkit-calc("));
+ && (equalIgnoringCase(value->function->name, "calc")
+ || equalIgnoringCase(value->function->name, "-webkit-calc"));
}
inline int CSSPropertyParser::colorIntFromValue(CSSParserValue* v)
CSSParserValue* v = args->current();
Units unitType = FUnknown;
// Get the first value and its type
- if (validUnit(v, FInteger, HTMLStandardMode))
+ if (validUnit(v, FInteger))
unitType = FInteger;
- else if (validUnit(v, FPercent, HTMLStandardMode))
+ else if (validUnit(v, FPercent))
unitType = FPercent;
else
return false;
colorArray[0] = colorIntFromValue(v);
for (int i = 1; i < 3; i++) {
- v = args->next();
- if (v->unit != CSSParserValue::Operator && v->iValue != ',')
+ args->next();
+ if (!consumeComma(args))
return false;
- v = args->next();
- if (!validUnit(v, unitType, HTMLStandardMode))
+ v = args->current();
+ if (!validUnit(v, unitType))
return false;
colorArray[i] = colorIntFromValue(v);
}
if (parseAlpha) {
- v = args->next();
- if (v->unit != CSSParserValue::Operator && v->iValue != ',')
+ args->next();
+ if (!consumeComma(args))
return false;
- v = args->next();
- if (!validUnit(v, FNumber, HTMLStandardMode))
+ v = args->current();
+ if (!validUnit(v, FNumber))
return false;
// Convert the floating pointer number of alpha to an integer in the range [0, 256),
// with an equal distribution across all 256 values.
CSSParserValueList* args = value->function->args.get();
CSSParserValue* v = args->current();
// Get the first value
- if (!validUnit(v, FNumber, HTMLStandardMode))
+ if (!validUnit(v, FNumber))
return false;
// normalize the Hue value and change it to be between 0 and 1.0
colorArray[0] = (((static_cast<int>(v->fValue) % 360) + 360) % 360) / 360.0;
for (int i = 1; i < 3; i++) {
- v = args->next();
- if (v->unit != CSSParserValue::Operator && v->iValue != ',')
+ args->next();
+ if (!consumeComma(args))
return false;
- v = args->next();
- if (!validUnit(v, FPercent, HTMLStandardMode))
+ v = args->current();
+ if (!validUnit(v, FPercent))
return false;
double percentValue = m_parsedCalculation ? m_parsedCalculation.release()->doubleValue() : v->fValue;
colorArray[i] = std::max(0.0, std::min(100.0, percentValue)) / 100.0; // needs to be value between 0 and 1.0
}
if (parseAlpha) {
- v = args->next();
- if (v->unit != CSSParserValue::Operator && v->iValue != ',')
+ args->next();
+ if (!consumeComma(args))
return false;
- v = args->next();
- if (!validUnit(v, FNumber, HTMLStandardMode))
+ v = args->current();
+ if (!validUnit(v, FNumber))
return false;
colorArray[3] = std::max(0.0, std::min(1.0, v->fValue));
}
} else if (value->unit == CSSParserValue::Function &&
value->function->args != 0 &&
value->function->args->size() == 5 /* rgb + two commas */ &&
- equalIgnoringCase(value->function->name, "rgb(")) {
+ equalIgnoringCase(value->function->name, "rgb")) {
int colorValues[3];
if (!parseColorParameters(value, colorValues, false))
return false;
if (value->unit == CSSParserValue::Function &&
value->function->args != 0 &&
value->function->args->size() == 7 /* rgba + three commas */ &&
- equalIgnoringCase(value->function->name, "rgba(")) {
+ equalIgnoringCase(value->function->name, "rgba")) {
int colorValues[4];
if (!parseColorParameters(value, colorValues, true))
return false;
} else if (value->unit == CSSParserValue::Function &&
value->function->args != 0 &&
value->function->args->size() == 5 /* hsl + two commas */ &&
- equalIgnoringCase(value->function->name, "hsl(")) {
+ equalIgnoringCase(value->function->name, "hsl")) {
double colorValues[3];
if (!parseHSLParameters(value, colorValues, false))
return false;
} else if (value->unit == CSSParserValue::Function &&
value->function->args != 0 &&
value->function->args->size() == 7 /* hsla + three commas */ &&
- equalIgnoringCase(value->function->name, "hsla(")) {
+ equalIgnoringCase(value->function->name, "hsla")) {
double colorValues[4];
if (!parseHSLParameters(value, colorValues, true))
return false;
return nullptr;
}
-bool CSSPropertyParser::parseReflect(CSSPropertyID propId, bool important)
+PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseReflect()
{
// box-reflect: <direction> <offset> <mask>
direction = cssValuePool().createIdentifierValue(val->id);
break;
default:
- return false;
+ return nullptr;
}
// The offset comes next.
offset = cssValuePool().createValue(0, CSSPrimitiveValue::CSS_PX);
else {
if (!validUnit(val, FLength | FPercent))
- return false;
+ return nullptr;
offset = createPrimitiveNumericValue(val);
}
RefPtrWillBeRawPtr<CSSValue> mask = nullptr;
val = m_valueList->next();
if (val) {
- mask = parseBorderImage(propId);
+ mask = parseBorderImage(CSSPropertyWebkitBoxReflect);
if (!mask)
- return false;
+ return nullptr;
}
- RefPtrWillBeRawPtr<CSSReflectValue> reflectValue = CSSReflectValue::create(direction.release(), offset.release(), mask.release());
- addProperty(propId, reflectValue.release(), important);
- m_valueList->next();
- return true;
+ return CSSReflectValue::create(direction.release(), offset.release(), mask.release());
}
static bool isFlexBasisMiddleArg(double flexGrow, double flexShrink, double unsetValue, int argSize)
if (flexShrink == unsetValue)
flexShrink = 1;
if (!flexBasis)
- flexBasis = cssValuePool().createValue(0, CSSPrimitiveValue::CSS_PX);
+ flexBasis = cssValuePool().createValue(0, CSSPrimitiveValue::CSS_PERCENTAGE);
addProperty(CSSPropertyFlexGrow, cssValuePool().createValue(clampToFloat(flexGrow), CSSPrimitiveValue::CSS_NUMBER), important);
addProperty(CSSPropertyFlexShrink, cssValuePool().createValue(clampToFloat(flexShrink), CSSPrimitiveValue::CSS_NUMBER), important);
return true;
}
-bool CSSPropertyParser::parseObjectPosition(bool important)
+PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseObjectPosition()
{
RefPtrWillBeRawPtr<CSSValue> xValue = nullptr;
RefPtrWillBeRawPtr<CSSValue> yValue = nullptr;
- parseFillPosition(m_valueList.get(), xValue, yValue);
+ parseFillPosition(m_valueList, xValue, yValue);
if (!xValue || !yValue)
- return false;
- addProperty(
- CSSPropertyObjectPosition,
- createPrimitiveValuePair(toCSSPrimitiveValue(xValue.get()), toCSSPrimitiveValue(yValue.get()), Pair::KeepIdenticalValues),
- important);
- return true;
+ return nullptr;
+ return createPrimitiveValuePair(toCSSPrimitiveValue(xValue.get()), toCSSPrimitiveValue(yValue.get()), Pair::KeepIdenticalValues);
}
class BorderImageParseContext {
context.commitImage(parser.createCSSImageValueWithReferrer(val->string, parser.m_context.completeURL(val->string)));
} else if (isGeneratedImageValue(val)) {
RefPtrWillBeRawPtr<CSSValue> value = nullptr;
- if (parser.parseGeneratedImage(parser.m_valueList.get(), value))
+ if (parser.parseGeneratedImage(parser.m_valueList, value))
context.commitImage(value.release());
else
return false;
- } else if (val->unit == CSSParserValue::Function && equalIgnoringCase(val->function->name, "-webkit-image-set(")) {
- RefPtrWillBeRawPtr<CSSValue> value = parser.parseImageSet(parser.m_valueList.get());
+ } else if (val->unit == CSSParserValue::Function && equalIgnoringCase(val->function->name, "-webkit-image-set")) {
+ RefPtrWillBeRawPtr<CSSValue> value = parser.parseImageSet(parser.m_valueList);
if (value)
context.commitImage(value.release());
else
BorderImageSliceParseContext context(this);
for (CSSParserValue* val = m_valueList->current(); val; val = m_valueList->next()) {
// FIXME calc() http://webkit.org/b/16662 : calc is parsed but values are not created yet.
- if (context.allowNumber() && !isCalculation(val) && validUnit(val, FInteger | FNonNeg | FPercent, HTMLStandardMode)) {
+ if (context.allowNumber() && !isCalculation(val) && validUnit(val, FInteger | FNonNeg | FPercent)) {
context.commitNumber(val);
} else if (context.allowFill() && val->id == CSSValueFill) {
context.commitFill();
} else
completeBorderRadii(radii[1]);
- ImplicitScope implicitScope(this, PropertyImplicit);
+ ImplicitScope implicitScope(this);
addProperty(CSSPropertyBorderTopLeftRadius, createPrimitiveValuePair(radii[0][0].release(), radii[1][0].release()), important);
addProperty(CSSPropertyBorderTopRightRadius, createPrimitiveValuePair(radii[0][1].release(), radii[1][1].release()), important);
addProperty(CSSPropertyBorderBottomRightRadius, createPrimitiveValuePair(radii[0][2].release(), radii[1][2].release()), important);
return true;
}
-bool CSSPropertyParser::parseAspectRatio(bool important)
+PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAspectRatio()
{
unsigned num = m_valueList->size();
if (num == 1 && m_valueList->valueAt(0)->id == CSSValueNone) {
- addProperty(CSSPropertyWebkitAspectRatio, cssValuePool().createIdentifierValue(CSSValueNone), important);
- return true;
+ m_valueList->next();
+ return cssValuePool().createIdentifierValue(CSSValueNone);
}
if (num != 3)
- return false;
+ return nullptr;
- CSSParserValue* lvalue = m_valueList->valueAt(0);
- CSSParserValue* op = m_valueList->valueAt(1);
- CSSParserValue* rvalue = m_valueList->valueAt(2);
+ CSSParserValue* lvalue = m_valueList->current();
+ CSSParserValue* op = m_valueList->next();
+ CSSParserValue* rvalue = m_valueList->next();
+ m_valueList->next();
if (!isForwardSlashOperator(op))
- return false;
+ return nullptr;
if (!validUnit(lvalue, FNumber | FNonNeg) || !validUnit(rvalue, FNumber | FNonNeg))
- return false;
+ return nullptr;
if (!lvalue->fValue || !rvalue->fValue)
- return false;
-
- addProperty(CSSPropertyWebkitAspectRatio, CSSAspectRatioValue::create(narrowPrecisionToFloat(lvalue->fValue), narrowPrecisionToFloat(rvalue->fValue)), important);
+ return nullptr;
- return true;
+ return CSSAspectRatioValue::create(narrowPrecisionToFloat(lvalue->fValue), narrowPrecisionToFloat(rvalue->fValue));
}
-bool CSSPropertyParser::parseCounter(CSSPropertyID propId, int defaultValue, bool important)
+PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseCounter(int defaultValue)
{
- enum { ID, VAL } state = ID;
-
RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
- RefPtrWillBeRawPtr<CSSPrimitiveValue> counterName = nullptr;
- while (true) {
+ while (m_valueList->current()) {
CSSParserValue* val = m_valueList->current();
- switch (state) {
- case ID:
- if (val && val->unit == CSSPrimitiveValue::CSS_IDENT) {
- counterName = createPrimitiveStringValue(val);
- state = VAL;
- m_valueList->next();
- continue;
- }
- break;
- case VAL: {
- int i = defaultValue;
- if (val && val->unit == CSSPrimitiveValue::CSS_NUMBER) {
- i = clampToInteger(val->fValue);
- m_valueList->next();
- }
+ if (val->unit != CSSPrimitiveValue::CSS_IDENT)
+ return nullptr;
+ RefPtrWillBeRawPtr<CSSPrimitiveValue> counterName = createPrimitiveStringValue(val);
+ m_valueList->next();
- list->append(createPrimitiveValuePair(counterName.release(),
- cssValuePool().createValue(i, CSSPrimitiveValue::CSS_NUMBER)));
- state = ID;
- continue;
- }
+ val = m_valueList->current();
+ int i = defaultValue;
+ if (val && validUnit(val, FInteger)) {
+ i = clampToInteger(val->fValue);
+ m_valueList->next();
}
- break;
- }
- if (list->length() > 0) {
- addProperty(propId, list.release(), important);
- return true;
+ list->append(createPrimitiveValuePair(counterName.release(),
+ cssValuePool().createValue(i, CSSPrimitiveValue::CSS_NUMBER)));
}
- return false;
+ if (!list->length())
+ return nullptr;
+ return list.release();
}
// This should go away once we drop support for -webkit-gradient
{
RefPtrWillBeRawPtr<CSSPrimitiveValue> result = nullptr;
if (a->unit == CSSPrimitiveValue::CSS_IDENT) {
- if ((equalIgnoringCase(a, "left") && horizontal)
- || (equalIgnoringCase(a, "top") && !horizontal))
+ if ((a->id == CSSValueLeft && horizontal)
+ || (a->id == CSSValueTop && !horizontal))
result = cssValuePool().createValue(0., CSSPrimitiveValue::CSS_PERCENTAGE);
- else if ((equalIgnoringCase(a, "right") && horizontal)
- || (equalIgnoringCase(a, "bottom") && !horizontal))
+ else if ((a->id == CSSValueRight && horizontal)
+ || (a->id == CSSValueBottom && !horizontal))
result = cssValuePool().createValue(100., CSSPrimitiveValue::CSS_PERCENTAGE);
- else if (equalIgnoringCase(a, "center"))
+ else if (a->id == CSSValueCenter)
result = cssValuePool().createValue(50., CSSPrimitiveValue::CSS_PERCENTAGE);
} else if (a->unit == CSSPrimitiveValue::CSS_NUMBER || a->unit == CSSPrimitiveValue::CSS_PERCENTAGE) {
result = cssValuePool().createValue(a->fValue, static_cast<CSSPrimitiveValue::UnitType>(a->unit));
if (a->unit != CSSParserValue::Function)
return false;
- if (!equalIgnoringCase(a->function->name, "from(") &&
- !equalIgnoringCase(a->function->name, "to(") &&
- !equalIgnoringCase(a->function->name, "color-stop("))
+ if (!equalIgnoringCase(a->function->name, "from") &&
+ !equalIgnoringCase(a->function->name, "to") &&
+ !equalIgnoringCase(a->function->name, "color-stop"))
return false;
CSSParserValueList* args = a->function->args.get();
if (!args)
return false;
- if (equalIgnoringCase(a->function->name, "from(")
- || equalIgnoringCase(a->function->name, "to(")) {
+ if (equalIgnoringCase(a->function->name, "from")
+ || equalIgnoringCase(a->function->name, "to")) {
// The "from" and "to" stops expect 1 argument.
if (args->size() != 1)
return false;
- if (equalIgnoringCase(a->function->name, "from("))
+ if (equalIgnoringCase(a->function->name, "from"))
stop.m_position = cssValuePool().createValue(0, CSSPrimitiveValue::CSS_NUMBER);
else
stop.m_position = cssValuePool().createValue(1, CSSPrimitiveValue::CSS_NUMBER);
}
// The "color-stop" function expects 3 arguments.
- if (equalIgnoringCase(a->function->name, "color-stop(")) {
+ if (equalIgnoringCase(a->function->name, "color-stop")) {
if (args->size() != 3)
return false;
else
return false;
- stopArg = args->next();
- if (stopArg->unit != CSSParserValue::Operator || stopArg->iValue != ',')
+ args->next();
+ if (!consumeComma(args))
return false;
- stopArg = args->next();
+ stopArg = args->current();
CSSValueID id = stopArg->id;
if (id == CSSValueWebkitText || (id >= CSSValueAqua && id <= CSSValueWindowtext) || id == CSSValueMenu)
stop.m_color = cssValuePool().createIdentifierValue(id);
CSSParserValue* a = args->current();
if (!a || a->unit != CSSPrimitiveValue::CSS_IDENT)
return false;
- if (equalIgnoringCase(a, "linear"))
+ if (a->id == CSSValueLinear)
gradientType = CSSDeprecatedLinearGradient;
else if (equalIgnoringCase(a, "radial"))
gradientType = CSSDeprecatedRadialGradient;
// The rest of the gradient types shouldn't appear here.
ASSERT_NOT_REACHED();
}
+ args->next();
- // Comma.
- a = args->next();
- if (!isComma(a))
+ if (!consumeComma(args))
return false;
// Next comes the starting point for the gradient as an x y pair. There is no
// comma between the x and the y values.
// First X. It can be left, right, number or percent.
- a = args->next();
+ a = args->current();
if (!a)
return false;
RefPtrWillBeRawPtr<CSSPrimitiveValue> point = parseDeprecatedGradientPoint(a, true);
result->setFirstY(point.release());
// Comma after the first point.
- a = args->next();
- if (!isComma(a))
+ args->next();
+ if (!consumeComma(args))
return false;
// For radial gradients only, we now expect a numeric radius.
if (gradientType == CSSDeprecatedRadialGradient) {
- a = args->next();
+ a = args->current();
if (!a || a->unit != CSSPrimitiveValue::CSS_NUMBER)
return false;
toCSSRadialGradientValue(result.get())->setFirstRadius(createPrimitiveNumericValue(a));
// Comma after the first radius.
- a = args->next();
- if (!isComma(a))
+ args->next();
+ if (!consumeComma(args))
return false;
}
// Next is the ending point for the gradient as an x, y pair.
// Second X. It can be left, right, number or percent.
- a = args->next();
+ a = args->current();
if (!a)
return false;
point = parseDeprecatedGradientPoint(a, true);
if (!point)
return false;
result->setSecondY(point.release());
+ args->next();
// For radial gradients only, we now expect the second radius.
if (gradientType == CSSDeprecatedRadialGradient) {
// Comma after the second point.
- a = args->next();
- if (!isComma(a))
+ if (!consumeComma(args))
return false;
- a = args->next();
+ a = args->current();
if (!a || a->unit != CSSPrimitiveValue::CSS_NUMBER)
return false;
toCSSRadialGradientValue(result.get())->setSecondRadius(createPrimitiveNumericValue(a));
+ args->next();
}
// We now will accept any number of stops (0 or more).
- a = args->next();
+ a = args->current();
while (a) {
// Look for the comma before the next stop.
- if (!isComma(a))
+ if (!consumeComma(args))
return false;
// Now examine the stop itself.
- a = args->next();
+ a = args->current();
if (!a)
return false;
RefPtrWillBeRawPtr<CSSValue> centerY = nullptr;
// parse2ValuesFillPosition advances the args next pointer.
parse2ValuesFillPosition(args, centerX, centerY);
+
+ if ((centerX || centerY) && !consumeComma(args))
+ return false;
+
a = args->current();
if (!a)
return false;
- if (centerX || centerY) {
- // Comma
- if (!isComma(a))
- return false;
-
- a = args->next();
- if (!a)
- return false;
- }
-
result->setFirstX(toCSSPrimitiveValue(centerX.get()));
result->setSecondX(toCSSPrimitiveValue(centerX.get()));
// CSS3 radial gradients always share the same start and end point.
// at <position>
RefPtrWillBeRawPtr<CSSValue> centerX = nullptr;
RefPtrWillBeRawPtr<CSSValue> centerY = nullptr;
- if (a->unit == CSSPrimitiveValue::CSS_IDENT && equalIgnoringCase(a, "at")) {
+ if (a->unit == CSSPrimitiveValue::CSS_IDENT && a->id == CSSValueAt) {
a = args->next();
if (!a)
return false;
if (val->unit != CSSParserValue::Function)
return false;
- if (equalIgnoringCase(val->function->name, "-webkit-gradient(")) {
+ if (equalIgnoringCase(val->function->name, "-webkit-gradient")) {
// FIXME: This should send a deprecation message.
if (m_context.useCounter())
m_context.useCounter()->count(UseCounter::DeprecatedWebKitGradient);
return parseDeprecatedGradient(valueList, value);
}
- if (equalIgnoringCase(val->function->name, "-webkit-linear-gradient(")) {
+ if (equalIgnoringCase(val->function->name, "-webkit-linear-gradient")) {
// FIXME: This should send a deprecation message.
if (m_context.useCounter())
m_context.useCounter()->count(UseCounter::DeprecatedWebKitLinearGradient);
return parseDeprecatedLinearGradient(valueList, value, NonRepeating);
}
- if (equalIgnoringCase(val->function->name, "linear-gradient("))
+ if (equalIgnoringCase(val->function->name, "linear-gradient"))
return parseLinearGradient(valueList, value, NonRepeating);
- if (equalIgnoringCase(val->function->name, "-webkit-repeating-linear-gradient(")) {
+ if (equalIgnoringCase(val->function->name, "-webkit-repeating-linear-gradient")) {
// FIXME: This should send a deprecation message.
if (m_context.useCounter())
m_context.useCounter()->count(UseCounter::DeprecatedWebKitRepeatingLinearGradient);
return parseDeprecatedLinearGradient(valueList, value, Repeating);
}
- if (equalIgnoringCase(val->function->name, "repeating-linear-gradient("))
+ if (equalIgnoringCase(val->function->name, "repeating-linear-gradient"))
return parseLinearGradient(valueList, value, Repeating);
- if (equalIgnoringCase(val->function->name, "-webkit-radial-gradient(")) {
+ if (equalIgnoringCase(val->function->name, "-webkit-radial-gradient")) {
// FIXME: This should send a deprecation message.
if (m_context.useCounter())
m_context.useCounter()->count(UseCounter::DeprecatedWebKitRadialGradient);
return parseDeprecatedRadialGradient(valueList, value, NonRepeating);
}
- if (equalIgnoringCase(val->function->name, "radial-gradient("))
+ if (equalIgnoringCase(val->function->name, "radial-gradient"))
return parseRadialGradient(valueList, value, NonRepeating);
- if (equalIgnoringCase(val->function->name, "-webkit-repeating-radial-gradient(")) {
+ if (equalIgnoringCase(val->function->name, "-webkit-repeating-radial-gradient")) {
if (m_context.useCounter())
m_context.useCounter()->count(UseCounter::DeprecatedWebKitRepeatingRadialGradient);
return parseDeprecatedRadialGradient(valueList, value, Repeating);
}
- if (equalIgnoringCase(val->function->name, "repeating-radial-gradient("))
+ if (equalIgnoringCase(val->function->name, "repeating-radial-gradient"))
return parseRadialGradient(valueList, value, Repeating);
- if (equalIgnoringCase(val->function->name, "-webkit-canvas("))
+ if (equalIgnoringCase(val->function->name, "-webkit-canvas"))
return parseCanvas(valueList, value);
- if (equalIgnoringCase(val->function->name, "-webkit-cross-fade("))
+ if (equalIgnoringCase(val->function->name, "-webkit-cross-fade"))
return parseCrossfade(valueList, value);
return false;
CSSParserValueList* args = valueList->current()->function->args.get();
if (!args || args->size() != 5)
return false;
- CSSParserValue* a = args->current();
RefPtrWillBeRawPtr<CSSValue> fromImageValue = nullptr;
RefPtrWillBeRawPtr<CSSValue> toImageValue = nullptr;
// The first argument is the "from" image. It is a fill image.
- if (!a || !parseFillImage(args, fromImageValue))
+ if (!args->current() || !parseFillImage(args, fromImageValue))
return false;
- a = args->next();
+ args->next();
- // Skip a comma
- if (!isComma(a))
+ if (!consumeComma(args))
return false;
- a = args->next();
// The second argument is the "to" image. It is a fill image.
- if (!a || !parseFillImage(args, toImageValue))
+ if (!args->current() || !parseFillImage(args, toImageValue))
return false;
- a = args->next();
+ args->next();
- // Skip a comma
- if (!isComma(a))
+ if (!consumeComma(args))
return false;
- a = args->next();
// The third argument is the crossfade value. It is a percentage or a fractional number.
RefPtrWillBeRawPtr<CSSPrimitiveValue> percentage = nullptr;
- if (!a)
+ CSSParserValue* value = args->current();
+ if (!value)
return false;
- if (a->unit == CSSPrimitiveValue::CSS_PERCENTAGE)
- percentage = cssValuePool().createValue(clampTo<double>(a->fValue / 100, 0, 1), CSSPrimitiveValue::CSS_NUMBER);
- else if (a->unit == CSSPrimitiveValue::CSS_NUMBER)
- percentage = cssValuePool().createValue(clampTo<double>(a->fValue, 0, 1), CSSPrimitiveValue::CSS_NUMBER);
+ if (value->unit == CSSPrimitiveValue::CSS_PERCENTAGE)
+ percentage = cssValuePool().createValue(clampTo<double>(value->fValue / 100, 0, 1), CSSPrimitiveValue::CSS_NUMBER);
+ else if (value->unit == CSSPrimitiveValue::CSS_NUMBER)
+ percentage = cssValuePool().createValue(clampTo<double>(value->fValue, 0, 1), CSSPrimitiveValue::CSS_NUMBER);
else
return false;
RefPtrWillBeRawPtr<CSSImageSetValue> imageSet = CSSImageSetValue::create();
- CSSParserValue* arg = functionArgs->current();
- while (arg) {
+ while (functionArgs->current()) {
+ CSSParserValue* arg = functionArgs->current();
if (arg->unit != CSSPrimitiveValue::CSS_URI)
return nullptr;
if (imageScaleFactor <= 0)
return nullptr;
imageSet->append(cssValuePool().createValue(imageScaleFactor, CSSPrimitiveValue::CSS_NUMBER));
+ functionArgs->next();
// If there are no more arguments, we're done.
- arg = functionArgs->next();
- if (!arg)
+ if (!functionArgs->current())
break;
// If there are more arguments, they should be after a comma.
- if (!isComma(arg))
+ if (!consumeComma(functionArgs))
return nullptr;
-
- // Skip the comma and move on to the next argument.
- arg = functionArgs->next();
}
return imageSet.release();
}
-bool CSSPropertyParser::parseWillChange(bool important)
+PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseWillChange()
{
- ASSERT(RuntimeEnabledFeatures::cssWillChangeEnabled());
-
RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createCommaSeparated();
if (m_valueList->current()->id == CSSValueAuto) {
- if (m_valueList->next())
- return false;
+ // FIXME: This will be read back as an empty string instead of auto
+ return values.release();
}
// Every comma-separated list of CSS_IDENTs is a valid will-change value,
// unless the list includes an explicitly disallowed CSS_IDENT.
- bool expectComma = false;
- for (CSSParserValue* currentValue = m_valueList->current(); currentValue; currentValue = m_valueList->next()) {
- if (expectComma) {
- if (!isComma(currentValue))
- return false;
- expectComma = false;
- continue;
- }
-
- if (currentValue->unit != CSSPrimitiveValue::CSS_IDENT)
- return false;
+ while (true) {
+ CSSParserValue* currentValue = m_valueList->current();
+ if (!currentValue || currentValue->unit != CSSPrimitiveValue::CSS_IDENT)
+ return nullptr;
CSSPropertyID property = cssPropertyID(currentValue->string);
- if (property && RuntimeCSSEnabled::isCSSPropertyEnabled(property)) {
+ if (property) {
+ ASSERT(CSSPropertyMetadata::isEnabledProperty(property));
// Now "all" is used by both CSSValue and CSSPropertyValue.
- // Need to return false when currentValue is CSSPropertyAll.
+ // Need to return nullptr when currentValue is CSSPropertyAll.
if (property == CSSPropertyWillChange || property == CSSPropertyAll)
- return false;
+ return nullptr;
values->append(cssValuePool().createIdentifierValue(property));
} else {
switch (currentValue->id) {
case CSSValueDefault:
case CSSValueInitial:
case CSSValueInherit:
- return false;
+ return nullptr;
case CSSValueContents:
case CSSValueScrollPosition:
values->append(cssValuePool().createIdentifierValue(currentValue->id));
break;
}
}
- expectComma = true;
+
+ if (!m_valueList->next())
+ break;
+ if (!consumeComma(m_valueList))
+ return nullptr;
}
- addProperty(CSSPropertyWillChange, values.release(), important);
- return true;
+ return values.release();
}
static void filterInfoForName(const CSSParserString& name, CSSFilterValue::FilterOperationType& filterType, unsigned& maximumArgumentCount)
{
- if (equalIgnoringCase(name, "grayscale("))
+ if (equalIgnoringCase(name, "grayscale"))
filterType = CSSFilterValue::GrayscaleFilterOperation;
- else if (equalIgnoringCase(name, "sepia("))
+ else if (equalIgnoringCase(name, "sepia"))
filterType = CSSFilterValue::SepiaFilterOperation;
- else if (equalIgnoringCase(name, "saturate("))
+ else if (equalIgnoringCase(name, "saturate"))
filterType = CSSFilterValue::SaturateFilterOperation;
- else if (equalIgnoringCase(name, "hue-rotate("))
+ else if (equalIgnoringCase(name, "hue-rotate"))
filterType = CSSFilterValue::HueRotateFilterOperation;
- else if (equalIgnoringCase(name, "invert("))
+ else if (equalIgnoringCase(name, "invert"))
filterType = CSSFilterValue::InvertFilterOperation;
- else if (equalIgnoringCase(name, "opacity("))
+ else if (equalIgnoringCase(name, "opacity"))
filterType = CSSFilterValue::OpacityFilterOperation;
- else if (equalIgnoringCase(name, "brightness("))
+ else if (equalIgnoringCase(name, "brightness"))
filterType = CSSFilterValue::BrightnessFilterOperation;
- else if (equalIgnoringCase(name, "contrast("))
+ else if (equalIgnoringCase(name, "contrast"))
filterType = CSSFilterValue::ContrastFilterOperation;
- else if (equalIgnoringCase(name, "blur("))
+ else if (equalIgnoringCase(name, "blur"))
filterType = CSSFilterValue::BlurFilterOperation;
- else if (equalIgnoringCase(name, "drop-shadow(")) {
+ else if (equalIgnoringCase(name, "drop-shadow")) {
filterType = CSSFilterValue::DropShadowFilterOperation;
maximumArgumentCount = 4; // x-offset, y-offset, blur-radius, color -- spread and inset style not allowed.
}
case CSSFilterValue::OpacityFilterOperation:
case CSSFilterValue::ContrastFilterOperation: {
// One optional argument, 0-1 or 0%-100%, if missing use 100%.
- if (args->size() > 1)
- return nullptr;
-
if (args->size()) {
CSSParserValue* value = args->current();
// FIXME (crbug.com/397061): Support calc expressions like calc(10% + 0.5)
- if (value->unit != CSSPrimitiveValue::CSS_PERCENTAGE && !validUnit(value, FNumber | FNonNeg, HTMLStandardMode))
+ if (value->unit != CSSPrimitiveValue::CSS_PERCENTAGE && !validUnit(value, FNumber | FNonNeg))
return nullptr;
double amount = value->fValue;
}
case CSSFilterValue::BrightnessFilterOperation: {
// One optional argument, if missing use 100%.
- if (args->size() > 1)
- return nullptr;
-
if (args->size()) {
CSSParserValue* value = args->current();
// FIXME (crbug.com/397061): Support calc expressions like calc(10% + 0.5)
- if (value->unit != CSSPrimitiveValue::CSS_PERCENTAGE && !validUnit(value, FNumber, HTMLStandardMode))
+ if (value->unit != CSSPrimitiveValue::CSS_PERCENTAGE && !validUnit(value, FNumber))
return nullptr;
filterValue->append(cssValuePool().createValue(value->fValue, static_cast<CSSPrimitiveValue::UnitType>(value->unit)));
}
case CSSFilterValue::HueRotateFilterOperation: {
// hue-rotate() takes one optional angle.
- if (args->size() > 1)
- return nullptr;
-
if (args->size()) {
CSSParserValue* argument = args->current();
if (!validUnit(argument, FAngle, HTMLStandardMode))
}
case CSSFilterValue::BlurFilterOperation: {
// Blur takes a single length. Zero parameters are allowed.
- if (args->size() > 1)
- return nullptr;
-
if (args->size()) {
CSSParserValue* argument = args->current();
if (!validUnit(argument, FLength | FNonNeg, HTMLStandardMode))
return nullptr;
CSSParserValueList* args = value->function->args.get();
- if (!args)
+ if (!args || args->size() > maximumArgumentCount)
return nullptr;
RefPtrWillBeRawPtr<CSSFilterValue> filterValue = parseBuiltinFilterArguments(args, filterType);
return list.release();
}
-bool CSSPropertyParser::parseWebkitPerspectiveOrigin(CSSPropertyID propId, CSSPropertyID& propId1, CSSPropertyID& propId2, RefPtrWillBeRawPtr<CSSValue>& value, RefPtrWillBeRawPtr<CSSValue>& value2)
-{
- propId1 = propId;
- propId2 = propId;
- if (propId == CSSPropertyWebkitPerspectiveOrigin) {
- propId1 = CSSPropertyWebkitPerspectiveOriginX;
- propId2 = CSSPropertyWebkitPerspectiveOriginY;
- }
-
- switch (propId) {
- case CSSPropertyWebkitPerspectiveOrigin:
- if (m_valueList->size() > 2)
- return false;
- parse2ValuesFillPosition(m_valueList.get(), value, value2);
- break;
- case CSSPropertyWebkitPerspectiveOriginX: {
- value = parseFillPositionX(m_valueList.get());
- if (value)
- m_valueList->next();
- break;
- }
- case CSSPropertyWebkitPerspectiveOriginY: {
- value = parseFillPositionY(m_valueList.get());
- if (value)
- m_valueList->next();
- break;
- }
- default:
- ASSERT_NOT_REACHED();
- return false;
- }
-
- return value;
-}
-
-bool CSSPropertyParser::parseTouchAction(bool important)
+PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseTouchAction()
{
CSSParserValue* value = m_valueList->current();
RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
if (m_valueList->size() == 1 && value && (value->id == CSSValueAuto || value->id == CSSValueNone || value->id == CSSValueManipulation)) {
list->append(cssValuePool().createIdentifierValue(value->id));
- addProperty(CSSPropertyTouchAction, list.release(), important);
m_valueList->next();
- return true;
+ return list.release();
}
- bool isValid = true;
- while (isValid && value) {
+ while (value) {
switch (value->id) {
case CSSValuePanX:
case CSSValuePanY: {
RefPtrWillBeRawPtr<CSSValue> panValue = cssValuePool().createIdentifierValue(value->id);
- if (list->hasValue(panValue.get())) {
- isValid = false;
- break;
- }
+ if (list->hasValue(panValue.get()))
+ return nullptr;
list->append(panValue.release());
break;
}
default:
- isValid = false;
- break;
+ return nullptr;
}
- if (isValid)
- value = m_valueList->next();
+ value = m_valueList->next();
}
- if (list->length() && isValid) {
- addProperty(CSSPropertyTouchAction, list.release(), important);
- return true;
- }
+ if (list->length())
+ return list.release();
- return false;
+ return nullptr;
}
void CSSPropertyParser::addTextDecorationProperty(CSSPropertyID propId, PassRefPtrWillBeRawPtr<CSSValue> value, bool important)
bool CSSPropertyParser::parseTextDecoration(CSSPropertyID propId, bool important)
{
- if (propId == CSSPropertyTextDecorationLine
- && !RuntimeEnabledFeatures::css3TextDecorationsEnabled())
- return false;
+ ASSERT(propId != CSSPropertyTextDecorationLine || RuntimeEnabledFeatures::css3TextDecorationsEnabled());
CSSParserValue* value = m_valueList->current();
if (value && value->id == CSSValueNone) {
}
RefPtrWillBeRawPtr<CSSValueList> settings = CSSValueList::createCommaSeparated();
- for (CSSParserValue* value = m_valueList->current(); value; value = m_valueList->next()) {
- if (!parseFontFeatureTag(settings.get()))
+ while (true) {
+ if (!m_valueList->current() || !parseFontFeatureTag(settings.get()))
return false;
-
- // If the list isn't parsed fully, the current value should be comma.
- value = m_valueList->current();
- if (value && !isComma(value))
+ if (!m_valueList->current())
+ break;
+ if (!consumeComma(m_valueList))
return false;
}
- if (settings->length()) {
- addProperty(CSSPropertyWebkitFontFeatureSettings, settings.release(), important);
- return true;
- }
- return false;
+ addProperty(CSSPropertyWebkitFontFeatureSettings, settings.release(), important);
+ return true;
}
bool CSSPropertyParser::parseFontVariantLigatures(bool important)
const char* name = buffer;
const Property* hashTableEntry = findProperty(name, length);
- return hashTableEntry ? static_cast<CSSPropertyID>(hashTableEntry->id) : CSSPropertyInvalid;
+ if (!hashTableEntry)
+ return CSSPropertyInvalid;
+ CSSPropertyID property = static_cast<CSSPropertyID>(hashTableEntry->id);
+ if (!CSSPropertyMetadata::isEnabledProperty(property))
+ return CSSPropertyInvalid;
+ return property;
}
CSSPropertyID cssPropertyID(const String& string)
case CSSPropertyBaselineShift:
// baseline | super | sub | <percentage> | <length> | inherit
- if (id == CSSValueBaseline || id == CSSValueSub
- || id >= CSSValueSuper)
+ if (id == CSSValueBaseline || id == CSSValueSub || id == CSSValueSuper)
validPrimitive = true;
else
validPrimitive = validUnit(value, FLength | FPercent, SVGAttributeMode);
validPrimitive = true;
break;
- case CSSPropertyImageRendering: // auto | optimizeSpeed | pixelated
- if (RuntimeEnabledFeatures::imageRenderingPixelatedEnabled() && id == CSSValuePixelated) {
- validPrimitive = true;
- break;
- }
case CSSPropertyColorRendering: // optimizeQuality | inherit
if (id == CSSValueAuto || id == CSSValueOptimizespeed
|| id == CSSValueOptimizequality)
/* shorthand properties */
case CSSPropertyMarker: {
ShorthandScope scope(this, propId);
- CSSPropertyParser::ImplicitScope implicitScope(this, PropertyImplicit);
+ CSSPropertyParser::ImplicitScope implicitScope(this);
if (!parseValue(CSSPropertyMarkerStart, important))
return false;
if (m_valueList->current()) {