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

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

Issue 169453006: Optimize StylePropertySet::findPropertyIndex() to improve CSS properties performance (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 10 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 | « no previous file | 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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 142
143 class ImmutableStylePropertySet : public StylePropertySet { 143 class ImmutableStylePropertySet : public StylePropertySet {
144 public: 144 public:
145 ~ImmutableStylePropertySet(); 145 ~ImmutableStylePropertySet();
146 static PassRefPtr<ImmutableStylePropertySet> create(const CSSProperty* prope rties, unsigned count, CSSParserMode); 146 static PassRefPtr<ImmutableStylePropertySet> create(const CSSProperty* prope rties, unsigned count, CSSParserMode);
147 147
148 unsigned propertyCount() const { return m_arraySize; } 148 unsigned propertyCount() const { return m_arraySize; }
149 149
150 const CSSValue** valueArray() const; 150 const CSSValue** valueArray() const;
151 const StylePropertyMetadata* metadataArray() const; 151 const StylePropertyMetadata* metadataArray() const;
152 int findPropertyIndex(CSSPropertyID) const;
152 153
153 void* m_storage; 154 void* m_storage;
154 155
155 private: 156 private:
156 ImmutableStylePropertySet(const CSSProperty*, unsigned count, CSSParserMode) ; 157 ImmutableStylePropertySet(const CSSProperty*, unsigned count, CSSParserMode) ;
157 }; 158 };
158 159
159 inline const CSSValue** ImmutableStylePropertySet::valueArray() const 160 inline const CSSValue** ImmutableStylePropertySet::valueArray() const
160 { 161 {
161 return reinterpret_cast<const CSSValue**>(const_cast<const void**>(&(this->m _storage))); 162 return reinterpret_cast<const CSSValue**>(const_cast<const void**>(&(this->m _storage)));
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 bool removePropertiesInSet(const CSSPropertyID* set, unsigned length); 202 bool removePropertiesInSet(const CSSPropertyID* set, unsigned length);
202 void removeEquivalentProperties(const StylePropertySet*); 203 void removeEquivalentProperties(const StylePropertySet*);
203 void removeEquivalentProperties(const CSSStyleDeclaration*); 204 void removeEquivalentProperties(const CSSStyleDeclaration*);
204 205
205 void mergeAndOverrideOnConflict(const StylePropertySet*); 206 void mergeAndOverrideOnConflict(const StylePropertySet*);
206 207
207 void clear(); 208 void clear();
208 void parseDeclaration(const String& styleDeclaration, StyleSheetContents* co ntextStyleSheet); 209 void parseDeclaration(const String& styleDeclaration, StyleSheetContents* co ntextStyleSheet);
209 210
210 CSSStyleDeclaration* ensureCSSStyleDeclaration(); 211 CSSStyleDeclaration* ensureCSSStyleDeclaration();
212 int findPropertyIndex(CSSPropertyID) const;
211 213
212 Vector<CSSProperty, 4> m_propertyVector; 214 Vector<CSSProperty, 4> m_propertyVector;
213 215
214 private: 216 private:
215 explicit MutableStylePropertySet(CSSParserMode); 217 explicit MutableStylePropertySet(CSSParserMode);
216 explicit MutableStylePropertySet(const StylePropertySet&); 218 explicit MutableStylePropertySet(const StylePropertySet&);
217 MutableStylePropertySet(const CSSProperty* properties, unsigned count); 219 MutableStylePropertySet(const CSSProperty* properties, unsigned count);
218 220
219 bool removeShorthandProperty(CSSPropertyID); 221 bool removeShorthandProperty(CSSPropertyID);
220 CSSProperty* findCSSPropertyWithID(CSSPropertyID); 222 CSSProperty* findCSSPropertyWithID(CSSPropertyID);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 { 262 {
261 if (!derefBase()) 263 if (!derefBase())
262 return; 264 return;
263 265
264 if (m_isMutable) 266 if (m_isMutable)
265 delete toMutableStylePropertySet(this); 267 delete toMutableStylePropertySet(this);
266 else 268 else
267 delete toImmutableStylePropertySet(this); 269 delete toImmutableStylePropertySet(this);
268 } 270 }
269 271
272 inline int StylePropertySet::findPropertyIndex(CSSPropertyID propertyID) const
273 {
274 if (m_isMutable)
275 return toMutableStylePropertySet(this)->findPropertyIndex(propertyID);
276 return toImmutableStylePropertySet(this)->findPropertyIndex(propertyID);
277 }
278
270 } // namespace WebCore 279 } // namespace WebCore
271 280
272 #endif // StylePropertySet_h 281 #endif // StylePropertySet_h
OLDNEW
« no previous file with comments | « no previous file | Source/core/css/StylePropertySet.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698