| 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/SimpleLength.h" | |
| 6 | |
| 7 #include "core/css/CSSPrimitiveValue.h" | |
| 8 #include "core/css/cssom/StyleCalcLength.h" | |
| 9 #include "wtf/text/StringBuilder.h" | |
| 10 | |
| 11 namespace blink { | |
| 12 | |
| 13 CSSValue* SimpleLength::toCSSValue() const | |
| 14 { | |
| 15 return cssValuePool().createValue(m_value, m_unit); | |
| 16 } | |
| 17 | |
| 18 bool SimpleLength::containsPercent() const | |
| 19 { | |
| 20 return lengthUnit() == CSSPrimitiveValue::UnitType::Percentage; | |
| 21 } | |
| 22 | |
| 23 LengthValue* SimpleLength::addInternal(const LengthValue* other, ExceptionState&
exceptionState) | |
| 24 { | |
| 25 const SimpleLength* o = toSimpleLength(other); | |
| 26 if (m_unit == o->m_unit) | |
| 27 return create(m_value + o->value(), m_unit); | |
| 28 | |
| 29 // Different units resolve to a calc. | |
| 30 StyleCalcLength* result = StyleCalcLength::create(this, exceptionState); | |
| 31 return result->add(other, exceptionState); | |
| 32 } | |
| 33 | |
| 34 LengthValue* SimpleLength::subtractInternal(const LengthValue* other, ExceptionS
tate& exceptionState) | |
| 35 { | |
| 36 const SimpleLength* o = toSimpleLength(other); | |
| 37 if (m_unit == o->m_unit) | |
| 38 return create(m_value - o->value(), m_unit); | |
| 39 | |
| 40 // Different units resolve to a calc. | |
| 41 StyleCalcLength* result = StyleCalcLength::create(this, exceptionState); | |
| 42 return result->subtract(other, exceptionState); | |
| 43 } | |
| 44 | |
| 45 LengthValue* SimpleLength::multiplyInternal(double x, ExceptionState& exceptionS
tate) | |
| 46 { | |
| 47 return create(m_value * x, m_unit); | |
| 48 } | |
| 49 | |
| 50 LengthValue* SimpleLength::divideInternal(double x, ExceptionState& exceptionSta
te) | |
| 51 { | |
| 52 return create(m_value / x, m_unit); | |
| 53 } | |
| 54 | |
| 55 } // namespace blink | |
| OLD | NEW |