summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormeade <meade@chromium.org>2016-03-02 20:52:20 -0800
committerCommit bot <commit-bot@chromium.org>2016-03-03 04:54:01 +0000
commitfee5771921b6f93f36a3b102c30b3711db8b7b5b (patch)
treee0c523af37046ad486b9558e6dfd756617245f32
parentce1315b94863f40d6323fa488490ed866aae4ed4 (diff)
downloadchromium_src-fee5771921b6f93f36a3b102c30b3711db8b7b5b.zip
chromium_src-fee5771921b6f93f36a3b102c30b3711db8b7b5b.tar.gz
chromium_src-fee5771921b6f93f36a3b102c30b3711db8b7b5b.tar.bz2
Add a StyleValueFactory that converts CSSValues to StyleValues.
BUG=545318 Review URL: https://codereview.chromium.org/1752173002 Cr-Commit-Position: refs/heads/master@{#378958}
-rw-r--r--third_party/WebKit/Source/core/core.gypi2
-rw-r--r--third_party/WebKit/Source/core/css/cssom/StyleValue.cpp7
-rw-r--r--third_party/WebKit/Source/core/css/cssom/StyleValue.h1
-rw-r--r--third_party/WebKit/Source/core/css/cssom/StyleValueFactory.cpp25
-rw-r--r--third_party/WebKit/Source/core/css/cssom/StyleValueFactory.h25
5 files changed, 53 insertions, 7 deletions
diff --git a/third_party/WebKit/Source/core/core.gypi b/third_party/WebKit/Source/core/core.gypi
index 4b1018d..27c2390 100644
--- a/third_party/WebKit/Source/core/core.gypi
+++ b/third_party/WebKit/Source/core/core.gypi
@@ -1320,6 +1320,8 @@
'css/cssom/StylePropertyMap.h',
'css/cssom/StyleValue.cpp',
'css/cssom/StyleValue.h',
+ 'css/cssom/StyleValueFactory.cpp',
+ 'css/cssom/StyleValueFactory.h',
'css/cssom/TransformComponent.h',
'css/cssom/TransformValue.cpp',
'css/cssom/TransformValue.h',
diff --git a/third_party/WebKit/Source/core/css/cssom/StyleValue.cpp b/third_party/WebKit/Source/core/css/cssom/StyleValue.cpp
index e91a459..4b168d6 100644
--- a/third_party/WebKit/Source/core/css/cssom/StyleValue.cpp
+++ b/third_party/WebKit/Source/core/css/cssom/StyleValue.cpp
@@ -5,15 +5,10 @@
#include "core/css/cssom/StyleValue.h"
#include "bindings/core/v8/ScriptValue.h"
+#include "core/css/cssom/SimpleLength.h"
namespace blink {
-StyleValue* StyleValue::create(const CSSValue& val)
-{
- // TODO: implement.
- return nullptr;
-}
-
ScriptValue StyleValue::parse(ScriptState* state, const String& property, const String& cssText)
{
// TODO: implement.
diff --git a/third_party/WebKit/Source/core/css/cssom/StyleValue.h b/third_party/WebKit/Source/core/css/cssom/StyleValue.h
index 9f90924..726518b 100644
--- a/third_party/WebKit/Source/core/css/cssom/StyleValue.h
+++ b/third_party/WebKit/Source/core/css/cssom/StyleValue.h
@@ -27,7 +27,6 @@ public:
virtual StyleValueType type() const = 0;
- static StyleValue* create(const CSSValue&);
static ScriptValue parse(ScriptState*, const String& property, const String& cssText);
virtual PassRefPtrWillBeRawPtr<CSSValue> toCSSValue() const = 0;
diff --git a/third_party/WebKit/Source/core/css/cssom/StyleValueFactory.cpp b/third_party/WebKit/Source/core/css/cssom/StyleValueFactory.cpp
new file mode 100644
index 0000000..2a0a0a7
--- /dev/null
+++ b/third_party/WebKit/Source/core/css/cssom/StyleValueFactory.cpp
@@ -0,0 +1,25 @@
+// Copyright 2016 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/StyleValueFactory.h"
+
+#include "core/css/CSSValue.h"
+#include "core/css/cssom/SimpleLength.h"
+#include "core/css/cssom/StyleValue.h"
+
+namespace blink {
+
+StyleValue* StyleValueFactory::create(CSSPropertyID propertyID, const CSSValue& value)
+{
+ if (value.isPrimitiveValue()) {
+ const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value);
+ if (primitiveValue.isLength() && !primitiveValue.isCalculated()) {
+ return SimpleLength::create(primitiveValue.getDoubleValue(), primitiveValue.typeWithCalcResolved());
+ }
+ }
+ // TODO(meade): Implement the rest.
+ return nullptr;
+}
+
+} // namespace blink
diff --git a/third_party/WebKit/Source/core/css/cssom/StyleValueFactory.h b/third_party/WebKit/Source/core/css/cssom/StyleValueFactory.h
new file mode 100644
index 0000000..36a4437
--- /dev/null
+++ b/third_party/WebKit/Source/core/css/cssom/StyleValueFactory.h
@@ -0,0 +1,25 @@
+// Copyright 2016 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.
+
+#ifndef StyleValueFactory_h
+#define StyleValueFactory_h
+
+#include "core/CSSPropertyNames.h"
+#include "wtf/Allocator.h"
+
+namespace blink {
+
+class CSSValue;
+class StyleValue;
+
+class StyleValueFactory {
+ STATIC_ONLY(StyleValueFactory);
+
+public:
+ static StyleValue* create(CSSPropertyID, const CSSValue&);
+};
+
+} // namespace blink
+
+#endif