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

Side by Side Diff: third_party/WebKit/Source/core/css/parser/CSSPropertyParser.h

Issue 1877073004: Move the grid shorthand into CSSPropertyParser (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Patch for landing Created 4 years, 8 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) 2004, 2005, 2006, 2008, 2009, 2010 Apple Inc. All rights reserv ed. 3 * Copyright (C) 2004, 2005, 2006, 2008, 2009, 2010 Apple Inc. All rights reserv ed.
4 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> 4 * Copyright (C) 2008 Eric Seidel <eric@webkit.org>
5 * Copyright (C) 2009 - 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserve d. 5 * Copyright (C) 2009 - 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserve d.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
11 * 11 *
12 * This library is distributed in the hope that it will be useful, 12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details. 15 * Library General Public License for more details.
16 * 16 *
17 * You should have received a copy of the GNU Library General Public License 17 * You should have received a copy of the GNU Library General Public License
18 * along with this library; see the file COPYING.LIB. If not, write to 18 * along with this library; see the file COPYING.LIB. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 * Boston, MA 02110-1301, USA. 20 * Boston, MA 02110-1301, USA.
21 */ 21 */
22 22
23 #ifndef CSSPropertyParser_h 23 #ifndef CSSPropertyParser_h
24 #define CSSPropertyParser_h 24 #define CSSPropertyParser_h
25 25
26 #include "core/css/CSSGridTemplateAreasValue.h"
27 #include "core/css/StyleRule.h" 26 #include "core/css/StyleRule.h"
28 #include "core/css/parser/CSSParserTokenRange.h" 27 #include "core/css/parser/CSSParserTokenRange.h"
29 #include "platform/Length.h"
30 28
31 namespace blink { 29 namespace blink {
32 30
33 class CSSCustomIdentValue;
34 class CSSFunctionValue;
35 class CSSGradientValue;
36 class CSSGridLineNamesValue;
37 struct CSSParserString; 31 struct CSSParserString;
38 struct CSSParserValue;
39 class CSSParserValueList;
40 class CSSPrimitiveValue;
41 class CSSProperty; 32 class CSSProperty;
42 class CSSValue; 33 class CSSValue;
43 class CSSValueList;
44 class StylePropertyShorthand; 34 class StylePropertyShorthand;
45 35
46 // TODO(rob.buis) to move to cpp file once legacy parser is removed. 36 // Inputs: PropertyID, isImportant bool, CSSParserTokenRange.
47 enum TrackSizeRestriction { FixedSizeOnly, AllowAll };
48
49 // Inputs: PropertyID, isImportant bool, CSSParserValueList.
50 // Outputs: Vector of CSSProperties 37 // Outputs: Vector of CSSProperties
51 38
52 class CSSPropertyParser { 39 class CSSPropertyParser {
53 STACK_ALLOCATED(); 40 STACK_ALLOCATED();
54 public: 41 public:
55 static bool parseValue(CSSPropertyID, bool important, 42 static bool parseValue(CSSPropertyID, bool important,
56 const CSSParserTokenRange&, const CSSParserContext&, 43 const CSSParserTokenRange&, const CSSParserContext&,
57 HeapVector<CSSProperty, 256>&, StyleRule::RuleType); 44 HeapVector<CSSProperty, 256>&, StyleRule::RuleType);
58 45
59 // Parses a non-shorthand CSS property 46 // Parses a non-shorthand CSS property
60 static CSSValue* parseSingleValue(CSSPropertyID, const CSSParserTokenRange&, const CSSParserContext&); 47 static CSSValue* parseSingleValue(CSSPropertyID, const CSSParserTokenRange&, const CSSParserContext&);
61 48
62 // TODO(timloh): This doesn't seem like the right place for these 49 // TODO(timloh): This doesn't seem like the right place for these
63 static bool isSystemColor(CSSValueID); 50 static bool isSystemColor(CSSValueID);
64 static bool isColorKeyword(CSSValueID); 51 static bool isColorKeyword(CSSValueID);
65 static bool isValidNumericValue(double); 52 static bool isValidNumericValue(double);
66 53
67 private: 54 private:
68 CSSPropertyParser(const CSSParserTokenRange&, const CSSParserContext&, 55 CSSPropertyParser(const CSSParserTokenRange&, const CSSParserContext&,
69 HeapVector<CSSProperty, 256>*); 56 HeapVector<CSSProperty, 256>*);
70 57
71 // TODO(timloh): Rename once the CSSParserValue-based parseValue is removed 58 // TODO(timloh): Rename once the CSSParserValue-based parseValue is removed
72 bool parseValueStart(CSSPropertyID unresolvedProperty, bool important); 59 bool parseValueStart(CSSPropertyID unresolvedProperty, bool important);
73 bool consumeCSSWideKeyword(CSSPropertyID unresolvedProperty, bool important) ; 60 bool consumeCSSWideKeyword(CSSPropertyID unresolvedProperty, bool important) ;
74 CSSValue* parseSingleValue(CSSPropertyID); 61 CSSValue* parseSingleValue(CSSPropertyID);
75 62
76 bool legacyParseShorthand(CSSPropertyID, bool important);
77
78 bool inShorthand() const { return m_inParseShorthand; }
79 bool inQuirksMode() const { return isQuirksModeBehavior(m_context.mode()); } 63 bool inQuirksMode() const { return isQuirksModeBehavior(m_context.mode()); }
80 64
81 bool parseViewportDescriptor(CSSPropertyID propId, bool important); 65 bool parseViewportDescriptor(CSSPropertyID propId, bool important);
82 bool parseFontFaceDescriptor(CSSPropertyID); 66 bool parseFontFaceDescriptor(CSSPropertyID);
83 67
84 void addProperty(CSSPropertyID, CSSValue*, bool important, bool implicit = f alse); 68 void addProperty(CSSPropertyID, CSSValue*, bool important, bool implicit = f alse);
85 void addExpandedPropertyForValue(CSSPropertyID propId, CSSValue*, bool); 69 void addExpandedPropertyForValue(CSSPropertyID propId, CSSValue*, bool);
86 70
87 bool consumeBorder(bool important); 71 bool consumeBorder(bool important);
88 72
89 bool parseShorthand(CSSPropertyID, bool important); 73 bool parseShorthand(CSSPropertyID, bool important);
90 bool consumeShorthandGreedily(const StylePropertyShorthand&, bool important) ; 74 bool consumeShorthandGreedily(const StylePropertyShorthand&, bool important) ;
91 bool consume4Values(const StylePropertyShorthand&, bool important); 75 bool consume4Values(const StylePropertyShorthand&, bool important);
92 76
93 // Legacy parsing allows <string>s for animation-name 77 // Legacy parsing allows <string>s for animation-name
94 bool consumeAnimationShorthand(const StylePropertyShorthand&, bool useLegacy Parsing, bool important); 78 bool consumeAnimationShorthand(const StylePropertyShorthand&, bool useLegacy Parsing, bool important);
95 bool consumeBackgroundShorthand(const StylePropertyShorthand&, bool importan t); 79 bool consumeBackgroundShorthand(const StylePropertyShorthand&, bool importan t);
96 80
97 bool consumeColumns(bool important); 81 bool consumeColumns(bool important);
98 82
99 bool consumeGridItemPositionShorthand(CSSPropertyID, bool important); 83 bool consumeGridItemPositionShorthand(CSSPropertyID, bool important);
100 bool consumeGridTemplateRowsAndAreasAndColumns(bool important); 84 bool consumeGridTemplateRowsAndAreasAndColumns(bool important);
101 bool consumeGridTemplateShorthand(bool important); 85 bool consumeGridTemplateShorthand(bool important);
102 bool parseGridShorthand(bool important); 86 bool consumeGridShorthand(bool important);
103 bool consumeGridAreaShorthand(bool important); 87 bool consumeGridAreaShorthand(bool important);
104 bool parseGridLineNames(CSSParserValueList&, CSSValueList&, CSSGridLineNames Value* = nullptr);
105 88
106 bool consumeFont(bool important); 89 bool consumeFont(bool important);
107 bool consumeSystemFont(bool important); 90 bool consumeSystemFont(bool important);
108 91
109 bool consumeBorderSpacing(bool important); 92 bool consumeBorderSpacing(bool important);
110 93
111 // CSS3 Parsing Routines (for properties specific to CSS3) 94 // CSS3 Parsing Routines (for properties specific to CSS3)
112 bool consumeBorderImage(CSSPropertyID, bool important); 95 bool consumeBorderImage(CSSPropertyID, bool important);
113 96
114 bool consumeFlex(bool important); 97 bool consumeFlex(bool important);
(...skipping 13 matching lines...) Expand all
128 if (!(--m_parser->m_inParseShorthand)) 111 if (!(--m_parser->m_inParseShorthand))
129 m_parser->m_currentShorthand = CSSPropertyInvalid; 112 m_parser->m_currentShorthand = CSSPropertyInvalid;
130 } 113 }
131 114
132 private: 115 private:
133 CSSPropertyParser* m_parser; 116 CSSPropertyParser* m_parser;
134 }; 117 };
135 118
136 private: 119 private:
137 // Inputs: 120 // Inputs:
138 CSSParserValueList* m_valueList;
139 CSSParserTokenRange m_range; 121 CSSParserTokenRange m_range;
140 const CSSParserContext& m_context; 122 const CSSParserContext& m_context;
141 123
142 // Outputs: 124 // Outputs:
143 HeapVector<CSSProperty, 256>* m_parsedProperties; 125 HeapVector<CSSProperty, 256>* m_parsedProperties;
144 126
145 // Locals during parsing: 127 // Locals during parsing:
146 int m_inParseShorthand; 128 int m_inParseShorthand;
147 CSSPropertyID m_currentShorthand; 129 CSSPropertyID m_currentShorthand;
148 Member<CSSCalcValue> m_parsedCalculation;
149 }; 130 };
150 131
151 // TODO(rob.buis): should move to CSSPropertyParser after conversion.
152 bool allTracksAreFixedSized(CSSValueList&);
153 bool parseGridTemplateAreasRow(const String&, NamedGridAreaMap&, const size_t, s ize_t&);
154 CSSValueList* consumeGridAutoFlow(CSSParserTokenRange&);
155 CSSValue* consumeGridTrackSize(CSSParserTokenRange&, CSSParserMode, TrackSizeRes triction = AllowAll);
156
157 CSSPropertyID unresolvedCSSPropertyID(const CSSParserString&); 132 CSSPropertyID unresolvedCSSPropertyID(const CSSParserString&);
158 CSSValueID cssValueKeywordID(const CSSParserString&); 133 CSSValueID cssValueKeywordID(const CSSParserString&);
159 134
160 } // namespace blink 135 } // namespace blink
161 136
162 #endif // CSSPropertyParser_h 137 #endif // CSSPropertyParser_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/core.gypi ('k') | third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698