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

Side by Side Diff: Source/core/css/CSSParser-in.cpp

Issue 14334014: Parse "-webkit-columns: auto <length>" properly. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase master + minor coding style fix that the old version of check-webkit-style didn't complain a… Created 7 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 2642 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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 const StylePropertyShorthand& shorthand = webkitColumnsShorthand();
3217 unsigned propertiesParsed = 0;
3218 unsigned autoCount = 0;
3219 bool propertyFound[]= { false, false };
Julien - ping for review 2013/07/23 17:26:50 This definitely works but this makes the code a lo
mstensho (USE GERRIT) 2013/07/23 21:35:33 Done.
3220
3221 ASSERT(WTF_ARRAY_LENGTH(propertyFound) == shorthand.length());
3222 ASSERT(!shorthand.propertiesForInitialization());
3223
3224 while (CSSParserValue* value = m_valueList->current()) {
3225 if (propertiesParsed >= shorthand.length())
3226 return false; // Too many values. Invalid declaration.
3227 if (value->id == CSSValueAuto) {
3228 // 'auto' is a valid value for any longhand, and at this point we do n't know
3229 // which one(s) it is meant for. We need to look at the other values first. Just
3230 // ignore 'auto' for now. After having processed the value list, set unassigned
3231 // properties to 'auto'.
3232 m_valueList->next();
3233 propertiesParsed++;
3234 autoCount++;
3235 } else {
3236 bool found = false;
3237 for (unsigned propIndex = 0; propIndex < shorthand.length(); ++propI ndex) {
3238 if (!propertyFound[propIndex] && parseValue(shorthand.properties ()[propIndex], important)) {
3239 propertyFound[propIndex] = found = true;
Julien - ping for review 2013/07/23 17:26:50 This is a style violation, we use one statement pe
mstensho (USE GERRIT) 2013/07/23 21:35:33 Done.
3240 propertiesParsed++;
3241 break;
3242 }
3243 }
3244
3245 // If we didn't find at least one match, this is an
3246 // invalid shorthand and we have to ignore it.
3247 if (!found)
3248 return false;
3249 }
3250 }
3251
3252 if (!autoCount && propertiesParsed == shorthand.length())
3253 return true;
3254
3255 // Fill in any remaining properties with the 'initial' or 'auto' value.
3256 RefPtr<CSSValue> value;
3257 if (autoCount) {
3258 value = cssValuePool().createIdentifierValue(CSSValueAuto);
3259 } else {
3260 value = cssValuePool().createImplicitInitialValue();
3261 m_implicitShorthand = true;
3262 }
3263
3264 for (unsigned i = 0; i < shorthand.length(); ++i) {
3265 if (propertyFound[i])
3266 continue;
3267
3268 addProperty(shorthand.properties()[i], value, important);
Julien - ping for review 2013/07/23 17:26:50 The parseValue call above already calls addPropert
mstensho (USE GERRIT) 2013/07/23 21:35:33 Here we set the unspecified or auto longhands that
3269 if (autoCount) {
3270 autoCount--;
3271 if (!autoCount) {
3272 // We have assigned as many 'auto' values as were specified. Now make the remaining
3273 // ones implicit, so that we don't get too many of them if we la ter decide to
3274 // reconstruct a shorthand based on longhands.
3275 m_implicitShorthand = true;
3276 }
3277 }
3278 }
3279 m_implicitShorthand = false;
3280
3281 return true;
3282 }
3283
3213 bool CSSParser::parseShorthand(CSSPropertyID propId, const StylePropertyShorthan d& shorthand, bool important) 3284 bool CSSParser::parseShorthand(CSSPropertyID propId, const StylePropertyShorthan d& shorthand, bool important)
3214 { 3285 {
3215 // We try to match as many properties as possible 3286 // We try to match as many properties as possible
3216 // We set up an array of booleans to mark which property has been found, 3287 // 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. 3288 // and we try to search for properties until it makes no longer any sense.
3218 ShorthandScope scope(this, propId); 3289 ShorthandScope scope(this, propId);
3219 3290
3220 bool found = false; 3291 bool found = false;
3221 unsigned propertiesParsed = 0; 3292 unsigned propertiesParsed = 0;
3222 bool propertyFound[6]= { false, false, false, false, false, false }; // 6 is enough size. 3293 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
11740 { 11811 {
11741 // The tokenizer checks for the construct of an+b. 11812 // The tokenizer checks for the construct of an+b.
11742 // However, since the {ident} rule precedes the {nth} rule, some of those 11813 // However, since the {ident} rule precedes the {nth} rule, some of those
11743 // tokens are identified as string literal. Furthermore we need to accept 11814 // tokens are identified as string literal. Furthermore we need to accept
11744 // "odd" and "even" which does not match to an+b. 11815 // "odd" and "even" which does not match to an+b.
11745 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even") 11816 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even")
11746 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n"); 11817 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n");
11747 } 11818 }
11748 11819
11749 } 11820 }
OLDNEW
« LayoutTests/fast/multicol/columns-shorthand-parsing-2.html ('K') | « Source/core/css/CSSParser.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698