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

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

Issue 1883983003: Remove CSSParserValues (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
(Empty)
1 /*
2 * Copyright (C) 2003 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2004, 2005, 2006, 2008, 2009, 2010 Apple Inc. All rights reserv ed.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
14 *
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
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19 */
20
21 #ifndef CSSParserValues_h
22 #define CSSParserValues_h
23
24 #include "core/CSSValueKeywords.h"
25 #include "core/css/CSSPrimitiveValue.h"
26 #include "core/css/CSSValueList.h"
27 #include "core/css/parser/CSSParserString.h"
28 #include "core/css/parser/CSSParserTokenRange.h"
29 #include "wtf/Allocator.h"
30
31 namespace blink {
32
33 class QualifiedName;
34
35 struct CSSParserFunction;
36 struct CSSParserCalcFunction;
37 class CSSParserValueList;
38
39 struct CSSParserValue {
40 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW();
41 CSSValueID id;
42 bool isInt;
43 union {
44 double fValue;
45 int iValue;
46 CSSParserString string;
47 CSSParserFunction* function;
48 CSSParserCalcFunction* calcFunction;
49 CSSParserValueList* valueList;
50 struct {
51 UChar32 start;
52 UChar32 end;
53 } m_unicodeRange;
54 };
55 enum {
56 Operator = 0x100000,
57 Function = 0x100001,
58 CalcFunction = 0x100002,
59 ValueList = 0x100003,
60 HexColor = 0x100004,
61 Identifier = 0x100005,
62 // Represents a dimension by a list of two values, a UnitType::Number an d an Identifier
63 DimensionList = 0x100006,
64 // Represents a unicode range by a pair of UChar32 values
65 UnicodeRange = 0x100007,
66 String = 0x100008,
67 URI = 0x100009,
68 };
69 int m_unit;
70 CSSPrimitiveValue::UnitType unit() const { return static_cast<CSSPrimitiveVa lue::UnitType>(m_unit); }
71 void setUnit(CSSPrimitiveValue::UnitType unit) { m_unit = static_cast<int>(u nit); }
72
73 inline void setFromNumber(double value, CSSPrimitiveValue::UnitType);
74 inline void setFromOperator(UChar);
75 inline void setFromValueList(PassOwnPtr<CSSParserValueList>);
76 };
77
78 class CORE_EXPORT CSSParserValueList {
79 USING_FAST_MALLOC(CSSParserValueList);
80 public:
81 CSSParserValueList()
82 : m_current(0)
83 {
84 }
85 CSSParserValueList(CSSParserTokenRange);
86 ~CSSParserValueList();
87
88 void addValue(const CSSParserValue&);
89
90 unsigned size() const { return m_values.size(); }
91 unsigned currentIndex() { return m_current; }
92 CSSParserValue* current() { return m_current < m_values.size() ? &m_values[m _current] : nullptr; }
93 CSSParserValue* next() { ++m_current; return current(); }
94 CSSParserValue* previous()
95 {
96 if (!m_current)
97 return 0;
98 --m_current;
99 return current();
100 }
101 void setCurrentIndex(unsigned index)
102 {
103 ASSERT(index < m_values.size());
104 if (index < m_values.size())
105 m_current = index;
106 }
107
108 CSSParserValue* valueAt(unsigned i) { return i < m_values.size() ? &m_values [i] : nullptr; }
109
110 void clearAndLeakValues() { m_values.clear(); m_current = 0;}
111 void destroyAndClear();
112
113 private:
114 unsigned m_current;
115 Vector<CSSParserValue, 4> m_values;
116 };
117
118 struct CSSParserFunction {
119 USING_FAST_MALLOC(CSSParserFunction);
120 public:
121 CSSValueID id;
122 OwnPtr<CSSParserValueList> args;
123 };
124
125 struct CSSParserCalcFunction {
126 USING_FAST_MALLOC(CSSParserCalcFunction);
127 public:
128 CSSParserCalcFunction(CSSParserTokenRange args_) : args(args_) {}
129 CSSParserTokenRange args;
130 };
131
132 inline void CSSParserValue::setFromNumber(double value, CSSPrimitiveValue::UnitT ype unit)
133 {
134 id = CSSValueInvalid;
135 isInt = false;
136 fValue = value;
137 this->setUnit(std::isfinite(value) ? unit : CSSPrimitiveValue::UnitType::Unk nown);
138 }
139
140 inline void CSSParserValue::setFromOperator(UChar c)
141 {
142 id = CSSValueInvalid;
143 m_unit = Operator;
144 iValue = c;
145 isInt = false;
146 }
147
148 inline void CSSParserValue::setFromValueList(PassOwnPtr<CSSParserValueList> valu eList)
149 {
150 id = CSSValueInvalid;
151 this->valueList = valueList.leakPtr();
152 m_unit = ValueList;
153 isInt = false;
154 }
155
156 } // namespace blink
157
158 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/core.gypi ('k') | third_party/WebKit/Source/core/css/parser/CSSParserValues.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698