| 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/CSSImageValue.h" | 7 #include "core/css/CSSImageValue.h" |
| 8 #include "core/css/CSSValue.h" | 8 #include "core/css/CSSValue.h" |
| 9 #include "core/css/cssom/CSSNumberValue.h" | 9 #include "core/css/cssom/CSSNumberValue.h" |
| 10 #include "core/css/cssom/CSSSimpleLength.h" | 10 #include "core/css/cssom/CSSSimpleLength.h" |
| 11 #include "core/css/cssom/CSSStyleValue.h" | 11 #include "core/css/cssom/CSSStyleValue.h" |
| 12 #include "core/css/cssom/CSSStyleVariableReferenceValue.h" | 12 #include "core/css/cssom/CSSStyleVariableReferenceValue.h" |
| 13 #include "core/css/cssom/CSSTransformValue.h" | 13 #include "core/css/cssom/CSSTransformValue.h" |
| 14 #include "core/css/cssom/CSSURLImageValue.h" | 14 #include "core/css/cssom/CSSURLImageValue.h" |
| 15 #include "core/css/cssom/CSSUnparsedValue.h" | 15 #include "core/css/cssom/CSSUnparsedValue.h" |
| 16 #include "core/css/cssom/CSSUnsupportedStyleValue.h" | 16 #include "core/css/cssom/CSSUnsupportedStyleValue.h" |
| 17 | 17 |
| 18 namespace blink { | 18 namespace blink { |
| 19 | 19 |
| 20 namespace { | 20 namespace { |
| 21 | 21 |
| 22 CSSStyleValue* styleValueForPrimitiveValue(const CSSPrimitiveValue& primitiveVal
ue) | 22 CSSStyleValue* styleValueForPrimitiveValue(const CSSPrimitiveValue& primitiveVal
ue) |
| 23 { | 23 { |
| 24 if (primitiveValue.isNumber()) | 24 if (primitiveValue.isNumber()) |
| 25 return CSSNumberValue::create(primitiveValue.getDoubleValue()); | 25 return CSSNumberValue::create(primitiveValue.getDoubleValue()); |
| 26 if (primitiveValue.isLength()) | 26 if (primitiveValue.isLength() || primitiveValue.isPercentage()) |
| 27 return CSSSimpleLength::fromCSSValue(primitiveValue); | 27 return CSSSimpleLength::fromCSSValue(primitiveValue); |
| 28 | 28 |
| 29 return nullptr; | 29 return nullptr; |
| 30 } | 30 } |
| 31 | 31 |
| 32 CSSStyleValue* styleValueForProperty(CSSPropertyID propertyID, const CSSValue& v
alue) | 32 CSSStyleValue* styleValueForProperty(CSSPropertyID propertyID, const CSSValue& v
alue) |
| 33 { | 33 { |
| 34 switch (propertyID) { | 34 switch (propertyID) { |
| 35 case CSSPropertyTransform: | 35 case CSSPropertyTransform: |
| 36 return CSSTransformValue::fromCSSValue(value); | 36 return CSSTransformValue::fromCSSValue(value); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 styleValue = styleValueForProperty(propertyID, *innerValue); | 77 styleValue = styleValueForProperty(propertyID, *innerValue); |
| 78 if (!styleValue) { | 78 if (!styleValue) { |
| 79 return unsupportedCSSValue(value); | 79 return unsupportedCSSValue(value); |
| 80 } | 80 } |
| 81 styleValueVector.append(styleValue); | 81 styleValueVector.append(styleValue); |
| 82 } | 82 } |
| 83 return styleValueVector; | 83 return styleValueVector; |
| 84 } | 84 } |
| 85 | 85 |
| 86 } // namespace blink | 86 } // namespace blink |
| OLD | NEW |