| 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/CSSLengthValue.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/CSSPrimitiveValueUnitTrie.h" | 8 #include "core/css/CSSPrimitiveValueUnitTrie.h" |
| 9 #include "core/css/cssom/CSSCalcLength.h" |
| 9 #include "core/css/cssom/CSSSimpleLength.h" | 10 #include "core/css/cssom/CSSSimpleLength.h" |
| 10 #include "core/css/cssom/CalcDictionary.h" | 11 #include "core/css/cssom/CalcDictionary.h" |
| 11 #include "core/css/cssom/StyleCalcLength.h" | |
| 12 #include "wtf/HashMap.h" | 12 #include "wtf/HashMap.h" |
| 13 | 13 |
| 14 namespace blink { | 14 namespace blink { |
| 15 | 15 |
| 16 CSSPrimitiveValue::UnitType CSSLengthValue::unitFromName(const String& name) | 16 CSSPrimitiveValue::UnitType CSSLengthValue::unitFromName(const String& name) |
| 17 { | 17 { |
| 18 if (equalIgnoringASCIICase(name, "percent") || name == "%") { | 18 if (equalIgnoringASCIICase(name, "percent") || name == "%") { |
| 19 return CSSPrimitiveValue::UnitType::Percentage; | 19 return CSSPrimitiveValue::UnitType::Percentage; |
| 20 } | 20 } |
| 21 if (name.is8Bit()) | 21 if (name.is8Bit()) |
| 22 return lookupCSSPrimitiveValueUnit(name.characters8(), name.length()); | 22 return lookupCSSPrimitiveValueUnit(name.characters8(), name.length()); |
| 23 return lookupCSSPrimitiveValueUnit(name.characters16(), name.length()); | 23 return lookupCSSPrimitiveValueUnit(name.characters16(), name.length()); |
| 24 } | 24 } |
| 25 | 25 |
| 26 CSSLengthValue* CSSLengthValue::from(const String& cssString, ExceptionState& ex
ceptionState) | 26 CSSLengthValue* CSSLengthValue::from(const String& cssString, ExceptionState& ex
ceptionState) |
| 27 { | 27 { |
| 28 // TODO: Implement | 28 // TODO: Implement |
| 29 return nullptr; | 29 return nullptr; |
| 30 } | 30 } |
| 31 | 31 |
| 32 CSSLengthValue* CSSLengthValue::from(double value, const String& type, Exception
State&) | 32 CSSLengthValue* CSSLengthValue::from(double value, const String& type, Exception
State&) |
| 33 { | 33 { |
| 34 return CSSSimpleLength::create(value, unitFromName(type)); | 34 return CSSSimpleLength::create(value, unitFromName(type)); |
| 35 } | 35 } |
| 36 | 36 |
| 37 CSSLengthValue* CSSLengthValue::from(const CalcDictionary& dictionary, Exception
State& exceptionState) | 37 CSSLengthValue* CSSLengthValue::from(const CalcDictionary& dictionary, Exception
State& exceptionState) |
| 38 { | 38 { |
| 39 return StyleCalcLength::create(dictionary, exceptionState); | 39 return CSSCalcLength::create(dictionary, exceptionState); |
| 40 } | 40 } |
| 41 | 41 |
| 42 CSSLengthValue* CSSLengthValue::add(const CSSLengthValue* other, ExceptionState&
exceptionState) | 42 CSSLengthValue* CSSLengthValue::add(const CSSLengthValue* other, ExceptionState&
exceptionState) |
| 43 { | 43 { |
| 44 if (type() == other->type() || type() == CalcLengthType) | 44 if (type() == other->type() || type() == CalcLengthType) |
| 45 return addInternal(other, exceptionState); | 45 return addInternal(other, exceptionState); |
| 46 | 46 |
| 47 StyleCalcLength* result = StyleCalcLength::create(this, exceptionState); | 47 CSSCalcLength* result = CSSCalcLength::create(this, exceptionState); |
| 48 return result->add(other, exceptionState); | 48 return result->add(other, exceptionState); |
| 49 } | 49 } |
| 50 | 50 |
| 51 CSSLengthValue* CSSLengthValue::subtract(const CSSLengthValue* other, ExceptionS
tate& exceptionState) | 51 CSSLengthValue* CSSLengthValue::subtract(const CSSLengthValue* other, ExceptionS
tate& exceptionState) |
| 52 { | 52 { |
| 53 if (type() == other->type() || type() == CalcLengthType) | 53 if (type() == other->type() || type() == CalcLengthType) |
| 54 return subtractInternal(other, exceptionState); | 54 return subtractInternal(other, exceptionState); |
| 55 | 55 |
| 56 StyleCalcLength* result = StyleCalcLength::create(this, exceptionState); | 56 CSSCalcLength* result = CSSCalcLength::create(this, exceptionState); |
| 57 return result->subtract(other, exceptionState); | 57 return result->subtract(other, exceptionState); |
| 58 } | 58 } |
| 59 | 59 |
| 60 CSSLengthValue* CSSLengthValue::multiply(double x, ExceptionState& exceptionStat
e) | 60 CSSLengthValue* CSSLengthValue::multiply(double x, ExceptionState& exceptionStat
e) |
| 61 { | 61 { |
| 62 return multiplyInternal(x, exceptionState); | 62 return multiplyInternal(x, exceptionState); |
| 63 } | 63 } |
| 64 | 64 |
| 65 CSSLengthValue* CSSLengthValue::divide(double x, ExceptionState& exceptionState) | 65 CSSLengthValue* CSSLengthValue::divide(double x, ExceptionState& exceptionState) |
| 66 { | 66 { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 85 return nullptr; | 85 return nullptr; |
| 86 } | 86 } |
| 87 | 87 |
| 88 CSSLengthValue* CSSLengthValue::divideInternal(double, ExceptionState&) | 88 CSSLengthValue* CSSLengthValue::divideInternal(double, ExceptionState&) |
| 89 { | 89 { |
| 90 NOTREACHED(); | 90 NOTREACHED(); |
| 91 return nullptr; | 91 return nullptr; |
| 92 } | 92 } |
| 93 | 93 |
| 94 } // namespace blink | 94 } // namespace blink |
| OLD | NEW |