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