Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(676)

Unified Diff: Source/core/css/parser/CSSPropertyParser.cpp

Issue 98663004: Add support for unprefixed CSS Transforms (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase. Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/css/parser/CSSPropertyParser.h ('k') | Source/core/css/resolver/AnimatedStyleBuilder.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/css/parser/CSSPropertyParser.cpp
diff --git a/Source/core/css/parser/CSSPropertyParser.cpp b/Source/core/css/parser/CSSPropertyParser.cpp
index d789b39fb7d88ef9f3672af8bb08475ea64cb903..120f724ec5951c16ccdeabf73db715752c208b76 100644
--- a/Source/core/css/parser/CSSPropertyParser.cpp
+++ b/Source/core/css/parser/CSSPropertyParser.cpp
@@ -1104,11 +1104,12 @@ bool CSSPropertyParser::parseValue(CSSPropertyID propId, bool important)
else
validPrimitive = validUnit(value, FTime | FInteger | FNonNeg);
break;
+ case CSSPropertyTransform:
case CSSPropertyWebkitTransform:
if (id == CSSValueNone)
validPrimitive = true;
else {
- RefPtrWillBeRawPtr<CSSValue> transformValue = parseTransform();
+ RefPtrWillBeRawPtr<CSSValue> transformValue = parseTransform(propId);
if (transformValue) {
addProperty(propId, transformValue.release(), important);
return true;
@@ -1116,6 +1117,18 @@ bool CSSPropertyParser::parseValue(CSSPropertyID propId, bool important)
return false;
}
break;
+ case CSSPropertyTransformOrigin: {
+ RefPtrWillBeRawPtr<CSSValueList> list = parseTransformOrigin();
+ if (!list)
+ return false;
+ // These values are added to match gecko serialization.
+ if (list->length() == 1)
+ list->append(cssValuePool().createValue(50, CSSPrimitiveValue::CSS_PERCENTAGE));
+ if (list->length() == 2)
+ list->append(cssValuePool().createValue(0, CSSPrimitiveValue::CSS_PX));
+ addProperty(propId, list.release(), important);
+ return true;
+ }
case CSSPropertyWebkitTransformOrigin:
case CSSPropertyWebkitTransformOriginX:
case CSSPropertyWebkitTransformOriginY:
@@ -1124,7 +1137,7 @@ bool CSSPropertyParser::parseValue(CSSPropertyID propId, bool important)
RefPtrWillBeRawPtr<CSSValue> val2 = nullptr;
RefPtrWillBeRawPtr<CSSValue> val3 = nullptr;
CSSPropertyID propId1, propId2, propId3;
- if (parseTransformOrigin(propId, propId1, propId2, propId3, val1, val2, val3)) {
+ if (parseWebkitTransformOrigin(propId, propId1, propId2, propId3, val1, val2, val3)) {
addProperty(propId1, val1.release(), important);
if (val2)
addProperty(propId2, val2.release(), important);
@@ -1134,28 +1147,40 @@ bool CSSPropertyParser::parseValue(CSSPropertyID propId, bool important)
}
return false;
}
+ case CSSPropertyPerspective:
+ if (id == CSSValueNone) {
+ validPrimitive = true;
+ } else if (validUnit(value, FLength | FNonNeg)) {
+ addProperty(propId, createPrimitiveNumericValue(value), important);
+ return true;
+ }
+ break;
case CSSPropertyWebkitPerspective:
- if (id == CSSValueNone)
+ if (id == CSSValueNone) {
validPrimitive = true;
- else {
+ } else if (validUnit(value, FNumber | FLength | FNonNeg)) {
// Accepting valueless numbers is a quirk of the -webkit prefixed version of the property.
- if (validUnit(value, FNumber | FLength | FNonNeg)) {
- RefPtrWillBeRawPtr<CSSValue> val = createPrimitiveNumericValue(value);
- if (val) {
- addProperty(propId, val.release(), important);
- return true;
- }
- return false;
- }
+ addProperty(propId, createPrimitiveNumericValue(value), important);
+ return true;
}
break;
+ case CSSPropertyPerspectiveOrigin: {
+ RefPtrWillBeRawPtr<CSSValueList> list = parseTransformOrigin();
+ if (!list || list->length() == 3)
+ return false;
+ // This values are added to match gecko serialization.
+ if (list->length() == 1)
+ list->append(cssValuePool().createValue(50, CSSPrimitiveValue::CSS_PERCENTAGE));
+ 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 (parsePerspectiveOrigin(propId, propId1, propId2, val1, val2)) {
+ if (parseWebkitPerspectiveOrigin(propId, propId1, propId2, val1, val2)) {
addProperty(propId1, val1.release(), important);
if (val2)
addProperty(propId2, val2.release(), important);
@@ -1550,6 +1575,7 @@ bool CSSPropertyParser::parseValue(CSSPropertyID propId, bool important)
case CSSPropertyTouchActionDelay:
case CSSPropertyVisibility:
case CSSPropertyWebkitAppearance:
+ case CSSPropertyBackfaceVisibility:
case CSSPropertyWebkitBackfaceVisibility:
case CSSPropertyWebkitBorderAfterStyle:
case CSSPropertyWebkitBorderBeforeStyle:
@@ -1588,6 +1614,7 @@ bool CSSPropertyParser::parseValue(CSSPropertyID propId, bool important)
case CSSPropertyWebkitTextCombine:
case CSSPropertyWebkitTextEmphasisPosition:
case CSSPropertyWebkitTextSecurity:
+ case CSSPropertyTransformStyle:
case CSSPropertyWebkitTransformStyle:
case CSSPropertyWebkitUserDrag:
case CSSPropertyWebkitUserModify:
@@ -3100,7 +3127,7 @@ PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAnimationProperty(Anima
return nullptr;
}
-bool CSSPropertyParser::parseTransformOriginShorthand(RefPtrWillBeRawPtr<CSSValue>& value1, RefPtrWillBeRawPtr<CSSValue>& value2, RefPtrWillBeRawPtr<CSSValue>& value3)
+bool CSSPropertyParser::parseWebkitTransformOriginShorthand(RefPtrWillBeRawPtr<CSSValue>& value1, RefPtrWillBeRawPtr<CSSValue>& value2, RefPtrWillBeRawPtr<CSSValue>& value3)
{
parse2ValuesFillPosition(m_valueList.get(), value1, value2);
@@ -7229,8 +7256,71 @@ PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseFilter()
return list.release();
}
+PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseTransformOrigin()
+{
+ CSSParserValue* value = m_valueList->current();
+ CSSValueID id = value->id;
+ RefPtrWillBeRawPtr<CSSValue> xValue;
+ RefPtrWillBeRawPtr<CSSValue> yValue;
+ RefPtrWillBeRawPtr<CSSValue> zValue;
+ if (id == CSSValueLeft || id == CSSValueRight) {
+ xValue = cssValuePool().createIdentifierValue(id);
+ } else if (id == CSSValueTop || id == CSSValueBottom) {
+ yValue = cssValuePool().createIdentifierValue(id);
+ } else if (id == CSSValueCenter) {
+ // Unresolved as to whether this is X or Y.
+ } else if (validUnit(value, FPercent | FLength)) {
+ xValue = createPrimitiveNumericValue(value);
+ } else {
+ return nullptr;
+ }
+
+ if ((value = m_valueList->next())) {
+ id = value->id;
+ if (!xValue && (id == CSSValueLeft || id == CSSValueRight)) {
+ xValue = cssValuePool().createIdentifierValue(id);
+ } else if (!yValue && (id == CSSValueTop || id == CSSValueBottom)) {
+ yValue = cssValuePool().createIdentifierValue(id);
+ } else if (id == CSSValueCenter) {
+ // Resolved below.
+ } else if (!yValue && validUnit(value, FPercent | FLength)) {
+ yValue = createPrimitiveNumericValue(value);
+ } else {
+ return nullptr;
+ }
+
+ // If X or Y have not been resolved, they must be center.
+ if (!xValue)
+ xValue = cssValuePool().createIdentifierValue(CSSValueCenter);
+ if (!yValue)
+ yValue = cssValuePool().createIdentifierValue(CSSValueCenter);
+
+ if ((value = m_valueList->next())) {
+ if (!validUnit(value, FLength))
+ return nullptr;
+ zValue = createPrimitiveNumericValue(value);
+
+ if ((value = m_valueList->next()))
+ return nullptr;
+ }
+ } else if (!xValue) {
+ if (yValue) {
+ xValue = cssValuePool().createValue(50, CSSPrimitiveValue::CSS_PERCENTAGE);
+ } else {
+ xValue = cssValuePool().createIdentifierValue(CSSValueCenter);
+ }
+ }
+
+ RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
+ list->append(xValue.release());
+ if (yValue)
+ list->append(yValue.release());
+ if (zValue)
+ list->append(zValue.release());
+ return list.release();
+}
-bool CSSPropertyParser::parseTransformOrigin(CSSPropertyID propId, CSSPropertyID& propId1, CSSPropertyID& propId2, CSSPropertyID& propId3, RefPtrWillBeRawPtr<CSSValue>& value, RefPtrWillBeRawPtr<CSSValue>& value2, RefPtrWillBeRawPtr<CSSValue>& value3)
+bool CSSPropertyParser::parseWebkitTransformOrigin(CSSPropertyID propId, CSSPropertyID& propId1, CSSPropertyID& propId2, CSSPropertyID& propId3, RefPtrWillBeRawPtr<CSSValue>& value, RefPtrWillBeRawPtr<CSSValue>& value2, RefPtrWillBeRawPtr<CSSValue>& value3)
{
propId1 = propId;
propId2 = propId;
@@ -7243,9 +7333,9 @@ bool CSSPropertyParser::parseTransformOrigin(CSSPropertyID propId, CSSPropertyID
switch (propId) {
case CSSPropertyWebkitTransformOrigin:
- if (!parseTransformOriginShorthand(value, value2, value3))
+ if (!parseWebkitTransformOriginShorthand(value, value2, value3))
return false;
- // parseTransformOriginShorthand advances the m_valueList pointer
+ // parseWebkitTransformOriginShorthand advances the m_valueList pointer
break;
case CSSPropertyWebkitTransformOriginX: {
value = parseFillPositionX(m_valueList.get());
@@ -7274,7 +7364,7 @@ bool CSSPropertyParser::parseTransformOrigin(CSSPropertyID propId, CSSPropertyID
return value;
}
-bool CSSPropertyParser::parsePerspectiveOrigin(CSSPropertyID propId, CSSPropertyID& propId1, CSSPropertyID& propId2, RefPtrWillBeRawPtr<CSSValue>& value, RefPtrWillBeRawPtr<CSSValue>& value2)
+bool CSSPropertyParser::parseWebkitPerspectiveOrigin(CSSPropertyID propId, CSSPropertyID& propId1, CSSPropertyID& propId2, RefPtrWillBeRawPtr<CSSValue>& value, RefPtrWillBeRawPtr<CSSValue>& value2)
{
propId1 = propId;
propId2 = propId;
« no previous file with comments | « Source/core/css/parser/CSSPropertyParser.h ('k') | Source/core/css/resolver/AnimatedStyleBuilder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698