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

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

Issue 21006006: Add forEach() to CSSVariablesMap (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 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 | Annotate | Revision Log
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,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details. 13 * Library General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU Library General Public License 15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB. If not, write to 16 * along with this library; see the file COPYING.LIB. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA. 18 * Boston, MA 02110-1301, USA.
19 */ 19 */
20 20
21 #ifndef StylePropertySet_h 21 #ifndef StylePropertySet_h
22 #define StylePropertySet_h 22 #define StylePropertySet_h
23 23
24 #include "CSSPropertyNames.h" 24 #include "CSSPropertyNames.h"
25 #include "core/css/CSSParserMode.h" 25 #include "core/css/CSSParserMode.h"
26 #include "core/css/CSSPrimitiveValue.h" 26 #include "core/css/CSSPrimitiveValue.h"
27 #include "core/css/CSSProperty.h" 27 #include "core/css/CSSProperty.h"
28 #include "core/css/CSSVariablesIterator.h"
28 #include "core/css/PropertySetCSSStyleDeclaration.h" 29 #include "core/css/PropertySetCSSStyleDeclaration.h"
29 #include "wtf/ListHashSet.h" 30 #include "wtf/ListHashSet.h"
30 #include "wtf/Vector.h" 31 #include "wtf/Vector.h"
31 #include "wtf/text/WTFString.h" 32 #include "wtf/text/WTFString.h"
32 33
33 namespace WebCore { 34 namespace WebCore {
34 35
35 class CSSRule; 36 class CSSRule;
36 class CSSStyleDeclaration; 37 class CSSStyleDeclaration;
37 class Element; 38 class Element;
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 return reinterpret_cast<const CSSValue**>(const_cast<const void**>(&(this->m _storage))); 169 return reinterpret_cast<const CSSValue**>(const_cast<const void**>(&(this->m _storage)));
169 } 170 }
170 171
171 inline const StylePropertyMetadata* ImmutableStylePropertySet::metadataArray() c onst 172 inline const StylePropertyMetadata* ImmutableStylePropertySet::metadataArray() c onst
172 { 173 {
173 return reinterpret_cast<const StylePropertyMetadata*>(&reinterpret_cast<cons t char*>(&(this->m_storage))[m_arraySize * sizeof(CSSValue*)]); 174 return reinterpret_cast<const StylePropertyMetadata*>(&reinterpret_cast<cons t char*>(&(this->m_storage))[m_arraySize * sizeof(CSSValue*)]);
174 } 175 }
175 176
176 class MutableStylePropertySet : public StylePropertySet { 177 class MutableStylePropertySet : public StylePropertySet {
177 public: 178 public:
179 ~MutableStylePropertySet();
178 static PassRefPtr<MutableStylePropertySet> create(CSSParserMode = CSSQuirksM ode); 180 static PassRefPtr<MutableStylePropertySet> create(CSSParserMode = CSSQuirksM ode);
179 static PassRefPtr<MutableStylePropertySet> create(const CSSProperty* propert ies, unsigned count); 181 static PassRefPtr<MutableStylePropertySet> create(const CSSProperty* propert ies, unsigned count);
180 182
181 unsigned propertyCount() const { return m_propertyVector.size(); } 183 unsigned propertyCount() const { return m_propertyVector.size(); }
182 PropertySetCSSStyleDeclaration* cssStyleDeclaration(); 184 PropertySetCSSStyleDeclaration* cssStyleDeclaration();
183 185
184 void addParsedProperties(const Vector<CSSProperty>&); 186 void addParsedProperties(const Vector<CSSProperty>&);
185 void addParsedProperty(const CSSProperty&); 187 void addParsedProperty(const CSSProperty&);
186 188
187 // These expand shorthand properties into multiple properties. 189 // These expand shorthand properties into multiple properties.
(...skipping 10 matching lines...) Expand all
198 200
199 bool removeProperty(CSSPropertyID, String* returnText = 0); 201 bool removeProperty(CSSPropertyID, String* returnText = 0);
200 void removePrefixedOrUnprefixedProperty(CSSPropertyID); 202 void removePrefixedOrUnprefixedProperty(CSSPropertyID);
201 void removeBlockProperties(); 203 void removeBlockProperties();
202 bool removePropertiesInSet(const CSSPropertyID* set, unsigned length); 204 bool removePropertiesInSet(const CSSPropertyID* set, unsigned length);
203 void removeEquivalentProperties(const StylePropertySet*); 205 void removeEquivalentProperties(const StylePropertySet*);
204 void removeEquivalentProperties(const CSSStyleDeclaration*); 206 void removeEquivalentProperties(const CSSStyleDeclaration*);
205 bool removeVariable(const AtomicString& name); 207 bool removeVariable(const AtomicString& name);
206 bool clearVariables(); 208 bool clearVariables();
207 209
210 PassRefPtr<CSSVariablesIterator> variablesIterator() { return VariablesItera tor::create(this); }
211
208 void mergeAndOverrideOnConflict(const StylePropertySet*); 212 void mergeAndOverrideOnConflict(const StylePropertySet*);
209 213
210 void clear(); 214 void clear();
211 void parseDeclaration(const String& styleDeclaration, StyleSheetContents* co ntextStyleSheet); 215 void parseDeclaration(const String& styleDeclaration, StyleSheetContents* co ntextStyleSheet);
212 216
213 CSSStyleDeclaration* ensureCSSStyleDeclaration(); 217 CSSStyleDeclaration* ensureCSSStyleDeclaration();
214 CSSStyleDeclaration* ensureInlineCSSStyleDeclaration(Element* parentElement) ; 218 CSSStyleDeclaration* ensureInlineCSSStyleDeclaration(Element* parentElement) ;
215 219
216 Vector<CSSProperty, 4> m_propertyVector; 220 Vector<CSSProperty, 4> m_propertyVector;
217 221
218 private: 222 private:
223 class VariablesIterator : public CSSVariablesIterator {
224 public:
225 virtual ~VariablesIterator();
226 static PassRefPtr<VariablesIterator> create(MutableStylePropertySet*);
227 void addedVariable(const AtomicString& name);
228 void removedVariable(const AtomicString& name);
229 void clearedVariables();
230 private:
231 explicit VariablesIterator(MutableStylePropertySet* propertySet) : m_pro pertySet(propertySet) { }
232 virtual void advance() OVERRIDE;
233 virtual bool atEnd() const OVERRIDE { return m_remainingNames.isEmpty(); }
234 virtual AtomicString name() const OVERRIDE { return m_remainingNames.las t(); }
235 virtual String value() const OVERRIDE { return m_propertySet->variableVa lue(name()); }
236
237
238 Vector<AtomicString> m_remainingNames;
239 Vector<AtomicString> m_newNames;
240 RefPtr<MutableStylePropertySet> m_propertySet;
241 };
242
243 typedef Vector<RefPtr<VariablesIterator> > VariablesIterators;
244 VariablesIterators* activeVariablesIterators();
245 typedef HashMap<MutableStylePropertySet*, VariablesIterators > VariablesIter atorsMap;
246 static VariablesIteratorsMap* activeVariablesIteratorsMap();
247
219 explicit MutableStylePropertySet(CSSParserMode); 248 explicit MutableStylePropertySet(CSSParserMode);
220 explicit MutableStylePropertySet(const StylePropertySet&); 249 explicit MutableStylePropertySet(const StylePropertySet&);
221 MutableStylePropertySet(const CSSProperty* properties, unsigned count); 250 MutableStylePropertySet(const CSSProperty* properties, unsigned count);
222 251
223 bool removeShorthandProperty(CSSPropertyID); 252 bool removeShorthandProperty(CSSPropertyID);
224 CSSProperty* findCSSPropertyWithID(CSSPropertyID); 253 CSSProperty* findCSSPropertyWithID(CSSPropertyID);
225 OwnPtr<PropertySetCSSStyleDeclaration> m_cssomWrapper; 254 OwnPtr<PropertySetCSSStyleDeclaration> m_cssomWrapper;
226 255
227 friend class StylePropertySet; 256 friend class StylePropertySet;
228 }; 257 };
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 289
261 if (m_isMutable) 290 if (m_isMutable)
262 delete static_cast<MutableStylePropertySet*>(this); 291 delete static_cast<MutableStylePropertySet*>(this);
263 else 292 else
264 delete static_cast<ImmutableStylePropertySet*>(this); 293 delete static_cast<ImmutableStylePropertySet*>(this);
265 } 294 }
266 295
267 } // namespace WebCore 296 } // namespace WebCore
268 297
269 #endif // StylePropertySet_h 298 #endif // StylePropertySet_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698