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/CSSImageValue.h" | |
| 7 #include "core/css/CSSValue.h" | 8 #include "core/css/CSSValue.h" |
| 8 #include "core/css/cssom/CSSNumberValue.h" | 9 #include "core/css/cssom/CSSNumberValue.h" |
| 9 #include "core/css/cssom/CSSSimpleLength.h" | 10 #include "core/css/cssom/CSSSimpleLength.h" |
| 10 #include "core/css/cssom/CSSStyleValue.h" | 11 #include "core/css/cssom/CSSStyleValue.h" |
| 11 #include "core/css/cssom/CSSStyleVariableReferenceValue.h" | 12 #include "core/css/cssom/CSSStyleVariableReferenceValue.h" |
| 12 #include "core/css/cssom/CSSTokenStreamValue.h" | 13 #include "core/css/cssom/CSSTokenStreamValue.h" |
| 13 #include "core/css/cssom/CSSTransformValue.h" | 14 #include "core/css/cssom/CSSTransformValue.h" |
| 15 #include "core/css/cssom/CSSURLImageValue.h" | |
| 14 #include "core/css/cssom/CSSUnsupportedStyleValue.h" | 16 #include "core/css/cssom/CSSUnsupportedStyleValue.h" |
| 15 | 17 |
| 16 namespace blink { | 18 namespace blink { |
| 17 | 19 |
| 18 namespace { | 20 namespace { |
| 19 | 21 |
| 20 CSSStyleValue* styleValueForProperty(CSSPropertyID propertyID, const CSSValue& v alue) | 22 CSSStyleValue* styleValueForProperty(CSSPropertyID propertyID, const CSSValue& v alue) |
| 21 { | 23 { |
| 22 switch (propertyID) { | 24 switch (propertyID) { |
| 23 case CSSPropertyTransform: | 25 case CSSPropertyTransform: |
| 24 return CSSTransformValue::fromCSSValue(value); | 26 return CSSTransformValue::fromCSSValue(value); |
| 25 default: | 27 default: |
| 26 // TODO(meade): Implement other complex properties. | 28 // TODO(meade): Implement other complex properties. |
| 27 break; | 29 break; |
| 28 } | 30 } |
| 29 | 31 |
| 30 if (value.isPrimitiveValue()) { | 32 if (value.isPrimitiveValue()) { |
| 31 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); | 33 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); |
| 32 if (primitiveValue.isLength() && !primitiveValue.isCalculated()) | 34 if (primitiveValue.isLength() && !primitiveValue.isCalculated()) |
| 33 return CSSSimpleLength::create(primitiveValue.getDoubleValue(), prim itiveValue.typeWithCalcResolved()); | 35 return CSSSimpleLength::create(primitiveValue.getDoubleValue(), prim itiveValue.typeWithCalcResolved()); |
| 34 if (primitiveValue.isNumber()) | 36 if (primitiveValue.isNumber()) |
| 35 return CSSNumberValue::create(primitiveValue.getDoubleValue()); | 37 return CSSNumberValue::create(primitiveValue.getDoubleValue()); |
| 36 } | 38 } |
| 37 | 39 |
| 38 if (value.isVariableReferenceValue()) { | 40 if (value.isVariableReferenceValue()) { |
| 39 return CSSTokenStreamValue::fromCSSValue(toCSSVariableReferenceValue(val ue)); | 41 return CSSTokenStreamValue::fromCSSValue(toCSSVariableReferenceValue(val ue)); |
| 40 } | 42 } |
| 41 | 43 |
| 44 if (value.isImageValue()) { | |
| 45 const CSSImageValue& imageValue = toCSSImageValue(value); | |
| 46 return CSSURLImageValue::create(imageValue.valueWithURLMadeAbsolute()); | |
|
esprehn
2016/08/30 21:39:19
Note this causes two allocations for every image v
anthonyhkf
2016/08/31 01:45:59
Acknowledged.
| |
| 47 } | |
| 48 | |
| 42 return nullptr; | 49 return nullptr; |
| 43 } | 50 } |
| 44 | 51 |
| 45 CSSStyleValueVector unsupportedCSSValue(const CSSValue& value) | 52 CSSStyleValueVector unsupportedCSSValue(const CSSValue& value) |
| 46 { | 53 { |
| 47 CSSStyleValueVector styleValueVector; | 54 CSSStyleValueVector styleValueVector; |
| 48 styleValueVector.append(CSSUnsupportedStyleValue::create(value.cssText())); | 55 styleValueVector.append(CSSUnsupportedStyleValue::create(value.cssText())); |
| 49 return styleValueVector; | 56 return styleValueVector; |
| 50 } | 57 } |
| 51 | 58 |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 70 styleValue = styleValueForProperty(propertyID, *innerValue); | 77 styleValue = styleValueForProperty(propertyID, *innerValue); |
| 71 if (!styleValue) { | 78 if (!styleValue) { |
| 72 return unsupportedCSSValue(value); | 79 return unsupportedCSSValue(value); |
| 73 } | 80 } |
| 74 styleValueVector.append(styleValue); | 81 styleValueVector.append(styleValue); |
| 75 } | 82 } |
| 76 return styleValueVector; | 83 return styleValueVector; |
| 77 } | 84 } |
| 78 | 85 |
| 79 } // namespace blink | 86 } // namespace blink |
| OLD | NEW |