| Index: third_party/WebKit/Source/core/css/cssom/CSSLengthValue.cpp
|
| diff --git a/third_party/WebKit/Source/core/css/cssom/CSSLengthValue.cpp b/third_party/WebKit/Source/core/css/cssom/CSSLengthValue.cpp
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..658a4e1fbd7a306a52ed0f237b953b37b3f20e8b
|
| --- /dev/null
|
| +++ b/third_party/WebKit/Source/core/css/cssom/CSSLengthValue.cpp
|
| @@ -0,0 +1,91 @@
|
| +// Copyright 2015 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "core/css/cssom/CSSLengthValue.h"
|
| +
|
| +#include "bindings/core/v8/ExceptionState.h"
|
| +#include "core/css/cssom/CSSSimpleLength.h"
|
| +#include "core/css/cssom/CSSStyleCalcLength.h"
|
| +#include "core/css/cssom/CalcDictionary.h"
|
| +#include "wtf/HashMap.h"
|
| +
|
| +namespace blink {
|
| +
|
| +CSSPrimitiveValue::UnitType CSSLengthValue::unitFromName(const String& name)
|
| +{
|
| + if (equalIgnoringASCIICase(name, "percent") || name == "%") {
|
| + return CSSPrimitiveValue::UnitType::Percentage;
|
| + }
|
| + return CSSPrimitiveValue::fromName(name);
|
| +}
|
| +
|
| +CSSLengthValue* CSSLengthValue::parse(const String& cssString, ExceptionState& exceptionState)
|
| +{
|
| + // TODO: Implement
|
| + return nullptr;
|
| +}
|
| +
|
| +CSSLengthValue* CSSLengthValue::fromValue(double value, const String& type, ExceptionState&)
|
| +{
|
| + return CSSSimpleLength::create(value, unitFromName(type));
|
| +}
|
| +
|
| +CSSLengthValue* CSSLengthValue::fromDictionary(const CalcDictionary& dictionary, ExceptionState& exceptionState)
|
| +{
|
| + return CSSStyleCalcLength::create(dictionary, exceptionState);
|
| +}
|
| +
|
| +CSSLengthValue* CSSLengthValue::add(const CSSLengthValue* other, ExceptionState& exceptionState)
|
| +{
|
| + if (type() == other->type() || type() == CalcLengthType)
|
| + return addInternal(other, exceptionState);
|
| +
|
| + CSSStyleCalcLength* result = CSSStyleCalcLength::create(this, exceptionState);
|
| + return result->add(other, exceptionState);
|
| +}
|
| +
|
| +CSSLengthValue* CSSLengthValue::subtract(const CSSLengthValue* other, ExceptionState& exceptionState)
|
| +{
|
| + if (type() == other->type() || type() == CalcLengthType)
|
| + return subtractInternal(other, exceptionState);
|
| +
|
| + CSSStyleCalcLength* result = CSSStyleCalcLength::create(this, exceptionState);
|
| + return result->subtract(other, exceptionState);
|
| +}
|
| +
|
| +CSSLengthValue* CSSLengthValue::multiply(double x, ExceptionState& exceptionState)
|
| +{
|
| + return multiplyInternal(x, exceptionState);
|
| +}
|
| +
|
| +CSSLengthValue* CSSLengthValue::divide(double x, ExceptionState& exceptionState)
|
| +{
|
| + return divideInternal(x, exceptionState);
|
| +}
|
| +
|
| +CSSLengthValue* CSSLengthValue::addInternal(const CSSLengthValue*, ExceptionState&)
|
| +{
|
| + ASSERT_NOT_REACHED();
|
| + return nullptr;
|
| +}
|
| +
|
| +CSSLengthValue* CSSLengthValue::subtractInternal(const CSSLengthValue*, ExceptionState&)
|
| +{
|
| + ASSERT_NOT_REACHED();
|
| + return nullptr;
|
| +}
|
| +
|
| +CSSLengthValue* CSSLengthValue::multiplyInternal(double, ExceptionState&)
|
| +{
|
| + ASSERT_NOT_REACHED();
|
| + return nullptr;
|
| +}
|
| +
|
| +CSSLengthValue* CSSLengthValue::divideInternal(double, ExceptionState&)
|
| +{
|
| + ASSERT_NOT_REACHED();
|
| + return nullptr;
|
| +}
|
| +
|
| +} // namespace blink
|
|
|