Chromium Code Reviews| 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 3313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3324 addAnimationValue(values[i], cssValuePool().createImplicitInitialVal ue()); | 3324 addAnimationValue(values[i], cssValuePool().createImplicitInitialVal ue()); |
| 3325 } | 3325 } |
| 3326 | 3326 |
| 3327 // Now add all of the properties we found. | 3327 // Now add all of the properties we found. |
| 3328 for (i = 0; i < numProperties; i++) | 3328 for (i = 0; i < numProperties; i++) |
| 3329 addPropertyWithPrefixingVariant(shorthand.properties()[i], values[i].rel ease(), important); | 3329 addPropertyWithPrefixingVariant(shorthand.properties()[i], values[i].rel ease(), important); |
| 3330 | 3330 |
| 3331 return true; | 3331 return true; |
| 3332 } | 3332 } |
| 3333 | 3333 |
| 3334 bool CSSParser::parseShorthand(CSSPropertyID propId, const StylePropertyShorthan d& shorthand, bool important) | 3334 bool CSSParser::parseShorthand(CSSPropertyID propId, const StylePropertyShorthan d& shorthand, bool important) |
|
Julien - ping for review
2013/07/23 00:56:29
I believe that's your problem: you are using the g
mstensho (USE GERRIT)
2013/07/23 14:19:07
Done.
| |
| 3335 { | 3335 { |
| 3336 // We try to match as many properties as possible | 3336 // We try to match as many properties as possible. |
| 3337 // We set up an array of booleans to mark which property has been found, | 3337 // We set up an array of booleans to mark which property has been found, |
| 3338 // and we try to search for properties until it makes no longer any sense. | 3338 // and we try to search for properties until it makes no longer any sense. |
| 3339 ShorthandScope scope(this, propId); | 3339 ShorthandScope scope(this, propId); |
| 3340 | 3340 |
| 3341 bool found = false; | |
| 3342 unsigned propertiesParsed = 0; | 3341 unsigned propertiesParsed = 0; |
| 3343 bool propertyFound[6]= { false, false, false, false, false, false }; // 6 is enough size. | 3342 bool propertyFound[6]= { false, false, false, false, false, false }; // 6 is enough size. |
| 3343 unsigned autoCount = 0; | |
| 3344 | 3344 |
| 3345 while (m_valueList->current()) { | 3345 while (CSSParserValue* value = m_valueList->current()) { |
| 3346 found = false; | 3346 if (propertiesParsed >= shorthand.length()) |
| 3347 for (unsigned propIndex = 0; !found && propIndex < shorthand.length(); + +propIndex) { | 3347 return false; // Too many values. Invalid declaration. |
| 3348 if (!propertyFound[propIndex] && parseValue(shorthand.properties()[p ropIndex], important)) { | 3348 if (shorthand.allAcceptAuto() && value->id == CSSValueAuto) { |
| 3349 // 'auto' is a valid value for all longhands, and at this point we d on't know which one | |
| 3350 // it is meant for. We need to look at the other values first. Just ignore 'auto' for | |
| 3351 // now. After having processed the value list, set unassigned proper ties to 'auto'. | |
| 3352 m_valueList->next(); | |
| 3353 propertiesParsed++; | |
| 3354 autoCount++; | |
| 3355 } else { | |
| 3356 bool found = false; | |
| 3357 for (unsigned propIndex = 0; propIndex < shorthand.length(); ++propI ndex) { | |
| 3358 if (!propertyFound[propIndex] && parseValue(shorthand.properties ()[propIndex], important)) { | |
| 3349 propertyFound[propIndex] = found = true; | 3359 propertyFound[propIndex] = found = true; |
| 3350 propertiesParsed++; | 3360 propertiesParsed++; |
| 3361 break; | |
| 3362 } | |
| 3351 } | 3363 } |
| 3364 | |
| 3365 // If we didn't find at least one match, this is an | |
| 3366 // invalid shorthand and we have to ignore it. | |
| 3367 if (!found) | |
| 3368 return false; | |
| 3352 } | 3369 } |
| 3353 | |
| 3354 // if we didn't find at least one match, this is an | |
| 3355 // invalid shorthand and we have to ignore it | |
| 3356 if (!found) | |
| 3357 return false; | |
| 3358 } | 3370 } |
| 3359 | 3371 |
| 3360 if (propertiesParsed == shorthand.length()) | 3372 if (propertiesParsed == shorthand.length() && !autoCount) |
| 3361 return true; | 3373 return true; |
| 3362 | 3374 |
| 3363 // Fill in any remaining properties with the initial value. | 3375 // Fill in any remaining properties with the 'initial' or 'auto' value. |
| 3364 ImplicitScope implicitScope(this, PropertyImplicit); | 3376 RefPtr<CSSValue> value; |
| 3377 if (autoCount) | |
| 3378 value = cssValuePool().createIdentifierValue(CSSValueAuto); | |
| 3379 else { | |
| 3380 value = cssValuePool().createImplicitInitialValue(); | |
| 3381 m_implicitShorthand = true; | |
| 3382 } | |
| 3383 | |
| 3365 const StylePropertyShorthand* const* const propertiesForInitialization = sho rthand.propertiesForInitialization(); | 3384 const StylePropertyShorthand* const* const propertiesForInitialization = sho rthand.propertiesForInitialization(); |
| 3366 for (unsigned i = 0; i < shorthand.length(); ++i) { | 3385 for (unsigned i = 0; i < shorthand.length(); ++i) { |
| 3367 if (propertyFound[i]) | 3386 if (propertyFound[i]) |
| 3368 continue; | 3387 continue; |
| 3369 | 3388 |
| 3370 if (propertiesForInitialization) { | 3389 if (propertiesForInitialization) { |
| 3390 ASSERT(!autoCount); // Not properly supported. | |
| 3371 const StylePropertyShorthand& initProperties = *(propertiesForInitia lization[i]); | 3391 const StylePropertyShorthand& initProperties = *(propertiesForInitia lization[i]); |
| 3372 for (unsigned propIndex = 0; propIndex < initProperties.length(); ++ propIndex) | 3392 for (unsigned propIndex = 0; propIndex < initProperties.length(); ++ propIndex) |
| 3373 addProperty(initProperties.properties()[propIndex], cssValuePool ().createImplicitInitialValue(), important); | 3393 addProperty(initProperties.properties()[propIndex], value, impor tant); |
| 3374 } else | 3394 } else |
| 3375 addProperty(shorthand.properties()[i], cssValuePool().createImplicit InitialValue(), important); | 3395 addProperty(shorthand.properties()[i], value, important); |
| 3396 if (autoCount) { | |
| 3397 autoCount--; | |
| 3398 if (!autoCount) { | |
| 3399 // We have assigned as many 'auto' values as were specified. Now make the remaining | |
| 3400 // ones implicit, so that we don't get too many of them if we la ter decide to | |
| 3401 // reconstruct a shorthand based on longhands. | |
| 3402 m_implicitShorthand = true; | |
| 3403 } | |
| 3404 } | |
| 3376 } | 3405 } |
| 3406 m_implicitShorthand = false; | |
| 3377 | 3407 |
| 3378 return true; | 3408 return true; |
| 3379 } | 3409 } |
| 3380 | 3410 |
| 3381 bool CSSParser::parse4Values(CSSPropertyID propId, const CSSPropertyID *properti es, bool important) | 3411 bool CSSParser::parse4Values(CSSPropertyID propId, const CSSPropertyID *properti es, bool important) |
| 3382 { | 3412 { |
| 3383 /* From the CSS 2 specs, 8.3 | 3413 /* From the CSS 2 specs, 8.3 |
| 3384 * If there is only one value, it applies to all sides. If there are two val ues, the top and | 3414 * If there is only one value, it applies to all sides. If there are two val ues, the top and |
| 3385 * bottom margins are set to the first value and the right and left margins are set to the second. | 3415 * bottom margins are set to the first value and the right and left margins are set to the second. |
| 3386 * If there are three values, the top is set to the first value, the left an d right are set to the | 3416 * If there are three values, the top is set to the first value, the left an d right are set to the |
| (...skipping 8338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 11725 { | 11755 { |
| 11726 // The tokenizer checks for the construct of an+b. | 11756 // The tokenizer checks for the construct of an+b. |
| 11727 // However, since the {ident} rule precedes the {nth} rule, some of those | 11757 // However, since the {ident} rule precedes the {nth} rule, some of those |
| 11728 // tokens are identified as string literal. Furthermore we need to accept | 11758 // tokens are identified as string literal. Furthermore we need to accept |
| 11729 // "odd" and "even" which does not match to an+b. | 11759 // "odd" and "even" which does not match to an+b. |
| 11730 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even") | 11760 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even") |
| 11731 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n"); | 11761 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n"); |
| 11732 } | 11762 } |
| 11733 | 11763 |
| 11734 } | 11764 } |
| OLD | NEW |