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

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: Corrected test expectations Created 7 years, 3 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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 return reinterpret_cast<const CSSValue**>(const_cast<const void**>(&(this->m _storage))); 165 return reinterpret_cast<const CSSValue**>(const_cast<const void**>(&(this->m _storage)));
165 } 166 }
166 167
167 inline const StylePropertyMetadata* ImmutableStylePropertySet::metadataArray() c onst 168 inline const StylePropertyMetadata* ImmutableStylePropertySet::metadataArray() c onst
168 { 169 {
169 return reinterpret_cast<const StylePropertyMetadata*>(&reinterpret_cast<cons t char*>(&(this->m_storage))[m_arraySize * sizeof(CSSValue*)]); 170 return reinterpret_cast<const StylePropertyMetadata*>(&reinterpret_cast<cons t char*>(&(this->m_storage))[m_arraySize * sizeof(CSSValue*)]);
170 } 171 }
171 172
172 class MutableStylePropertySet : public StylePropertySet { 173 class MutableStylePropertySet : public StylePropertySet {
173 public: 174 public:
175 ~MutableStylePropertySet() { }
174 static PassRefPtr<MutableStylePropertySet> create(CSSParserMode = CSSQuirksM ode); 176 static PassRefPtr<MutableStylePropertySet> create(CSSParserMode = CSSQuirksM ode);
175 static PassRefPtr<MutableStylePropertySet> create(const CSSProperty* propert ies, unsigned count); 177 static PassRefPtr<MutableStylePropertySet> create(const CSSProperty* propert ies, unsigned count);
176 178
177 unsigned propertyCount() const { return m_propertyVector.size(); } 179 unsigned propertyCount() const { return m_propertyVector.size(); }
178 PropertySetCSSStyleDeclaration* cssStyleDeclaration(); 180 PropertySetCSSStyleDeclaration* cssStyleDeclaration();
179 181
180 void addParsedProperties(const Vector<CSSProperty, 256>&); 182 void addParsedProperties(const Vector<CSSProperty, 256>&);
181 void addParsedProperty(const CSSProperty&); 183 void addParsedProperty(const CSSProperty&);
182 184
183 // These expand shorthand properties into multiple properties. 185 // These expand shorthand properties into multiple properties.
(...skipping 10 matching lines...) Expand all
194 196
195 bool removeProperty(CSSPropertyID, String* returnText = 0); 197 bool removeProperty(CSSPropertyID, String* returnText = 0);
196 void removePrefixedOrUnprefixedProperty(CSSPropertyID); 198 void removePrefixedOrUnprefixedProperty(CSSPropertyID);
197 void removeBlockProperties(); 199 void removeBlockProperties();
198 bool removePropertiesInSet(const CSSPropertyID* set, unsigned length); 200 bool removePropertiesInSet(const CSSPropertyID* set, unsigned length);
199 void removeEquivalentProperties(const StylePropertySet*); 201 void removeEquivalentProperties(const StylePropertySet*);
200 void removeEquivalentProperties(const CSSStyleDeclaration*); 202 void removeEquivalentProperties(const CSSStyleDeclaration*);
201 bool removeVariable(const AtomicString& name); 203 bool removeVariable(const AtomicString& name);
202 bool clearVariables(); 204 bool clearVariables();
203 205
206 PassRefPtr<CSSVariablesIterator> variablesIterator() { return VariablesItera tor::create(this); }
207
204 void mergeAndOverrideOnConflict(const StylePropertySet*); 208 void mergeAndOverrideOnConflict(const StylePropertySet*);
205 209
206 void clear(); 210 void clear();
207 void parseDeclaration(const String& styleDeclaration, StyleSheetContents* co ntextStyleSheet); 211 void parseDeclaration(const String& styleDeclaration, StyleSheetContents* co ntextStyleSheet);
208 212
209 CSSStyleDeclaration* ensureCSSStyleDeclaration(); 213 CSSStyleDeclaration* ensureCSSStyleDeclaration();
210 CSSStyleDeclaration* ensureInlineCSSStyleDeclaration(Element* parentElement) ; 214 CSSStyleDeclaration* ensureInlineCSSStyleDeclaration(Element* parentElement) ;
211 215
212 Vector<CSSProperty, 4> m_propertyVector; 216 Vector<CSSProperty, 4> m_propertyVector;
213 217
214 private: 218 private:
219 class VariablesIterator : public CSSVariablesIterator {
220 public:
221 virtual ~VariablesIterator() { }
222 static PassRefPtr<VariablesIterator> create(MutableStylePropertySet*);
223 private:
224 explicit VariablesIterator(MutableStylePropertySet* propertySet) : m_pro pertySet(propertySet) { }
225 virtual void advance() OVERRIDE;
226 virtual bool atEnd() const OVERRIDE { return m_remainingNames.isEmpty(); }
227 virtual AtomicString name() const OVERRIDE { return m_remainingNames.las t(); }
228 virtual String value() const OVERRIDE { return m_propertySet->variableVa lue(name()); }
229 virtual void addedVariable(const AtomicString& name) OVERRIDE;
230 virtual void removedVariable(const AtomicString& name) OVERRIDE;
231 virtual void clearedVariables() OVERRIDE;
232
233 Vector<AtomicString> m_remainingNames;
234 Vector<AtomicString> m_newNames;
235 RefPtr<MutableStylePropertySet> m_propertySet;
236 };
237
215 explicit MutableStylePropertySet(CSSParserMode); 238 explicit MutableStylePropertySet(CSSParserMode);
216 explicit MutableStylePropertySet(const StylePropertySet&); 239 explicit MutableStylePropertySet(const StylePropertySet&);
217 MutableStylePropertySet(const CSSProperty* properties, unsigned count); 240 MutableStylePropertySet(const CSSProperty* properties, unsigned count);
218 241
219 bool removeShorthandProperty(CSSPropertyID); 242 bool removeShorthandProperty(CSSPropertyID);
220 CSSProperty* findCSSPropertyWithID(CSSPropertyID); 243 CSSProperty* findCSSPropertyWithID(CSSPropertyID);
221 OwnPtr<PropertySetCSSStyleDeclaration> m_cssomWrapper; 244 OwnPtr<PropertySetCSSStyleDeclaration> m_cssomWrapper;
222 245
223 friend class StylePropertySet; 246 friend class StylePropertySet;
224 }; 247 };
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 279
257 if (m_isMutable) 280 if (m_isMutable)
258 delete static_cast<MutableStylePropertySet*>(this); 281 delete static_cast<MutableStylePropertySet*>(this);
259 else 282 else
260 delete static_cast<ImmutableStylePropertySet*>(this); 283 delete static_cast<ImmutableStylePropertySet*>(this);
261 } 284 }
262 285
263 } // namespace WebCore 286 } // namespace WebCore
264 287
265 #endif // StylePropertySet_h 288 #endif // StylePropertySet_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698