| 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 reserv
ed. | 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2012 Apple Inc. All rights reserv
ed. |
| 4 * | 4 * |
| 5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
| 6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
| 7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
| 8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
| 9 * | 9 * |
| 10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
| 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 * Library General Public License for more details. | 13 * Library General Public License for more details. |
| 14 * | 14 * |
| 15 * You should have received a copy of the GNU Library General Public License | 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 | 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, | 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 18 * Boston, MA 02110-1301, USA. | 18 * Boston, MA 02110-1301, USA. |
| 19 */ | 19 */ |
| 20 | 20 |
| 21 #include "core/css/CSSPrimitiveValue.h" | 21 #include "core/css/CSSPrimitiveValue.h" |
| 22 | 22 |
| 23 #include "core/css/CSSCalculationValue.h" | 23 #include "core/css/CSSCalculationValue.h" |
| 24 #include "core/css/CSSHelper.h" | 24 #include "core/css/CSSHelper.h" |
| 25 #include "core/css/CSSMarkup.h" | 25 #include "core/css/CSSMarkup.h" |
| 26 #include "core/css/CSSToLengthConversionData.h" | 26 #include "core/css/CSSToLengthConversionData.h" |
| 27 #include "core/css/CSSValuePool.h" | 27 #include "core/css/CSSValuePool.h" |
| 28 #include "platform/LayoutUnit.h" | 28 #include "platform/LayoutUnit.h" |
| 29 #include "wtf/SizeAssertions.h" |
| 29 #include "wtf/StdLibExtras.h" | 30 #include "wtf/StdLibExtras.h" |
| 30 | 31 |
| 31 using namespace WTF; | 32 using namespace WTF; |
| 32 | 33 |
| 33 namespace blink { | 34 namespace blink { |
| 34 | 35 |
| 35 namespace { | 36 namespace { |
| 36 | 37 |
| 37 // Max/min values for CSS, needs to slightly smaller/larger than the true max/mi
n values to allow for rounding without overflowing. | 38 // Max/min values for CSS, needs to slightly smaller/larger than the true max/mi
n values to allow for rounding without overflowing. |
| 38 // Subtract two (rather than one) to allow for values to be converted to float a
nd back without exceeding the LayoutUnit::max. | 39 // Subtract two (rather than one) to allow for values to be converted to float a
nd back without exceeding the LayoutUnit::max. |
| 39 const int maxValueForCssLength = INT_MAX / kFixedPointDenominator - 2; | 40 const int maxValueForCssLength = INT_MAX / kFixedPointDenominator - 2; |
| 40 const int minValueForCssLength = INT_MIN / kFixedPointDenominator + 2; | 41 const int minValueForCssLength = INT_MIN / kFixedPointDenominator + 2; |
| 41 | 42 |
| 42 } // namespace | 43 } // namespace |
| 43 | 44 |
| 45 struct SameSizeAsCSSPrimitiveValue : CSSValue { |
| 46 double num; |
| 47 }; |
| 48 ASSERT_SIZE(CSSPrimitiveValue, SameSizeAsCSSPrimitiveValue); |
| 49 |
| 44 float CSSPrimitiveValue::clampToCSSLengthRange(double value) | 50 float CSSPrimitiveValue::clampToCSSLengthRange(double value) |
| 45 { | 51 { |
| 46 return clampTo<float>(value, minValueForCssLength, maxValueForCssLength); | 52 return clampTo<float>(value, minValueForCssLength, maxValueForCssLength); |
| 47 } | 53 } |
| 48 | 54 |
| 49 CSSPrimitiveValue::UnitCategory CSSPrimitiveValue::unitTypeToUnitCategory(UnitTy
pe type) | 55 CSSPrimitiveValue::UnitCategory CSSPrimitiveValue::unitTypeToUnitCategory(UnitTy
pe type) |
| 50 { | 56 { |
| 51 switch (type) { | 57 switch (type) { |
| 52 case UnitType::Number: | 58 case UnitType::Number: |
| 53 return CSSPrimitiveValue::UNumber; | 59 return CSSPrimitiveValue::UNumber; |
| (...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 761 case UnitType::Calc: | 767 case UnitType::Calc: |
| 762 visitor->trace(m_value.calc); | 768 visitor->trace(m_value.calc); |
| 763 break; | 769 break; |
| 764 default: | 770 default: |
| 765 break; | 771 break; |
| 766 } | 772 } |
| 767 CSSValue::traceAfterDispatch(visitor); | 773 CSSValue::traceAfterDispatch(visitor); |
| 768 } | 774 } |
| 769 | 775 |
| 770 } // namespace blink | 776 } // namespace blink |
| OLD | NEW |