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

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

Issue 474873002: Clean parsing for -webkit-transform-origin* (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: tweak logic to be clearer Created 6 years, 4 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
« no previous file with comments | « Source/core/css/parser/CSSPropertyParser.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1132 matching lines...) Expand 10 before | Expand all | Expand 10 after
1143 if (!list) 1143 if (!list)
1144 return false; 1144 return false;
1145 // These values are added to match gecko serialization. 1145 // These values are added to match gecko serialization.
1146 if (list->length() == 1) 1146 if (list->length() == 1)
1147 list->append(cssValuePool().createValue(50, CSSPrimitiveValue::CSS_P ERCENTAGE)); 1147 list->append(cssValuePool().createValue(50, CSSPrimitiveValue::CSS_P ERCENTAGE));
1148 if (list->length() == 2) 1148 if (list->length() == 2)
1149 list->append(cssValuePool().createValue(0, CSSPrimitiveValue::CSS_PX )); 1149 list->append(cssValuePool().createValue(0, CSSPrimitiveValue::CSS_PX ));
1150 addProperty(propId, list.release(), important); 1150 addProperty(propId, list.release(), important);
1151 return true; 1151 return true;
1152 } 1152 }
1153 case CSSPropertyWebkitTransformOriginX:
1154 parsedValue = parseFillPositionX(m_valueList.get());
1155 if (parsedValue)
1156 m_valueList->next();
1157 break;
1158 case CSSPropertyWebkitTransformOriginY:
1159 parsedValue = parseFillPositionY(m_valueList.get());
1160 if (parsedValue)
1161 m_valueList->next();
1162 break;
1163 case CSSPropertyWebkitTransformOriginZ:
1164 validPrimitive = validUnit(value, FLength);
1165 break;
1153 case CSSPropertyWebkitTransformOrigin: 1166 case CSSPropertyWebkitTransformOrigin:
1154 case CSSPropertyWebkitTransformOriginX: 1167 return parseWebkitTransformOriginShorthand(important);
1155 case CSSPropertyWebkitTransformOriginY:
1156 case CSSPropertyWebkitTransformOriginZ: {
1157 RefPtrWillBeRawPtr<CSSValue> val1 = nullptr;
1158 RefPtrWillBeRawPtr<CSSValue> val2 = nullptr;
1159 RefPtrWillBeRawPtr<CSSValue> val3 = nullptr;
1160 CSSPropertyID propId1, propId2, propId3;
1161 if (parseWebkitTransformOrigin(propId, propId1, propId2, propId3, val1, val2, val3)) {
1162 addProperty(propId1, val1.release(), important);
1163 if (val2)
1164 addProperty(propId2, val2.release(), important);
1165 if (val3)
1166 addProperty(propId3, val3.release(), important);
1167 return true;
1168 }
1169 return false;
1170 }
1171 case CSSPropertyPerspective: 1168 case CSSPropertyPerspective:
1172 if (id == CSSValueNone) { 1169 if (id == CSSValueNone) {
1173 validPrimitive = true; 1170 validPrimitive = true;
1174 } else if (validUnit(value, FLength | FNonNeg)) { 1171 } else if (validUnit(value, FLength | FNonNeg)) {
1175 addProperty(propId, createPrimitiveNumericValue(value), important); 1172 addProperty(propId, createPrimitiveNumericValue(value), important);
1176 return true; 1173 return true;
1177 } 1174 }
1178 break; 1175 break;
1179 case CSSPropertyWebkitPerspective: 1176 case CSSPropertyWebkitPerspective:
1180 if (id == CSSValueNone) { 1177 if (id == CSSValueNone) {
(...skipping 1945 matching lines...) Expand 10 before | Expand all | Expand 10 after
3126 CSSPropertyID result = cssPropertyID(value->string); 3123 CSSPropertyID result = cssPropertyID(value->string);
3127 if (result && RuntimeCSSEnabled::isCSSPropertyEnabled(result)) 3124 if (result && RuntimeCSSEnabled::isCSSPropertyEnabled(result))
3128 return cssValuePool().createIdentifierValue(result); 3125 return cssValuePool().createIdentifierValue(result);
3129 if (equalIgnoringCase(value, "none")) 3126 if (equalIgnoringCase(value, "none"))
3130 return cssValuePool().createIdentifierValue(CSSValueNone); 3127 return cssValuePool().createIdentifierValue(CSSValueNone);
3131 if (equalIgnoringCase(value, "inherit") || equalIgnoringCase(value, "initial ")) 3128 if (equalIgnoringCase(value, "inherit") || equalIgnoringCase(value, "initial "))
3132 return nullptr; 3129 return nullptr;
3133 return createPrimitiveStringValue(value); 3130 return createPrimitiveStringValue(value);
3134 } 3131 }
3135 3132
3136 bool CSSPropertyParser::parseWebkitTransformOriginShorthand(RefPtrWillBeRawPtr<C SSValue>& value1, RefPtrWillBeRawPtr<CSSValue>& value2, RefPtrWillBeRawPtr<CSSVa lue>& value3) 3133 bool CSSPropertyParser::parseWebkitTransformOriginShorthand(bool important)
3137 { 3134 {
3138 parse2ValuesFillPosition(m_valueList.get(), value1, value2); 3135 RefPtrWillBeRawPtr<CSSValue> originX;
3136 RefPtrWillBeRawPtr<CSSValue> originY;
3137 RefPtrWillBeRawPtr<CSSValue> originZ;
3139 3138
3140 // now get z 3139 parse2ValuesFillPosition(m_valueList.get(), originX, originY);
3140
3141 if (m_valueList->current()) { 3141 if (m_valueList->current()) {
3142 if (validUnit(m_valueList->current(), FLength)) { 3142 if (!validUnit(m_valueList->current(), FLength))
3143 value3 = createPrimitiveNumericValue(m_valueList->current()); 3143 return false;
3144 m_valueList->next(); 3144 originZ = createPrimitiveNumericValue(m_valueList->current());
3145 return true; 3145 m_valueList->next();
3146 } 3146 } else {
3147 return false; 3147 originZ = cssValuePool().createImplicitInitialValue();
3148 } 3148 }
3149 value3 = cssValuePool().createImplicitInitialValue(); 3149
3150 addProperty(CSSPropertyWebkitTransformOriginX, originX.release(), important) ;
3151 addProperty(CSSPropertyWebkitTransformOriginY, originY.release(), important) ;
3152 addProperty(CSSPropertyWebkitTransformOriginZ, originZ.release(), important) ;
3153
3150 return true; 3154 return true;
3151 } 3155 }
3152 3156
3153 bool CSSPropertyParser::parseCubicBezierTimingFunctionValue(CSSParserValueList*& args, double& result) 3157 bool CSSPropertyParser::parseCubicBezierTimingFunctionValue(CSSParserValueList*& args, double& result)
3154 { 3158 {
3155 CSSParserValue* v = args->current(); 3159 CSSParserValue* v = args->current();
3156 if (!validUnit(v, FNumber)) 3160 if (!validUnit(v, FNumber))
3157 return false; 3161 return false;
3158 result = v->fValue; 3162 result = v->fValue;
3159 v = args->next(); 3163 v = args->next();
(...skipping 4394 matching lines...) Expand 10 before | Expand all | Expand 10 after
7554 7558
7555 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated() ; 7559 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated() ;
7556 list->append(xValue.release()); 7560 list->append(xValue.release());
7557 if (yValue) 7561 if (yValue)
7558 list->append(yValue.release()); 7562 list->append(yValue.release());
7559 if (zValue) 7563 if (zValue)
7560 list->append(zValue.release()); 7564 list->append(zValue.release());
7561 return list.release(); 7565 return list.release();
7562 } 7566 }
7563 7567
7564 bool CSSPropertyParser::parseWebkitTransformOrigin(CSSPropertyID propId, CSSProp ertyID& propId1, CSSPropertyID& propId2, CSSPropertyID& propId3, RefPtrWillBeRaw Ptr<CSSValue>& value, RefPtrWillBeRawPtr<CSSValue>& value2, RefPtrWillBeRawPtr<C SSValue>& value3)
7565 {
7566 propId1 = propId;
7567 propId2 = propId;
7568 propId3 = propId;
7569 if (propId == CSSPropertyWebkitTransformOrigin) {
7570 propId1 = CSSPropertyWebkitTransformOriginX;
7571 propId2 = CSSPropertyWebkitTransformOriginY;
7572 propId3 = CSSPropertyWebkitTransformOriginZ;
7573 }
7574
7575 switch (propId) {
7576 case CSSPropertyWebkitTransformOrigin:
7577 if (!parseWebkitTransformOriginShorthand(value, value2, value3))
7578 return false;
7579 // parseWebkitTransformOriginShorthand advances the m_valueList poin ter
7580 break;
7581 case CSSPropertyWebkitTransformOriginX: {
7582 value = parseFillPositionX(m_valueList.get());
7583 if (value)
7584 m_valueList->next();
7585 break;
7586 }
7587 case CSSPropertyWebkitTransformOriginY: {
7588 value = parseFillPositionY(m_valueList.get());
7589 if (value)
7590 m_valueList->next();
7591 break;
7592 }
7593 case CSSPropertyWebkitTransformOriginZ: {
7594 if (validUnit(m_valueList->current(), FLength))
7595 value = createPrimitiveNumericValue(m_valueList->current());
7596 if (value)
7597 m_valueList->next();
7598 break;
7599 }
7600 default:
7601 ASSERT_NOT_REACHED();
7602 return false;
7603 }
7604
7605 return value;
7606 }
7607
7608 bool CSSPropertyParser::parseWebkitPerspectiveOrigin(CSSPropertyID propId, CSSPr opertyID& propId1, CSSPropertyID& propId2, RefPtrWillBeRawPtr<CSSValue>& value, RefPtrWillBeRawPtr<CSSValue>& value2) 7568 bool CSSPropertyParser::parseWebkitPerspectiveOrigin(CSSPropertyID propId, CSSPr opertyID& propId1, CSSPropertyID& propId2, RefPtrWillBeRawPtr<CSSValue>& value, RefPtrWillBeRawPtr<CSSValue>& value2)
7609 { 7569 {
7610 propId1 = propId; 7570 propId1 = propId;
7611 propId2 = propId; 7571 propId2 = propId;
7612 if (propId == CSSPropertyWebkitPerspectiveOrigin) { 7572 if (propId == CSSPropertyWebkitPerspectiveOrigin) {
7613 propId1 = CSSPropertyWebkitPerspectiveOriginX; 7573 propId1 = CSSPropertyWebkitPerspectiveOriginX;
7614 propId2 = CSSPropertyWebkitPerspectiveOriginY; 7574 propId2 = CSSPropertyWebkitPerspectiveOriginY;
7615 } 7575 }
7616 7576
7617 switch (propId) { 7577 switch (propId) {
(...skipping 914 matching lines...) Expand 10 before | Expand all | Expand 10 after
8532 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueFill)); 8492 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueFill));
8533 if (!seenStroke) 8493 if (!seenStroke)
8534 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueStroke) ); 8494 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueStroke) );
8535 if (!seenMarkers) 8495 if (!seenMarkers)
8536 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueMarkers )); 8496 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueMarkers ));
8537 8497
8538 return parsedValues.release(); 8498 return parsedValues.release();
8539 } 8499 }
8540 8500
8541 } // namespace blink 8501 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/css/parser/CSSPropertyParser.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698