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

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

Issue 1373433002: Split out CSSPrimitiveValue's PropertyID into CSSCustomIdentValue (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@split_string
Patch Set: Rebase Created 5 years, 2 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 * (C) 1999-2003 Lars Knoll (knoll@kde.org) 2 * (C) 1999-2003 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved. 3 * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved.
4 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> 4 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 DotsPerPixel, 94 DotsPerPixel,
95 DotsPerInch, 95 DotsPerInch,
96 DotsPerCentimeter, 96 DotsPerCentimeter,
97 Fraction, 97 Fraction,
98 Integer, 98 Integer,
99 Rems, 99 Rems,
100 Chs, 100 Chs,
101 Calc, 101 Calc,
102 CalcPercentageWithNumber, 102 CalcPercentageWithNumber,
103 CalcPercentageWithLength, 103 CalcPercentageWithLength,
104 PropertyID,
105 ValueID, 104 ValueID,
106 105
107 // This value is used to handle quirky margins in reflow roots (body, td , and th) like WinIE. 106 // This value is used to handle quirky margins in reflow roots (body, td , and th) like WinIE.
108 // The basic idea is that a stylesheet can use the value __qem (for quir ky em) instead of em. 107 // The basic idea is that a stylesheet can use the value __qem (for quir ky em) instead of em.
109 // When the quirky value is used, if you're in quirks mode, the margin w ill collapse away 108 // When the quirky value is used, if you're in quirks mode, the margin w ill collapse away
110 // inside a table cell. This quirk is specified in the HTML spec but our impl is different. 109 // inside a table cell. This quirk is specified in the HTML spec but our impl is different.
111 // TODO: Remove this. crbug.com/443952 110 // TODO: Remove this. crbug.com/443952
112 QuirkyEms, 111 QuirkyEms,
113 }; 112 };
114 113
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 bool isQuirkyEms() const { return type() == UnitType::QuirkyEms; } 168 bool isQuirkyEms() const { return type() == UnitType::QuirkyEms; }
170 bool isViewportPercentageLength() const { return isViewportPercentageLength( type()); } 169 bool isViewportPercentageLength() const { return isViewportPercentageLength( type()); }
171 static bool isViewportPercentageLength(UnitType type) { return type >= UnitT ype::ViewportWidth && type <= UnitType::ViewportMax; } 170 static bool isViewportPercentageLength(UnitType type) { return type >= UnitT ype::ViewportWidth && type <= UnitType::ViewportMax; }
172 static bool isLength(UnitType type) 171 static bool isLength(UnitType type)
173 { 172 {
174 return (type >= UnitType::Ems && type <= UnitType::Picas) || type == Uni tType::QuirkyEms || type == UnitType::Rems || type == UnitType::Chs || isViewpor tPercentageLength(type); 173 return (type >= UnitType::Ems && type <= UnitType::Picas) || type == Uni tType::QuirkyEms || type == UnitType::Rems || type == UnitType::Chs || isViewpor tPercentageLength(type);
175 } 174 }
176 bool isLength() const { return isLength(typeWithCalcResolved()); } 175 bool isLength() const { return isLength(typeWithCalcResolved()); }
177 bool isNumber() const { return typeWithCalcResolved() == UnitType::Number || typeWithCalcResolved() == UnitType::Integer; } 176 bool isNumber() const { return typeWithCalcResolved() == UnitType::Number || typeWithCalcResolved() == UnitType::Integer; }
178 bool isPercentage() const { return typeWithCalcResolved() == UnitType::Perce ntage; } 177 bool isPercentage() const { return typeWithCalcResolved() == UnitType::Perce ntage; }
179 bool isPropertyID() const { return type() == UnitType::PropertyID; }
180 bool isPx() const { return typeWithCalcResolved() == UnitType::Pixels; } 178 bool isPx() const { return typeWithCalcResolved() == UnitType::Pixels; }
181 bool isRGBColor() const { return type() == UnitType::RGBColor; } 179 bool isRGBColor() const { return type() == UnitType::RGBColor; }
182 bool isTime() const { return type() == UnitType::Seconds || type() == UnitTy pe::Milliseconds; } 180 bool isTime() const { return type() == UnitType::Seconds || type() == UnitTy pe::Milliseconds; }
183 bool isCalculated() const { return type() == UnitType::Calc; } 181 bool isCalculated() const { return type() == UnitType::Calc; }
184 bool isCalculatedPercentageWithNumber() const { return typeWithCalcResolved( ) == UnitType::CalcPercentageWithNumber; } 182 bool isCalculatedPercentageWithNumber() const { return typeWithCalcResolved( ) == UnitType::CalcPercentageWithNumber; }
185 bool isCalculatedPercentageWithLength() const { return typeWithCalcResolved( ) == UnitType::CalcPercentageWithLength; } 183 bool isCalculatedPercentageWithLength() const { return typeWithCalcResolved( ) == UnitType::CalcPercentageWithLength; }
186 static bool isDotsPerInch(UnitType type) { return type == UnitType::DotsPerI nch; } 184 static bool isDotsPerInch(UnitType type) { return type == UnitType::DotsPerI nch; }
187 static bool isDotsPerPixel(UnitType type) { return type == UnitType::DotsPer Pixel; } 185 static bool isDotsPerPixel(UnitType type) { return type == UnitType::DotsPer Pixel; }
188 static bool isDotsPerCentimeter(UnitType type) { return type == UnitType::Do tsPerCentimeter; } 186 static bool isDotsPerCentimeter(UnitType type) { return type == UnitType::Do tsPerCentimeter; }
189 static bool isResolution(UnitType type) { return type >= UnitType::DotsPerPi xel && type <= UnitType::DotsPerCentimeter; } 187 static bool isResolution(UnitType type) { return type >= UnitType::DotsPerPi xel && type <= UnitType::DotsPerCentimeter; }
190 bool isFlex() const { return typeWithCalcResolved() == UnitType::Fraction; } 188 bool isFlex() const { return typeWithCalcResolved() == UnitType::Fraction; }
191 bool isValueID() const { return type() == UnitType::ValueID; } 189 bool isValueID() const { return type() == UnitType::ValueID; }
192 bool colorIsDerivedFromElement() const; 190 bool colorIsDerivedFromElement() const;
193 191
194 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> createIdentifier(CSSValueID valueID) 192 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> createIdentifier(CSSValueID valueID)
195 { 193 {
196 return adoptRefWillBeNoop(new CSSPrimitiveValue(valueID)); 194 return adoptRefWillBeNoop(new CSSPrimitiveValue(valueID));
197 } 195 }
198 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> createIdentifier(CSSPropert yID propertyID)
199 {
200 return adoptRefWillBeNoop(new CSSPrimitiveValue(propertyID));
201 }
202 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> createColor(RGBA32 rgbValue ) 196 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> createColor(RGBA32 rgbValue )
203 { 197 {
204 return adoptRefWillBeNoop(new CSSPrimitiveValue(rgbValue)); 198 return adoptRefWillBeNoop(new CSSPrimitiveValue(rgbValue));
205 } 199 }
206 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> create(double value, UnitTy pe type) 200 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> create(double value, UnitTy pe type)
207 { 201 {
208 return adoptRefWillBeNoop(new CSSPrimitiveValue(value, type)); 202 return adoptRefWillBeNoop(new CSSPrimitiveValue(value, type));
209 } 203 }
210 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> create(const Length& value, float zoom) 204 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> create(const Length& value, float zoom)
211 { 205 {
(...skipping 20 matching lines...) Expand all
232 Length convertToLength(const CSSToLengthConversionData&) const; 226 Length convertToLength(const CSSToLengthConversionData&) const;
233 227
234 double getDoubleValue() const; 228 double getDoubleValue() const;
235 float getFloatValue() const { return getValue<float>(); } 229 float getFloatValue() const { return getValue<float>(); }
236 int getIntValue() const { return getValue<int>(); } 230 int getIntValue() const { return getValue<int>(); }
237 template<typename T> inline T getValue() const { return clampTo<T>(getDouble Value()); } 231 template<typename T> inline T getValue() const { return clampTo<T>(getDouble Value()); }
238 232
239 RGBA32 getRGBA32Value() const { ASSERT(isRGBColor()); return m_value.rgbcolo r; } 233 RGBA32 getRGBA32Value() const { ASSERT(isRGBColor()); return m_value.rgbcolo r; }
240 234
241 CSSCalcValue* cssCalcValue() const { ASSERT(isCalculated()); return m_value. calc; } 235 CSSCalcValue* cssCalcValue() const { ASSERT(isCalculated()); return m_value. calc; }
242 CSSPropertyID getPropertyID() const { ASSERT(isPropertyID()); return m_value .propertyID; }
243 236
244 CSSValueID getValueID() const { return type() == UnitType::ValueID ? m_value .valueID : CSSValueInvalid; } 237 CSSValueID getValueID() const { return type() == UnitType::ValueID ? m_value .valueID : CSSValueInvalid; }
245 238
246 template<typename T> inline operator T() const; // Defined in CSSPrimitiveVa lueMappings.h 239 template<typename T> inline operator T() const; // Defined in CSSPrimitiveVa lueMappings.h
247 240
248 static const char* unitTypeToString(UnitType); 241 static const char* unitTypeToString(UnitType);
249 String customCSSText() const; 242 String customCSSText() const;
250 243
251 bool equals(const CSSPrimitiveValue&) const; 244 bool equals(const CSSPrimitiveValue&) const;
252 245
253 DECLARE_TRACE_AFTER_DISPATCH(); 246 DECLARE_TRACE_AFTER_DISPATCH();
254 247
255 static UnitType canonicalUnitTypeForCategory(UnitCategory); 248 static UnitType canonicalUnitTypeForCategory(UnitCategory);
256 static double conversionToCanonicalUnitsScaleFactor(UnitType); 249 static double conversionToCanonicalUnitsScaleFactor(UnitType);
257 250
258 // Returns true and populates lengthUnitType, if unitType is a length unit. Otherwise, returns false. 251 // Returns true and populates lengthUnitType, if unitType is a length unit. Otherwise, returns false.
259 static bool unitTypeToLengthUnitType(UnitType, LengthUnitType&); 252 static bool unitTypeToLengthUnitType(UnitType, LengthUnitType&);
260 static UnitType lengthUnitTypeToUnitType(LengthUnitType); 253 static UnitType lengthUnitTypeToUnitType(LengthUnitType);
261 254
262 private: 255 private:
263 CSSPrimitiveValue(CSSValueID); 256 CSSPrimitiveValue(CSSValueID);
264 CSSPrimitiveValue(CSSPropertyID);
265 CSSPrimitiveValue(RGBA32 color); 257 CSSPrimitiveValue(RGBA32 color);
266 CSSPrimitiveValue(const Length&, float zoom); 258 CSSPrimitiveValue(const Length&, float zoom);
267 CSSPrimitiveValue(double, UnitType); 259 CSSPrimitiveValue(double, UnitType);
268 260
269 template<typename T> CSSPrimitiveValue(T); // Defined in CSSPrimitiveValueMa ppings.h 261 template<typename T> CSSPrimitiveValue(T); // Defined in CSSPrimitiveValueMa ppings.h
270 template<typename T> CSSPrimitiveValue(T* val) 262 template<typename T> CSSPrimitiveValue(T* val)
271 : CSSValue(PrimitiveClass) 263 : CSSValue(PrimitiveClass)
272 { 264 {
273 init(PassRefPtrWillBeRawPtr<T>(val)); 265 init(PassRefPtrWillBeRawPtr<T>(val));
274 } 266 }
(...skipping 10 matching lines...) Expand all
285 277
286 void init(UnitType); 278 void init(UnitType);
287 void init(const Length&); 279 void init(const Length&);
288 void init(PassRefPtrWillBeRawPtr<CSSCalcValue>); 280 void init(PassRefPtrWillBeRawPtr<CSSCalcValue>);
289 281
290 double computeLengthDouble(const CSSToLengthConversionData&) const; 282 double computeLengthDouble(const CSSToLengthConversionData&) const;
291 283
292 inline UnitType type() const { return static_cast<UnitType>(m_primitiveUnitT ype); } 284 inline UnitType type() const { return static_cast<UnitType>(m_primitiveUnitT ype); }
293 285
294 union { 286 union {
295 CSSPropertyID propertyID;
296 CSSValueID valueID; 287 CSSValueID valueID;
297 double num; 288 double num;
298 RGBA32 rgbcolor; 289 RGBA32 rgbcolor;
299 // FIXME: oilpan: Should be a member, but no support for members in unio ns. Just trace the raw ptr for now. 290 // FIXME: oilpan: Should be a member, but no support for members in unio ns. Just trace the raw ptr for now.
300 CSSCalcValue* calc; 291 CSSCalcValue* calc;
301 } m_value; 292 } m_value;
302 }; 293 };
303 294
304 using CSSLengthArray = CSSPrimitiveValue::CSSLengthArray; 295 using CSSLengthArray = CSSPrimitiveValue::CSSLengthArray;
305 using CSSLengthTypeArray = CSSPrimitiveValue::CSSLengthTypeArray; 296 using CSSLengthTypeArray = CSSPrimitiveValue::CSSLengthTypeArray;
306 297
307 DEFINE_CSS_VALUE_TYPE_CASTS(CSSPrimitiveValue, isPrimitiveValue()); 298 DEFINE_CSS_VALUE_TYPE_CASTS(CSSPrimitiveValue, isPrimitiveValue());
308 299
309 } // namespace blink 300 } // namespace blink
310 301
311 #endif // CSSPrimitiveValue_h 302 #endif // CSSPrimitiveValue_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/CSSCustomIdentValue.cpp ('k') | third_party/WebKit/Source/core/css/CSSPrimitiveValue.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698