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

Side by Side Diff: Source/core/css/StylePropertySet.h

Issue 1164573002: CSSValue Immediates: Change CSSValue to an object instead of a pointer (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 5 years, 4 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
« no previous file with comments | « Source/core/css/StylePropertySerializer.cpp ('k') | Source/core/css/StylePropertySet.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * (C) 1999-2003 Lars Knoll (knoll@kde.org) 2 * (C) 1999-2003 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2004, 2005, 2006, 2008, 2012 Apple Inc. All rights reserved. 3 * Copyright (C) 2004, 2005, 2006, 2008, 2012 Apple Inc. All rights reserved.
4 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 { 63 {
64 } 64 }
65 65
66 CSSPropertyID id() const { return static_cast<CSSPropertyID>(propertyMet adata().m_propertyID); } 66 CSSPropertyID id() const { return static_cast<CSSPropertyID>(propertyMet adata().m_propertyID); }
67 CSSPropertyID shorthandID() const { return propertyMetadata().shorthandI D(); } 67 CSSPropertyID shorthandID() const { return propertyMetadata().shorthandI D(); }
68 68
69 bool isImportant() const { return propertyMetadata().m_important; } 69 bool isImportant() const { return propertyMetadata().m_important; }
70 bool isInherited() const { return propertyMetadata().m_inherited; } 70 bool isInherited() const { return propertyMetadata().m_inherited; }
71 bool isImplicit() const { return propertyMetadata().m_implicit; } 71 bool isImplicit() const { return propertyMetadata().m_implicit; }
72 72
73 const CSSValue* value() const { return propertyValue(); } 73 const CSSValue value() const { return propertyValue(); }
74 // FIXME: We should try to remove this mutable overload. 74 // FIXME: We should try to remove this mutable overload.
75 CSSValue* value() { return const_cast<CSSValue*>(propertyValue()); } 75 CSSValue value() { return propertyValue(); }
76 76
77 // FIXME: Remove this. 77 // FIXME: Remove this.
78 CSSProperty toCSSProperty() const { return CSSProperty(propertyMetadata( ), const_cast<CSSValue*>(propertyValue())); } 78 CSSProperty toCSSProperty() const { return CSSProperty(propertyMetadata( ), propertyValue()); }
79 79
80 const StylePropertyMetadata& propertyMetadata() const; 80 const StylePropertyMetadata& propertyMetadata() const;
81 81
82 private: 82 private:
83 const CSSValue* propertyValue() const; 83 const CSSValue propertyValue() const;
84 84
85 const StylePropertySet& m_propertySet; 85 const StylePropertySet& m_propertySet;
86 unsigned m_index; 86 unsigned m_index;
87 }; 87 };
88 88
89 unsigned propertyCount() const; 89 unsigned propertyCount() const;
90 bool isEmpty() const; 90 bool isEmpty() const;
91 PropertyReference propertyAt(unsigned index) const { return PropertyReferenc e(*this, index); } 91 PropertyReference propertyAt(unsigned index) const { return PropertyReferenc e(*this, index); }
92 int findPropertyIndex(CSSPropertyID) const; 92 int findPropertyIndex(CSSPropertyID) const;
93 bool hasProperty(CSSPropertyID property) const { return findPropertyIndex(pr operty) != -1; } 93 bool hasProperty(CSSPropertyID property) const { return findPropertyIndex(pr operty) != -1; }
94 94
95 PassRefPtrWillBeRawPtr<CSSValue> getPropertyCSSValue(CSSPropertyID) const; 95 NullableCSSValue getPropertyCSSValue(CSSPropertyID) const;
96 String getPropertyValue(CSSPropertyID) const; 96 String getPropertyValue(CSSPropertyID) const;
97 97
98 bool propertyIsImportant(CSSPropertyID) const; 98 bool propertyIsImportant(CSSPropertyID) const;
99 CSSPropertyID getPropertyShorthand(CSSPropertyID) const; 99 CSSPropertyID getPropertyShorthand(CSSPropertyID) const;
100 bool isPropertyImplicit(CSSPropertyID) const; 100 bool isPropertyImplicit(CSSPropertyID) const;
101 101
102 CSSParserMode cssParserMode() const { return static_cast<CSSParserMode>(m_cs sParserMode); } 102 CSSParserMode cssParserMode() const { return static_cast<CSSParserMode>(m_cs sParserMode); }
103 103
104 PassRefPtrWillBeRawPtr<MutableStylePropertySet> mutableCopy() const; 104 PassRefPtrWillBeRawPtr<MutableStylePropertySet> mutableCopy() const;
105 PassRefPtrWillBeRawPtr<ImmutableStylePropertySet> immutableCopyIfNeeded() co nst; 105 PassRefPtrWillBeRawPtr<ImmutableStylePropertySet> immutableCopyIfNeeded() co nst;
106 106
107 PassRefPtrWillBeRawPtr<MutableStylePropertySet> copyPropertiesInSet(const Ve ctor<CSSPropertyID>&) const; 107 PassRefPtrWillBeRawPtr<MutableStylePropertySet> copyPropertiesInSet(const Ve ctor<CSSPropertyID>&) const;
108 108
109 String asText() const; 109 String asText() const;
110 110
111 bool isMutable() const { return m_isMutable; } 111 bool isMutable() const { return m_isMutable; }
112 112
113 bool hasFailedOrCanceledSubresources() const; 113 bool hasFailedOrCanceledSubresources() const;
114 114
115 static unsigned averageSizeInBytes(); 115 static unsigned averageSizeInBytes();
116 116
117 #ifndef NDEBUG 117 #ifndef NDEBUG
118 void showStyle(); 118 void showStyle();
119 #endif 119 #endif
120 120
121 bool propertyMatches(CSSPropertyID, const CSSValue*) const; 121 bool propertyMatches(CSSPropertyID, const CSSValue) const;
122 122
123 DECLARE_TRACE(); 123 DECLARE_TRACE();
124 DEFINE_INLINE_TRACE_AFTER_DISPATCH() { } 124 DEFINE_INLINE_TRACE_AFTER_DISPATCH() { }
125 125
126 protected: 126 protected:
127 127
128 enum { MaxArraySize = (1 << 28) - 1 }; 128 enum { MaxArraySize = (1 << 28) - 1 };
129 129
130 StylePropertySet(CSSParserMode cssParserMode) 130 StylePropertySet(CSSParserMode cssParserMode)
131 : m_cssParserMode(cssParserMode) 131 : m_cssParserMode(cssParserMode)
(...skipping 14 matching lines...) Expand all
146 friend class PropertySetCSSStyleDeclaration; 146 friend class PropertySetCSSStyleDeclaration;
147 }; 147 };
148 148
149 class CORE_EXPORT ImmutableStylePropertySet : public StylePropertySet { 149 class CORE_EXPORT ImmutableStylePropertySet : public StylePropertySet {
150 public: 150 public:
151 ~ImmutableStylePropertySet(); 151 ~ImmutableStylePropertySet();
152 static PassRefPtrWillBeRawPtr<ImmutableStylePropertySet> create(const CSSPro perty* properties, unsigned count, CSSParserMode); 152 static PassRefPtrWillBeRawPtr<ImmutableStylePropertySet> create(const CSSPro perty* properties, unsigned count, CSSParserMode);
153 153
154 unsigned propertyCount() const { return m_arraySize; } 154 unsigned propertyCount() const { return m_arraySize; }
155 155
156 const RawPtrWillBeMember<CSSValue>* valueArray() const; 156 const CSSValue* valueArray() const;
157 const StylePropertyMetadata* metadataArray() const; 157 const StylePropertyMetadata* metadataArray() const;
158 int findPropertyIndex(CSSPropertyID) const; 158 int findPropertyIndex(CSSPropertyID) const;
159 159
160 DECLARE_TRACE_AFTER_DISPATCH(); 160 DECLARE_TRACE_AFTER_DISPATCH();
161 161
162 void* operator new(std::size_t, void* location) 162 void* operator new(std::size_t, void* location)
163 { 163 {
164 return location; 164 return location;
165 } 165 }
166 166
167 void* m_storage; 167 void* m_storage;
168 168
169 private: 169 private:
170 ImmutableStylePropertySet(const CSSProperty*, unsigned count, CSSParserMode) ; 170 ImmutableStylePropertySet(const CSSProperty*, unsigned count, CSSParserMode) ;
171 }; 171 };
172 172
173 inline const RawPtrWillBeMember<CSSValue>* ImmutableStylePropertySet::valueArray () const 173 inline const CSSValue* ImmutableStylePropertySet::valueArray() const
174 { 174 {
175 return reinterpret_cast<const RawPtrWillBeMember<CSSValue>*>(const_cast<cons t void**>(&(this->m_storage))); 175 return reinterpret_cast<const CSSValue*>(const_cast<const void**>(&(this->m_ storage)));
176 } 176 }
177 177
178 inline const StylePropertyMetadata* ImmutableStylePropertySet::metadataArray() c onst 178 inline const StylePropertyMetadata* ImmutableStylePropertySet::metadataArray() c onst
179 { 179 {
180 return reinterpret_cast<const StylePropertyMetadata*>(&reinterpret_cast<cons t char*>(&(this->m_storage))[m_arraySize * sizeof(RawPtrWillBeMember<CSSValue>)] ); 180 return reinterpret_cast<const StylePropertyMetadata*>(&reinterpret_cast<cons t char*>(&(this->m_storage))[m_arraySize * sizeof(CSSValue)]);
181 } 181 }
182 182
183 DEFINE_TYPE_CASTS(ImmutableStylePropertySet, StylePropertySet, set, !set->isMuta ble(), !set.isMutable()); 183 DEFINE_TYPE_CASTS(ImmutableStylePropertySet, StylePropertySet, set, !set->isMuta ble(), !set.isMutable());
184 184
185 class CORE_EXPORT MutableStylePropertySet : public StylePropertySet { 185 class CORE_EXPORT MutableStylePropertySet : public StylePropertySet {
186 public: 186 public:
187 ~MutableStylePropertySet() { } 187 ~MutableStylePropertySet() { }
188 static PassRefPtrWillBeRawPtr<MutableStylePropertySet> create(CSSParserMode = HTMLQuirksMode); 188 static PassRefPtrWillBeRawPtr<MutableStylePropertySet> create(CSSParserMode = HTMLQuirksMode);
189 static PassRefPtrWillBeRawPtr<MutableStylePropertySet> create(const CSSPrope rty* properties, unsigned count); 189 static PassRefPtrWillBeRawPtr<MutableStylePropertySet> create(const CSSPrope rty* properties, unsigned count);
190 190
191 unsigned propertyCount() const { return m_propertyVector.size(); } 191 unsigned propertyCount() const { return m_propertyVector.size(); }
192 192
193 // Returns whether this style set was changed. 193 // Returns whether this style set was changed.
194 bool addParsedProperties(const WillBeHeapVector<CSSProperty, 256>&); 194 bool addParsedProperties(const WillBeHeapVector<CSSProperty, 256>&);
195 bool addRespectingCascade(const CSSProperty&); 195 bool addRespectingCascade(const CSSProperty&);
196 196
197 // These expand shorthand properties into multiple properties. 197 // These expand shorthand properties into multiple properties.
198 bool setProperty(CSSPropertyID unresolvedProperty, const String& value, bool important = false, StyleSheetContents* contextStyleSheet = 0); 198 bool setProperty(CSSPropertyID unresolvedProperty, const String& value, bool important = false, StyleSheetContents* contextStyleSheet = 0);
199 void setProperty(CSSPropertyID, PassRefPtrWillBeRawPtr<CSSValue>, bool impor tant = false); 199 void setProperty(CSSPropertyID, CSSValue, bool important = false);
200 200
201 // These do not. FIXME: This is too messy, we can do better. 201 // These do not. FIXME: This is too messy, we can do better.
202 bool setProperty(CSSPropertyID, CSSValueID identifier, bool important = fals e); 202 bool setProperty(CSSPropertyID, CSSValueID identifier, bool important = fals e);
203 bool setProperty(const CSSProperty&, CSSProperty* slot = 0); 203 bool setProperty(const CSSProperty&, CSSProperty* slot = 0);
204 204
205 bool removeProperty(CSSPropertyID, String* returnText = 0); 205 bool removeProperty(CSSPropertyID, String* returnText = 0);
206 bool removePropertiesInSet(const CSSPropertyID* set, unsigned length); 206 bool removePropertiesInSet(const CSSPropertyID* set, unsigned length);
207 void removeEquivalentProperties(const StylePropertySet*); 207 void removeEquivalentProperties(const StylePropertySet*);
208 void removeEquivalentProperties(const CSSStyleDeclaration*); 208 void removeEquivalentProperties(const CSSStyleDeclaration*);
209 209
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 return toMutableStylePropertySet(set.get()); 248 return toMutableStylePropertySet(set.get());
249 } 249 }
250 250
251 inline const StylePropertyMetadata& StylePropertySet::PropertyReference::propert yMetadata() const 251 inline const StylePropertyMetadata& StylePropertySet::PropertyReference::propert yMetadata() const
252 { 252 {
253 if (m_propertySet.isMutable()) 253 if (m_propertySet.isMutable())
254 return toMutableStylePropertySet(m_propertySet).m_propertyVector.at(m_in dex).metadata(); 254 return toMutableStylePropertySet(m_propertySet).m_propertyVector.at(m_in dex).metadata();
255 return toImmutableStylePropertySet(m_propertySet).metadataArray()[m_index]; 255 return toImmutableStylePropertySet(m_propertySet).metadataArray()[m_index];
256 } 256 }
257 257
258 inline const CSSValue* StylePropertySet::PropertyReference::propertyValue() cons t 258 inline const CSSValue StylePropertySet::PropertyReference::propertyValue() const
259 { 259 {
260 if (m_propertySet.isMutable()) 260 if (m_propertySet.isMutable())
261 return toMutableStylePropertySet(m_propertySet).m_propertyVector.at(m_in dex).value(); 261 return toMutableStylePropertySet(m_propertySet).m_propertyVector.at(m_in dex).value();
262 return toImmutableStylePropertySet(m_propertySet).valueArray()[m_index]; 262 return toImmutableStylePropertySet(m_propertySet).valueArray()[m_index];
263 } 263 }
264 264
265 inline unsigned StylePropertySet::propertyCount() const 265 inline unsigned StylePropertySet::propertyCount() const
266 { 266 {
267 if (m_isMutable) 267 if (m_isMutable)
268 return toMutableStylePropertySet(this)->m_propertyVector.size(); 268 return toMutableStylePropertySet(this)->m_propertyVector.size();
(...skipping 21 matching lines...) Expand all
290 inline int StylePropertySet::findPropertyIndex(CSSPropertyID propertyID) const 290 inline int StylePropertySet::findPropertyIndex(CSSPropertyID propertyID) const
291 { 291 {
292 if (m_isMutable) 292 if (m_isMutable)
293 return toMutableStylePropertySet(this)->findPropertyIndex(propertyID); 293 return toMutableStylePropertySet(this)->findPropertyIndex(propertyID);
294 return toImmutableStylePropertySet(this)->findPropertyIndex(propertyID); 294 return toImmutableStylePropertySet(this)->findPropertyIndex(propertyID);
295 } 295 }
296 296
297 } // namespace blink 297 } // namespace blink
298 298
299 #endif // StylePropertySet_h 299 #endif // StylePropertySet_h
OLDNEW
« no previous file with comments | « Source/core/css/StylePropertySerializer.cpp ('k') | Source/core/css/StylePropertySet.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698