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