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

Side by Side Diff: Source/core/css/parser/CSSPropertyParser.cpp

Issue 212483003: CSS Transforms: Implement transform-origin (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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2003 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 2003 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) 3 * Copyright (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com)
4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. 4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved.
5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> 5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com>
6 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> 6 * Copyright (C) 2008 Eric Seidel <eric@webkit.org>
7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) 7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/)
8 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. 8 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved.
9 * Copyright (C) 2012 Intel Corporation. All rights reserved. 9 * Copyright (C) 2012 Intel Corporation. All rights reserved.
10 * 10 *
(...skipping 1102 matching lines...) Expand 10 before | Expand all | Expand 10 after
1113 validPrimitive = true; 1113 validPrimitive = true;
1114 else { 1114 else {
1115 RefPtrWillBeRawPtr<CSSValue> transformValue = parseTransform(propId) ; 1115 RefPtrWillBeRawPtr<CSSValue> transformValue = parseTransform(propId) ;
1116 if (transformValue) { 1116 if (transformValue) {
1117 addProperty(propId, transformValue.release(), important); 1117 addProperty(propId, transformValue.release(), important);
1118 return true; 1118 return true;
1119 } 1119 }
1120 return false; 1120 return false;
1121 } 1121 }
1122 break; 1122 break;
1123 case CSSPropertyTransformOrigin: {
1124 RefPtrWillBeRawPtr<CSSValueList> list = parseTransformOrigin();
1125 if (!list)
1126 return false;
1127 // These values are added to match gecko serialization.
1128 if (list->length() == 1)
1129 list->append(cssValuePool().createValue(50, CSSPrimitiveValue::CSS_P ERCENTAGE));
1130 if (list->length() == 2)
1131 list->append(cssValuePool().createValue(0, CSSPrimitiveValue::CSS_PX ));
1132 addProperty(propId, list.release(), important);
1133 return true;
1134 }
1123 case CSSPropertyWebkitTransformOrigin: 1135 case CSSPropertyWebkitTransformOrigin:
1124 case CSSPropertyWebkitTransformOriginX: 1136 case CSSPropertyWebkitTransformOriginX:
1125 case CSSPropertyWebkitTransformOriginY: 1137 case CSSPropertyWebkitTransformOriginY:
1126 case CSSPropertyWebkitTransformOriginZ: { 1138 case CSSPropertyWebkitTransformOriginZ: {
1127 RefPtrWillBeRawPtr<CSSValue> val1 = nullptr; 1139 RefPtrWillBeRawPtr<CSSValue> val1 = nullptr;
1128 RefPtrWillBeRawPtr<CSSValue> val2 = nullptr; 1140 RefPtrWillBeRawPtr<CSSValue> val2 = nullptr;
1129 RefPtrWillBeRawPtr<CSSValue> val3 = nullptr; 1141 RefPtrWillBeRawPtr<CSSValue> val3 = nullptr;
1130 CSSPropertyID propId1, propId2, propId3; 1142 CSSPropertyID propId1, propId2, propId3;
1131 if (parseTransformOrigin(propId, propId1, propId2, propId3, val1, val2, val3)) { 1143 if (parseWebkitTransformOrigin(propId, propId1, propId2, propId3, val1, val2, val3)) {
1132 addProperty(propId1, val1.release(), important); 1144 addProperty(propId1, val1.release(), important);
1133 if (val2) 1145 if (val2)
1134 addProperty(propId2, val2.release(), important); 1146 addProperty(propId2, val2.release(), important);
1135 if (val3) 1147 if (val3)
1136 addProperty(propId3, val3.release(), important); 1148 addProperty(propId3, val3.release(), important);
1137 return true; 1149 return true;
1138 } 1150 }
1139 return false; 1151 return false;
1140 } 1152 }
1141 case CSSPropertyPerspective: 1153 case CSSPropertyPerspective:
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after
1607 // check for parser state. We need to invalidate if someone adds them outsid e 1619 // check for parser state. We need to invalidate if someone adds them outsid e
1608 // a @viewport rule. 1620 // a @viewport rule.
1609 case CSSPropertyMaxZoom: 1621 case CSSPropertyMaxZoom:
1610 case CSSPropertyMinZoom: 1622 case CSSPropertyMinZoom:
1611 case CSSPropertyOrientation: 1623 case CSSPropertyOrientation:
1612 case CSSPropertyUserZoom: 1624 case CSSPropertyUserZoom:
1613 validPrimitive = false; 1625 validPrimitive = false;
1614 break; 1626 break;
1615 // FIXME: crbug.com/154772 Unimplemented css-transforms properties 1627 // FIXME: crbug.com/154772 Unimplemented css-transforms properties
1616 case CSSPropertyPerspectiveOrigin: 1628 case CSSPropertyPerspectiveOrigin:
1617 case CSSPropertyTransformOrigin:
1618 return false; 1629 return false;
1619 default: 1630 default:
1620 return parseSVGValue(propId, important); 1631 return parseSVGValue(propId, important);
1621 } 1632 }
1622 1633
1623 if (validPrimitive) { 1634 if (validPrimitive) {
1624 parsedValue = parseValidPrimitive(id, value); 1635 parsedValue = parseValidPrimitive(id, value);
1625 m_valueList->next(); 1636 m_valueList->next();
1626 } 1637 }
1627 ASSERT(!m_parsedCalculation); 1638 ASSERT(!m_parsedCalculation);
(...skipping 1469 matching lines...) Expand 10 before | Expand all | Expand 10 after
3097 return cssValuePool().createIdentifierValue(CSSValueAll); 3108 return cssValuePool().createIdentifierValue(CSSValueAll);
3098 } 3109 }
3099 if (equalIgnoringCase(value, "none")) { 3110 if (equalIgnoringCase(value, "none")) {
3100 context.commitAnimationPropertyKeyword(); 3111 context.commitAnimationPropertyKeyword();
3101 context.sawAnimationPropertyKeyword(); 3112 context.sawAnimationPropertyKeyword();
3102 return cssValuePool().createIdentifierValue(CSSValueNone); 3113 return cssValuePool().createIdentifierValue(CSSValueNone);
3103 } 3114 }
3104 return nullptr; 3115 return nullptr;
3105 } 3116 }
3106 3117
3107 bool CSSPropertyParser::parseTransformOriginShorthand(RefPtrWillBeRawPtr<CSSValu e>& value1, RefPtrWillBeRawPtr<CSSValue>& value2, RefPtrWillBeRawPtr<CSSValue>& value3) 3118 bool CSSPropertyParser::parseWebkitTransformOriginShorthand(RefPtrWillBeRawPtr<C SSValue>& value1, RefPtrWillBeRawPtr<CSSValue>& value2, RefPtrWillBeRawPtr<CSSVa lue>& value3)
3108 { 3119 {
3109 parse2ValuesFillPosition(m_valueList.get(), value1, value2); 3120 parse2ValuesFillPosition(m_valueList.get(), value1, value2);
3110 3121
3111 // now get z 3122 // now get z
3112 if (m_valueList->current()) { 3123 if (m_valueList->current()) {
3113 if (validUnit(m_valueList->current(), FLength)) { 3124 if (validUnit(m_valueList->current(), FLength)) {
3114 value3 = createPrimitiveNumericValue(m_valueList->current()); 3125 value3 = createPrimitiveNumericValue(m_valueList->current());
3115 m_valueList->next(); 3126 m_valueList->next();
3116 return true; 3127 return true;
3117 } 3128 }
(...skipping 4108 matching lines...) Expand 10 before | Expand all | Expand 10 after
7226 RefPtrWillBeRawPtr<CSSFilterValue> filterValue = parseBuiltinFilterA rguments(args, filterType); 7237 RefPtrWillBeRawPtr<CSSFilterValue> filterValue = parseBuiltinFilterA rguments(args, filterType);
7227 if (!filterValue) 7238 if (!filterValue)
7228 return nullptr; 7239 return nullptr;
7229 7240
7230 list->append(filterValue); 7241 list->append(filterValue);
7231 } 7242 }
7232 } 7243 }
7233 7244
7234 return list.release(); 7245 return list.release();
7235 } 7246 }
7247 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseTransformOrigin()
7248 {
7249 CSSParserValue* value = m_valueList->current();
7250 CSSValueID id = value->id;
7251 RefPtrWillBeRawPtr<CSSValue> xValue;
7252 RefPtrWillBeRawPtr<CSSValue> yValue;
7253 RefPtrWillBeRawPtr<CSSValue> zValue;
7254 if (id == CSSValueLeft || id == CSSValueRight) {
7255 xValue = cssValuePool().createIdentifierValue(id);
7256 } else if (id == CSSValueTop || id == CSSValueBottom) {
7257 yValue = cssValuePool().createIdentifierValue(id);
7258 } else if (id == CSSValueCenter) {
7259 // Unresolved as to whether this is X or Y.
7260 } else if (validUnit(value, FPercent | FLength)) {
7261 xValue = createPrimitiveNumericValue(value);
7262 } else {
7263 return nullptr;
7264 }
7236 7265
7237 bool CSSPropertyParser::parseTransformOrigin(CSSPropertyID propId, CSSPropertyID & propId1, CSSPropertyID& propId2, CSSPropertyID& propId3, RefPtrWillBeRawPtr<CS SValue>& value, RefPtrWillBeRawPtr<CSSValue>& value2, RefPtrWillBeRawPtr<CSSValu e>& value3) 7266 if ((value = m_valueList->next())) {
7267 id = value->id;
7268 if (!xValue && (id == CSSValueLeft || id == CSSValueRight)) {
7269 xValue = cssValuePool().createIdentifierValue(id);
7270 } else if (!yValue && (id == CSSValueTop || id == CSSValueBottom)) {
7271 yValue = cssValuePool().createIdentifierValue(id);
7272 } else if (id == CSSValueCenter) {
7273 // Resolved below.
7274 } else if (!yValue && validUnit(value, FPercent | FLength)) {
7275 yValue = createPrimitiveNumericValue(value);
7276 } else {
7277 return nullptr;
7278 }
7279
7280 // If X or Y have not been resolved, they must be center.
7281 if (!xValue)
7282 xValue = cssValuePool().createIdentifierValue(CSSValueCenter);
7283 if (!yValue)
7284 yValue = cssValuePool().createIdentifierValue(CSSValueCenter);
7285
7286 if ((value = m_valueList->next())) {
7287 if (!validUnit(value, FLength))
7288 return nullptr;
7289 zValue = createPrimitiveNumericValue(value);
7290
7291 if ((value = m_valueList->next()))
7292 return nullptr;
7293 }
7294 } else if (!xValue) {
7295 if (yValue) {
7296 xValue = cssValuePool().createValue(50, CSSPrimitiveValue::CSS_PERCE NTAGE);
7297 } else {
7298 xValue = cssValuePool().createIdentifierValue(CSSValueCenter);
7299 }
7300 }
7301
7302 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated() ;
7303 list->append(xValue.release());
7304 if (yValue)
7305 list->append(yValue.release());
7306 if (zValue)
7307 list->append(zValue.release());
7308 return list.release();
7309 }
7310
7311 bool CSSPropertyParser::parseWebkitTransformOrigin(CSSPropertyID propId, CSSProp ertyID& propId1, CSSPropertyID& propId2, CSSPropertyID& propId3, RefPtrWillBeRaw Ptr<CSSValue>& value, RefPtrWillBeRawPtr<CSSValue>& value2, RefPtrWillBeRawPtr<C SSValue>& value3)
7238 { 7312 {
7239 propId1 = propId; 7313 propId1 = propId;
7240 propId2 = propId; 7314 propId2 = propId;
7241 propId3 = propId; 7315 propId3 = propId;
7242 if (propId == CSSPropertyWebkitTransformOrigin) { 7316 if (propId == CSSPropertyWebkitTransformOrigin) {
7243 propId1 = CSSPropertyWebkitTransformOriginX; 7317 propId1 = CSSPropertyWebkitTransformOriginX;
7244 propId2 = CSSPropertyWebkitTransformOriginY; 7318 propId2 = CSSPropertyWebkitTransformOriginY;
7245 propId3 = CSSPropertyWebkitTransformOriginZ; 7319 propId3 = CSSPropertyWebkitTransformOriginZ;
7246 } 7320 }
7247 7321
7248 switch (propId) { 7322 switch (propId) {
7249 case CSSPropertyWebkitTransformOrigin: 7323 case CSSPropertyWebkitTransformOrigin:
7250 if (!parseTransformOriginShorthand(value, value2, value3)) 7324 if (!parseWebkitTransformOriginShorthand(value, value2, value3))
7251 return false; 7325 return false;
7252 // parseTransformOriginShorthand advances the m_valueList pointer 7326 // parseWebkitTransformOriginShorthand advances the m_valueList poin ter
7253 break; 7327 break;
7254 case CSSPropertyWebkitTransformOriginX: { 7328 case CSSPropertyWebkitTransformOriginX: {
7255 value = parseFillPositionX(m_valueList.get()); 7329 value = parseFillPositionX(m_valueList.get());
7256 if (value) 7330 if (value)
7257 m_valueList->next(); 7331 m_valueList->next();
7258 break; 7332 break;
7259 } 7333 }
7260 case CSSPropertyWebkitTransformOriginY: { 7334 case CSSPropertyWebkitTransformOriginY: {
7261 value = parseFillPositionY(m_valueList.get()); 7335 value = parseFillPositionY(m_valueList.get());
7262 if (value) 7336 if (value)
(...skipping 978 matching lines...) Expand 10 before | Expand all | Expand 10 after
8241 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueFill)); 8315 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueFill));
8242 if (!seenStroke) 8316 if (!seenStroke)
8243 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueStroke) ); 8317 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueStroke) );
8244 if (!seenMarkers) 8318 if (!seenMarkers)
8245 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueMarkers )); 8319 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueMarkers ));
8246 8320
8247 return parsedValues.release(); 8321 return parsedValues.release();
8248 } 8322 }
8249 8323
8250 } // namespace WebCore 8324 } // namespace WebCore
OLDNEW
« 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