OLD | NEW |
---|---|
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 2642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2653 // [ [ 'font-style' || 'font-variant' || 'font-weight' ]? 'font-size' [ / 'line-height' ]? | 2653 // [ [ 'font-style' || 'font-variant' || 'font-weight' ]? 'font-size' [ / 'line-height' ]? |
2654 // 'font-family' ] | caption | icon | menu | message-box | small-caption | status-bar | inherit | 2654 // 'font-family' ] | caption | icon | menu | message-box | small-caption | status-bar | inherit |
2655 if (id >= CSSValueCaption && id <= CSSValueStatusBar) | 2655 if (id >= CSSValueCaption && id <= CSSValueStatusBar) |
2656 validPrimitive = true; | 2656 validPrimitive = true; |
2657 else | 2657 else |
2658 return parseFont(important); | 2658 return parseFont(important); |
2659 break; | 2659 break; |
2660 case CSSPropertyListStyle: | 2660 case CSSPropertyListStyle: |
2661 return parseShorthand(propId, listStyleShorthand(), important); | 2661 return parseShorthand(propId, listStyleShorthand(), important); |
2662 case CSSPropertyWebkitColumns: | 2662 case CSSPropertyWebkitColumns: |
2663 return parseShorthand(propId, webkitColumnsShorthand(), important); | 2663 return parseColumnsShorthand(important); |
2664 case CSSPropertyWebkitColumnRule: | 2664 case CSSPropertyWebkitColumnRule: |
2665 return parseShorthand(propId, webkitColumnRuleShorthand(), important); | 2665 return parseShorthand(propId, webkitColumnRuleShorthand(), important); |
2666 case CSSPropertyWebkitTextStroke: | 2666 case CSSPropertyWebkitTextStroke: |
2667 return parseShorthand(propId, webkitTextStrokeShorthand(), important); | 2667 return parseShorthand(propId, webkitTextStrokeShorthand(), important); |
2668 case CSSPropertyWebkitAnimation: | 2668 case CSSPropertyWebkitAnimation: |
2669 return parseAnimationShorthand(important); | 2669 return parseAnimationShorthand(important); |
2670 case CSSPropertyTransition: | 2670 case CSSPropertyTransition: |
2671 case CSSPropertyWebkitTransition: | 2671 case CSSPropertyWebkitTransition: |
2672 return parseTransitionShorthand(propId, important); | 2672 return parseTransitionShorthand(propId, important); |
2673 case CSSPropertyInvalid: | 2673 case CSSPropertyInvalid: |
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3203 addAnimationValue(values[i], cssValuePool().createImplicitInitialVal ue()); | 3203 addAnimationValue(values[i], cssValuePool().createImplicitInitialVal ue()); |
3204 } | 3204 } |
3205 | 3205 |
3206 // Now add all of the properties we found. | 3206 // Now add all of the properties we found. |
3207 for (i = 0; i < numProperties; i++) | 3207 for (i = 0; i < numProperties; i++) |
3208 addPropertyWithPrefixingVariant(shorthand.properties()[i], values[i].rel ease(), important); | 3208 addPropertyWithPrefixingVariant(shorthand.properties()[i], values[i].rel ease(), important); |
3209 | 3209 |
3210 return true; | 3210 return true; |
3211 } | 3211 } |
3212 | 3212 |
3213 bool CSSParser::parseColumnsShorthand(bool important) | |
3214 { | |
3215 ShorthandScope scope(this, CSSPropertyWebkitColumns); | |
3216 unsigned propertiesParsed = 0; | |
3217 unsigned autoCount = 0; | |
3218 bool columnCountFound = false; | |
3219 bool columnWidthFound = false; | |
Julien - ping for review
2013/07/24 21:41:11
Ideally variable names should be good English: col
mstensho (USE GERRIT)
2013/07/25 12:01:59
Done.
| |
3220 | |
3221 while (CSSParserValue* value = m_valueList->current()) { | |
3222 if (propertiesParsed >= 2) | |
3223 return false; // Too many values for this shorthand. Invalid declara tion. | |
3224 if (value->id == CSSValueAuto) { | |
3225 // 'auto' is a valid value for any of the two longhands, and at this point we | |
3226 // don't know which one(s) it is meant for. We need to see if there are other | |
3227 // values first. Just count the 'auto' occurrence for now. After hav ing | |
3228 // processed the value list, set unassigned properties to 'auto'. | |
3229 m_valueList->next(); | |
3230 autoCount++; | |
3231 } else { | |
3232 if (!columnCountFound && parseValue(CSSPropertyWebkitColumnCount, im portant)) { | |
3233 columnCountFound = true; | |
3234 } else if (!columnWidthFound && parseValue(CSSPropertyWebkitColumnWi dth, important)) { | |
3235 columnWidthFound = true; | |
3236 } else { | |
3237 // If we didn't find at least one match, this is an | |
3238 // invalid shorthand and we have to ignore it. | |
3239 return false; | |
3240 } | |
3241 } | |
3242 propertiesParsed++; | |
3243 } | |
3244 | |
3245 if (!autoCount && propertiesParsed == 2) | |
3246 return true; | |
3247 | |
Julien - ping for review
2013/07/24 21:41:11
Probably worth adding this assert:
ASSERT(!column
mstensho (USE GERRIT)
2013/07/25 12:01:59
Done.
| |
3248 // Fill in any remaining properties with the 'initial' or 'auto' value. | |
3249 RefPtr<CSSValue> value; | |
3250 if (autoCount) { | |
3251 // 'auto' is among the values. Set remaining properties to 'auto'. | |
3252 value = cssValuePool().createIdentifierValue(CSSValueAuto); | |
3253 } else { | |
3254 // 'auto' isn't among the values, but we still have to make sure that th e unspecified | |
3255 // longhand gets set to its initial value. | |
3256 value = cssValuePool().createImplicitInitialValue(); | |
3257 m_implicitShorthand = true; | |
3258 } | |
3259 if (!columnCountFound) { | |
3260 addProperty(CSSPropertyWebkitColumnCount, value, important); | |
3261 if (autoCount == 1) { | |
3262 // Only one 'auto' value was specified, and we have just assigned it to a longhand. If | |
3263 // the other longhand needs to be set to 'auto' as well, make sure i t's marked as | |
3264 // "implicit", so that we don't get too many 'auto' occurrences if w e later decide to | |
3265 // reconstruct the shorthand based on these longhands (using getComp utedStyle(), for | |
3266 // instance). | |
3267 m_implicitShorthand = true; | |
3268 } | |
3269 } | |
3270 if (!columnWidthFound) | |
3271 addProperty(CSSPropertyWebkitColumnWidth, value, important); | |
3272 m_implicitShorthand = false; | |
3273 | |
Julien - ping for review
2013/07/24 21:41:11
This code is way too complicated and I don't think
mstensho (USE GERRIT)
2013/07/25 12:01:59
OK, I've tried to do this now. This eliminated the
| |
3274 return true; | |
3275 } | |
3276 | |
3213 bool CSSParser::parseShorthand(CSSPropertyID propId, const StylePropertyShorthan d& shorthand, bool important) | 3277 bool CSSParser::parseShorthand(CSSPropertyID propId, const StylePropertyShorthan d& shorthand, bool important) |
3214 { | 3278 { |
3215 // We try to match as many properties as possible | 3279 // We try to match as many properties as possible |
3216 // We set up an array of booleans to mark which property has been found, | 3280 // We set up an array of booleans to mark which property has been found, |
3217 // and we try to search for properties until it makes no longer any sense. | 3281 // and we try to search for properties until it makes no longer any sense. |
3218 ShorthandScope scope(this, propId); | 3282 ShorthandScope scope(this, propId); |
3219 | 3283 |
3220 bool found = false; | 3284 bool found = false; |
3221 unsigned propertiesParsed = 0; | 3285 unsigned propertiesParsed = 0; |
3222 bool propertyFound[6]= { false, false, false, false, false, false }; // 6 is enough size. | 3286 bool propertyFound[6]= { false, false, false, false, false, false }; // 6 is enough size. |
(...skipping 8517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
11740 { | 11804 { |
11741 // The tokenizer checks for the construct of an+b. | 11805 // The tokenizer checks for the construct of an+b. |
11742 // However, since the {ident} rule precedes the {nth} rule, some of those | 11806 // However, since the {ident} rule precedes the {nth} rule, some of those |
11743 // tokens are identified as string literal. Furthermore we need to accept | 11807 // tokens are identified as string literal. Furthermore we need to accept |
11744 // "odd" and "even" which does not match to an+b. | 11808 // "odd" and "even" which does not match to an+b. |
11745 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even") | 11809 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even") |
11746 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n"); | 11810 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n"); |
11747 } | 11811 } |
11748 | 11812 |
11749 } | 11813 } |
OLD | NEW |