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

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

Issue 15758002: Unprefix Flexbox (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: tests Created 7 years, 6 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 | Annotate | Revision Log
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 747 matching lines...) Expand 10 before | Expand all | Expand 10 after
758 return true; 758 return true;
759 break; 759 break;
760 case CSSPropertyWebkitBoxOrient: 760 case CSSPropertyWebkitBoxOrient:
761 if (valueID == CSSValueHorizontal || valueID == CSSValueVertical || valu eID == CSSValueInlineAxis || valueID == CSSValueBlockAxis) 761 if (valueID == CSSValueHorizontal || valueID == CSSValueVertical || valu eID == CSSValueInlineAxis || valueID == CSSValueBlockAxis)
762 return true; 762 return true;
763 break; 763 break;
764 case CSSPropertyWebkitBoxPack: 764 case CSSPropertyWebkitBoxPack:
765 if (valueID == CSSValueStart || valueID == CSSValueEnd || valueID == CSS ValueCenter || valueID == CSSValueJustify) 765 if (valueID == CSSValueStart || valueID == CSSValueEnd || valueID == CSS ValueCenter || valueID == CSSValueJustify)
766 return true; 766 return true;
767 break; 767 break;
768 case CSSPropertyWebkitAlignContent: 768 case CSSPropertyAlignContent:
769 if (valueID == CSSValueFlexStart || valueID == CSSValueFlexEnd || value ID == CSSValueCenter || valueID == CSSValueSpaceBetween || valueID == CSSValueSp aceAround || valueID == CSSValueStretch) 769 if (valueID == CSSValueFlexStart || valueID == CSSValueFlexEnd || value ID == CSSValueCenter || valueID == CSSValueSpaceBetween || valueID == CSSValueSp aceAround || valueID == CSSValueStretch)
770 return true; 770 return true;
771 break; 771 break;
772 case CSSPropertyWebkitAlignItems: 772 case CSSPropertyAlignItems:
773 if (valueID == CSSValueFlexStart || valueID == CSSValueFlexEnd || valueI D == CSSValueCenter || valueID == CSSValueBaseline || valueID == CSSValueStretch ) 773 if (valueID == CSSValueFlexStart || valueID == CSSValueFlexEnd || valueI D == CSSValueCenter || valueID == CSSValueBaseline || valueID == CSSValueStretch )
774 return true; 774 return true;
775 break; 775 break;
776 case CSSPropertyWebkitAlignSelf: 776 case CSSPropertyAlignSelf:
777 if (valueID == CSSValueAuto || valueID == CSSValueFlexStart || valueID = = CSSValueFlexEnd || valueID == CSSValueCenter || valueID == CSSValueBaseline || valueID == CSSValueStretch) 777 if (valueID == CSSValueAuto || valueID == CSSValueFlexStart || valueID = = CSSValueFlexEnd || valueID == CSSValueCenter || valueID == CSSValueBaseline || valueID == CSSValueStretch)
778 return true; 778 return true;
779 break; 779 break;
780 case CSSPropertyWebkitFlexDirection: 780 case CSSPropertyFlexDirection:
781 if (valueID == CSSValueRow || valueID == CSSValueRowReverse || valueID = = CSSValueColumn || valueID == CSSValueColumnReverse) 781 if (valueID == CSSValueRow || valueID == CSSValueRowReverse || valueID = = CSSValueColumn || valueID == CSSValueColumnReverse)
782 return true; 782 return true;
783 break; 783 break;
784 case CSSPropertyWebkitFlexWrap: 784 case CSSPropertyFlexWrap:
785 if (valueID == CSSValueNowrap || valueID == CSSValueWrap || valueID == C SSValueWrapReverse) 785 if (valueID == CSSValueNowrap || valueID == CSSValueWrap || valueID == C SSValueWrapReverse)
786 return true; 786 return true;
787 break; 787 break;
788 case CSSPropertyWebkitJustifyContent: 788 case CSSPropertyJustifyContent:
789 if (valueID == CSSValueFlexStart || valueID == CSSValueFlexEnd || valueI D == CSSValueCenter || valueID == CSSValueSpaceBetween || valueID == CSSValueSpa ceAround) 789 if (valueID == CSSValueFlexStart || valueID == CSSValueFlexEnd || valueI D == CSSValueCenter || valueID == CSSValueSpaceBetween || valueID == CSSValueSpa ceAround)
790 return true; 790 return true;
791 break; 791 break;
792 case CSSPropertyWebkitFontKerning: 792 case CSSPropertyWebkitFontKerning:
793 if (valueID == CSSValueAuto || valueID == CSSValueNormal || valueID == C SSValueNone) 793 if (valueID == CSSValueAuto || valueID == CSSValueNormal || valueID == C SSValueNone)
794 return true; 794 return true;
795 break; 795 break;
796 case CSSPropertyWebkitFontSmoothing: 796 case CSSPropertyWebkitFontSmoothing:
797 if (valueID == CSSValueAuto || valueID == CSSValueNone || valueID == CSS ValueAntialiased || valueID == CSSValueSubpixelAntialiased) 797 if (valueID == CSSValueAuto || valueID == CSSValueNone || valueID == CSS ValueAntialiased || valueID == CSSValueSubpixelAntialiased)
798 return true; 798 return true;
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
981 case CSSPropertyWebkitBoxAlign: 981 case CSSPropertyWebkitBoxAlign:
982 case CSSPropertyWebkitBoxDecorationBreak: 982 case CSSPropertyWebkitBoxDecorationBreak:
983 case CSSPropertyWebkitBoxDirection: 983 case CSSPropertyWebkitBoxDirection:
984 case CSSPropertyWebkitBoxLines: 984 case CSSPropertyWebkitBoxLines:
985 case CSSPropertyWebkitBoxOrient: 985 case CSSPropertyWebkitBoxOrient:
986 case CSSPropertyWebkitBoxPack: 986 case CSSPropertyWebkitBoxPack:
987 case CSSPropertyWebkitColumnBreakAfter: 987 case CSSPropertyWebkitColumnBreakAfter:
988 case CSSPropertyWebkitColumnBreakBefore: 988 case CSSPropertyWebkitColumnBreakBefore:
989 case CSSPropertyWebkitColumnBreakInside: 989 case CSSPropertyWebkitColumnBreakInside:
990 case CSSPropertyWebkitColumnRuleStyle: 990 case CSSPropertyWebkitColumnRuleStyle:
991 case CSSPropertyWebkitAlignContent: 991 case CSSPropertyAlignContent:
992 case CSSPropertyWebkitAlignItems: 992 case CSSPropertyAlignItems:
993 case CSSPropertyWebkitAlignSelf: 993 case CSSPropertyAlignSelf:
994 case CSSPropertyWebkitFlexDirection: 994 case CSSPropertyFlexDirection:
995 case CSSPropertyWebkitFlexWrap: 995 case CSSPropertyFlexWrap:
996 case CSSPropertyWebkitJustifyContent: 996 case CSSPropertyJustifyContent:
997 case CSSPropertyWebkitFontKerning: 997 case CSSPropertyWebkitFontKerning:
998 case CSSPropertyWebkitFontSmoothing: 998 case CSSPropertyWebkitFontSmoothing:
999 case CSSPropertyWebkitHyphens: 999 case CSSPropertyWebkitHyphens:
1000 case CSSPropertyGridAutoFlow: 1000 case CSSPropertyGridAutoFlow:
1001 case CSSPropertyWebkitLineAlign: 1001 case CSSPropertyWebkitLineAlign:
1002 case CSSPropertyWebkitLineBreak: 1002 case CSSPropertyWebkitLineBreak:
1003 case CSSPropertyWebkitLineSnap: 1003 case CSSPropertyWebkitLineSnap:
1004 case CSSPropertyWebkitMarginAfterCollapse: 1004 case CSSPropertyWebkitMarginAfterCollapse:
1005 case CSSPropertyWebkitMarginBeforeCollapse: 1005 case CSSPropertyWebkitMarginBeforeCollapse:
1006 case CSSPropertyWebkitMarginBottomCollapse: 1006 case CSSPropertyWebkitMarginBottomCollapse:
(...skipping 1259 matching lines...) Expand 10 before | Expand all | Expand 10 after
2266 } 2266 }
2267 return false; 2267 return false;
2268 } 2268 }
2269 break; 2269 break;
2270 case CSSPropertyMixBlendMode: 2270 case CSSPropertyMixBlendMode:
2271 if (!RuntimeEnabledFeatures::cssCompositingEnabled()) 2271 if (!RuntimeEnabledFeatures::cssCompositingEnabled())
2272 return false; 2272 return false;
2273 2273
2274 validPrimitive = true; 2274 validPrimitive = true;
2275 break; 2275 break;
2276 case CSSPropertyWebkitFlex: { 2276 case CSSPropertyFlex: {
2277 ShorthandScope scope(this, propId); 2277 ShorthandScope scope(this, propId);
2278 if (id == CSSValueNone) { 2278 if (id == CSSValueNone) {
2279 addProperty(CSSPropertyWebkitFlexGrow, cssValuePool().createValue(0, CSSPrimitiveValue::CSS_NUMBER), important); 2279 addProperty(CSSPropertyFlexGrow, cssValuePool().createValue(0, CSSPr imitiveValue::CSS_NUMBER), important);
2280 addProperty(CSSPropertyWebkitFlexShrink, cssValuePool().createValue( 0, CSSPrimitiveValue::CSS_NUMBER), important); 2280 addProperty(CSSPropertyFlexShrink, cssValuePool().createValue(0, CSS PrimitiveValue::CSS_NUMBER), important);
2281 addProperty(CSSPropertyWebkitFlexBasis, cssValuePool().createIdentif ierValue(CSSValueAuto), important); 2281 addProperty(CSSPropertyFlexBasis, cssValuePool().createIdentifierVal ue(CSSValueAuto), important);
2282 return true; 2282 return true;
2283 } 2283 }
2284 return parseFlex(m_valueList.get(), important); 2284 return parseFlex(m_valueList.get(), important);
2285 } 2285 }
2286 case CSSPropertyWebkitFlexBasis: 2286 case CSSPropertyFlexBasis:
2287 // FIXME: Support intrinsic dimensions too. 2287 // FIXME: Support intrinsic dimensions too.
2288 if (id == CSSValueAuto) 2288 if (id == CSSValueAuto)
2289 validPrimitive = true; 2289 validPrimitive = true;
2290 else 2290 else
2291 validPrimitive = (!id && validUnit(value, FLength | FPercent | FNonN eg)); 2291 validPrimitive = (!id && validUnit(value, FLength | FPercent | FNonN eg));
2292 break; 2292 break;
2293 case CSSPropertyWebkitFlexGrow: 2293 case CSSPropertyFlexGrow:
2294 case CSSPropertyWebkitFlexShrink: 2294 case CSSPropertyFlexShrink:
2295 validPrimitive = validUnit(value, FNumber | FNonNeg); 2295 validPrimitive = validUnit(value, FNumber | FNonNeg);
2296 break; 2296 break;
2297 case CSSPropertyWebkitOrder: 2297 case CSSPropertyOrder:
2298 if (validUnit(value, FInteger, CSSStrictMode)) { 2298 if (validUnit(value, FInteger, CSSStrictMode)) {
2299 // We restrict the smallest value to int min + 2 because we use int min and int min + 1 as special values in a hash set. 2299 // We restrict the smallest value to int min + 2 because we use int min and int min + 1 as special values in a hash set.
2300 parsedValue = cssValuePool().createValue(max(static_cast<double>(std ::numeric_limits<int>::min() + 2), value->fValue), 2300 parsedValue = cssValuePool().createValue(max(static_cast<double>(std ::numeric_limits<int>::min() + 2), value->fValue),
2301 static_cast<CSSPrim itiveValue::UnitTypes>(value->unit)); 2301 static_cast<CSSPrim itiveValue::UnitTypes>(value->unit));
2302 m_valueList->next(); 2302 m_valueList->next();
2303 } 2303 }
2304 break; 2304 break;
2305 case CSSPropertyWebkitMarquee: 2305 case CSSPropertyWebkitMarquee:
2306 return parseShorthand(propId, webkitMarqueeShorthand(), important); 2306 return parseShorthand(propId, webkitMarqueeShorthand(), important);
2307 case CSSPropertyWebkitMarqueeIncrement: 2307 case CSSPropertyWebkitMarqueeIncrement:
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
2629 return parse4Values(propId, borderWidthShorthand().properties(), importa nt); 2629 return parse4Values(propId, borderWidthShorthand().properties(), importa nt);
2630 case CSSPropertyBorderStyle: 2630 case CSSPropertyBorderStyle:
2631 // <border-style>{1,4} | inherit 2631 // <border-style>{1,4} | inherit
2632 return parse4Values(propId, borderStyleShorthand().properties(), importa nt); 2632 return parse4Values(propId, borderStyleShorthand().properties(), importa nt);
2633 case CSSPropertyMargin: 2633 case CSSPropertyMargin:
2634 // <margin-width>{1,4} | inherit 2634 // <margin-width>{1,4} | inherit
2635 return parse4Values(propId, marginShorthand().properties(), important); 2635 return parse4Values(propId, marginShorthand().properties(), important);
2636 case CSSPropertyPadding: 2636 case CSSPropertyPadding:
2637 // <padding-width>{1,4} | inherit 2637 // <padding-width>{1,4} | inherit
2638 return parse4Values(propId, paddingShorthand().properties(), important); 2638 return parse4Values(propId, paddingShorthand().properties(), important);
2639 case CSSPropertyWebkitFlexFlow: 2639 case CSSPropertyFlexFlow:
2640 return parseShorthand(propId, webkitFlexFlowShorthand(), important); 2640 return parseShorthand(propId, flexFlowShorthand(), important);
2641 case CSSPropertyFont: 2641 case CSSPropertyFont:
2642 // [ [ 'font-style' || 'font-variant' || 'font-weight' ]? 'font-size' [ / 'line-height' ]? 2642 // [ [ 'font-style' || 'font-variant' || 'font-weight' ]? 'font-size' [ / 'line-height' ]?
2643 // 'font-family' ] | caption | icon | menu | message-box | small-caption | status-bar | inherit 2643 // 'font-family' ] | caption | icon | menu | message-box | small-caption | status-bar | inherit
2644 if (id >= CSSValueCaption && id <= CSSValueStatusBar) 2644 if (id >= CSSValueCaption && id <= CSSValueStatusBar)
2645 validPrimitive = true; 2645 validPrimitive = true;
2646 else 2646 else
2647 return parseFont(important); 2647 return parseFont(important);
2648 break; 2648 break;
2649 case CSSPropertyListStyle: 2649 case CSSPropertyListStyle:
2650 return parseShorthand(propId, listStyleShorthand(), important); 2650 return parseShorthand(propId, listStyleShorthand(), important);
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
2777 case CSSPropertyWebkitBoxAlign: 2777 case CSSPropertyWebkitBoxAlign:
2778 case CSSPropertyWebkitBoxDecorationBreak: 2778 case CSSPropertyWebkitBoxDecorationBreak:
2779 case CSSPropertyWebkitBoxDirection: 2779 case CSSPropertyWebkitBoxDirection:
2780 case CSSPropertyWebkitBoxLines: 2780 case CSSPropertyWebkitBoxLines:
2781 case CSSPropertyWebkitBoxOrient: 2781 case CSSPropertyWebkitBoxOrient:
2782 case CSSPropertyWebkitBoxPack: 2782 case CSSPropertyWebkitBoxPack:
2783 case CSSPropertyWebkitColumnBreakAfter: 2783 case CSSPropertyWebkitColumnBreakAfter:
2784 case CSSPropertyWebkitColumnBreakBefore: 2784 case CSSPropertyWebkitColumnBreakBefore:
2785 case CSSPropertyWebkitColumnBreakInside: 2785 case CSSPropertyWebkitColumnBreakInside:
2786 case CSSPropertyWebkitColumnRuleStyle: 2786 case CSSPropertyWebkitColumnRuleStyle:
2787 case CSSPropertyWebkitAlignContent: 2787 case CSSPropertyAlignContent:
2788 case CSSPropertyWebkitAlignItems: 2788 case CSSPropertyAlignItems:
2789 case CSSPropertyWebkitAlignSelf: 2789 case CSSPropertyAlignSelf:
2790 case CSSPropertyWebkitFlexDirection: 2790 case CSSPropertyFlexDirection:
2791 case CSSPropertyWebkitFlexWrap: 2791 case CSSPropertyFlexWrap:
2792 case CSSPropertyWebkitJustifyContent: 2792 case CSSPropertyJustifyContent:
2793 case CSSPropertyWebkitFontKerning: 2793 case CSSPropertyWebkitFontKerning:
2794 case CSSPropertyWebkitFontSmoothing: 2794 case CSSPropertyWebkitFontSmoothing:
2795 case CSSPropertyWebkitHyphens: 2795 case CSSPropertyWebkitHyphens:
2796 case CSSPropertyGridAutoFlow: 2796 case CSSPropertyGridAutoFlow:
2797 case CSSPropertyWebkitLineAlign: 2797 case CSSPropertyWebkitLineAlign:
2798 case CSSPropertyWebkitLineBreak: 2798 case CSSPropertyWebkitLineBreak:
2799 case CSSPropertyWebkitLineSnap: 2799 case CSSPropertyWebkitLineSnap:
2800 case CSSPropertyWebkitMarginAfterCollapse: 2800 case CSSPropertyWebkitMarginAfterCollapse:
2801 case CSSPropertyWebkitMarginBeforeCollapse: 2801 case CSSPropertyWebkitMarginBeforeCollapse:
2802 case CSSPropertyWebkitMarginBottomCollapse: 2802 case CSSPropertyWebkitMarginBottomCollapse:
(...skipping 3446 matching lines...) Expand 10 before | Expand all | Expand 10 after
6249 args->next(); 6249 args->next();
6250 } 6250 }
6251 6251
6252 if (flexGrow == unsetValue) 6252 if (flexGrow == unsetValue)
6253 flexGrow = 1; 6253 flexGrow = 1;
6254 if (flexShrink == unsetValue) 6254 if (flexShrink == unsetValue)
6255 flexShrink = 1; 6255 flexShrink = 1;
6256 if (!flexBasis) 6256 if (!flexBasis)
6257 flexBasis = cssValuePool().createValue(0, CSSPrimitiveValue::CSS_PX); 6257 flexBasis = cssValuePool().createValue(0, CSSPrimitiveValue::CSS_PX);
6258 6258
6259 addProperty(CSSPropertyWebkitFlexGrow, cssValuePool().createValue(clampToFlo at(flexGrow), CSSPrimitiveValue::CSS_NUMBER), important); 6259 addProperty(CSSPropertyFlexGrow, cssValuePool().createValue(clampToFloat(fle xGrow), CSSPrimitiveValue::CSS_NUMBER), important);
6260 addProperty(CSSPropertyWebkitFlexShrink, cssValuePool().createValue(clampToF loat(flexShrink), CSSPrimitiveValue::CSS_NUMBER), important); 6260 addProperty(CSSPropertyFlexShrink, cssValuePool().createValue(clampToFloat(f lexShrink), CSSPrimitiveValue::CSS_NUMBER), important);
6261 addProperty(CSSPropertyWebkitFlexBasis, flexBasis, important); 6261 addProperty(CSSPropertyFlexBasis, flexBasis, important);
6262 return true; 6262 return true;
6263 } 6263 }
6264 6264
6265 struct BorderImageParseContext { 6265 struct BorderImageParseContext {
6266 BorderImageParseContext() 6266 BorderImageParseContext()
6267 : m_canAdvance(false) 6267 : m_canAdvance(false)
6268 , m_allowCommit(true) 6268 , m_allowCommit(true)
6269 , m_allowImage(true) 6269 , m_allowImage(true)
6270 , m_allowImageSlice(true) 6270 , m_allowImageSlice(true)
6271 , m_allowRepeat(true) 6271 , m_allowRepeat(true)
(...skipping 5515 matching lines...) Expand 10 before | Expand all | Expand 10 after
11787 { 11787 {
11788 // The tokenizer checks for the construct of an+b. 11788 // The tokenizer checks for the construct of an+b.
11789 // However, since the {ident} rule precedes the {nth} rule, some of those 11789 // However, since the {ident} rule precedes the {nth} rule, some of those
11790 // tokens are identified as string literal. Furthermore we need to accept 11790 // tokens are identified as string literal. Furthermore we need to accept
11791 // "odd" and "even" which does not match to an+b. 11791 // "odd" and "even" which does not match to an+b.
11792 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even") 11792 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even")
11793 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n"); 11793 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n");
11794 } 11794 }
11795 11795
11796 } 11796 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698