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, 2007, 2008, 2012 Apple Inc. All rights | 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2012 Apple Inc. All rights |
4 * reserved. | 4 * reserved. |
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 19 matching lines...) Expand all Loading... |
30 #include "wtf/SizeAssertions.h" | 30 #include "wtf/SizeAssertions.h" |
31 #include "wtf/StdLibExtras.h" | 31 #include "wtf/StdLibExtras.h" |
32 | 32 |
33 namespace blink { | 33 namespace blink { |
34 | 34 |
35 namespace { | 35 namespace { |
36 | 36 |
37 // Max/min values for CSS, needs to slightly smaller/larger than the true | 37 // Max/min values for CSS, needs to slightly smaller/larger than the true |
38 // max/min values to allow for rounding without overflowing. | 38 // max/min values to allow for rounding without overflowing. |
39 // Subtract two (rather than one) to allow for values to be converted to float | 39 // Subtract two (rather than one) to allow for values to be converted to float |
40 // and back without exceeding the LayoutUnit::max. | 40 // and back without exceeding the LayoutUnit::Max. |
41 const int kMaxValueForCssLength = INT_MAX / kFixedPointDenominator - 2; | 41 const int kMaxValueForCssLength = INT_MAX / kFixedPointDenominator - 2; |
42 const int kMinValueForCssLength = INT_MIN / kFixedPointDenominator + 2; | 42 const int kMinValueForCssLength = INT_MIN / kFixedPointDenominator + 2; |
43 | 43 |
44 } // namespace | 44 } // namespace |
45 | 45 |
46 struct SameSizeAsCSSPrimitiveValue : CSSValue { | 46 struct SameSizeAsCSSPrimitiveValue : CSSValue { |
47 double num; | 47 double num; |
48 }; | 48 }; |
49 ASSERT_SIZE(CSSPrimitiveValue, SameSizeAsCSSPrimitiveValue); | 49 ASSERT_SIZE(CSSPrimitiveValue, SameSizeAsCSSPrimitiveValue); |
50 | 50 |
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 return Length(CssCalcValue()->ToCalcValue(conversion_data)); | 407 return Length(CssCalcValue()->ToCalcValue(conversion_data)); |
408 } | 408 } |
409 | 409 |
410 double CSSPrimitiveValue::GetDoubleValue() const { | 410 double CSSPrimitiveValue::GetDoubleValue() const { |
411 return GetType() != UnitType::kCalc ? value_.num : value_.calc->DoubleValue(); | 411 return GetType() != UnitType::kCalc ? value_.num : value_.calc->DoubleValue(); |
412 } | 412 } |
413 | 413 |
414 CSSPrimitiveValue::UnitType CSSPrimitiveValue::CanonicalUnitTypeForCategory( | 414 CSSPrimitiveValue::UnitType CSSPrimitiveValue::CanonicalUnitTypeForCategory( |
415 UnitCategory category) { | 415 UnitCategory category) { |
416 // The canonical unit type is chosen according to the way | 416 // The canonical unit type is chosen according to the way |
417 // CSSPropertyParser::validUnit() chooses the default unit in each category | 417 // CSSPropertyParser::ValidUnit() chooses the default unit in each category |
418 // (based on unitflags). | 418 // (based on unitflags). |
419 switch (category) { | 419 switch (category) { |
420 case kUNumber: | 420 case kUNumber: |
421 return UnitType::kNumber; | 421 return UnitType::kNumber; |
422 case kULength: | 422 case kULength: |
423 return UnitType::kPixels; | 423 return UnitType::kPixels; |
424 case kUPercent: | 424 case kUPercent: |
425 return UnitType::kUnknown; // Cannot convert between numbers and percent. | 425 return UnitType::kUnknown; // Cannot convert between numbers and percent. |
426 case kUTime: | 426 case kUTime: |
427 return UnitType::kMilliseconds; | 427 return UnitType::kMilliseconds; |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
715 case UnitType::kCalc: | 715 case UnitType::kCalc: |
716 visitor->Trace(value_.calc); | 716 visitor->Trace(value_.calc); |
717 break; | 717 break; |
718 default: | 718 default: |
719 break; | 719 break; |
720 } | 720 } |
721 CSSValue::TraceAfterDispatch(visitor); | 721 CSSValue::TraceAfterDispatch(visitor); |
722 } | 722 } |
723 | 723 |
724 } // namespace blink | 724 } // namespace blink |
OLD | NEW |