| 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/CSSLengthValue.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/ExceptionState.h" | 7 #include "bindings/core/v8/ExceptionState.h" |
| 8 #include "core/css/cssom/CalcDictionary.h" | 8 #include "core/css/cssom/CalcDictionary.h" |
| 9 #include "core/css/cssom/SimpleLength.h" | 9 #include "core/css/cssom/SimpleLength.h" |
| 10 #include "core/css/cssom/StyleCalcLength.h" | 10 #include "core/css/cssom/StyleCalcLength.h" |
| 11 #include "wtf/HashMap.h" | 11 #include "wtf/HashMap.h" |
| 12 | 12 |
| 13 namespace blink { | 13 namespace blink { |
| 14 | 14 |
| 15 CSSPrimitiveValue::UnitType LengthValue::unitFromName(const String& name) | 15 CSSPrimitiveValue::UnitType CSSLengthValue::unitFromName(const String& name) |
| 16 { | 16 { |
| 17 if (equalIgnoringASCIICase(name, "percent") || name == "%") { | 17 if (equalIgnoringASCIICase(name, "percent") || name == "%") { |
| 18 return CSSPrimitiveValue::UnitType::Percentage; | 18 return CSSPrimitiveValue::UnitType::Percentage; |
| 19 } | 19 } |
| 20 return CSSPrimitiveValue::fromName(name); | 20 return CSSPrimitiveValue::fromName(name); |
| 21 } | 21 } |
| 22 | 22 |
| 23 LengthValue* LengthValue::from(const String& cssString, ExceptionState& exceptio
nState) | 23 CSSLengthValue* CSSLengthValue::from(const String& cssString, ExceptionState& ex
ceptionState) |
| 24 { | 24 { |
| 25 // TODO: Implement | 25 // TODO: Implement |
| 26 return nullptr; | 26 return nullptr; |
| 27 } | 27 } |
| 28 | 28 |
| 29 LengthValue* LengthValue::from(double value, const String& type, ExceptionState&
) | 29 CSSLengthValue* CSSLengthValue::from(double value, const String& type, Exception
State&) |
| 30 { | 30 { |
| 31 return SimpleLength::create(value, unitFromName(type)); | 31 return SimpleLength::create(value, unitFromName(type)); |
| 32 } | 32 } |
| 33 | 33 |
| 34 LengthValue* LengthValue::from(const CalcDictionary& dictionary, ExceptionState&
exceptionState) | 34 CSSLengthValue* CSSLengthValue::from(const CalcDictionary& dictionary, Exception
State& exceptionState) |
| 35 { | 35 { |
| 36 return StyleCalcLength::create(dictionary, exceptionState); | 36 return StyleCalcLength::create(dictionary, exceptionState); |
| 37 } | 37 } |
| 38 | 38 |
| 39 LengthValue* LengthValue::add(const LengthValue* other, ExceptionState& exceptio
nState) | 39 CSSLengthValue* CSSLengthValue::add(const CSSLengthValue* other, ExceptionState&
exceptionState) |
| 40 { | 40 { |
| 41 if (type() == other->type() || type() == CalcLengthType) | 41 if (type() == other->type() || type() == CalcLengthType) |
| 42 return addInternal(other, exceptionState); | 42 return addInternal(other, exceptionState); |
| 43 | 43 |
| 44 StyleCalcLength* result = StyleCalcLength::create(this, exceptionState); | 44 StyleCalcLength* result = StyleCalcLength::create(this, exceptionState); |
| 45 return result->add(other, exceptionState); | 45 return result->add(other, exceptionState); |
| 46 } | 46 } |
| 47 | 47 |
| 48 LengthValue* LengthValue::subtract(const LengthValue* other, ExceptionState& exc
eptionState) | 48 CSSLengthValue* CSSLengthValue::subtract(const CSSLengthValue* other, ExceptionS
tate& exceptionState) |
| 49 { | 49 { |
| 50 if (type() == other->type() || type() == CalcLengthType) | 50 if (type() == other->type() || type() == CalcLengthType) |
| 51 return subtractInternal(other, exceptionState); | 51 return subtractInternal(other, exceptionState); |
| 52 | 52 |
| 53 StyleCalcLength* result = StyleCalcLength::create(this, exceptionState); | 53 StyleCalcLength* result = StyleCalcLength::create(this, exceptionState); |
| 54 return result->subtract(other, exceptionState); | 54 return result->subtract(other, exceptionState); |
| 55 } | 55 } |
| 56 | 56 |
| 57 LengthValue* LengthValue::multiply(double x, ExceptionState& exceptionState) | 57 CSSLengthValue* CSSLengthValue::multiply(double x, ExceptionState& exceptionStat
e) |
| 58 { | 58 { |
| 59 return multiplyInternal(x, exceptionState); | 59 return multiplyInternal(x, exceptionState); |
| 60 } | 60 } |
| 61 | 61 |
| 62 LengthValue* LengthValue::divide(double x, ExceptionState& exceptionState) | 62 CSSLengthValue* CSSLengthValue::divide(double x, ExceptionState& exceptionState) |
| 63 { | 63 { |
| 64 return divideInternal(x, exceptionState); | 64 return divideInternal(x, exceptionState); |
| 65 } | 65 } |
| 66 | 66 |
| 67 LengthValue* LengthValue::addInternal(const LengthValue*, ExceptionState&) | 67 CSSLengthValue* CSSLengthValue::addInternal(const CSSLengthValue*, ExceptionStat
e&) |
| 68 { | 68 { |
| 69 ASSERT_NOT_REACHED(); | 69 NOTREACHED(); |
| 70 return nullptr; | 70 return nullptr; |
| 71 } | 71 } |
| 72 | 72 |
| 73 LengthValue* LengthValue::subtractInternal(const LengthValue*, ExceptionState&) | 73 CSSLengthValue* CSSLengthValue::subtractInternal(const CSSLengthValue*, Exceptio
nState&) |
| 74 { | 74 { |
| 75 ASSERT_NOT_REACHED(); | 75 NOTREACHED(); |
| 76 return nullptr; | 76 return nullptr; |
| 77 } | 77 } |
| 78 | 78 |
| 79 LengthValue* LengthValue::multiplyInternal(double, ExceptionState&) | 79 CSSLengthValue* CSSLengthValue::multiplyInternal(double, ExceptionState&) |
| 80 { | 80 { |
| 81 ASSERT_NOT_REACHED(); | 81 NOTREACHED(); |
| 82 return nullptr; | 82 return nullptr; |
| 83 } | 83 } |
| 84 | 84 |
| 85 LengthValue* LengthValue::divideInternal(double, ExceptionState&) | 85 CSSLengthValue* CSSLengthValue::divideInternal(double, ExceptionState&) |
| 86 { | 86 { |
| 87 ASSERT_NOT_REACHED(); | 87 NOTREACHED(); |
| 88 return nullptr; | 88 return nullptr; |
| 89 } | 89 } |
| 90 | 90 |
| 91 } // namespace blink | 91 } // namespace blink |
| OLD | NEW |