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

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

Issue 717933002: Clean up after getPropertyCSSValue (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase / fix debug compile? Created 6 years, 1 month 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
« no previous file with comments | « Source/core/css/CSSImageValue.cpp ('k') | Source/core/css/CSSPrimitiveValue.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 18 matching lines...) Expand all
29 #include "wtf/Forward.h" 29 #include "wtf/Forward.h"
30 #include "wtf/MathExtras.h" 30 #include "wtf/MathExtras.h"
31 #include "wtf/PassRefPtr.h" 31 #include "wtf/PassRefPtr.h"
32 32
33 namespace blink { 33 namespace blink {
34 34
35 class CSSBasicShape; 35 class CSSBasicShape;
36 class CSSCalcValue; 36 class CSSCalcValue;
37 class CSSToLengthConversionData; 37 class CSSToLengthConversionData;
38 class Counter; 38 class Counter;
39 class ExceptionState;
40 class Length; 39 class Length;
41 class LengthSize; 40 class LengthSize;
42 class Pair; 41 class Pair;
43 class Quad; 42 class Quad;
44 class RGBColor; 43 class RGBColor;
45 class Rect; 44 class Rect;
46 class RenderStyle; 45 class RenderStyle;
47 46
48 // Dimension calculations are imprecise, often resulting in values of e.g. 47 // Dimension calculations are imprecise, often resulting in values of e.g.
49 // 44.99998. We need to go ahead and round if we're really close to the next 48 // 44.99998. We need to go ahead and round if we're really close to the next
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 * For screen output we assume 1 inch == 72 px, for printer we assume 300 dp i 272 * For screen output we assume 1 inch == 72 px, for printer we assume 300 dp i
274 * 273 *
275 * this is screen/printer dependent, so we probably need a config option for this, 274 * this is screen/printer dependent, so we probably need a config option for this,
276 * and some tool to calibrate. 275 * and some tool to calibrate.
277 */ 276 */
278 template<typename T> T computeLength(const CSSToLengthConversionData&); 277 template<typename T> T computeLength(const CSSToLengthConversionData&);
279 278
280 // Converts to a Length, mapping various unit types appropriately. 279 // Converts to a Length, mapping various unit types appropriately.
281 template<int> Length convertToLength(const CSSToLengthConversionData&); 280 template<int> Length convertToLength(const CSSToLengthConversionData&);
282 281
283 double getDoubleValue(UnitType, ExceptionState&) const;
284 double getDoubleValue(UnitType) const; 282 double getDoubleValue(UnitType) const;
285 double getDoubleValue() const; 283 double getDoubleValue() const;
286 284
287 // setFloatValue(..., ExceptionState&) and setStringValue() must use unsigne d short instead of UnitType to match IDL bindings.
288 void setFloatValue(unsigned short unitType, double floatValue, ExceptionStat e&);
289 float getFloatValue(unsigned short unitType, ExceptionState& exceptionState) const { return getValue<float>(static_cast<UnitType>(unitType), exceptionState) ; }
290 float getFloatValue(UnitType type) const { return getValue<float>(type); } 285 float getFloatValue(UnitType type) const { return getValue<float>(type); }
291 float getFloatValue() const { return getValue<float>(); } 286 float getFloatValue() const { return getValue<float>(); }
292 287
293 int getIntValue(UnitType type, ExceptionState& exceptionState) const { retur n getValue<int>(type, exceptionState); }
294 int getIntValue(UnitType type) const { return getValue<int>(type); } 288 int getIntValue(UnitType type) const { return getValue<int>(type); }
295 int getIntValue() const { return getValue<int>(); } 289 int getIntValue() const { return getValue<int>(); }
296 290
297 template<typename T> inline T getValue(UnitType type, ExceptionState& except ionState) const { return clampTo<T>(getDoubleValue(type, exceptionState)); }
298 template<typename T> inline T getValue(UnitType type) const { return clampTo <T>(getDoubleValue(type)); } 291 template<typename T> inline T getValue(UnitType type) const { return clampTo <T>(getDoubleValue(type)); }
299 template<typename T> inline T getValue() const { return clampTo<T>(getDouble Value()); } 292 template<typename T> inline T getValue() const { return clampTo<T>(getDouble Value()); }
300 293
301 void setStringValue(unsigned short stringType, const String& stringValue, Ex ceptionState&);
302 String getStringValue(ExceptionState&) const;
303 String getStringValue() const; 294 String getStringValue() const;
304 295
305 Counter* getCounterValue(ExceptionState&) const;
306 Counter* getCounterValue() const { return m_primitiveUnitType != CSS_COUNTER ? 0 : m_value.counter; } 296 Counter* getCounterValue() const { return m_primitiveUnitType != CSS_COUNTER ? 0 : m_value.counter; }
307 297
308 Rect* getRectValue(ExceptionState&) const;
309 Rect* getRectValue() const { return m_primitiveUnitType != CSS_RECT ? 0 : m_ value.rect; } 298 Rect* getRectValue() const { return m_primitiveUnitType != CSS_RECT ? 0 : m_ value.rect; }
310 299
311 Quad* getQuadValue(ExceptionState&) const;
312 Quad* getQuadValue() const { return m_primitiveUnitType != CSS_QUAD ? 0 : m_ value.quad; } 300 Quad* getQuadValue() const { return m_primitiveUnitType != CSS_QUAD ? 0 : m_ value.quad; }
313 301
314 PassRefPtrWillBeRawPtr<RGBColor> getRGBColorValue(ExceptionState&) const;
315 RGBA32 getRGBA32Value() const { return m_primitiveUnitType != CSS_RGBCOLOR ? 0 : m_value.rgbcolor; } 302 RGBA32 getRGBA32Value() const { return m_primitiveUnitType != CSS_RGBCOLOR ? 0 : m_value.rgbcolor; }
316 303
317 Pair* getPairValue(ExceptionState&) const;
318 Pair* getPairValue() const { return m_primitiveUnitType != CSS_PAIR ? 0 : m_ value.pair; } 304 Pair* getPairValue() const { return m_primitiveUnitType != CSS_PAIR ? 0 : m_ value.pair; }
319 305
320 CSSBasicShape* getShapeValue() const { return m_primitiveUnitType != CSS_SHA PE ? 0 : m_value.shape; } 306 CSSBasicShape* getShapeValue() const { return m_primitiveUnitType != CSS_SHA PE ? 0 : m_value.shape; }
321 307
322 CSSCalcValue* cssCalcValue() const { return m_primitiveUnitType != CSS_CALC ? 0 : m_value.calc; } 308 CSSCalcValue* cssCalcValue() const { return m_primitiveUnitType != CSS_CALC ? 0 : m_value.calc; }
323 309
324 CSSPropertyID getPropertyID() const { return m_primitiveUnitType == CSS_PROP ERTY_ID ? m_value.propertyID : CSSPropertyInvalid; } 310 CSSPropertyID getPropertyID() const { return m_primitiveUnitType == CSS_PROP ERTY_ID ? m_value.propertyID : CSSPropertyInvalid; }
325 CSSValueID getValueID() const { return m_primitiveUnitType == CSS_VALUE_ID ? m_value.valueID : CSSValueInvalid; } 311 CSSValueID getValueID() const { return m_primitiveUnitType == CSS_VALUE_ID ? m_value.valueID : CSSValueInvalid; }
326 312
327 template<typename T> inline operator T() const; // Defined in CSSPrimitiveVa lueMappings.h 313 template<typename T> inline operator T() const; // Defined in CSSPrimitiveVa lueMappings.h
328 314
329 static const char* unitTypeToString(UnitType); 315 static const char* unitTypeToString(UnitType);
330 String customCSSText(CSSTextFormattingFlags = QuoteCSSStringIfNeeded) const; 316 String customCSSText(CSSTextFormattingFlags = QuoteCSSStringIfNeeded) const;
331 317
332 bool isQuirkValue() { return m_isQuirkValue; } 318 bool isQuirkValue() { return m_isQuirkValue; }
333 319
334 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> cloneForCSSOM() const;
335 void setCSSOMSafe() { m_isCSSOMSafe = true; }
336
337 bool equals(const CSSPrimitiveValue&) const; 320 bool equals(const CSSPrimitiveValue&) const;
338 321
339 void traceAfterDispatch(Visitor*); 322 void traceAfterDispatch(Visitor*);
340 323
341 static UnitType canonicalUnitTypeForCategory(UnitCategory); 324 static UnitType canonicalUnitTypeForCategory(UnitCategory);
342 static double conversionToCanonicalUnitsScaleFactor(UnitType); 325 static double conversionToCanonicalUnitsScaleFactor(UnitType);
343 326
344 // Returns true and populates lengthUnitType, if unitType is a length unit. Otherwise, returns false. 327 // Returns true and populates lengthUnitType, if unitType is a length unit. Otherwise, returns false.
345 static bool unitTypeToLengthUnitType(UnitType, LengthUnitType&); 328 static bool unitTypeToLengthUnitType(UnitType, LengthUnitType&);
346 static UnitType lengthUnitTypeToUnitType(LengthUnitType); 329 static UnitType lengthUnitTypeToUnitType(LengthUnitType);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 } m_value; 385 } m_value;
403 }; 386 };
404 387
405 typedef CSSPrimitiveValue::CSSLengthArray CSSLengthArray; 388 typedef CSSPrimitiveValue::CSSLengthArray CSSLengthArray;
406 389
407 DEFINE_CSS_VALUE_TYPE_CASTS(CSSPrimitiveValue, isPrimitiveValue()); 390 DEFINE_CSS_VALUE_TYPE_CASTS(CSSPrimitiveValue, isPrimitiveValue());
408 391
409 } // namespace blink 392 } // namespace blink
410 393
411 #endif // CSSPrimitiveValue_h 394 #endif // CSSPrimitiveValue_h
OLDNEW
« no previous file with comments | « Source/core/css/CSSImageValue.cpp ('k') | Source/core/css/CSSPrimitiveValue.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698