OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "core/css/cssom/LengthValue.h" | 5 #include "core/css/cssom/LengthValue.h" |
6 | 6 |
7 #include "bindings/core/v8/ExceptionState.h" | 7 #include "bindings/core/v8/ExceptionState.h" |
8 #include "core/css/CSSPrimitiveValue.h" | |
9 #include "core/css/CSSToLengthConversionData.h" | |
8 #include "core/css/cssom/CalcDictionary.h" | 10 #include "core/css/cssom/CalcDictionary.h" |
9 #include "core/css/cssom/SimpleLength.h" | 11 #include "core/css/cssom/SimpleLength.h" |
10 #include "core/css/cssom/StyleCalcLength.h" | 12 #include "core/css/cssom/StyleCalcLength.h" |
13 #include "core/style/ComputedStyle.h" | |
11 #include "wtf/HashMap.h" | 14 #include "wtf/HashMap.h" |
12 | 15 |
13 namespace blink { | 16 namespace blink { |
14 | 17 |
15 CSSPrimitiveValue::UnitType LengthValue::unitFromName(const String& name) | 18 CSSPrimitiveValue::UnitType LengthValue::unitFromName(const String& name) |
16 { | 19 { |
17 if (equalIgnoringASCIICase(name, "percent") || name == "%") { | 20 if (equalIgnoringASCIICase(name, "percent") || name == "%") { |
18 return CSSPrimitiveValue::UnitType::Percentage; | 21 return CSSPrimitiveValue::UnitType::Percentage; |
19 } | 22 } |
20 return CSSPrimitiveValue::fromName(name); | 23 return CSSPrimitiveValue::fromName(name); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
57 LengthValue* LengthValue::multiply(double x, ExceptionState& exceptionState) | 60 LengthValue* LengthValue::multiply(double x, ExceptionState& exceptionState) |
58 { | 61 { |
59 return multiplyInternal(x, exceptionState); | 62 return multiplyInternal(x, exceptionState); |
60 } | 63 } |
61 | 64 |
62 LengthValue* LengthValue::divide(double x, ExceptionState& exceptionState) | 65 LengthValue* LengthValue::divide(double x, ExceptionState& exceptionState) |
63 { | 66 { |
64 return divideInternal(x, exceptionState); | 67 return divideInternal(x, exceptionState); |
65 } | 68 } |
66 | 69 |
70 double LengthValue::computeLengthPx(ExceptionState& exceptionState) const | |
71 { | |
72 if (isRelative()) { | |
73 exceptionState.throwTypeError("Cannot resolve a relative unit to a pixel value."); | |
meade_UTC10
2016/02/11 00:56:30
Add a TODO to implement this?
tridgell
2016/02/12 04:22:27
Done.
| |
74 return 0; | |
75 } | |
76 | |
77 CSSValue* cssValue = toCSSValue(); | |
78 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(cssValue); | |
79 ComputedStyle* computedStyle = const_cast<ComputedStyle*>(ComputedStyle::cre ate().get()); | |
80 CSSToLengthConversionData conversionData = CSSToLengthConversionData(compute dStyle, | |
81 CSSToLengthConversionData::FontSizes(), CSSToLengthConversionData::Viewp ortSize(), 1); | |
82 | |
83 return primitiveValue->CSSPrimitiveValue::computeLength<double>(conversionDa ta); | |
84 } | |
85 | |
67 LengthValue* LengthValue::addInternal(const LengthValue*, ExceptionState&) | 86 LengthValue* LengthValue::addInternal(const LengthValue*, ExceptionState&) |
68 { | 87 { |
69 ASSERT_NOT_REACHED(); | 88 ASSERT_NOT_REACHED(); |
70 return nullptr; | 89 return nullptr; |
71 } | 90 } |
72 | 91 |
73 LengthValue* LengthValue::subtractInternal(const LengthValue*, ExceptionState&) | 92 LengthValue* LengthValue::subtractInternal(const LengthValue*, ExceptionState&) |
74 { | 93 { |
75 ASSERT_NOT_REACHED(); | 94 ASSERT_NOT_REACHED(); |
76 return nullptr; | 95 return nullptr; |
77 } | 96 } |
78 | 97 |
79 LengthValue* LengthValue::multiplyInternal(double, ExceptionState&) | 98 LengthValue* LengthValue::multiplyInternal(double, ExceptionState&) |
80 { | 99 { |
81 ASSERT_NOT_REACHED(); | 100 ASSERT_NOT_REACHED(); |
82 return nullptr; | 101 return nullptr; |
83 } | 102 } |
84 | 103 |
85 LengthValue* LengthValue::divideInternal(double, ExceptionState&) | 104 LengthValue* LengthValue::divideInternal(double, ExceptionState&) |
86 { | 105 { |
87 ASSERT_NOT_REACHED(); | 106 ASSERT_NOT_REACHED(); |
88 return nullptr; | 107 return nullptr; |
89 } | 108 } |
90 | 109 |
91 } // namespace blink | 110 } // namespace blink |
OLD | NEW |