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

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

Issue 17090005: [CSS Grid Layout] Implement 'justify-self' parsing (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fixed a bug in parseColor uncovered by the patch Created 6 years, 11 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 666 matching lines...) Expand 10 before | Expand all | Expand 10 after
677 case CSSPropertyInternalCallback: 677 case CSSPropertyInternalCallback:
678 // This property is only injected programmatically, not parsed from styl esheets. 678 // This property is only injected programmatically, not parsed from styl esheets.
679 return false; 679 return false;
680 case CSSPropertyColumnFill: 680 case CSSPropertyColumnFill:
681 if (RuntimeEnabledFeatures::regionBasedColumnsEnabled()) { 681 if (RuntimeEnabledFeatures::regionBasedColumnsEnabled()) {
682 if (valueID == CSSValueAuto || valueID == CSSValueBalance) 682 if (valueID == CSSValueAuto || valueID == CSSValueBalance)
683 return true; 683 return true;
684 } 684 }
685 break; 685 break;
686 case CSSPropertyAlignContent: 686 case CSSPropertyAlignContent:
687 // FIXME: Per CSS alignment, this property should accept an optional <ov erflow-position>. We should share this parsing code with 'justify-self'.
687 if (valueID == CSSValueFlexStart || valueID == CSSValueFlexEnd || value ID == CSSValueCenter || valueID == CSSValueSpaceBetween || valueID == CSSValueSp aceAround || valueID == CSSValueStretch) 688 if (valueID == CSSValueFlexStart || valueID == CSSValueFlexEnd || value ID == CSSValueCenter || valueID == CSSValueSpaceBetween || valueID == CSSValueSp aceAround || valueID == CSSValueStretch)
688 return true; 689 return true;
689 break; 690 break;
690 case CSSPropertyAlignItems: 691 case CSSPropertyAlignItems:
692 // FIXME: Per CSS alignment, this property should accept the same argume nts as 'justify-self' so we should share its parsing code.
691 if (valueID == CSSValueFlexStart || valueID == CSSValueFlexEnd || valueI D == CSSValueCenter || valueID == CSSValueBaseline || valueID == CSSValueStretch ) 693 if (valueID == CSSValueFlexStart || valueID == CSSValueFlexEnd || valueI D == CSSValueCenter || valueID == CSSValueBaseline || valueID == CSSValueStretch )
692 return true; 694 return true;
693 break; 695 break;
694 case CSSPropertyAlignSelf: 696 case CSSPropertyAlignSelf:
697 // FIXME: Per CSS alignment, this property should accept the same argume nts as 'justify-self' so we should share its parsing code.
695 if (valueID == CSSValueAuto || valueID == CSSValueFlexStart || valueID = = CSSValueFlexEnd || valueID == CSSValueCenter || valueID == CSSValueBaseline || valueID == CSSValueStretch) 698 if (valueID == CSSValueAuto || valueID == CSSValueFlexStart || valueID = = CSSValueFlexEnd || valueID == CSSValueCenter || valueID == CSSValueBaseline || valueID == CSSValueStretch)
696 return true; 699 return true;
697 break; 700 break;
698 case CSSPropertyFlexDirection: 701 case CSSPropertyFlexDirection:
699 if (valueID == CSSValueRow || valueID == CSSValueRowReverse || valueID = = CSSValueColumn || valueID == CSSValueColumnReverse) 702 if (valueID == CSSValueRow || valueID == CSSValueRowReverse || valueID = = CSSValueColumn || valueID == CSSValueColumnReverse)
700 return true; 703 return true;
701 break; 704 break;
702 case CSSPropertyFlexWrap: 705 case CSSPropertyFlexWrap:
703 if (valueID == CSSValueNowrap || valueID == CSSValueWrap || valueID == C SSValueWrapReverse) 706 if (valueID == CSSValueNowrap || valueID == CSSValueWrap || valueID == C SSValueWrapReverse)
704 return true; 707 return true;
705 break; 708 break;
706 case CSSPropertyJustifyContent: 709 case CSSPropertyJustifyContent:
710 // FIXME: Per CSS alignment, this property should accept an optional <ov erflow-position>. We should share this parsing code with 'justify-self'.
707 if (valueID == CSSValueFlexStart || valueID == CSSValueFlexEnd || valueI D == CSSValueCenter || valueID == CSSValueSpaceBetween || valueID == CSSValueSpa ceAround) 711 if (valueID == CSSValueFlexStart || valueID == CSSValueFlexEnd || valueI D == CSSValueCenter || valueID == CSSValueSpaceBetween || valueID == CSSValueSpa ceAround)
708 return true; 712 return true;
709 break; 713 break;
710 case CSSPropertyFontKerning: 714 case CSSPropertyFontKerning:
711 if (valueID == CSSValueAuto || valueID == CSSValueNormal || valueID == C SSValueNone) 715 if (valueID == CSSValueAuto || valueID == CSSValueNormal || valueID == C SSValueNone)
712 return true; 716 return true;
713 break; 717 break;
714 case CSSPropertyWebkitFontSmoothing: 718 case CSSPropertyWebkitFontSmoothing:
715 if (valueID == CSSValueAuto || valueID == CSSValueNone || valueID == CSS ValueAntialiased || valueID == CSSValueSubpixelAntialiased) 719 if (valueID == CSSValueAuto || valueID == CSSValueNone || valueID == CSS ValueAntialiased || valueID == CSSValueSubpixelAntialiased)
716 return true; 720 return true;
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after
1221 { 1225 {
1222 if (!document) 1226 if (!document)
1223 return false; 1227 return false;
1224 1228
1225 CSSParserString cssColor; 1229 CSSParserString cssColor;
1226 cssColor.init(string); 1230 cssColor.init(string);
1227 CSSValueID id = cssValueKeywordID(cssColor); 1231 CSSValueID id = cssValueKeywordID(cssColor);
1228 if (id <= 0) 1232 if (id <= 0)
1229 return false; 1233 return false;
1230 1234
1231 color = RenderTheme::theme().systemColor(id).rgb(); 1235 Color parsedColor = RenderTheme::theme().systemColor(id);
1232 return true; 1236 color = parsedColor.rgb();
1237 return parsedColor.isValid();
1233 } 1238 }
1234 1239
1235 void BisonCSSParser::parseSelector(const String& string, CSSSelectorList& select orList) 1240 void BisonCSSParser::parseSelector(const String& string, CSSSelectorList& select orList)
1236 { 1241 {
1237 m_selectorListForParseSelector = &selectorList; 1242 m_selectorListForParseSelector = &selectorList;
1238 1243
1239 setupParser("@-internal-selector ", string, ""); 1244 setupParser("@-internal-selector ", string, "");
1240 1245
1241 cssyyparse(this); 1246 cssyyparse(this);
1242 1247
(...skipping 1176 matching lines...) Expand 10 before | Expand all | Expand 10 after
2419 case CSSPropertyWebkitTransitionProperty: { 2424 case CSSPropertyWebkitTransitionProperty: {
2420 RefPtr<CSSValue> val; 2425 RefPtr<CSSValue> val;
2421 AnimationParseContext context; 2426 AnimationParseContext context;
2422 if (parseAnimationProperty(propId, val, context)) { 2427 if (parseAnimationProperty(propId, val, context)) {
2423 addPropertyWithPrefixingVariant(propId, val.release(), important); 2428 addPropertyWithPrefixingVariant(propId, val.release(), important);
2424 return true; 2429 return true;
2425 } 2430 }
2426 return false; 2431 return false;
2427 } 2432 }
2428 2433
2434 case CSSPropertyJustifySelf:
2435 if (!RuntimeEnabledFeatures::cssGridLayoutEnabled())
2436 return false;
2437
2438 return parseJustifySelf(propId, important);
2429 case CSSPropertyGridAutoColumns: 2439 case CSSPropertyGridAutoColumns:
2430 case CSSPropertyGridAutoRows: 2440 case CSSPropertyGridAutoRows:
2431 if (!RuntimeEnabledFeatures::cssGridLayoutEnabled()) 2441 if (!RuntimeEnabledFeatures::cssGridLayoutEnabled())
2432 return false; 2442 return false;
2433 parsedValue = parseGridTrackSize(*m_valueList); 2443 parsedValue = parseGridTrackSize(*m_valueList);
2434 break; 2444 break;
2435 2445
2436 case CSSPropertyGridDefinitionColumns: 2446 case CSSPropertyGridDefinitionColumns:
2437 case CSSPropertyGridDefinitionRows: 2447 case CSSPropertyGridDefinitionRows:
2438 if (!RuntimeEnabledFeatures::cssGridLayoutEnabled()) 2448 if (!RuntimeEnabledFeatures::cssGridLayoutEnabled())
(...skipping 2634 matching lines...) Expand 10 before | Expand all | Expand 10 after
5073 i++; 5083 i++;
5074 } 5084 }
5075 if (valid) { 5085 if (valid) {
5076 addProperty(propId, cssValuePool().createValue(rect.release()), importan t); 5086 addProperty(propId, cssValuePool().createValue(rect.release()), importan t);
5077 m_valueList->next(); 5087 m_valueList->next();
5078 return true; 5088 return true;
5079 } 5089 }
5080 return false; 5090 return false;
5081 } 5091 }
5082 5092
5093 static bool isItemPositionKeyword(CSSValueID id)
5094 {
5095 return id == CSSValueStart || id == CSSValueEnd || id == CSSValueCenter
5096 || id == CSSValueSelfStart || id == CSSValueSelfEnd || id == CSSValueFle xStart
5097 || id == CSSValueFlexEnd || id == CSSValueLeft || id == CSSValueRight;
5098 }
5099
5100 bool BisonCSSParser::parseJustifySelf(CSSPropertyID propId, bool important)
5101 {
5102 // auto | baseline | stretch | [<item-position> && <overflow-position>? ]
5103 // <item-position> = center | start | end | self-start | self-end | flex-sta rt | flex-end | left | right;
5104 // <overflow-position> = true | safe
5105
5106 CSSParserValue* value = m_valueList->current();
5107
5108 if (value->id == CSSValueAuto || value->id == CSSValueBaseline || value->id == CSSValueStretch) {
5109 if (m_valueList->next())
5110 return false;
5111
5112 addProperty(propId, cssValuePool().createIdentifierValue(value->id), imp ortant);
5113 return true;
5114 }
5115
5116 RefPtr<CSSPrimitiveValue> position = 0;
5117 RefPtr<CSSPrimitiveValue> overflowAlignmentKeyword = 0;
5118 if (isItemPositionKeyword(value->id)) {
5119 position = cssValuePool().createIdentifierValue(value->id);
5120 value = m_valueList->next();
5121 if (value) {
5122 if (value->id == CSSValueTrue || value->id == CSSValueSafe)
5123 overflowAlignmentKeyword = cssValuePool().createIdentifierValue( value->id);
5124 else
5125 return false;
5126 }
5127 } else if (value->id == CSSValueTrue || value->id == CSSValueSafe) {
5128 overflowAlignmentKeyword = cssValuePool().createIdentifierValue(value->i d);
5129 value = m_valueList->next();
5130 if (value) {
5131 if (isItemPositionKeyword(value->id))
5132 position = cssValuePool().createIdentifierValue(value->id);
5133 else
5134 return false;
5135 }
5136 } else {
5137 return false;
5138 }
5139
5140 if (m_valueList->next())
5141 return false;
5142
5143 ASSERT(position);
5144 if (overflowAlignmentKeyword)
5145 addProperty(propId, createPrimitiveValuePair(position, overflowAlignment Keyword), important);
5146 else
5147 addProperty(propId, position.release(), important);
5148
5149 return true;
5150 }
5151
5083 PassRefPtr<CSSBasicShape> BisonCSSParser::parseBasicShapeRectangle(CSSParserValu eList* args) 5152 PassRefPtr<CSSBasicShape> BisonCSSParser::parseBasicShapeRectangle(CSSParserValu eList* args)
5084 { 5153 {
5085 ASSERT(args); 5154 ASSERT(args);
5086 5155
5087 // rect(x, y, width, height, [[rx], ry]) 5156 // rect(x, y, width, height, [[rx], ry])
5088 if (args->size() != 7 && args->size() != 9 && args->size() != 11) 5157 if (args->size() != 7 && args->size() != 9 && args->size() != 11)
5089 return 0; 5158 return 0;
5090 5159
5091 RefPtr<CSSBasicShapeRectangle> shape = CSSBasicShapeRectangle::create(); 5160 RefPtr<CSSBasicShapeRectangle> shape = CSSBasicShapeRectangle::create();
5092 5161
(...skipping 5429 matching lines...) Expand 10 before | Expand all | Expand 10 after
10522 { 10591 {
10523 // The tokenizer checks for the construct of an+b. 10592 // The tokenizer checks for the construct of an+b.
10524 // However, since the {ident} rule precedes the {nth} rule, some of those 10593 // However, since the {ident} rule precedes the {nth} rule, some of those
10525 // tokens are identified as string literal. Furthermore we need to accept 10594 // tokens are identified as string literal. Furthermore we need to accept
10526 // "odd" and "even" which does not match to an+b. 10595 // "odd" and "even" which does not match to an+b.
10527 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even") 10596 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even")
10528 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n"); 10597 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n");
10529 } 10598 }
10530 10599
10531 } 10600 }
OLDNEW
« no previous file with comments | « Source/core/css/parser/BisonCSSParser.h ('k') | Source/core/css/resolver/StyleBuilderCustom.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698