Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(148)

Unified Diff: third_party/WebKit/Source/core/css/cssom/CSSLengthValue.cpp

Issue 1949343002: [Obsolete] Typed CSSOM: Prefix LengthValue, CalcLength and SimpleLength with "CSS" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rename layout test files Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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
« no previous file with comments | « third_party/WebKit/Source/core/css/cssom/CSSLengthValue.h ('k') | third_party/WebKit/Source/core/css/cssom/CSSLengthValue.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698