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

Side by Side Diff: sky/engine/core/css/parser/CSSPropertyParser.cpp

Issue 1229273004: Remove Animations and Transitions. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 5 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
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 27 matching lines...) Expand all
38 #include "sky/engine/core/css/CSSFunctionValue.h" 38 #include "sky/engine/core/css/CSSFunctionValue.h"
39 #include "sky/engine/core/css/CSSGradientValue.h" 39 #include "sky/engine/core/css/CSSGradientValue.h"
40 #include "sky/engine/core/css/CSSInheritedValue.h" 40 #include "sky/engine/core/css/CSSInheritedValue.h"
41 #include "sky/engine/core/css/CSSInitialValue.h" 41 #include "sky/engine/core/css/CSSInitialValue.h"
42 #include "sky/engine/core/css/CSSLineBoxContainValue.h" 42 #include "sky/engine/core/css/CSSLineBoxContainValue.h"
43 #include "sky/engine/core/css/CSSPrimitiveValue.h" 43 #include "sky/engine/core/css/CSSPrimitiveValue.h"
44 #include "sky/engine/core/css/CSSPropertyMetadata.h" 44 #include "sky/engine/core/css/CSSPropertyMetadata.h"
45 #include "sky/engine/core/css/CSSPropertySourceData.h" 45 #include "sky/engine/core/css/CSSPropertySourceData.h"
46 #include "sky/engine/core/css/CSSSelector.h" 46 #include "sky/engine/core/css/CSSSelector.h"
47 #include "sky/engine/core/css/CSSShadowValue.h" 47 #include "sky/engine/core/css/CSSShadowValue.h"
48 #include "sky/engine/core/css/CSSTimingFunctionValue.h"
49 #include "sky/engine/core/css/CSSTransformValue.h" 48 #include "sky/engine/core/css/CSSTransformValue.h"
50 #include "sky/engine/core/css/CSSUnicodeRangeValue.h" 49 #include "sky/engine/core/css/CSSUnicodeRangeValue.h"
51 #include "sky/engine/core/css/CSSValueList.h" 50 #include "sky/engine/core/css/CSSValueList.h"
52 #include "sky/engine/core/css/CSSValuePool.h" 51 #include "sky/engine/core/css/CSSValuePool.h"
53 #include "sky/engine/core/css/HashTools.h" 52 #include "sky/engine/core/css/HashTools.h"
54 #include "sky/engine/core/css/Pair.h" 53 #include "sky/engine/core/css/Pair.h"
55 #include "sky/engine/core/css/Rect.h" 54 #include "sky/engine/core/css/Rect.h"
56 #include "sky/engine/core/css/parser/BisonCSSParser.h" 55 #include "sky/engine/core/css/parser/BisonCSSParser.h"
57 #include "sky/engine/core/css/parser/CSSParserIdioms.h" 56 #include "sky/engine/core/css/parser/CSSParserIdioms.h"
58 #include "sky/engine/core/css/parser/CSSParserValues.h" 57 #include "sky/engine/core/css/parser/CSSParserValues.h"
(...skipping 857 matching lines...) Expand 10 before | Expand all | Expand 10 after
916 return false; 915 return false;
917 RefPtr<CSSValue> originX = nullptr; 916 RefPtr<CSSValue> originX = nullptr;
918 RefPtr<CSSValue> originY = nullptr; 917 RefPtr<CSSValue> originY = nullptr;
919 parse2ValuesFillPosition(m_valueList, originX, originY); 918 parse2ValuesFillPosition(m_valueList, originX, originY);
920 if (!originX) 919 if (!originX)
921 return false; 920 return false;
922 addProperty(CSSPropertyWebkitPerspectiveOriginX, originX.release()); 921 addProperty(CSSPropertyWebkitPerspectiveOriginX, originX.release());
923 addProperty(CSSPropertyWebkitPerspectiveOriginY, originY.release()); 922 addProperty(CSSPropertyWebkitPerspectiveOriginY, originY.release());
924 return true; 923 return true;
925 } 924 }
926 case CSSPropertyAnimationDelay:
927 case CSSPropertyAnimationDirection:
928 case CSSPropertyAnimationDuration:
929 case CSSPropertyAnimationFillMode:
930 case CSSPropertyAnimationName:
931 case CSSPropertyAnimationPlayState:
932 case CSSPropertyAnimationIterationCount:
933 case CSSPropertyAnimationTimingFunction:
934 case CSSPropertyTransitionDelay:
935 case CSSPropertyTransitionDuration:
936 case CSSPropertyTransitionTimingFunction:
937 case CSSPropertyTransitionProperty: {
938 if (RefPtr<CSSValueList> val = parseAnimationPropertyList(propId)) {
939 addProperty(propId, val.release());
940 return true;
941 }
942 return false;
943 }
944
945 case CSSPropertyWillChange:
946 parsedValue = parseWillChange();
947 break;
948 // End of CSS3 properties 925 // End of CSS3 properties
949 926
950 // Apple specific properties. These will never be standardized and are pure ly to 927 // Apple specific properties. These will never be standardized and are pure ly to
951 // support custom WebKit-based Apple applications. 928 // support custom WebKit-based Apple applications.
952 case CSSPropertyWebkitFontSizeDelta: // <length> 929 case CSSPropertyWebkitFontSizeDelta: // <length>
953 validPrimitive = validUnit(value, FLength); 930 validPrimitive = validUnit(value, FLength);
954 break; 931 break;
955 932
956 case CSSPropertyWebkitHighlight: 933 case CSSPropertyWebkitHighlight:
957 if (id == CSSValueNone || value->unit == CSSPrimitiveValue::CSS_STRING) 934 if (id == CSSValueNone || value->unit == CSSPrimitiveValue::CSS_STRING)
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
1035 // <padding-width>{1,4} | inherit 1012 // <padding-width>{1,4} | inherit
1036 return parse4Values(propId, paddingShorthand().properties()); 1013 return parse4Values(propId, paddingShorthand().properties());
1037 case CSSPropertyFlexFlow: 1014 case CSSPropertyFlexFlow:
1038 return parseShorthand(propId, flexFlowShorthand()); 1015 return parseShorthand(propId, flexFlowShorthand());
1039 case CSSPropertyFont: 1016 case CSSPropertyFont:
1040 // [ [ 'font-style' || 'font-variant' || 'font-weight' ]? 'font-size' [ / 'line-height' ]? 1017 // [ [ 'font-style' || 'font-variant' || 'font-weight' ]? 'font-size' [ / 'line-height' ]?
1041 // 'font-family' ] | inherit 1018 // 'font-family' ] | inherit
1042 return parseFont(); 1019 return parseFont();
1043 case CSSPropertyWebkitTextStroke: 1020 case CSSPropertyWebkitTextStroke:
1044 return parseShorthand(propId, webkitTextStrokeShorthand()); 1021 return parseShorthand(propId, webkitTextStrokeShorthand());
1045 case CSSPropertyAnimation:
1046 return parseAnimationShorthand(propId);
1047 case CSSPropertyTransition:
1048 return parseTransitionShorthand(propId);
1049 case CSSPropertyInvalid: 1022 case CSSPropertyInvalid:
1050 return false; 1023 return false;
1051 // CSS Text Layout Module Level 3: Vertical writing support 1024 // CSS Text Layout Module Level 3: Vertical writing support
1052 case CSSPropertyWebkitTextEmphasis: 1025 case CSSPropertyWebkitTextEmphasis:
1053 return parseShorthand(propId, webkitTextEmphasisShorthand()); 1026 return parseShorthand(propId, webkitTextEmphasisShorthand());
1054 1027
1055 case CSSPropertyWebkitTextEmphasisStyle: 1028 case CSSPropertyWebkitTextEmphasisStyle:
1056 return parseTextEmphasisStyle(); 1029 return parseTextEmphasisStyle();
1057 1030
1058 case CSSPropertyWebkitTextOrientation: 1031 case CSSPropertyWebkitTextOrientation:
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
1283 1256
1284 // Add in clip values when we hit the corresponding origin property. 1257 // Add in clip values when we hit the corresponding origin property.
1285 if (properties[i] == CSSPropertyBackgroundOrigin && !foundClip) 1258 if (properties[i] == CSSPropertyBackgroundOrigin && !foundClip)
1286 addProperty(CSSPropertyBackgroundClip, clipValue.release()); 1259 addProperty(CSSPropertyBackgroundClip, clipValue.release());
1287 } 1260 }
1288 1261
1289 m_implicitShorthand = false; 1262 m_implicitShorthand = false;
1290 return true; 1263 return true;
1291 } 1264 }
1292 1265
1293 static bool isValidTransitionPropertyList(CSSValueList* value)
1294 {
1295 if (value->length() < 2)
1296 return true;
1297 for (CSSValueListIterator i = value; i.hasMore(); i.advance()) {
1298 // FIXME: Shorthand parsing shouldn't add initial to the list since it w on't round-trip
1299 if (i.value()->isInitialValue())
1300 continue;
1301 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(i.value());
1302 if (primitiveValue->isValueID() && primitiveValue->getValueID() == CSSVa lueNone)
1303 return false;
1304 }
1305 return true;
1306 }
1307
1308 bool CSSPropertyParser::parseAnimationShorthand(CSSPropertyID propId)
1309 {
1310 const StylePropertyShorthand& animationProperties = parsingShorthandForPrope rty(propId);
1311 const unsigned numProperties = 8;
1312
1313 // The list of properties in the shorthand should be the same
1314 // length as the list with animation name in last position, even though they are
1315 // in a different order.
1316 ASSERT(numProperties == animationProperties.length());
1317 ASSERT(numProperties == shorthandForProperty(propId).length());
1318
1319 ShorthandScope scope(this, propId);
1320
1321 bool parsedProperty[numProperties] = { false };
1322 RefPtr<CSSValueList> values[numProperties];
1323 for (size_t i = 0; i < numProperties; ++i)
1324 values[i] = CSSValueList::createCommaSeparated();
1325
1326 while (m_valueList->current()) {
1327 if (consumeComma(m_valueList)) {
1328 // We hit the end. Fill in all remaining values with the initial val ue.
1329 for (size_t i = 0; i < numProperties; ++i) {
1330 if (!parsedProperty[i])
1331 values[i]->append(cssValuePool().createImplicitInitialValue( ));
1332 parsedProperty[i] = false;
1333 }
1334 if (!m_valueList->current())
1335 break;
1336 }
1337
1338 bool found = false;
1339 for (size_t i = 0; i < numProperties; ++i) {
1340 if (parsedProperty[i])
1341 continue;
1342 if (RefPtr<CSSValue> val = parseAnimationProperty(animationPropertie s.properties()[i])) {
1343 parsedProperty[i] = found = true;
1344 values[i]->append(val.release());
1345 break;
1346 }
1347 }
1348
1349 // if we didn't find at least one match, this is an
1350 // invalid shorthand and we have to ignore it
1351 if (!found)
1352 return false;
1353 }
1354
1355 for (size_t i = 0; i < numProperties; ++i) {
1356 // If we didn't find the property, set an intial value.
1357 if (!parsedProperty[i])
1358 values[i]->append(cssValuePool().createImplicitInitialValue());
1359
1360 addProperty(animationProperties.properties()[i], values[i].release());
1361 }
1362
1363 return true;
1364 }
1365
1366 bool CSSPropertyParser::parseTransitionShorthand(CSSPropertyID propId)
1367 {
1368 const unsigned numProperties = 4;
1369 const StylePropertyShorthand& shorthand = parsingShorthandForProperty(propId );
1370 ASSERT(numProperties == shorthand.length());
1371
1372 ShorthandScope scope(this, propId);
1373
1374 bool parsedProperty[numProperties] = { false };
1375 RefPtr<CSSValueList> values[numProperties];
1376 for (size_t i = 0; i < numProperties; ++i)
1377 values[i] = CSSValueList::createCommaSeparated();
1378
1379 while (m_valueList->current()) {
1380 if (consumeComma(m_valueList)) {
1381 // We hit the end. Fill in all remaining values with the initial val ue.
1382 for (size_t i = 0; i < numProperties; ++i) {
1383 if (!parsedProperty[i])
1384 values[i]->append(cssValuePool().createImplicitInitialValue( ));
1385 parsedProperty[i] = false;
1386 }
1387 if (!m_valueList->current())
1388 break;
1389 }
1390
1391 bool found = false;
1392 for (size_t i = 0; i < numProperties; ++i) {
1393 if (parsedProperty[i])
1394 continue;
1395 if (RefPtr<CSSValue> val = parseAnimationProperty(shorthand.properti es()[i])) {
1396 parsedProperty[i] = found = true;
1397 values[i]->append(val.release());
1398 break;
1399 }
1400 }
1401
1402 // if we didn't find at least one match, this is an
1403 // invalid shorthand and we have to ignore it
1404 if (!found)
1405 return false;
1406 }
1407
1408 ASSERT(shorthand.properties()[3] == CSSPropertyTransitionProperty);
1409 if (!isValidTransitionPropertyList(values[3].get()))
1410 return false;
1411
1412 // Fill in any remaining properties with the initial value and add
1413 for (size_t i = 0; i < numProperties; ++i) {
1414 if (!parsedProperty[i])
1415 values[i]->append(cssValuePool().createImplicitInitialValue());
1416 addProperty(shorthand.properties()[i], values[i].release());
1417 }
1418
1419 return true;
1420 }
1421
1422 bool CSSPropertyParser::parseShorthand(CSSPropertyID propId, const StyleProperty Shorthand& shorthand) 1266 bool CSSPropertyParser::parseShorthand(CSSPropertyID propId, const StyleProperty Shorthand& shorthand)
1423 { 1267 {
1424 // We try to match as many properties as possible 1268 // We try to match as many properties as possible
1425 // We set up an array of booleans to mark which property has been found, 1269 // We set up an array of booleans to mark which property has been found,
1426 // and we try to search for properties until it makes no longer any sense. 1270 // and we try to search for properties until it makes no longer any sense.
1427 ShorthandScope scope(this, propId); 1271 ShorthandScope scope(this, propId);
1428 1272
1429 bool found = false; 1273 bool found = false;
1430 unsigned propertiesParsed = 0; 1274 unsigned propertiesParsed = 0;
1431 bool propertyFound[6] = { false, false, false, false, false, false }; // 6 i s enough size. 1275 bool propertyFound[6] = { false, false, false, false, false, false }; // 6 i s enough size.
(...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after
2144 return true; 1988 return true;
2145 } 1989 }
2146 if (value) { 1990 if (value) {
2147 retValue1 = value.release(); 1991 retValue1 = value.release();
2148 retValue2 = value2.release(); 1992 retValue2 = value2.release();
2149 return true; 1993 return true;
2150 } 1994 }
2151 return false; 1995 return false;
2152 } 1996 }
2153 1997
2154 PassRefPtr<CSSValue> CSSPropertyParser::parseAnimationDelay()
2155 {
2156 CSSParserValue* value = m_valueList->current();
2157 if (validUnit(value, FTime))
2158 return createPrimitiveNumericValue(value);
2159 return nullptr;
2160 }
2161
2162 PassRefPtr<CSSValue> CSSPropertyParser::parseAnimationDirection()
2163 {
2164 CSSParserValue* value = m_valueList->current();
2165 if (value->id == CSSValueNormal || value->id == CSSValueAlternate || value-> id == CSSValueReverse || value->id == CSSValueAlternateReverse)
2166 return cssValuePool().createIdentifierValue(value->id);
2167 return nullptr;
2168 }
2169
2170 PassRefPtr<CSSValue> CSSPropertyParser::parseAnimationDuration()
2171 {
2172 CSSParserValue* value = m_valueList->current();
2173 if (validUnit(value, FTime | FNonNeg))
2174 return createPrimitiveNumericValue(value);
2175 return nullptr;
2176 }
2177
2178 PassRefPtr<CSSValue> CSSPropertyParser::parseAnimationFillMode()
2179 {
2180 CSSParserValue* value = m_valueList->current();
2181 if (value->id == CSSValueNone || value->id == CSSValueForwards || value->id == CSSValueBackwards || value->id == CSSValueBoth)
2182 return cssValuePool().createIdentifierValue(value->id);
2183 return nullptr;
2184 }
2185
2186 PassRefPtr<CSSValue> CSSPropertyParser::parseAnimationIterationCount()
2187 {
2188 CSSParserValue* value = m_valueList->current();
2189 if (value->id == CSSValueInfinite)
2190 return cssValuePool().createIdentifierValue(value->id);
2191 if (validUnit(value, FNumber | FNonNeg))
2192 return createPrimitiveNumericValue(value);
2193 return nullptr;
2194 }
2195
2196 PassRefPtr<CSSValue> CSSPropertyParser::parseAnimationName()
2197 {
2198 CSSParserValue* value = m_valueList->current();
2199 if (value->unit == CSSPrimitiveValue::CSS_STRING || value->unit == CSSPrimit iveValue::CSS_IDENT) {
2200 if (value->id == CSSValueNone || (value->unit == CSSPrimitiveValue::CSS_ STRING && equalIgnoringCase(value, "none"))) {
2201 return cssValuePool().createIdentifierValue(CSSValueNone);
2202 } else {
2203 return createPrimitiveStringValue(value);
2204 }
2205 }
2206 return nullptr;
2207 }
2208
2209 PassRefPtr<CSSValue> CSSPropertyParser::parseAnimationPlayState()
2210 {
2211 CSSParserValue* value = m_valueList->current();
2212 if (value->id == CSSValueRunning || value->id == CSSValuePaused)
2213 return cssValuePool().createIdentifierValue(value->id);
2214 return nullptr;
2215 }
2216
2217 PassRefPtr<CSSValue> CSSPropertyParser::parseAnimationProperty()
2218 {
2219 CSSParserValue* value = m_valueList->current();
2220 if (value->unit != CSSPrimitiveValue::CSS_IDENT)
2221 return nullptr;
2222 // Since all is valid css property keyword, cssPropertyID for all
2223 // returns non-null value. We need to check "all" before
2224 // cssPropertyID check.
2225 if (value->id == CSSValueAll)
2226 return cssValuePool().createIdentifierValue(CSSValueAll);
2227 CSSPropertyID property = cssPropertyID(value->string);
2228 if (property) {
2229 ASSERT(CSSPropertyMetadata::isEnabledProperty(property));
2230 return cssValuePool().createIdentifierValue(property);
2231 }
2232 if (value->id == CSSValueNone)
2233 return cssValuePool().createIdentifierValue(CSSValueNone);
2234 if (value->id == CSSValueInitial || value->id == CSSValueInherit)
2235 return nullptr;
2236 return createPrimitiveStringValue(value);
2237 }
2238
2239 bool CSSPropertyParser::parseWebkitTransformOriginShorthand() 1998 bool CSSPropertyParser::parseWebkitTransformOriginShorthand()
2240 { 1999 {
2241 RefPtr<CSSValue> originX = nullptr; 2000 RefPtr<CSSValue> originX = nullptr;
2242 RefPtr<CSSValue> originY = nullptr; 2001 RefPtr<CSSValue> originY = nullptr;
2243 RefPtr<CSSValue> originZ = nullptr; 2002 RefPtr<CSSValue> originZ = nullptr;
2244 2003
2245 parse2ValuesFillPosition(m_valueList, originX, originY); 2004 parse2ValuesFillPosition(m_valueList, originX, originY);
2246 2005
2247 if (m_valueList->current()) { 2006 if (m_valueList->current()) {
2248 if (!validUnit(m_valueList->current(), FLength)) 2007 if (!validUnit(m_valueList->current(), FLength))
2249 return false; 2008 return false;
2250 originZ = createPrimitiveNumericValue(m_valueList->current()); 2009 originZ = createPrimitiveNumericValue(m_valueList->current());
2251 m_valueList->next(); 2010 m_valueList->next();
2252 } else { 2011 } else {
2253 originZ = cssValuePool().createImplicitInitialValue(); 2012 originZ = cssValuePool().createImplicitInitialValue();
2254 } 2013 }
2255 2014
2256 addProperty(CSSPropertyWebkitTransformOriginX, originX.release()); 2015 addProperty(CSSPropertyWebkitTransformOriginX, originX.release());
2257 addProperty(CSSPropertyWebkitTransformOriginY, originY.release()); 2016 addProperty(CSSPropertyWebkitTransformOriginY, originY.release());
2258 addProperty(CSSPropertyWebkitTransformOriginZ, originZ.release()); 2017 addProperty(CSSPropertyWebkitTransformOriginZ, originZ.release());
2259 2018
2260 return true; 2019 return true;
2261 } 2020 }
2262 2021
2263 bool CSSPropertyParser::parseCubicBezierTimingFunctionValue(CSSParserValueList*& args, double& result)
2264 {
2265 CSSParserValue* v = args->current();
2266 if (!validUnit(v, FNumber))
2267 return false;
2268 result = v->fValue;
2269 v = args->next();
2270 if (!v)
2271 // The last number in the function has no comma after it, so we're done.
2272 return true;
2273 return consumeComma(args);
2274 }
2275
2276 PassRefPtr<CSSValue> CSSPropertyParser::parseAnimationTimingFunction()
2277 {
2278 CSSParserValue* value = m_valueList->current();
2279 if (value->id == CSSValueEase || value->id == CSSValueLinear || value->id == CSSValueEaseIn || value->id == CSSValueEaseOut
2280 || value->id == CSSValueEaseInOut || value->id == CSSValueStepStart || v alue->id == CSSValueStepEnd
2281 || value->id == CSSValueStepMiddle)
2282 return cssValuePool().createIdentifierValue(value->id);
2283
2284 // We must be a function.
2285 if (value->unit != CSSParserValue::Function)
2286 return nullptr;
2287
2288 CSSParserValueList* args = value->function->args.get();
2289
2290 if (equalIgnoringCase(value->function->name, "steps(")) {
2291 // For steps, 1 or 2 params must be specified (comma-separated)
2292 if (!args || (args->size() != 1 && args->size() != 3))
2293 return nullptr;
2294
2295 // There are two values.
2296 int numSteps;
2297 StepsTimingFunction::StepAtPosition stepAtPosition = StepsTimingFunction ::StepAtEnd;
2298
2299 CSSParserValue* v = args->current();
2300 if (!validUnit(v, FInteger))
2301 return nullptr;
2302 numSteps = clampToInteger(v->fValue);
2303 if (numSteps < 1)
2304 return nullptr;
2305
2306 if (args->next()) {
2307 // There is a comma so we need to parse the second value
2308 if (!consumeComma(args))
2309 return nullptr;
2310 switch (args->current()->id) {
2311 case CSSValueMiddle:
2312 stepAtPosition = StepsTimingFunction::StepAtMiddle;
2313 break;
2314 case CSSValueStart:
2315 stepAtPosition = StepsTimingFunction::StepAtStart;
2316 break;
2317 case CSSValueEnd:
2318 stepAtPosition = StepsTimingFunction::StepAtEnd;
2319 break;
2320 default:
2321 return nullptr;
2322 }
2323 }
2324
2325 return CSSStepsTimingFunctionValue::create(numSteps, stepAtPosition);
2326 }
2327
2328 if (equalIgnoringCase(value->function->name, "cubic-bezier(")) {
2329 // For cubic bezier, 4 values must be specified.
2330 if (!args || args->size() != 7)
2331 return nullptr;
2332
2333 // There are two points specified. The x values must be between 0 and 1 but the y values can exceed this range.
2334 double x1, y1, x2, y2;
2335
2336 if (!parseCubicBezierTimingFunctionValue(args, x1))
2337 return nullptr;
2338 if (x1 < 0 || x1 > 1)
2339 return nullptr;
2340 if (!parseCubicBezierTimingFunctionValue(args, y1))
2341 return nullptr;
2342 if (!parseCubicBezierTimingFunctionValue(args, x2))
2343 return nullptr;
2344 if (x2 < 0 || x2 > 1)
2345 return nullptr;
2346 if (!parseCubicBezierTimingFunctionValue(args, y2))
2347 return nullptr;
2348
2349 return CSSCubicBezierTimingFunctionValue::create(x1, y1, x2, y2);
2350 }
2351
2352 return nullptr;
2353 }
2354
2355 PassRefPtr<CSSValue> CSSPropertyParser::parseAnimationProperty(CSSPropertyID pro pId)
2356 {
2357 RefPtr<CSSValue> value = nullptr;
2358 switch (propId) {
2359 case CSSPropertyAnimationDelay:
2360 case CSSPropertyTransitionDelay:
2361 value = parseAnimationDelay();
2362 break;
2363 case CSSPropertyAnimationDirection:
2364 value = parseAnimationDirection();
2365 break;
2366 case CSSPropertyAnimationDuration:
2367 case CSSPropertyTransitionDuration:
2368 value = parseAnimationDuration();
2369 break;
2370 case CSSPropertyAnimationFillMode:
2371 value = parseAnimationFillMode();
2372 break;
2373 case CSSPropertyAnimationIterationCount:
2374 value = parseAnimationIterationCount();
2375 break;
2376 case CSSPropertyAnimationName:
2377 value = parseAnimationName();
2378 break;
2379 case CSSPropertyAnimationPlayState:
2380 value = parseAnimationPlayState();
2381 break;
2382 case CSSPropertyTransitionProperty:
2383 value = parseAnimationProperty();
2384 break;
2385 case CSSPropertyAnimationTimingFunction:
2386 case CSSPropertyTransitionTimingFunction:
2387 value = parseAnimationTimingFunction();
2388 break;
2389 default:
2390 ASSERT_NOT_REACHED();
2391 return nullptr;
2392 }
2393
2394 if (value)
2395 m_valueList->next();
2396 return value.release();
2397 }
2398
2399 PassRefPtr<CSSValueList> CSSPropertyParser::parseAnimationPropertyList(CSSProper tyID propId)
2400 {
2401 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
2402 while (m_valueList->current()) {
2403 RefPtr<CSSValue> value = parseAnimationProperty(propId);
2404 if (!value)
2405 return nullptr;
2406 list->append(value.release());
2407 if (CSSParserValue* parserValue = m_valueList->current()) {
2408 if (!isComma(parserValue))
2409 return nullptr;
2410 m_valueList->next();
2411 ASSERT(m_valueList->current());
2412 }
2413 }
2414 if (propId == CSSPropertyTransitionProperty && !isValidTransitionPropertyLis t(list.get()))
2415 return nullptr;
2416 ASSERT(list->length());
2417 return list.release();
2418 }
2419
2420 static inline bool isCSSWideKeyword(CSSParserValue& value) 2022 static inline bool isCSSWideKeyword(CSSParserValue& value)
2421 { 2023 {
2422 return value.id == CSSValueInitial || value.id == CSSValueInherit || value.i d == CSSValueDefault; 2024 return value.id == CSSValueInitial || value.id == CSSValueInherit || value.i d == CSSValueDefault;
2423 } 2025 }
2424 2026
2425 bool CSSPropertyParser::parseClipShape(CSSPropertyID propId) 2027 bool CSSPropertyParser::parseClipShape(CSSPropertyID propId)
2426 { 2028 {
2427 CSSParserValue* value = m_valueList->current(); 2029 CSSParserValue* value = m_valueList->current();
2428 CSSParserValueList* args = value->function->args.get(); 2030 CSSParserValueList* args = value->function->args.get();
2429 2031
(...skipping 2388 matching lines...) Expand 10 before | Expand all | Expand 10 after
4818 4420
4819 if (equalIgnoringCase(val->function->name, "radial-gradient(")) 4421 if (equalIgnoringCase(val->function->name, "radial-gradient("))
4820 return parseRadialGradient(valueList, value, NonRepeating); 4422 return parseRadialGradient(valueList, value, NonRepeating);
4821 4423
4822 if (equalIgnoringCase(val->function->name, "repeating-radial-gradient(")) 4424 if (equalIgnoringCase(val->function->name, "repeating-radial-gradient("))
4823 return parseRadialGradient(valueList, value, Repeating); 4425 return parseRadialGradient(valueList, value, Repeating);
4824 4426
4825 return false; 4427 return false;
4826 } 4428 }
4827 4429
4828 PassRefPtr<CSSValue> CSSPropertyParser::parseWillChange()
4829 {
4830 RefPtr<CSSValueList> values = CSSValueList::createCommaSeparated();
4831 if (m_valueList->current()->id == CSSValueAuto) {
4832 // FIXME: This will be read back as an empty string instead of auto
4833 return values.release();
4834 }
4835
4836 // Every comma-separated list of CSS_IDENTs is a valid will-change value,
4837 // unless the list includes an explicitly disallowed CSS_IDENT.
4838 while (true) {
4839 CSSParserValue* currentValue = m_valueList->current();
4840 if (!currentValue || currentValue->unit != CSSPrimitiveValue::CSS_IDENT)
4841 return nullptr;
4842
4843 CSSPropertyID property = cssPropertyID(currentValue->string);
4844 if (property) {
4845 ASSERT(CSSPropertyMetadata::isEnabledProperty(property));
4846 // Now "all" is used by both CSSValue and CSSPropertyValue.
4847 // Need to return nullptr when currentValue is CSSPropertyAll.
4848 if (property == CSSPropertyWillChange)
4849 return nullptr;
4850 values->append(cssValuePool().createIdentifierValue(property));
4851 } else {
4852 switch (currentValue->id) {
4853 case CSSValueNone:
4854 case CSSValueAll:
4855 case CSSValueAuto:
4856 case CSSValueDefault:
4857 case CSSValueInitial:
4858 case CSSValueInherit:
4859 return nullptr;
4860 case CSSValueContents:
4861 values->append(cssValuePool().createIdentifierValue(currentValue ->id));
4862 break;
4863 default:
4864 break;
4865 }
4866 }
4867
4868 if (!m_valueList->next())
4869 break;
4870 if (!consumeComma(m_valueList))
4871 return nullptr;
4872 }
4873
4874 return values.release();
4875 }
4876
4877 static void filterInfoForName(const CSSParserString& name, CSSFilterValue::Filte rOperationType& filterType, unsigned& maximumArgumentCount) 4430 static void filterInfoForName(const CSSParserString& name, CSSFilterValue::Filte rOperationType& filterType, unsigned& maximumArgumentCount)
4878 { 4431 {
4879 if (equalIgnoringCase(name, "grayscale(")) 4432 if (equalIgnoringCase(name, "grayscale("))
4880 filterType = CSSFilterValue::GrayscaleFilterOperation; 4433 filterType = CSSFilterValue::GrayscaleFilterOperation;
4881 else if (equalIgnoringCase(name, "sepia(")) 4434 else if (equalIgnoringCase(name, "sepia("))
4882 filterType = CSSFilterValue::SepiaFilterOperation; 4435 filterType = CSSFilterValue::SepiaFilterOperation;
4883 else if (equalIgnoringCase(name, "saturate(")) 4436 else if (equalIgnoringCase(name, "saturate("))
4884 filterType = CSSFilterValue::SaturateFilterOperation; 4437 filterType = CSSFilterValue::SaturateFilterOperation;
4885 else if (equalIgnoringCase(name, "hue-rotate(")) 4438 else if (equalIgnoringCase(name, "hue-rotate("))
4886 filterType = CSSFilterValue::HueRotateFilterOperation; 4439 filterType = CSSFilterValue::HueRotateFilterOperation;
(...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after
5597 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n"); 5150 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n");
5598 } 5151 }
5599 5152
5600 bool CSSPropertyParser::isSystemColor(int id) 5153 bool CSSPropertyParser::isSystemColor(int id)
5601 { 5154 {
5602 // FIXME(sky): remove 5155 // FIXME(sky): remove
5603 return false; 5156 return false;
5604 } 5157 }
5605 5158
5606 } // namespace blink 5159 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/core/css/parser/CSSPropertyParser.h ('k') | sky/engine/core/css/resolver/AnimatedStyleBuilder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698