Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(533)

Side by Side Diff: third_party/WebKit/Source/core/css/cssom/InlineStylePropertyMap.cpp

Issue 2036893003: [CSS Typed OM] Rename StyleValue -> CSSStyleValue (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update more union types Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/CSSPrimitiveValue.h" 9 #include "core/css/CSSPrimitiveValue.h"
10 #include "core/css/CSSPropertyMetadata.h" 10 #include "core/css/CSSPropertyMetadata.h"
(...skipping 17 matching lines...) Expand all
28 { 28 {
29 Vector<String> result; 29 Vector<String> result;
30 StylePropertySet& inlineStyleSet = m_ownerElement->ensureMutableInlineStyle( ); 30 StylePropertySet& inlineStyleSet = m_ownerElement->ensureMutableInlineStyle( );
31 for (unsigned i = 0; i < inlineStyleSet.propertyCount(); i++) { 31 for (unsigned i = 0; i < inlineStyleSet.propertyCount(); i++) {
32 CSSPropertyID propertyID = inlineStyleSet.propertyAt(i).id(); 32 CSSPropertyID propertyID = inlineStyleSet.propertyAt(i).id();
33 result.append(getPropertyNameString(propertyID)); 33 result.append(getPropertyNameString(propertyID));
34 } 34 }
35 return result; 35 return result;
36 } 36 }
37 37
38 void InlineStylePropertyMap::set(CSSPropertyID propertyID, StyleValueOrStyleValu eSequenceOrString& item, ExceptionState& exceptionState) 38 void InlineStylePropertyMap::set(CSSPropertyID propertyID, CSSStyleValueOrCSSSty leValueSequenceOrString& item, ExceptionState& exceptionState)
39 { 39 {
40 if (item.isStyleValue()) { 40 if (item.isCSSStyleValue()) {
41 StyleValue* styleValue = item.getAsStyleValue(); 41 CSSStyleValue* styleValue = item.getAsCSSStyleValue();
42 if (!CSSOMTypes::propertyCanTake(propertyID, *styleValue)) { 42 if (!CSSOMTypes::propertyCanTake(propertyID, *styleValue)) {
43 exceptionState.throwTypeError("Invalid type for property"); 43 exceptionState.throwTypeError("Invalid type for property");
44 return; 44 return;
45 } 45 }
46 m_ownerElement->setInlineStyleProperty(propertyID, styleValue->toCSSValu e()); 46 m_ownerElement->setInlineStyleProperty(propertyID, styleValue->toCSSValu e());
47 } else if (item.isStyleValueSequence()) { 47 } else if (item.isCSSStyleValueSequence()) {
48 if (!CSSPropertyMetadata::propertySupportsMultiple(propertyID)) { 48 if (!CSSPropertyMetadata::propertySupportsMultiple(propertyID)) {
49 exceptionState.throwTypeError("Property does not support multiple va lues"); 49 exceptionState.throwTypeError("Property does not support multiple va lues");
50 return; 50 return;
51 } 51 }
52 52
53 // TODO(meade): This won't always work. Figure out what kind of CSSValue List to create properly. 53 // TODO(meade): This won't always work. Figure out what kind of CSSValue List to create properly.
54 CSSValueList* valueList = CSSValueList::createSpaceSeparated(); 54 CSSValueList* valueList = CSSValueList::createSpaceSeparated();
55 StyleValueVector styleValueVector = item.getAsStyleValueSequence(); 55 StyleValueVector styleValueVector = item.getAsCSSStyleValueSequence();
56 for (const Member<StyleValue> value : styleValueVector) { 56 for (const Member<CSSStyleValue> value : styleValueVector) {
57 if (!CSSOMTypes::propertyCanTake(propertyID, *value)) { 57 if (!CSSOMTypes::propertyCanTake(propertyID, *value)) {
58 exceptionState.throwTypeError("Invalid type for property"); 58 exceptionState.throwTypeError("Invalid type for property");
59 return; 59 return;
60 } 60 }
61 valueList->append(value->toCSSValue()); 61 valueList->append(value->toCSSValue());
62 } 62 }
63 63
64 m_ownerElement->setInlineStyleProperty(propertyID, valueList); 64 m_ownerElement->setInlineStyleProperty(propertyID, valueList);
65 } else { 65 } else {
66 // Parse it. 66 // Parse it.
67 ASSERT(item.isString()); 67 ASSERT(item.isString());
68 // TODO(meade): Implement this. 68 // TODO(meade): Implement this.
69 exceptionState.throwTypeError("Not implemented yet"); 69 exceptionState.throwTypeError("Not implemented yet");
70 } 70 }
71 } 71 }
72 72
73 void InlineStylePropertyMap::append(CSSPropertyID propertyID, StyleValueOrStyleV alueSequenceOrString& item, ExceptionState& exceptionState) 73 void InlineStylePropertyMap::append(CSSPropertyID propertyID, CSSStyleValueOrCSS StyleValueSequenceOrString& item, ExceptionState& exceptionState)
74 { 74 {
75 if (!CSSPropertyMetadata::propertySupportsMultiple(propertyID)) { 75 if (!CSSPropertyMetadata::propertySupportsMultiple(propertyID)) {
76 exceptionState.throwTypeError("Property does not support multiple values "); 76 exceptionState.throwTypeError("Property does not support multiple values ");
77 return; 77 return;
78 } 78 }
79 79
80 CSSValue* cssValue = m_ownerElement->ensureMutableInlineStyle().getPropertyC SSValue(propertyID); 80 CSSValue* cssValue = m_ownerElement->ensureMutableInlineStyle().getPropertyC SSValue(propertyID);
81 CSSValueList* cssValueList = nullptr; 81 CSSValueList* cssValueList = nullptr;
82 if (cssValue->isValueList()) { 82 if (cssValue->isValueList()) {
83 cssValueList = toCSSValueList(cssValue); 83 cssValueList = toCSSValueList(cssValue);
84 } else { 84 } else {
85 // TODO(meade): Figure out what the correct behaviour here is. 85 // TODO(meade): Figure out what the correct behaviour here is.
86 exceptionState.throwTypeError("Property is not already list valued"); 86 exceptionState.throwTypeError("Property is not already list valued");
87 return; 87 return;
88 } 88 }
89 89
90 if (item.isStyleValue()) { 90 if (item.isCSSStyleValue()) {
91 StyleValue* styleValue = item.getAsStyleValue(); 91 CSSStyleValue* styleValue = item.getAsCSSStyleValue();
92 if (!CSSOMTypes::propertyCanTake(propertyID, *styleValue)) { 92 if (!CSSOMTypes::propertyCanTake(propertyID, *styleValue)) {
93 exceptionState.throwTypeError("Invalid type for property"); 93 exceptionState.throwTypeError("Invalid type for property");
94 return; 94 return;
95 } 95 }
96 cssValueList->append(item.getAsStyleValue()->toCSSValue()); 96 cssValueList->append(item.getAsCSSStyleValue()->toCSSValue());
97 } else if (item.isStyleValueSequence()) { 97 } else if (item.isCSSStyleValueSequence()) {
98 for (StyleValue* styleValue : item.getAsStyleValueSequence()) { 98 for (CSSStyleValue* styleValue : item.getAsCSSStyleValueSequence()) {
99 if (!CSSOMTypes::propertyCanTake(propertyID, *styleValue)) { 99 if (!CSSOMTypes::propertyCanTake(propertyID, *styleValue)) {
100 exceptionState.throwTypeError("Invalid type for property"); 100 exceptionState.throwTypeError("Invalid type for property");
101 return; 101 return;
102 } 102 }
103 cssValueList->append(styleValue->toCSSValue()); 103 cssValueList->append(styleValue->toCSSValue());
104 } 104 }
105 } else { 105 } else {
106 // Parse it. 106 // Parse it.
107 ASSERT(item.isString()); 107 ASSERT(item.isString());
108 // TODO(meade): Implement this. 108 // TODO(meade): Implement this.
(...skipping 10 matching lines...) Expand all
119 } 119 }
120 120
121 HeapVector<StylePropertyMap::StylePropertyMapEntry> InlineStylePropertyMap::getI terationEntries() 121 HeapVector<StylePropertyMap::StylePropertyMapEntry> InlineStylePropertyMap::getI terationEntries()
122 { 122 {
123 HeapVector<StylePropertyMap::StylePropertyMapEntry> result; 123 HeapVector<StylePropertyMap::StylePropertyMapEntry> result;
124 StylePropertySet& inlineStyleSet = m_ownerElement->ensureMutableInlineStyle( ); 124 StylePropertySet& inlineStyleSet = m_ownerElement->ensureMutableInlineStyle( );
125 for (unsigned i = 0; i < inlineStyleSet.propertyCount(); i++) { 125 for (unsigned i = 0; i < inlineStyleSet.propertyCount(); i++) {
126 StylePropertySet::PropertyReference propertyReference = inlineStyleSet.p ropertyAt(i); 126 StylePropertySet::PropertyReference propertyReference = inlineStyleSet.p ropertyAt(i);
127 CSSPropertyID propertyID = propertyReference.id(); 127 CSSPropertyID propertyID = propertyReference.id();
128 StyleValueVector styleValueVector = cssValueToStyleValueVector(propertyI D, *propertyReference.value()); 128 StyleValueVector styleValueVector = cssValueToStyleValueVector(propertyI D, *propertyReference.value());
129 StyleValueOrStyleValueSequence value; 129 CSSStyleValueOrCSSStyleValueSequence value;
130 if (styleValueVector.size() == 1) 130 if (styleValueVector.size() == 1)
131 value.setStyleValue(styleValueVector[0]); 131 value.setCSSStyleValue(styleValueVector[0]);
132 else 132 else
133 value.setStyleValueSequence(styleValueVector); 133 value.setCSSStyleValueSequence(styleValueVector);
134 result.append(std::make_pair(getPropertyNameString(propertyID), value)); 134 result.append(std::make_pair(getPropertyNameString(propertyID), value));
135 } 135 }
136 return result; 136 return result;
137 } 137 }
138 138
139 } // namespace blink 139 } // namespace blink
140 140
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698