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

Side by Side Diff: Source/core/css/parser/CSSParserValues.h

Issue 1239983004: Make CSSCalcValue work with CSSParserTokenRange (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix autoclose problem Created 5 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) 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 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details. 13 * Library General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU Library General Public License 15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB. If not, write to 16 * along with this library; see the file COPYING.LIB. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA. 18 * Boston, MA 02110-1301, USA.
19 */ 19 */
20 20
21 #ifndef CSSParserValues_h 21 #ifndef CSSParserValues_h
22 #define CSSParserValues_h 22 #define CSSParserValues_h
23 23
24 #include "core/CSSValueKeywords.h" 24 #include "core/CSSValueKeywords.h"
25 #include "core/css/CSSPrimitiveValue.h" 25 #include "core/css/CSSPrimitiveValue.h"
26 #include "core/css/CSSSelector.h" 26 #include "core/css/CSSSelector.h"
27 #include "core/css/CSSValueList.h" 27 #include "core/css/CSSValueList.h"
28 #include "core/css/parser/CSSParserString.h" 28 #include "core/css/parser/CSSParserString.h"
29 #include "core/css/parser/CSSParserTokenRange.h"
29 30
30 namespace blink { 31 namespace blink {
31 32
32 class QualifiedName; 33 class QualifiedName;
33 class CSSParserTokenRange;
34 34
35 struct CSSParserFunction; 35 struct CSSParserFunction;
36 struct CSSParserCalcFunction;
36 class CSSParserValueList; 37 class CSSParserValueList;
37 38
38 struct CSSParserValue { 39 struct CSSParserValue {
39 CSSValueID id; 40 CSSValueID id;
40 bool isInt; 41 bool isInt;
41 union { 42 union {
42 double fValue; 43 double fValue;
43 int iValue; 44 int iValue;
44 CSSParserString string; 45 CSSParserString string;
45 CSSParserFunction* function; 46 CSSParserFunction* function;
47 CSSParserCalcFunction* calcFunction;
46 CSSParserValueList* valueList; 48 CSSParserValueList* valueList;
47 struct { 49 struct {
48 UChar32 start; 50 UChar32 start;
49 UChar32 end; 51 UChar32 end;
50 } m_unicodeRange; 52 } m_unicodeRange;
51 }; 53 };
52 enum { 54 enum {
53 Operator = 0x100000, 55 Operator = 0x100000,
54 Function = 0x100001, 56 Function = 0x100001,
55 ValueList = 0x100002, 57 CalcFunction = 0x100002,
58 ValueList = 0x100003,
56 HexColor = 0x100004, 59 HexColor = 0x100004,
57 // Represents a dimension by a list of two values, a CSS_NUMBER and an C SS_IDENT 60 // Represents a dimension by a list of two values, a CSS_NUMBER and an C SS_IDENT
58 DimensionList = 0x100006, 61 DimensionList = 0x100006,
59 // Represents a unicode range by a pair of UChar32 values 62 // Represents a unicode range by a pair of UChar32 values
60 UnicodeRange = 0x100007, 63 UnicodeRange = 0x100007,
61 }; 64 };
62 int unit; 65 int unit;
63 66
64 inline void setFromNumber(double value, int unit = CSSPrimitiveValue::CSS_NU MBER); 67 inline void setFromNumber(double value, int unit = CSSPrimitiveValue::CSS_NU MBER);
65 inline void setFromOperator(UChar); 68 inline void setFromOperator(UChar);
66 inline void setFromFunction(CSSParserFunction*);
67 inline void setFromValueList(PassOwnPtr<CSSParserValueList>); 69 inline void setFromValueList(PassOwnPtr<CSSParserValueList>);
68 }; 70 };
69 71
70 class CORE_EXPORT CSSParserValueList { 72 class CORE_EXPORT CSSParserValueList {
71 WTF_MAKE_FAST_ALLOCATED(CSSParserValueList); 73 WTF_MAKE_FAST_ALLOCATED(CSSParserValueList);
72 public: 74 public:
73 CSSParserValueList() 75 CSSParserValueList()
74 : m_current(0) 76 : m_current(0)
75 { 77 {
76 } 78 }
(...skipping 30 matching lines...) Expand all
107 Vector<CSSParserValue, 4> m_values; 109 Vector<CSSParserValue, 4> m_values;
108 }; 110 };
109 111
110 struct CSSParserFunction { 112 struct CSSParserFunction {
111 WTF_MAKE_FAST_ALLOCATED(CSSParserFunction); 113 WTF_MAKE_FAST_ALLOCATED(CSSParserFunction);
112 public: 114 public:
113 CSSValueID id; 115 CSSValueID id;
114 OwnPtr<CSSParserValueList> args; 116 OwnPtr<CSSParserValueList> args;
115 }; 117 };
116 118
119 struct CSSParserCalcFunction {
120 WTF_MAKE_FAST_ALLOCATED(CSSParserCalcFunction);
121 public:
122 Vector<CSSParserToken> args;
Timothy Loh 2015/07/21 07:33:17 Just use a CSSParserTokenRange
rwlbuis 2015/07/22 02:19:06 Done. Note that I did it this way for the auto clo
123 };
124
117 class CSSParserSelector { 125 class CSSParserSelector {
118 WTF_MAKE_NONCOPYABLE(CSSParserSelector); WTF_MAKE_FAST_ALLOCATED(CSSParserSe lector); 126 WTF_MAKE_NONCOPYABLE(CSSParserSelector); WTF_MAKE_FAST_ALLOCATED(CSSParserSe lector);
119 public: 127 public:
120 CSSParserSelector(); 128 CSSParserSelector();
121 explicit CSSParserSelector(const QualifiedName&, bool isImplicit = false); 129 explicit CSSParserSelector(const QualifiedName&, bool isImplicit = false);
122 130
123 static PassOwnPtr<CSSParserSelector> create() { return adoptPtr(new CSSParse rSelector); } 131 static PassOwnPtr<CSSParserSelector> create() { return adoptPtr(new CSSParse rSelector); }
124 static PassOwnPtr<CSSParserSelector> create(const QualifiedName& name, bool isImplicit = false) { return adoptPtr(new CSSParserSelector(name, isImplicit)); } 132 static PassOwnPtr<CSSParserSelector> create(const QualifiedName& name, bool isImplicit = false) { return adoptPtr(new CSSParserSelector(name, isImplicit)); }
125 133
126 ~CSSParserSelector(); 134 ~CSSParserSelector();
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 } 187 }
180 188
181 inline void CSSParserValue::setFromOperator(UChar c) 189 inline void CSSParserValue::setFromOperator(UChar c)
182 { 190 {
183 id = CSSValueInvalid; 191 id = CSSValueInvalid;
184 unit = Operator; 192 unit = Operator;
185 iValue = c; 193 iValue = c;
186 isInt = false; 194 isInt = false;
187 } 195 }
188 196
189 inline void CSSParserValue::setFromFunction(CSSParserFunction* function)
190 {
191 id = CSSValueInvalid;
192 this->function = function;
193 unit = Function;
194 isInt = false;
195 }
196
197 inline void CSSParserValue::setFromValueList(PassOwnPtr<CSSParserValueList> valu eList) 197 inline void CSSParserValue::setFromValueList(PassOwnPtr<CSSParserValueList> valu eList)
198 { 198 {
199 id = CSSValueInvalid; 199 id = CSSValueInvalid;
200 this->valueList = valueList.leakPtr(); 200 this->valueList = valueList.leakPtr();
201 unit = ValueList; 201 unit = ValueList;
202 isInt = false; 202 isInt = false;
203 } 203 }
204 204
205 } 205 }
206 206
207 #endif 207 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698