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

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

Powered by Google App Engine
This is Rietveld 408576698