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

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

Issue 15758002: Unprefix Flexbox (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebased 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 | 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 743 matching lines...) Expand 10 before | Expand all | Expand 10 after
754 return true; 754 return true;
755 break; 755 break;
756 case CSSPropertyWebkitBoxOrient: 756 case CSSPropertyWebkitBoxOrient:
757 if (valueID == CSSValueHorizontal || valueID == CSSValueVertical || valu eID == CSSValueInlineAxis || valueID == CSSValueBlockAxis) 757 if (valueID == CSSValueHorizontal || valueID == CSSValueVertical || valu eID == CSSValueInlineAxis || valueID == CSSValueBlockAxis)
758 return true; 758 return true;
759 break; 759 break;
760 case CSSPropertyWebkitBoxPack: 760 case CSSPropertyWebkitBoxPack:
761 if (valueID == CSSValueStart || valueID == CSSValueEnd || valueID == CSS ValueCenter || valueID == CSSValueJustify) 761 if (valueID == CSSValueStart || valueID == CSSValueEnd || valueID == CSS ValueCenter || valueID == CSSValueJustify)
762 return true; 762 return true;
763 break; 763 break;
764 case CSSPropertyWebkitAlignContent: 764 case CSSPropertyAlignContent:
765 if (valueID == CSSValueFlexStart || valueID == CSSValueFlexEnd || value ID == CSSValueCenter || valueID == CSSValueSpaceBetween || valueID == CSSValueSp aceAround || valueID == CSSValueStretch) 765 if (valueID == CSSValueFlexStart || valueID == CSSValueFlexEnd || value ID == CSSValueCenter || valueID == CSSValueSpaceBetween || valueID == CSSValueSp aceAround || valueID == CSSValueStretch)
766 return true; 766 return true;
767 break; 767 break;
768 case CSSPropertyWebkitAlignItems: 768 case CSSPropertyAlignItems:
769 if (valueID == CSSValueFlexStart || valueID == CSSValueFlexEnd || valueI D == CSSValueCenter || valueID == CSSValueBaseline || valueID == CSSValueStretch ) 769 if (valueID == CSSValueFlexStart || valueID == CSSValueFlexEnd || valueI D == CSSValueCenter || valueID == CSSValueBaseline || valueID == CSSValueStretch )
770 return true; 770 return true;
771 break; 771 break;
772 case CSSPropertyWebkitAlignSelf: 772 case CSSPropertyAlignSelf:
773 if (valueID == CSSValueAuto || valueID == CSSValueFlexStart || valueID = = CSSValueFlexEnd || valueID == CSSValueCenter || valueID == CSSValueBaseline || valueID == CSSValueStretch) 773 if (valueID == CSSValueAuto || valueID == CSSValueFlexStart || valueID = = CSSValueFlexEnd || valueID == CSSValueCenter || valueID == CSSValueBaseline || valueID == CSSValueStretch)
774 return true; 774 return true;
775 break; 775 break;
776 case CSSPropertyWebkitFlexDirection: 776 case CSSPropertyFlexDirection:
777 if (valueID == CSSValueRow || valueID == CSSValueRowReverse || valueID = = CSSValueColumn || valueID == CSSValueColumnReverse) 777 if (valueID == CSSValueRow || valueID == CSSValueRowReverse || valueID = = CSSValueColumn || valueID == CSSValueColumnReverse)
778 return true; 778 return true;
779 break; 779 break;
780 case CSSPropertyWebkitFlexWrap: 780 case CSSPropertyFlexWrap:
781 if (valueID == CSSValueNowrap || valueID == CSSValueWrap || valueID == C SSValueWrapReverse) 781 if (valueID == CSSValueNowrap || valueID == CSSValueWrap || valueID == C SSValueWrapReverse)
782 return true; 782 return true;
783 break; 783 break;
784 case CSSPropertyWebkitJustifyContent: 784 case CSSPropertyJustifyContent:
785 if (valueID == CSSValueFlexStart || valueID == CSSValueFlexEnd || valueI D == CSSValueCenter || valueID == CSSValueSpaceBetween || valueID == CSSValueSpa ceAround) 785 if (valueID == CSSValueFlexStart || valueID == CSSValueFlexEnd || valueI D == CSSValueCenter || valueID == CSSValueSpaceBetween || valueID == CSSValueSpa ceAround)
786 return true; 786 return true;
787 break; 787 break;
788 case CSSPropertyWebkitFontKerning: 788 case CSSPropertyWebkitFontKerning:
789 if (valueID == CSSValueAuto || valueID == CSSValueNormal || valueID == C SSValueNone) 789 if (valueID == CSSValueAuto || valueID == CSSValueNormal || valueID == C SSValueNone)
790 return true; 790 return true;
791 break; 791 break;
792 case CSSPropertyWebkitFontSmoothing: 792 case CSSPropertyWebkitFontSmoothing:
793 if (valueID == CSSValueAuto || valueID == CSSValueNone || valueID == CSS ValueAntialiased || valueID == CSSValueSubpixelAntialiased) 793 if (valueID == CSSValueAuto || valueID == CSSValueNone || valueID == CSS ValueAntialiased || valueID == CSSValueSubpixelAntialiased)
794 return true; 794 return true;
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
977 case CSSPropertyWebkitBoxAlign: 977 case CSSPropertyWebkitBoxAlign:
978 case CSSPropertyWebkitBoxDecorationBreak: 978 case CSSPropertyWebkitBoxDecorationBreak:
979 case CSSPropertyWebkitBoxDirection: 979 case CSSPropertyWebkitBoxDirection:
980 case CSSPropertyWebkitBoxLines: 980 case CSSPropertyWebkitBoxLines:
981 case CSSPropertyWebkitBoxOrient: 981 case CSSPropertyWebkitBoxOrient:
982 case CSSPropertyWebkitBoxPack: 982 case CSSPropertyWebkitBoxPack:
983 case CSSPropertyWebkitColumnBreakAfter: 983 case CSSPropertyWebkitColumnBreakAfter:
984 case CSSPropertyWebkitColumnBreakBefore: 984 case CSSPropertyWebkitColumnBreakBefore:
985 case CSSPropertyWebkitColumnBreakInside: 985 case CSSPropertyWebkitColumnBreakInside:
986 case CSSPropertyWebkitColumnRuleStyle: 986 case CSSPropertyWebkitColumnRuleStyle:
987 case CSSPropertyWebkitAlignContent: 987 case CSSPropertyAlignContent:
988 case CSSPropertyWebkitAlignItems: 988 case CSSPropertyAlignItems:
989 case CSSPropertyWebkitAlignSelf: 989 case CSSPropertyAlignSelf:
990 case CSSPropertyWebkitFlexDirection: 990 case CSSPropertyFlexDirection:
991 case CSSPropertyWebkitFlexWrap: 991 case CSSPropertyFlexWrap:
992 case CSSPropertyWebkitJustifyContent: 992 case CSSPropertyJustifyContent:
993 case CSSPropertyWebkitFontKerning: 993 case CSSPropertyWebkitFontKerning:
994 case CSSPropertyWebkitFontSmoothing: 994 case CSSPropertyWebkitFontSmoothing:
995 case CSSPropertyWebkitHyphens: 995 case CSSPropertyWebkitHyphens:
996 case CSSPropertyGridAutoFlow: 996 case CSSPropertyGridAutoFlow:
997 case CSSPropertyWebkitLineAlign: 997 case CSSPropertyWebkitLineAlign:
998 case CSSPropertyWebkitLineBreak: 998 case CSSPropertyWebkitLineBreak:
999 case CSSPropertyWebkitLineSnap: 999 case CSSPropertyWebkitLineSnap:
1000 case CSSPropertyWebkitMarginAfterCollapse: 1000 case CSSPropertyWebkitMarginAfterCollapse:
1001 case CSSPropertyWebkitMarginBeforeCollapse: 1001 case CSSPropertyWebkitMarginBeforeCollapse:
1002 case CSSPropertyWebkitMarginBottomCollapse: 1002 case CSSPropertyWebkitMarginBottomCollapse:
(...skipping 1276 matching lines...) Expand 10 before | Expand all | Expand 10 after
2279 } 2279 }
2280 return false; 2280 return false;
2281 } 2281 }
2282 break; 2282 break;
2283 case CSSPropertyMixBlendMode: 2283 case CSSPropertyMixBlendMode:
2284 if (!RuntimeEnabledFeatures::cssCompositingEnabled()) 2284 if (!RuntimeEnabledFeatures::cssCompositingEnabled())
2285 return false; 2285 return false;
2286 2286
2287 validPrimitive = true; 2287 validPrimitive = true;
2288 break; 2288 break;
2289 case CSSPropertyWebkitFlex: { 2289 case CSSPropertyFlex: {
2290 ShorthandScope scope(this, propId); 2290 ShorthandScope scope(this, propId);
2291 if (id == CSSValueNone) { 2291 if (id == CSSValueNone) {
2292 addProperty(CSSPropertyWebkitFlexGrow, cssValuePool().createValue(0, CSSPrimitiveValue::CSS_NUMBER), important); 2292 addProperty(CSSPropertyFlexGrow, cssValuePool().createValue(0, CSSPr imitiveValue::CSS_NUMBER), important);
2293 addProperty(CSSPropertyWebkitFlexShrink, cssValuePool().createValue( 0, CSSPrimitiveValue::CSS_NUMBER), important); 2293 addProperty(CSSPropertyFlexShrink, cssValuePool().createValue(0, CSS PrimitiveValue::CSS_NUMBER), important);
2294 addProperty(CSSPropertyWebkitFlexBasis, cssValuePool().createIdentif ierValue(CSSValueAuto), important); 2294 addProperty(CSSPropertyFlexBasis, cssValuePool().createIdentifierVal ue(CSSValueAuto), important);
2295 return true; 2295 return true;
2296 } 2296 }
2297 return parseFlex(m_valueList.get(), important); 2297 return parseFlex(m_valueList.get(), important);
2298 } 2298 }
2299 case CSSPropertyWebkitFlexBasis: 2299 case CSSPropertyFlexBasis:
2300 // FIXME: Support intrinsic dimensions too. 2300 // FIXME: Support intrinsic dimensions too.
2301 if (id == CSSValueAuto) 2301 if (id == CSSValueAuto)
2302 validPrimitive = true; 2302 validPrimitive = true;
2303 else 2303 else
2304 validPrimitive = (!id && validUnit(value, FLength | FPercent | FNonN eg)); 2304 validPrimitive = (!id && validUnit(value, FLength | FPercent | FNonN eg));
2305 break; 2305 break;
2306 case CSSPropertyWebkitFlexGrow: 2306 case CSSPropertyFlexGrow:
2307 case CSSPropertyWebkitFlexShrink: 2307 case CSSPropertyFlexShrink:
2308 validPrimitive = validUnit(value, FNumber | FNonNeg); 2308 validPrimitive = validUnit(value, FNumber | FNonNeg);
2309 break; 2309 break;
2310 case CSSPropertyWebkitOrder: 2310 case CSSPropertyOrder:
2311 if (validUnit(value, FInteger, CSSStrictMode)) { 2311 if (validUnit(value, FInteger, CSSStrictMode)) {
2312 // 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. 2312 // 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.
2313 parsedValue = cssValuePool().createValue(max(static_cast<double>(std ::numeric_limits<int>::min() + 2), value->fValue), 2313 parsedValue = cssValuePool().createValue(max(static_cast<double>(std ::numeric_limits<int>::min() + 2), value->fValue),
2314 static_cast<CSSPrim itiveValue::UnitTypes>(value->unit)); 2314 static_cast<CSSPrim itiveValue::UnitTypes>(value->unit));
2315 m_valueList->next(); 2315 m_valueList->next();
2316 } 2316 }
2317 break; 2317 break;
2318 case CSSPropertyWebkitMarquee: 2318 case CSSPropertyWebkitMarquee:
2319 return parseShorthand(propId, webkitMarqueeShorthand(), important); 2319 return parseShorthand(propId, webkitMarqueeShorthand(), important);
2320 case CSSPropertyWebkitMarqueeIncrement: 2320 case CSSPropertyWebkitMarqueeIncrement:
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
2639 return parse4Values(propId, borderWidthShorthand().properties(), importa nt); 2639 return parse4Values(propId, borderWidthShorthand().properties(), importa nt);
2640 case CSSPropertyBorderStyle: 2640 case CSSPropertyBorderStyle:
2641 // <border-style>{1,4} | inherit 2641 // <border-style>{1,4} | inherit
2642 return parse4Values(propId, borderStyleShorthand().properties(), importa nt); 2642 return parse4Values(propId, borderStyleShorthand().properties(), importa nt);
2643 case CSSPropertyMargin: 2643 case CSSPropertyMargin:
2644 // <margin-width>{1,4} | inherit 2644 // <margin-width>{1,4} | inherit
2645 return parse4Values(propId, marginShorthand().properties(), important); 2645 return parse4Values(propId, marginShorthand().properties(), important);
2646 case CSSPropertyPadding: 2646 case CSSPropertyPadding:
2647 // <padding-width>{1,4} | inherit 2647 // <padding-width>{1,4} | inherit
2648 return parse4Values(propId, paddingShorthand().properties(), important); 2648 return parse4Values(propId, paddingShorthand().properties(), important);
2649 case CSSPropertyWebkitFlexFlow: 2649 case CSSPropertyFlexFlow:
2650 return parseShorthand(propId, webkitFlexFlowShorthand(), important); 2650 return parseShorthand(propId, flexFlowShorthand(), important);
2651 case CSSPropertyFont: 2651 case CSSPropertyFont:
2652 // [ [ 'font-style' || 'font-variant' || 'font-weight' ]? 'font-size' [ / 'line-height' ]? 2652 // [ [ 'font-style' || 'font-variant' || 'font-weight' ]? 'font-size' [ / 'line-height' ]?
2653 // 'font-family' ] | caption | icon | menu | message-box | small-caption | status-bar | inherit 2653 // 'font-family' ] | caption | icon | menu | message-box | small-caption | status-bar | inherit
2654 if (id >= CSSValueCaption && id <= CSSValueStatusBar) 2654 if (id >= CSSValueCaption && id <= CSSValueStatusBar)
2655 validPrimitive = true; 2655 validPrimitive = true;
2656 else 2656 else
2657 return parseFont(important); 2657 return parseFont(important);
2658 break; 2658 break;
2659 case CSSPropertyListStyle: 2659 case CSSPropertyListStyle:
2660 return parseShorthand(propId, listStyleShorthand(), important); 2660 return parseShorthand(propId, listStyleShorthand(), important);
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
2787 case CSSPropertyWebkitBoxAlign: 2787 case CSSPropertyWebkitBoxAlign:
2788 case CSSPropertyWebkitBoxDecorationBreak: 2788 case CSSPropertyWebkitBoxDecorationBreak:
2789 case CSSPropertyWebkitBoxDirection: 2789 case CSSPropertyWebkitBoxDirection:
2790 case CSSPropertyWebkitBoxLines: 2790 case CSSPropertyWebkitBoxLines:
2791 case CSSPropertyWebkitBoxOrient: 2791 case CSSPropertyWebkitBoxOrient:
2792 case CSSPropertyWebkitBoxPack: 2792 case CSSPropertyWebkitBoxPack:
2793 case CSSPropertyWebkitColumnBreakAfter: 2793 case CSSPropertyWebkitColumnBreakAfter:
2794 case CSSPropertyWebkitColumnBreakBefore: 2794 case CSSPropertyWebkitColumnBreakBefore:
2795 case CSSPropertyWebkitColumnBreakInside: 2795 case CSSPropertyWebkitColumnBreakInside:
2796 case CSSPropertyWebkitColumnRuleStyle: 2796 case CSSPropertyWebkitColumnRuleStyle:
2797 case CSSPropertyWebkitAlignContent: 2797 case CSSPropertyAlignContent:
2798 case CSSPropertyWebkitAlignItems: 2798 case CSSPropertyAlignItems:
2799 case CSSPropertyWebkitAlignSelf: 2799 case CSSPropertyAlignSelf:
2800 case CSSPropertyWebkitFlexDirection: 2800 case CSSPropertyFlexDirection:
2801 case CSSPropertyWebkitFlexWrap: 2801 case CSSPropertyFlexWrap:
2802 case CSSPropertyWebkitJustifyContent: 2802 case CSSPropertyJustifyContent:
2803 case CSSPropertyWebkitFontKerning: 2803 case CSSPropertyWebkitFontKerning:
2804 case CSSPropertyWebkitFontSmoothing: 2804 case CSSPropertyWebkitFontSmoothing:
2805 case CSSPropertyWebkitHyphens: 2805 case CSSPropertyWebkitHyphens:
2806 case CSSPropertyGridAutoFlow: 2806 case CSSPropertyGridAutoFlow:
2807 case CSSPropertyWebkitLineAlign: 2807 case CSSPropertyWebkitLineAlign:
2808 case CSSPropertyWebkitLineBreak: 2808 case CSSPropertyWebkitLineBreak:
2809 case CSSPropertyWebkitLineSnap: 2809 case CSSPropertyWebkitLineSnap:
2810 case CSSPropertyWebkitMarginAfterCollapse: 2810 case CSSPropertyWebkitMarginAfterCollapse:
2811 case CSSPropertyWebkitMarginBeforeCollapse: 2811 case CSSPropertyWebkitMarginBeforeCollapse:
2812 case CSSPropertyWebkitMarginBottomCollapse: 2812 case CSSPropertyWebkitMarginBottomCollapse:
(...skipping 3465 matching lines...) Expand 10 before | Expand all | Expand 10 after
6278 args->next(); 6278 args->next();
6279 } 6279 }
6280 6280
6281 if (flexGrow == unsetValue) 6281 if (flexGrow == unsetValue)
6282 flexGrow = 1; 6282 flexGrow = 1;
6283 if (flexShrink == unsetValue) 6283 if (flexShrink == unsetValue)
6284 flexShrink = 1; 6284 flexShrink = 1;
6285 if (!flexBasis) 6285 if (!flexBasis)
6286 flexBasis = cssValuePool().createValue(0, CSSPrimitiveValue::CSS_PX); 6286 flexBasis = cssValuePool().createValue(0, CSSPrimitiveValue::CSS_PX);
6287 6287
6288 addProperty(CSSPropertyWebkitFlexGrow, cssValuePool().createValue(clampToFlo at(flexGrow), CSSPrimitiveValue::CSS_NUMBER), important); 6288 addProperty(CSSPropertyFlexGrow, cssValuePool().createValue(clampToFloat(fle xGrow), CSSPrimitiveValue::CSS_NUMBER), important);
6289 addProperty(CSSPropertyWebkitFlexShrink, cssValuePool().createValue(clampToF loat(flexShrink), CSSPrimitiveValue::CSS_NUMBER), important); 6289 addProperty(CSSPropertyFlexShrink, cssValuePool().createValue(clampToFloat(f lexShrink), CSSPrimitiveValue::CSS_NUMBER), important);
6290 addProperty(CSSPropertyWebkitFlexBasis, flexBasis, important); 6290 addProperty(CSSPropertyFlexBasis, flexBasis, important);
6291 return true; 6291 return true;
6292 } 6292 }
6293 6293
6294 struct BorderImageParseContext { 6294 struct BorderImageParseContext {
6295 BorderImageParseContext() 6295 BorderImageParseContext()
6296 : m_canAdvance(false) 6296 : m_canAdvance(false)
6297 , m_allowCommit(true) 6297 , m_allowCommit(true)
6298 , m_allowImage(true) 6298 , m_allowImage(true)
6299 , m_allowImageSlice(true) 6299 , m_allowImageSlice(true)
6300 , m_allowRepeat(true) 6300 , m_allowRepeat(true)
(...skipping 5523 matching lines...) Expand 10 before | Expand all | Expand 10 after
11824 { 11824 {
11825 // The tokenizer checks for the construct of an+b. 11825 // The tokenizer checks for the construct of an+b.
11826 // However, since the {ident} rule precedes the {nth} rule, some of those 11826 // However, since the {ident} rule precedes the {nth} rule, some of those
11827 // tokens are identified as string literal. Furthermore we need to accept 11827 // tokens are identified as string literal. Furthermore we need to accept
11828 // "odd" and "even" which does not match to an+b. 11828 // "odd" and "even" which does not match to an+b.
11829 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even") 11829 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even")
11830 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n"); 11830 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n");
11831 } 11831 }
11832 11832
11833 } 11833 }
OLDNEW
« no previous file with comments | « Source/core/css/CSSComputedStyleDeclaration.cpp ('k') | Source/core/css/CSSPrimitiveValueMappings.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698