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

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

Issue 15821009: Move property setting/removing/addParsedProperty/addParsedProperties functions to MutableStylePrope… (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/css/CSSParser.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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 bool isEmpty() const; 98 bool isEmpty() const;
99 PropertyReference propertyAt(unsigned index) const { return PropertyReferenc e(*this, index); } 99 PropertyReference propertyAt(unsigned index) const { return PropertyReferenc e(*this, index); }
100 int findPropertyIndex(CSSPropertyID) const; 100 int findPropertyIndex(CSSPropertyID) const;
101 101
102 PassRefPtr<CSSValue> getPropertyCSSValue(CSSPropertyID) const; 102 PassRefPtr<CSSValue> getPropertyCSSValue(CSSPropertyID) const;
103 String getPropertyValue(CSSPropertyID) const; 103 String getPropertyValue(CSSPropertyID) const;
104 bool propertyIsImportant(CSSPropertyID) const; 104 bool propertyIsImportant(CSSPropertyID) const;
105 CSSPropertyID getPropertyShorthand(CSSPropertyID) const; 105 CSSPropertyID getPropertyShorthand(CSSPropertyID) const;
106 bool isPropertyImplicit(CSSPropertyID) const; 106 bool isPropertyImplicit(CSSPropertyID) const;
107 107
108 // These expand shorthand properties into multiple properties. 108 PassRefPtr<MutableStylePropertySet> copyBlockProperties() const;
109 bool setProperty(CSSPropertyID, const String& value, bool important = false, StyleSheetContents* contextStyleSheet = 0);
110 void setProperty(CSSPropertyID, PassRefPtr<CSSValue>, bool important = false );
111
112 // These do not. FIXME: This is too messy, we can do better.
113 bool setProperty(CSSPropertyID, int identifier, bool important = false);
114 void appendPrefixingVariantProperty(const CSSProperty&);
115 void setPrefixingVariantProperty(const CSSProperty&);
116 void setProperty(const CSSProperty&, CSSProperty* slot = 0);
117
118 bool removeProperty(CSSPropertyID, String* returnText = 0);
119 void removePrefixedOrUnprefixedProperty(CSSPropertyID);
120
121 void addParsedProperties(const Vector<CSSProperty>&);
122 void addParsedProperty(const CSSProperty&);
123
124 PassRefPtr<StylePropertySet> copyBlockProperties() const;
125 void removeBlockProperties();
126 bool removePropertiesInSet(const CSSPropertyID* set, unsigned length);
127
128 void mergeAndOverrideOnConflict(const StylePropertySet*);
129 109
130 CSSParserMode cssParserMode() const { return static_cast<CSSParserMode>(m_cs sParserMode); } 110 CSSParserMode cssParserMode() const { return static_cast<CSSParserMode>(m_cs sParserMode); }
131 111
132 void addSubresourceStyleURLs(ListHashSet<KURL>&, StyleSheetContents* context StyleSheet) const; 112 void addSubresourceStyleURLs(ListHashSet<KURL>&, StyleSheetContents* context StyleSheet) const;
133 113
134 PassRefPtr<MutableStylePropertySet> mutableCopy() const; 114 PassRefPtr<MutableStylePropertySet> mutableCopy() const;
135 PassRefPtr<ImmutableStylePropertySet> immutableCopyIfNeeded() const; 115 PassRefPtr<ImmutableStylePropertySet> immutableCopyIfNeeded() const;
136 116
137 void removeEquivalentProperties(const StylePropertySet*);
138 void removeEquivalentProperties(const CSSStyleDeclaration*);
139
140 PassRefPtr<MutableStylePropertySet> copyPropertiesInSet(const Vector<CSSProp ertyID>&) const; 117 PassRefPtr<MutableStylePropertySet> copyPropertiesInSet(const Vector<CSSProp ertyID>&) const;
141 118
142 String asText() const; 119 String asText() const;
143 120
144 PropertySetCSSStyleDeclaration* cssStyleDeclaration(); 121 PropertySetCSSStyleDeclaration* cssStyleDeclaration();
145 122
146 bool isMutable() const { return m_isMutable; } 123 bool isMutable() const { return m_isMutable; }
147 bool hasCSSOMWrapper() const { return m_ownsCSSOMWrapper; } 124 bool hasCSSOMWrapper() const { return m_ownsCSSOMWrapper; }
148 125
149 bool hasFailedOrCanceledSubresources() const; 126 bool hasFailedOrCanceledSubresources() const;
150 127
151 static unsigned averageSizeInBytes(); 128 static unsigned averageSizeInBytes();
152 void reportMemoryUsage(MemoryObjectInfo*) const; 129 void reportMemoryUsage(MemoryObjectInfo*) const;
153 130
154 #ifndef NDEBUG 131 #ifndef NDEBUG
155 void showStyle(); 132 void showStyle();
156 #endif 133 #endif
157 134
158 const CSSValue** immutableValueArray() const; 135 const CSSValue** immutableValueArray() const;
159 const StylePropertyMetadata* immutableMetadataArray() const; 136 const StylePropertyMetadata* immutableMetadataArray() const;
160 137
138 bool propertyMatches(CSSPropertyID, const CSSValue*) const;
139
161 protected: 140 protected:
162 StylePropertySet(CSSParserMode cssParserMode) 141 StylePropertySet(CSSParserMode cssParserMode)
163 : m_cssParserMode(cssParserMode) 142 : m_cssParserMode(cssParserMode)
164 , m_ownsCSSOMWrapper(false) 143 , m_ownsCSSOMWrapper(false)
165 , m_isMutable(true) 144 , m_isMutable(true)
166 , m_arraySize(0) 145 , m_arraySize(0)
167 { } 146 { }
168 147
169 StylePropertySet(CSSParserMode cssParserMode, unsigned immutableArraySize) 148 StylePropertySet(CSSParserMode cssParserMode, unsigned immutableArraySize)
170 : m_cssParserMode(cssParserMode) 149 : m_cssParserMode(cssParserMode)
171 , m_ownsCSSOMWrapper(false) 150 , m_ownsCSSOMWrapper(false)
172 , m_isMutable(false) 151 , m_isMutable(false)
173 , m_arraySize(immutableArraySize) 152 , m_arraySize(immutableArraySize)
174 { } 153 { }
175 154
176 Vector<CSSProperty, 4>& mutablePropertyVector(); 155 Vector<CSSProperty, 4>& mutablePropertyVector();
177 const Vector<CSSProperty, 4>& mutablePropertyVector() const; 156 const Vector<CSSProperty, 4>& mutablePropertyVector() const;
178 157
179 unsigned m_cssParserMode : 2; 158 unsigned m_cssParserMode : 2;
180 mutable unsigned m_ownsCSSOMWrapper : 1; 159 mutable unsigned m_ownsCSSOMWrapper : 1;
181 mutable unsigned m_isMutable : 1; 160 mutable unsigned m_isMutable : 1;
182 unsigned m_arraySize : 28; 161 unsigned m_arraySize : 28;
183
184 private:
185 bool removeShorthandProperty(CSSPropertyID);
186 bool propertyMatches(CSSPropertyID, const CSSValue*) const;
187
188 CSSProperty* findMutableCSSPropertyWithID(CSSPropertyID);
189 162
190 friend class PropertySetCSSStyleDeclaration; 163 friend class PropertySetCSSStyleDeclaration;
191 }; 164 };
192 165
193 class ImmutableStylePropertySet : public StylePropertySet { 166 class ImmutableStylePropertySet : public StylePropertySet {
194 // This is needed because we malloc() space for an 167 // This is needed because we malloc() space for an
195 // ImmutableStylePropertySet plus following properties, as a performance 168 // ImmutableStylePropertySet plus following properties, as a performance
196 // tweak. 169 // tweak.
197 NEW_DELETE_SAME_AS_MALLOC_FREE; 170 NEW_DELETE_SAME_AS_MALLOC_FREE;
198 public: 171 public:
(...skipping 18 matching lines...) Expand all
217 return reinterpret_cast<const StylePropertyMetadata*>(&reinterpret_cast<cons t char*>((&static_cast<const ImmutableStylePropertySet*>(this)->m_storage))[m_ar raySize * sizeof(CSSValue*)]); 190 return reinterpret_cast<const StylePropertyMetadata*>(&reinterpret_cast<cons t char*>((&static_cast<const ImmutableStylePropertySet*>(this)->m_storage))[m_ar raySize * sizeof(CSSValue*)]);
218 } 191 }
219 192
220 class MutableStylePropertySet : public StylePropertySet { 193 class MutableStylePropertySet : public StylePropertySet {
221 public: 194 public:
222 static PassRefPtr<MutableStylePropertySet> create(CSSParserMode = CSSQuirksM ode); 195 static PassRefPtr<MutableStylePropertySet> create(CSSParserMode = CSSQuirksM ode);
223 static PassRefPtr<MutableStylePropertySet> create(const CSSProperty* propert ies, unsigned count); 196 static PassRefPtr<MutableStylePropertySet> create(const CSSProperty* propert ies, unsigned count);
224 197
225 MutableStylePropertySet(const StylePropertySet&); 198 MutableStylePropertySet(const StylePropertySet&);
226 199
200 void addParsedProperties(const Vector<CSSProperty>&);
201 void addParsedProperty(const CSSProperty&);
202
203 // These expand shorthand properties into multiple properties.
204 bool setProperty(CSSPropertyID, const String& value, bool important = false, StyleSheetContents* contextStyleSheet = 0);
205 void setProperty(CSSPropertyID, PassRefPtr<CSSValue>, bool important = false );
206
207 // These do not. FIXME: This is too messy, we can do better.
208 bool setProperty(CSSPropertyID, int identifier, bool important = false);
209 void appendPrefixingVariantProperty(const CSSProperty&);
210 void setPrefixingVariantProperty(const CSSProperty&);
211 void setProperty(const CSSProperty&, CSSProperty* slot = 0);
212
213 bool removeProperty(CSSPropertyID, String* returnText = 0);
214 void removePrefixedOrUnprefixedProperty(CSSPropertyID);
215 void removeBlockProperties();
216 bool removePropertiesInSet(const CSSPropertyID* set, unsigned length);
217 void removeEquivalentProperties(const StylePropertySet*);
218 void removeEquivalentProperties(const CSSStyleDeclaration*);
219
220 void mergeAndOverrideOnConflict(const StylePropertySet*);
221
227 void clear(); 222 void clear();
228 void parseDeclaration(const String& styleDeclaration, StyleSheetContents* co ntextStyleSheet); 223 void parseDeclaration(const String& styleDeclaration, StyleSheetContents* co ntextStyleSheet);
229 224
230 CSSStyleDeclaration* ensureCSSStyleDeclaration(); 225 CSSStyleDeclaration* ensureCSSStyleDeclaration();
231 CSSStyleDeclaration* ensureInlineCSSStyleDeclaration(const StyledElement* pa rentElement); 226 CSSStyleDeclaration* ensureInlineCSSStyleDeclaration(const StyledElement* pa rentElement);
232 227
233 Vector<CSSProperty, 4> m_propertyVector; 228 Vector<CSSProperty, 4> m_propertyVector;
234 229
235 private: 230 private:
236 MutableStylePropertySet(CSSParserMode cssParserMode) 231 MutableStylePropertySet(CSSParserMode cssParserMode)
237 : StylePropertySet(cssParserMode) 232 : StylePropertySet(cssParserMode)
238 { } 233 { }
234
239 MutableStylePropertySet(const CSSProperty* properties, unsigned count); 235 MutableStylePropertySet(const CSSProperty* properties, unsigned count);
236
237 bool removeShorthandProperty(CSSPropertyID);
238 CSSProperty* findCSSPropertyWithID(CSSPropertyID);
240 }; 239 };
241 240
242 inline Vector<CSSProperty, 4>& StylePropertySet::mutablePropertyVector() 241 inline Vector<CSSProperty, 4>& StylePropertySet::mutablePropertyVector()
243 { 242 {
244 ASSERT(m_isMutable); 243 ASSERT(m_isMutable);
245 return static_cast<MutableStylePropertySet*>(this)->m_propertyVector; 244 return static_cast<MutableStylePropertySet*>(this)->m_propertyVector;
246 } 245 }
247 246
248 inline const Vector<CSSProperty, 4>& StylePropertySet::mutablePropertyVector() c onst 247 inline const Vector<CSSProperty, 4>& StylePropertySet::mutablePropertyVector() c onst
249 { 248 {
(...skipping 20 matching lines...) Expand all
270 269
271 if (m_isMutable) 270 if (m_isMutable)
272 delete static_cast<MutableStylePropertySet*>(this); 271 delete static_cast<MutableStylePropertySet*>(this);
273 else 272 else
274 delete static_cast<ImmutableStylePropertySet*>(this); 273 delete static_cast<ImmutableStylePropertySet*>(this);
275 } 274 }
276 275
277 } // namespace WebCore 276 } // namespace WebCore
278 277
279 #endif // StylePropertySet_h 278 #endif // StylePropertySet_h
OLDNEW
« no previous file with comments | « Source/core/css/CSSParser.cpp ('k') | Source/core/css/StylePropertySet.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698