summaryrefslogtreecommitdiffstats
path: root/WebCore/css/CSSParser.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/css/CSSParser.cpp')
-rw-r--r--WebCore/css/CSSParser.cpp174
1 files changed, 145 insertions, 29 deletions
diff --git a/WebCore/css/CSSParser.cpp b/WebCore/css/CSSParser.cpp
index b79992f..b7155b3 100644
--- a/WebCore/css/CSSParser.cpp
+++ b/WebCore/css/CSSParser.cpp
@@ -4,6 +4,7 @@
* 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
@@ -171,7 +172,7 @@ CSSParser::~CSSParser()
}
delete m_floatingMediaQueryExp;
delete m_floatingMediaQuery;
- deleteAllValues(m_floatingSelectors);
+ fastDeleteAllValues(m_floatingSelectors);
deleteAllValues(m_floatingValueLists);
deleteAllValues(m_floatingFunctions);
deleteAllValues(m_reusableSelectorVector);
@@ -747,7 +748,11 @@ bool CSSParser::parseValue(int propId, bool important)
// 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
valid_primitive = true;
break;
@@ -920,8 +925,10 @@ bool CSSParser::parseValue(int propId, bool important)
case CSSPropertyBackgroundPosition:
case CSSPropertyBackgroundPositionX:
case CSSPropertyBackgroundPositionY:
- case CSSPropertyWebkitBackgroundSize:
+ case CSSPropertyBackgroundSize:
case CSSPropertyBackgroundRepeat:
+ case CSSPropertyBackgroundRepeatX:
+ case CSSPropertyBackgroundRepeatY:
case CSSPropertyWebkitMaskAttachment:
case CSSPropertyWebkitMaskClip:
case CSSPropertyWebkitMaskComposite:
@@ -931,17 +938,21 @@ bool CSSParser::parseValue(int propId, bool important)
case CSSPropertyWebkitMaskPositionX:
case CSSPropertyWebkitMaskPositionY:
case CSSPropertyWebkitMaskSize:
- case CSSPropertyWebkitMaskRepeat: {
+ 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)) {
addProperty(propId1, val1.release(), important);
if (val2)
addProperty(propId2, val2.release(), important);
- return true;
+ result = true;
}
- return false;
+ m_implicitShorthand = false;
+ return result;
}
case CSSPropertyListStyleImage: // <uri> | none | inherit
if (id == CSSValueNone) {
@@ -1231,7 +1242,7 @@ bool CSSParser::parseValue(int propId, bool important)
valid_primitive = validUnit(value, FLength, m_strict);
break;
case CSSPropertyTextShadow: // CSS2 property, dropped in CSS2.1, back in CSS3, so treat as CSS3
- case CSSPropertyBoxShadow:
+ case CSSPropertyWebkitBoxShadow:
if (id == CSSValueNone)
valid_primitive = true;
else
@@ -1313,6 +1324,28 @@ bool CSSParser::parseValue(int propId, bool important)
else
valid_primitive = validUnit(value, FTime|FInteger|FNonNeg, m_strict);
break;
+#if ENABLE(WCSS)
+ case CSSPropertyWapMarqueeDir:
+ if (id == CSSValueLtr || id == CSSValueRtl)
+ valid_primitive = true;
+ break;
+ case CSSPropertyWapMarqueeStyle:
+ if (id == CSSValueNone || id == CSSValueSlide || id == CSSValueScroll || id == CSSValueAlternate)
+ valid_primitive = true;
+ break;
+ case CSSPropertyWapMarqueeLoop:
+ if (id == CSSValueInfinite)
+ valid_primitive = true;
+ else
+ valid_primitive = validUnit(value, FInteger | FNonNeg, m_strict);
+ break;
+ case CSSPropertyWapMarqueeSpeed:
+ if (id == CSSValueNormal || id == CSSValueSlow || id == CSSValueFast)
+ valid_primitive = true;
+ else
+ valid_primitive = validUnit(value, FTime | FInteger | FNonNeg, m_strict);
+ break;
+#endif
case CSSPropertyWebkitUserDrag: // auto | none | element
if (id == CSSValueAuto || id == CSSValueNone || id == CSSValueElement)
valid_primitive = true;
@@ -1452,6 +1485,11 @@ bool CSSParser::parseValue(int propId, bool important)
id == CSSValueWave)
valid_primitive = true;
break;
+ case CSSPropertyTextRendering: // auto | optimizeSpeed | optimizeLegibility | geometricPrecision
+ if (id == CSSValueAuto || id == CSSValueOptimizespeed || id == CSSValueOptimizelegibility
+ || id == CSSValueGeometricprecision)
+ valid_primitive = true;
+ break;
case CSSPropertyTextLineThroughWidth:
case CSSPropertyTextOverlineWidth:
case CSSPropertyTextUnderlineWidth:
@@ -1542,6 +1580,12 @@ bool CSSParser::parseValue(int propId, bool important)
valid_primitive = true;
break;
+ case CSSPropertyWebkitFontSmoothing:
+ if (id == CSSValueAuto || id == CSSValueNone
+ || id == CSSValueAntialiased || id == CSSValueSubpixelAntialiased)
+ valid_primitive = true;
+ break;
+
#if ENABLE(DASHBOARD_SUPPORT)
case CSSPropertyWebkitDashboardRegion: // <dashboard-region> | <dashboard-region>
if (value->unit == CSSParserValue::Function || id == CSSValueNone)
@@ -1554,7 +1598,7 @@ bool CSSParser::parseValue(int propId, bool important)
case CSSPropertyBackground: {
// Position must come before color in this array because a plain old "0" is a legal color
// in quirks mode but it's usually the X coordinate of a position.
- // FIXME: Add CSSPropertyWebkitBackgroundSize to the shorthand.
+ // FIXME: Add CSSPropertyBackgroundSize to the shorthand.
const int properties[] = { CSSPropertyBackgroundImage, CSSPropertyBackgroundRepeat,
CSSPropertyBackgroundAttachment, CSSPropertyBackgroundPosition, CSSPropertyBackgroundOrigin,
CSSPropertyBackgroundColor };
@@ -1736,7 +1780,7 @@ void CSSParser::addFillValue(RefPtr<CSSValue>& lval, PassRefPtr<CSSValue> rval)
lval = rval;
}
-const int cMaxFillProperties = 7;
+const int cMaxFillProperties = 9;
bool CSSParser::parseFillShorthand(int propId, const int* properties, int numProperties, bool important)
{
@@ -1750,6 +1794,7 @@ bool CSSParser::parseFillShorthand(int propId, const int* properties, int numPro
RefPtr<CSSValue> values[cMaxFillProperties];
RefPtr<CSSValue> clipValue;
RefPtr<CSSValue> positionYValue;
+ RefPtr<CSSValue> repeatYValue;
int i;
while (m_valueList->current()) {
@@ -1767,6 +1812,8 @@ bool CSSParser::parseFillShorthand(int propId, const int* properties, int numPro
addFillValue(values[i], CSSInitialValue::createImplicit());
if (properties[i] == CSSPropertyBackgroundPosition || properties[i] == CSSPropertyWebkitMaskPosition)
addFillValue(positionYValue, CSSInitialValue::createImplicit());
+ if (properties[i] == CSSPropertyBackgroundRepeat || properties[i] == CSSPropertyWebkitMaskRepeat)
+ addFillValue(repeatYValue, CSSInitialValue::createImplicit());
if ((properties[i] == CSSPropertyBackgroundOrigin || properties[i] == CSSPropertyWebkitMaskOrigin) && !parsedProperty[i]) {
// If background-origin wasn't present, then reset background-clip also.
addFillValue(clipValue, CSSInitialValue::createImplicit());
@@ -1789,6 +1836,8 @@ bool CSSParser::parseFillShorthand(int propId, const int* properties, int numPro
addFillValue(values[i], val1.release());
if (properties[i] == CSSPropertyBackgroundPosition || properties[i] == CSSPropertyWebkitMaskPosition)
addFillValue(positionYValue, val2.release());
+ if (properties[i] == CSSPropertyBackgroundRepeat || properties[i] == CSSPropertyWebkitMaskRepeat)
+ addFillValue(repeatYValue, val2.release());
if (properties[i] == CSSPropertyBackgroundOrigin || properties[i] == CSSPropertyWebkitMaskOrigin) {
// Reparse the value as a clip, and see if we succeed.
if (parseFillProperty(CSSPropertyBackgroundClip, propId1, propId2, val1, val2))
@@ -1812,6 +1861,8 @@ bool CSSParser::parseFillShorthand(int propId, const int* properties, int numPro
addFillValue(values[i], CSSInitialValue::createImplicit());
if (properties[i] == CSSPropertyBackgroundPosition || properties[i] == CSSPropertyWebkitMaskPosition)
addFillValue(positionYValue, CSSInitialValue::createImplicit());
+ if (properties[i] == CSSPropertyBackgroundRepeat || properties[i] == CSSPropertyWebkitMaskRepeat)
+ addFillValue(repeatYValue, CSSInitialValue::createImplicit());
if ((properties[i] == CSSPropertyBackgroundOrigin || properties[i] == CSSPropertyWebkitMaskOrigin) && !parsedProperty[i]) {
// If background-origin wasn't present, then reset background-clip also.
addFillValue(clipValue, CSSInitialValue::createImplicit());
@@ -1829,6 +1880,14 @@ bool CSSParser::parseFillShorthand(int propId, const int* properties, int numPro
addProperty(CSSPropertyWebkitMaskPositionX, values[i].release(), important);
// it's OK to call positionYValue.release() since we only see CSSPropertyWebkitMaskPosition once
addProperty(CSSPropertyWebkitMaskPositionY, positionYValue.release(), important);
+ } else if (properties[i] == CSSPropertyBackgroundRepeat) {
+ addProperty(CSSPropertyBackgroundRepeatX, values[i].release(), important);
+ // it's OK to call repeatYValue.release() since we only see CSSPropertyBackgroundPosition once
+ addProperty(CSSPropertyBackgroundRepeatY, repeatYValue.release(), important);
+ } else if (properties[i] == CSSPropertyWebkitMaskRepeat) {
+ addProperty(CSSPropertyWebkitMaskRepeatX, values[i].release(), important);
+ // it's OK to call repeatYValue.release() since we only see CSSPropertyBackgroundPosition once
+ addProperty(CSSPropertyWebkitMaskRepeatY, repeatYValue.release(), important);
} else
addProperty(properties[i], values[i].release(), important);
@@ -2156,7 +2215,7 @@ PassRefPtr<CSSValue> CSSParser::parseAttr(CSSParserValueList* args)
if (attrName[0] == '-')
return 0;
- if (document()->isHTMLDocument())
+ if (document() && document()->isHTMLDocument())
attrName = attrName.lower();
return CSSPrimitiveValue::create(attrName, CSSPrimitiveValue::CSS_ATTR);
@@ -2269,9 +2328,59 @@ void CSSParser::parseFillPosition(RefPtr<CSSValue>& value1, RefPtr<CSSValue>& va
value1.swap(value2);
}
-PassRefPtr<CSSValue> CSSParser::parseFillSize()
+void CSSParser::parseFillRepeat(RefPtr<CSSValue>& value1, RefPtr<CSSValue>& value2)
+{
+ CSSParserValue* value = m_valueList->current();
+
+ int id = m_valueList->current()->id;
+ if (id == CSSValueRepeatX) {
+ m_implicitShorthand = true;
+ value1 = CSSPrimitiveValue::createIdentifier(CSSValueRepeat);
+ value2 = CSSPrimitiveValue::createIdentifier(CSSValueNoRepeat);
+ m_valueList->next();
+ return;
+ }
+ if (id == CSSValueRepeatY) {
+ m_implicitShorthand = true;
+ value1 = CSSPrimitiveValue::createIdentifier(CSSValueNoRepeat);
+ value2 = CSSPrimitiveValue::createIdentifier(CSSValueRepeat);
+ m_valueList->next();
+ return;
+ }
+ if (id == CSSValueRepeat || id == CSSValueNoRepeat || id == CSSValueRound || id == CSSValueSpace)
+ value1 = CSSPrimitiveValue::createIdentifier(id);
+ else {
+ value1 = 0;
+ return;
+ }
+
+ value = m_valueList->next();
+
+ // First check for the comma. If so, we are finished parsing this value or value pair.
+ if (value && value->unit == CSSParserValue::Operator && value->iValue == ',')
+ value = 0;
+
+ if (value)
+ id = m_valueList->current()->id;
+
+ if (value && (id == CSSValueRepeat || id == CSSValueNoRepeat || id == CSSValueRound || id == CSSValueSpace)) {
+ value2 = CSSPrimitiveValue::createIdentifier(id);
+ m_valueList->next();
+ } else {
+ // If only one value was specified, value2 is the same as value1.
+ m_implicitShorthand = true;
+ value2 = CSSPrimitiveValue::createIdentifier(static_cast<CSSPrimitiveValue*>(value1.get())->getIdent());
+ }
+}
+
+PassRefPtr<CSSValue> CSSParser::parseFillSize(bool& allowComma)
{
+ allowComma = true;
CSSParserValue* value = m_valueList->current();
+
+ if (value->id == CSSValueContain || value->id == CSSValueCover)
+ return CSSPrimitiveValue::createIdentifier(value->id);
+
RefPtr<CSSPrimitiveValue> parsedValue1;
if (value->id == CSSValueAuto)
@@ -2286,6 +2395,8 @@ PassRefPtr<CSSValue> CSSParser::parseFillSize()
if ((value = m_valueList->next())) {
if (value->id == CSSValueAuto)
parsedValue2 = CSSPrimitiveValue::create(0, CSSPrimitiveValue::CSS_UNKNOWN);
+ else if (value->unit == CSSParserValue::Operator && value->iValue == ',')
+ allowComma = false;
else {
if (!validUnit(value, FLength|FPercent, m_strict))
return 0;
@@ -2316,6 +2427,12 @@ bool CSSParser::parseFillProperty(int propId, int& propId1, int& propId2,
} else if (propId == CSSPropertyWebkitMaskPosition) {
propId1 = CSSPropertyWebkitMaskPositionX;
propId2 = CSSPropertyWebkitMaskPositionY;
+ } else if (propId == CSSPropertyBackgroundRepeat) {
+ propId1 = CSSPropertyBackgroundRepeatX;
+ propId2 = CSSPropertyBackgroundRepeatY;
+ } else if (propId == CSSPropertyWebkitMaskRepeat) {
+ propId1 = CSSPropertyWebkitMaskRepeatX;
+ propId2 = CSSPropertyWebkitMaskRepeatY;
}
while ((val = m_valueList->current())) {
@@ -2328,6 +2445,7 @@ bool CSSParser::parseFillProperty(int propId, int& propId1, int& propId2,
m_valueList->next();
allowComma = false;
} else {
+ allowComma = true;
switch (propId) {
case CSSPropertyBackgroundColor:
currValue = parseBackgroundColor();
@@ -2402,17 +2520,16 @@ bool CSSParser::parseFillProperty(int propId, int& propId1, int& propId2,
break;
case CSSPropertyBackgroundRepeat:
case CSSPropertyWebkitMaskRepeat:
- if (val->id >= CSSValueRepeat && val->id <= CSSValueNoRepeat) {
- currValue = CSSPrimitiveValue::createIdentifier(val->id);
- m_valueList->next();
- }
+ parseFillRepeat(currValue, currValue2);
+ // parseFillRepeat advances the m_valueList pointer
break;
- case CSSPropertyWebkitBackgroundSize:
- case CSSPropertyWebkitMaskSize:
- currValue = parseFillSize();
+ case CSSPropertyBackgroundSize:
+ case CSSPropertyWebkitMaskSize: {
+ currValue = parseFillSize(allowComma);
if (currValue)
m_valueList->next();
break;
+ }
}
if (!currValue)
return false;
@@ -2437,7 +2554,6 @@ bool CSSParser::parseFillProperty(int propId, int& propId1, int& propId2,
else
value2 = currValue2.release();
}
- allowComma = true;
}
// When parsing any fill shorthand property, we let it handle building up the lists for all
@@ -3554,7 +3670,7 @@ struct ShadowParseContext {
, allowBlur(false)
, allowSpread(false)
, allowColor(true)
- , allowStyle(prop == CSSPropertyBoxShadow)
+ , allowStyle(prop == CSSPropertyWebkitBoxShadow)
, allowBreak(true)
{
}
@@ -3586,7 +3702,7 @@ struct ShadowParseContext {
allowY = false;
allowBlur = false;
allowSpread = false;
- allowStyle = property == CSSPropertyBoxShadow;
+ allowStyle = property == CSSPropertyWebkitBoxShadow;
}
void commitLength(CSSParserValue* v)
@@ -3605,12 +3721,12 @@ struct ShadowParseContext {
allowY = false;
allowBlur = true;
allowColor = true;
- allowStyle = property == CSSPropertyBoxShadow;
+ allowStyle = property == CSSPropertyWebkitBoxShadow;
allowBreak = true;
} else if (allowBlur) {
blur = val.release();
allowBlur = false;
- allowSpread = property == CSSPropertyBoxShadow;
+ allowSpread = property == CSSPropertyWebkitBoxShadow;
} else if (allowSpread) {
spread = val.release();
allowSpread = false;
@@ -3627,7 +3743,7 @@ struct ShadowParseContext {
} else {
allowBlur = false;
allowSpread = false;
- allowStyle = property == CSSPropertyBoxShadow;
+ allowStyle = property == CSSPropertyWebkitBoxShadow;
}
}
@@ -4730,7 +4846,7 @@ UChar* CSSParser::text(int *length)
CSSSelector* CSSParser::createFloatingSelector()
{
- CSSSelector* selector = new CSSSelector;
+ CSSSelector* selector = fastNew<CSSSelector>();
m_floatingSelectors.add(selector);
return selector;
}
@@ -5126,11 +5242,11 @@ static int cssPropertyID(const UChar* propertyName, unsigned length)
const char* const opacity = "opacity";
name = opacity;
length = strlen(opacity);
- } else if (strcmp(buffer, "-webkit-box-shadow") == 0) {
- // CSS Backgrounds/Borders. -webkit-box-shadow worked in Safari 4 and earlier.
- const char* const boxShadow = "box-shadow";
- name = boxShadow;
- length = strlen(boxShadow);
+ } else if (strcmp(buffer, "-webkit-background-size") == 0) {
+ // CSS Backgrounds/Borders. -webkit-background-size worked in Safari 4 and earlier.
+ const char* const backgroundSize = "background-size";
+ name = backgroundSize;
+ length = strlen(backgroundSize);
} else if (hasPrefix(buffer + 7, length - 7, "-border-")) {
// -webkit-border-*-*-radius worked in Safari 4 and earlier. -webkit-border-radius syntax
// differs from border-radius, so it is remains as a distinct property.