OLD | NEW |
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 16 matching lines...) Expand all Loading... |
27 #include "core/css/CSSValue.h" | 27 #include "core/css/CSSValue.h" |
28 #include "platform/graphics/Color.h" | 28 #include "platform/graphics/Color.h" |
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 WebCore { | 33 namespace WebCore { |
34 | 34 |
35 class CSSBasicShape; | 35 class CSSBasicShape; |
36 class CSSCalcValue; | 36 class CSSCalcValue; |
| 37 class CSSToLengthConversionData; |
37 class Counter; | 38 class Counter; |
38 class ExceptionState; | 39 class ExceptionState; |
39 class Length; | 40 class Length; |
40 class Pair; | 41 class Pair; |
41 class Quad; | 42 class Quad; |
42 class RGBColor; | 43 class RGBColor; |
43 class Rect; | 44 class Rect; |
44 class RenderStyle; | 45 class RenderStyle; |
45 | 46 |
46 // Dimension calculations are imprecise, often resulting in values of e.g. | 47 // Dimension calculations are imprecise, often resulting in values of e.g. |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 return getValue<T>() / 1000; | 239 return getValue<T>() / 1000; |
239 if (timeUnit == Milliseconds && m_primitiveUnitType == CSS_MS) | 240 if (timeUnit == Milliseconds && m_primitiveUnitType == CSS_MS) |
240 return getValue<T>(); | 241 return getValue<T>(); |
241 if (timeUnit == Milliseconds && m_primitiveUnitType == CSS_S) | 242 if (timeUnit == Milliseconds && m_primitiveUnitType == CSS_S) |
242 return getValue<T>() * 1000; | 243 return getValue<T>() * 1000; |
243 ASSERT_NOT_REACHED(); | 244 ASSERT_NOT_REACHED(); |
244 return 0; | 245 return 0; |
245 } | 246 } |
246 | 247 |
247 /* | 248 /* |
248 * computes a length in pixels out of the given CSSValue. Need the RenderSty
le to get | 249 * Computes a length in pixels out of the given CSSValue |
249 * the fontinfo in case val is defined in em or ex. | |
250 * | 250 * |
251 * The metrics have to be a bit different for screen and printer output. | 251 * The metrics have to be a bit different for screen and printer output. |
252 * For screen output we assume 1 inch == 72 px, for printer we assume 300 dp
i | 252 * For screen output we assume 1 inch == 72 px, for printer we assume 300 dp
i |
253 * | 253 * |
254 * this is screen/printer dependent, so we probably need a config option for
this, | 254 * this is screen/printer dependent, so we probably need a config option for
this, |
255 * and some tool to calibrate. | 255 * and some tool to calibrate. |
256 */ | 256 */ |
257 template<typename T> T computeLength(const RenderStyle* currStyle, const Ren
derStyle* rootStyle, float multiplier = 1.0f, bool computingFontSize = false); | 257 template<typename T> T computeLength(const CSSToLengthConversionData&); |
258 | 258 |
259 // Converts to a Length, mapping various unit types appropriately. | 259 // Converts to a Length, mapping various unit types appropriately. |
260 template<int> Length convertToLength(const RenderStyle* currStyle, const Ren
derStyle* rootStyle, double multiplier = 1.0, bool computingFontSize = false); | 260 template<int> Length convertToLength(const CSSToLengthConversionData&); |
261 | 261 |
262 // use with care!!! | 262 // use with care!!! |
263 void setPrimitiveType(unsigned short type) { m_primitiveUnitType = type; } | 263 void setPrimitiveType(unsigned short type) { m_primitiveUnitType = type; } |
264 | 264 |
265 double getDoubleValue(unsigned short unitType, ExceptionState&) const; | 265 double getDoubleValue(unsigned short unitType, ExceptionState&) const; |
266 double getDoubleValue(unsigned short unitType) const; | 266 double getDoubleValue(unsigned short unitType) const; |
267 double getDoubleValue() const; | 267 double getDoubleValue() const; |
268 | 268 |
269 void setFloatValue(unsigned short unitType, double floatValue, ExceptionStat
e&); | 269 void setFloatValue(unsigned short unitType, double floatValue, ExceptionStat
e&); |
270 float getFloatValue(unsigned short unitType, ExceptionState& exceptionState)
const { return getValue<float>(unitType, exceptionState); } | 270 float getFloatValue(unsigned short unitType, ExceptionState& exceptionState)
const { return getValue<float>(unitType, exceptionState); } |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 | 359 |
360 void init(const Length&); | 360 void init(const Length&); |
361 void init(PassRefPtr<Counter>); | 361 void init(PassRefPtr<Counter>); |
362 void init(PassRefPtr<Rect>); | 362 void init(PassRefPtr<Rect>); |
363 void init(PassRefPtr<Pair>); | 363 void init(PassRefPtr<Pair>); |
364 void init(PassRefPtr<Quad>); | 364 void init(PassRefPtr<Quad>); |
365 void init(PassRefPtr<CSSBasicShape>); | 365 void init(PassRefPtr<CSSBasicShape>); |
366 void init(PassRefPtr<CSSCalcValue>); | 366 void init(PassRefPtr<CSSCalcValue>); |
367 bool getDoubleValueInternal(UnitTypes targetUnitType, double* result) const; | 367 bool getDoubleValueInternal(UnitTypes targetUnitType, double* result) const; |
368 | 368 |
369 double computeLengthDouble(const RenderStyle* currentStyle, const RenderStyl
e* rootStyle, float multiplier, bool computingFontSize); | 369 double computeLengthDouble(const CSSToLengthConversionData&); |
370 | 370 |
371 union { | 371 union { |
372 CSSPropertyID propertyID; | 372 CSSPropertyID propertyID; |
373 CSSValueID valueID; | 373 CSSValueID valueID; |
374 int parserOperator; | 374 int parserOperator; |
375 double num; | 375 double num; |
376 StringImpl* string; | 376 StringImpl* string; |
377 Counter* counter; | 377 Counter* counter; |
378 Rect* rect; | 378 Rect* rect; |
379 Quad* quad; | 379 Quad* quad; |
380 unsigned rgbcolor; | 380 unsigned rgbcolor; |
381 Pair* pair; | 381 Pair* pair; |
382 CSSBasicShape* shape; | 382 CSSBasicShape* shape; |
383 CSSCalcValue* calc; | 383 CSSCalcValue* calc; |
384 } m_value; | 384 } m_value; |
385 }; | 385 }; |
386 | 386 |
387 DEFINE_CSS_VALUE_TYPE_CASTS(CSSPrimitiveValue, isPrimitiveValue()); | 387 DEFINE_CSS_VALUE_TYPE_CASTS(CSSPrimitiveValue, isPrimitiveValue()); |
388 | 388 |
389 } // namespace WebCore | 389 } // namespace WebCore |
390 | 390 |
391 #endif // CSSPrimitiveValue_h | 391 #endif // CSSPrimitiveValue_h |
OLD | NEW |