Chromium Code Reviews| 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/CSSCalculationValue.h" | |
|
rjwright
2016/09/29 05:34:42
I don't think any of these extra includes are need
meade_UTC10
2016/09/29 05:53:13
Done.
| |
| 7 #include "core/css/CSSImageValue.h" | 8 #include "core/css/CSSImageValue.h" |
| 8 #include "core/css/CSSValue.h" | 9 #include "core/css/CSSValue.h" |
| 10 #include "core/css/cssom/CSSCalcLength.h" | |
| 9 #include "core/css/cssom/CSSNumberValue.h" | 11 #include "core/css/cssom/CSSNumberValue.h" |
| 12 #include "core/css/cssom/CSSOMTypes.h" | |
| 10 #include "core/css/cssom/CSSSimpleLength.h" | 13 #include "core/css/cssom/CSSSimpleLength.h" |
| 11 #include "core/css/cssom/CSSStyleValue.h" | 14 #include "core/css/cssom/CSSStyleValue.h" |
| 12 #include "core/css/cssom/CSSStyleVariableReferenceValue.h" | 15 #include "core/css/cssom/CSSStyleVariableReferenceValue.h" |
| 13 #include "core/css/cssom/CSSTransformValue.h" | 16 #include "core/css/cssom/CSSTransformValue.h" |
| 14 #include "core/css/cssom/CSSURLImageValue.h" | 17 #include "core/css/cssom/CSSURLImageValue.h" |
| 15 #include "core/css/cssom/CSSUnparsedValue.h" | 18 #include "core/css/cssom/CSSUnparsedValue.h" |
| 16 #include "core/css/cssom/CSSUnsupportedStyleValue.h" | 19 #include "core/css/cssom/CSSUnsupportedStyleValue.h" |
| 17 | 20 |
| 18 namespace blink { | 21 namespace blink { |
| 19 | 22 |
| 20 namespace { | 23 namespace { |
| 21 | 24 |
| 25 CSSStyleValue* styleValueForPrimitiveValue(CSSPropertyID propertyID, const CSSPr imitiveValue& primitiveValue) | |
|
rjwright
2016/09/29 05:34:42
propertyID isn't used
meade_UTC10
2016/09/29 05:53:13
Done.
| |
| 26 { | |
| 27 if (primitiveValue.isNumber()) | |
| 28 return CSSNumberValue::create(primitiveValue.getDoubleValue()); | |
| 29 if (primitiveValue.isLength()) | |
| 30 return CSSSimpleLength::fromCSSValue(primitiveValue); | |
| 31 | |
| 32 return nullptr; | |
| 33 } | |
| 34 | |
| 22 CSSStyleValue* styleValueForProperty(CSSPropertyID propertyID, const CSSValue& v alue) | 35 CSSStyleValue* styleValueForProperty(CSSPropertyID propertyID, const CSSValue& v alue) |
| 23 { | 36 { |
| 24 switch (propertyID) { | 37 switch (propertyID) { |
| 25 case CSSPropertyTransform: | 38 case CSSPropertyTransform: |
| 26 return CSSTransformValue::fromCSSValue(value); | 39 return CSSTransformValue::fromCSSValue(value); |
| 27 default: | 40 default: |
| 28 // TODO(meade): Implement other complex properties. | 41 // TODO(meade): Implement other complex properties. |
| 29 break; | 42 break; |
| 30 } | 43 } |
| 31 | 44 |
| 32 if (value.isPrimitiveValue()) { | 45 if (value.isPrimitiveValue()) |
| 33 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); | 46 return styleValueForPrimitiveValue(propertyID, toCSSPrimitiveValue(value )); |
| 34 if (primitiveValue.isLength() && !primitiveValue.isCalculated()) | 47 if (value.isVariableReferenceValue()) |
| 35 return CSSSimpleLength::create(primitiveValue.getDoubleValue(), prim itiveValue.typeWithCalcResolved()); | |
| 36 if (primitiveValue.isNumber()) | |
| 37 return CSSNumberValue::create(primitiveValue.getDoubleValue()); | |
| 38 } | |
| 39 | |
| 40 if (value.isVariableReferenceValue()) { | |
| 41 return CSSUnparsedValue::fromCSSValue(toCSSVariableReferenceValue(value) ); | 48 return CSSUnparsedValue::fromCSSValue(toCSSVariableReferenceValue(value) ); |
| 42 } | 49 if (value.isImageValue()) |
| 43 | 50 return CSSURLImageValue::create(toCSSImageValue(value).valueWithURLMadeA bsolute()); |
| 44 if (value.isImageValue()) { | |
| 45 const CSSImageValue& imageValue = toCSSImageValue(value); | |
| 46 return CSSURLImageValue::create(imageValue.valueWithURLMadeAbsolute()); | |
| 47 } | |
| 48 | 51 |
| 49 return nullptr; | 52 return nullptr; |
| 50 } | 53 } |
| 51 | 54 |
| 52 CSSStyleValueVector unsupportedCSSValue(const CSSValue& value) | 55 CSSStyleValueVector unsupportedCSSValue(const CSSValue& value) |
| 53 { | 56 { |
| 54 CSSStyleValueVector styleValueVector; | 57 CSSStyleValueVector styleValueVector; |
| 55 styleValueVector.append(CSSUnsupportedStyleValue::create(value.cssText())); | 58 styleValueVector.append(CSSUnsupportedStyleValue::create(value.cssText())); |
| 56 return styleValueVector; | 59 return styleValueVector; |
| 57 } | 60 } |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 77 styleValue = styleValueForProperty(propertyID, *innerValue); | 80 styleValue = styleValueForProperty(propertyID, *innerValue); |
| 78 if (!styleValue) { | 81 if (!styleValue) { |
| 79 return unsupportedCSSValue(value); | 82 return unsupportedCSSValue(value); |
| 80 } | 83 } |
| 81 styleValueVector.append(styleValue); | 84 styleValueVector.append(styleValue); |
| 82 } | 85 } |
| 83 return styleValueVector; | 86 return styleValueVector; |
| 84 } | 87 } |
| 85 | 88 |
| 86 } // namespace blink | 89 } // namespace blink |
| OLD | NEW |