| 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/InlineStylePropertyMap.h" | 5 #include "core/css/cssom/InlineStylePropertyMap.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/Iterable.h" | 7 #include "bindings/core/v8/Iterable.h" |
| 8 #include "core/CSSPropertyNames.h" | 8 #include "core/CSSPropertyNames.h" |
| 9 #include "core/css/CSSCustomIdentValue.h" |
| 10 #include "core/css/CSSCustomPropertyDeclaration.h" |
| 9 #include "core/css/CSSPrimitiveValue.h" | 11 #include "core/css/CSSPrimitiveValue.h" |
| 10 #include "core/css/CSSPropertyMetadata.h" | 12 #include "core/css/CSSPropertyMetadata.h" |
| 11 #include "core/css/CSSValueList.h" | 13 #include "core/css/CSSValueList.h" |
| 12 #include "core/css/StylePropertySet.h" | 14 #include "core/css/StylePropertySet.h" |
| 13 #include "core/css/cssom/CSSOMTypes.h" | 15 #include "core/css/cssom/CSSOMTypes.h" |
| 14 #include "core/css/cssom/CSSSimpleLength.h" | 16 #include "core/css/cssom/CSSSimpleLength.h" |
| 17 #include "core/css/cssom/CSSUnsupportedStyleValue.h" |
| 15 #include "core/css/cssom/StyleValueFactory.h" | 18 #include "core/css/cssom/StyleValueFactory.h" |
| 16 | 19 |
| 17 namespace blink { | 20 namespace blink { |
| 18 | 21 |
| 19 namespace { | 22 namespace { |
| 20 | 23 |
| 21 CSSValue* styleValueToCSSValue(CSSPropertyID propertyID, const CSSStyleValue& st
yleValue) | 24 CSSValue* styleValueToCSSValue(CSSPropertyID propertyID, const CSSStyleValue& st
yleValue) |
| 22 { | 25 { |
| 23 if (!CSSOMTypes::propertyCanTake(propertyID, styleValue)) | 26 if (!CSSOMTypes::propertyCanTake(propertyID, styleValue)) |
| 24 return nullptr; | 27 return nullptr; |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 m_ownerElement->removeInlineStyleProperty(propertyID); | 144 m_ownerElement->removeInlineStyleProperty(propertyID); |
| 142 } | 145 } |
| 143 | 146 |
| 144 HeapVector<StylePropertyMap::StylePropertyMapEntry> InlineStylePropertyMap::getI
terationEntries() | 147 HeapVector<StylePropertyMap::StylePropertyMapEntry> InlineStylePropertyMap::getI
terationEntries() |
| 145 { | 148 { |
| 146 HeapVector<StylePropertyMap::StylePropertyMapEntry> result; | 149 HeapVector<StylePropertyMap::StylePropertyMapEntry> result; |
| 147 StylePropertySet& inlineStyleSet = m_ownerElement->ensureMutableInlineStyle(
); | 150 StylePropertySet& inlineStyleSet = m_ownerElement->ensureMutableInlineStyle(
); |
| 148 for (unsigned i = 0; i < inlineStyleSet.propertyCount(); i++) { | 151 for (unsigned i = 0; i < inlineStyleSet.propertyCount(); i++) { |
| 149 StylePropertySet::PropertyReference propertyReference = inlineStyleSet.p
ropertyAt(i); | 152 StylePropertySet::PropertyReference propertyReference = inlineStyleSet.p
ropertyAt(i); |
| 150 CSSPropertyID propertyID = propertyReference.id(); | 153 CSSPropertyID propertyID = propertyReference.id(); |
| 151 CSSStyleValueVector styleValueVector = StyleValueFactory::cssValueToStyl
eValueVector(propertyID, *propertyReference.value()); | 154 String name; |
| 152 CSSStyleValueOrCSSStyleValueSequence value; | 155 CSSStyleValueOrCSSStyleValueSequence value; |
| 153 if (styleValueVector.size() == 1) | 156 if (propertyID == CSSPropertyVariable) { |
| 154 value.setCSSStyleValue(styleValueVector[0]); | 157 const CSSCustomPropertyDeclaration* customDeclaration = toCSSCustomP
ropertyDeclaration(propertyReference.value()); |
| 155 else | 158 name = customDeclaration->name(); |
| 156 value.setCSSStyleValueSequence(styleValueVector); | 159 // TODO(meade): Eventually custom properties will support other type
s, so actually return them instead of always returning a CSSUnsupportedStyleValu
e. |
| 157 result.append(std::make_pair(getPropertyNameString(propertyID), value)); | 160 value.setCSSStyleValue(CSSUnsupportedStyleValue::create(customDeclar
ation->customCSSText())); |
| 161 } else if (propertyID == CSSPropertyApplyAtRule) { |
| 162 name = "@apply"; |
| 163 value.setCSSStyleValue(CSSUnsupportedStyleValue::create(toCSSCustomI
dentValue(propertyReference.value())->value())); |
| 164 } else { |
| 165 name = getPropertyNameString(propertyID); |
| 166 CSSStyleValueVector styleValueVector = StyleValueFactory::cssValueTo
StyleValueVector(propertyID, *propertyReference.value()); |
| 167 if (styleValueVector.size() == 1) |
| 168 value.setCSSStyleValue(styleValueVector[0]); |
| 169 else |
| 170 value.setCSSStyleValueSequence(styleValueVector); |
| 171 } |
| 172 result.append(std::make_pair(name, value)); |
| 158 } | 173 } |
| 159 return result; | 174 return result; |
| 160 } | 175 } |
| 161 | 176 |
| 162 } // namespace blink | 177 } // namespace blink |
| 163 | 178 |
| OLD | NEW |