OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "core/css/cssom/StyleValueFactory.h" | 5 #include "core/css/cssom/StyleValueFactory.h" |
6 | 6 |
7 #include "core/css/CSSValue.h" | 7 #include "core/css/CSSValue.h" |
8 #include "core/css/cssom/CSSSimpleLength.h" | 8 #include "core/css/cssom/CSSLengthValue.h" |
9 #include "core/css/cssom/CSSStyleValue.h" | 9 #include "core/css/cssom/CSSStyleValue.h" |
10 #include "core/css/cssom/TransformValue.h" | 10 #include "core/css/cssom/TransformValue.h" |
11 | 11 |
12 namespace blink { | 12 namespace blink { |
13 | 13 |
14 CSSStyleValueVector StyleValueFactory::cssValueToStyleValueVector(CSSPropertyID
propertyID, const CSSValue& value) | 14 CSSStyleValueVector StyleValueFactory::cssValueToStyleValueVector(CSSPropertyID
propertyID, const CSSValue& value) |
15 { | 15 { |
16 CSSStyleValueVector styleValueVector; | 16 CSSStyleValueVector styleValueVector; |
17 | 17 |
18 if (value.isPrimitiveValue()) { | 18 if (value.isPrimitiveValue()) { |
19 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); | 19 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); |
20 if (primitiveValue.isLength() && !primitiveValue.isCalculated()) { | 20 if (primitiveValue.isLength()) { |
21 styleValueVector.append(CSSSimpleLength::create(primitiveValue.getDo
ubleValue(), primitiveValue.typeWithCalcResolved())); | 21 styleValueVector.append(CSSLengthValue::fromCSSValue(value)); |
22 return styleValueVector; | 22 return styleValueVector; |
23 } | 23 } |
24 } | 24 } |
25 | 25 |
26 switch (propertyID) { | 26 switch (propertyID) { |
27 case CSSPropertyTransform: | 27 case CSSPropertyTransform: |
28 styleValueVector.append(TransformValue::fromCSSValue(value)); | 28 styleValueVector.append(TransformValue::fromCSSValue(value)); |
29 break; | 29 break; |
30 default: | 30 default: |
31 // TODO(meade): Implement the rest. | 31 // TODO(meade): Implement the rest. |
32 break; | 32 break; |
33 } | 33 } |
34 return styleValueVector; | 34 return styleValueVector; |
35 } | 35 } |
36 | 36 |
| 37 CSSStyleValue* StyleValueFactory::cssValueToSingleStyleValue(CSSPropertyID prope
rtyID, const CSSValue& value) |
| 38 { |
| 39 CSSStyleValueVector styleValueVector = StyleValueFactory::cssValueToStyleVal
ueVector(propertyID, value); |
| 40 if (styleValueVector.size() != 1) |
| 41 return nullptr; |
| 42 |
| 43 return styleValueVector[0]; |
| 44 } |
| 45 |
37 } // namespace blink | 46 } // namespace blink |
OLD | NEW |