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

Side by Side Diff: third_party/WebKit/Source/core/css/resolver/StyleResolver.h

Issue 2479373005: Use template parameter to reduce branching in style resolve apply passes (Closed)
Patch Set: Enum Created 4 years, 1 month 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 | third_party/WebKit/Source/core/css/resolver/StyleResolver.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 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. 3 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc.
4 * All rights reserved. 4 * All rights reserved.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 212
213 void applyMatchedProperties(StyleResolverState&, const MatchResult&); 213 void applyMatchedProperties(StyleResolverState&, const MatchResult&);
214 bool applyAnimatedProperties(StyleResolverState&, 214 bool applyAnimatedProperties(StyleResolverState&,
215 const Element* animatingElement); 215 const Element* animatingElement);
216 void applyCallbackSelectors(StyleResolverState&); 216 void applyCallbackSelectors(StyleResolverState&);
217 217
218 // These flags indicate whether an apply pass for a given CSSPropertyPriority 218 // These flags indicate whether an apply pass for a given CSSPropertyPriority
219 // and isImportant is required. 219 // and isImportant is required.
220 class NeedsApplyPass { 220 class NeedsApplyPass {
221 public: 221 public:
222 bool needsUpdate() const { return m_needsUpdate; }
223 bool setNeedsUpdate(bool needsUpdate) {
224 return m_needsUpdate = needsUpdate;
225 }
226 bool get(CSSPropertyPriority priority, bool isImportant) const { 222 bool get(CSSPropertyPriority priority, bool isImportant) const {
227 DCHECK(!needsUpdate());
228 return m_flags[getIndex(priority, isImportant)]; 223 return m_flags[getIndex(priority, isImportant)];
229 } 224 }
230 void set(CSSPropertyPriority priority, bool isImportant) { 225 void set(CSSPropertyPriority priority, bool isImportant) {
231 DCHECK(needsUpdate());
232 m_flags[getIndex(priority, isImportant)] = true; 226 m_flags[getIndex(priority, isImportant)] = true;
233 } 227 }
234 228
235 private: 229 private:
236 static size_t getIndex(CSSPropertyPriority priority, bool isImportant) { 230 static size_t getIndex(CSSPropertyPriority priority, bool isImportant) {
237 DCHECK(priority >= 0 && priority < PropertyPriorityCount); 231 DCHECK(priority >= 0 && priority < PropertyPriorityCount);
238 return priority * 2 + isImportant; 232 return priority * 2 + isImportant;
239 } 233 }
240 bool m_needsUpdate = true;
241 bool m_flags[PropertyPriorityCount * 2] = {0}; 234 bool m_flags[PropertyPriorityCount * 2] = {0};
242 }; 235 };
243 236
244 template <CSSPropertyPriority priority> 237 enum ShouldUpdateNeedsApplyPass {
238 CheckNeedsApplyPass = false,
239 UpdateNeedsApplyPass = true,
240 };
241
242 template <CSSPropertyPriority priority, ShouldUpdateNeedsApplyPass>
245 void applyMatchedProperties(StyleResolverState&, 243 void applyMatchedProperties(StyleResolverState&,
246 const MatchedPropertiesRange&, 244 const MatchedPropertiesRange&,
247 bool important, 245 bool important,
248 bool inheritedOnly, 246 bool inheritedOnly,
249 NeedsApplyPass&); 247 NeedsApplyPass&);
250 template <CSSPropertyPriority priority> 248 template <CSSPropertyPriority priority, ShouldUpdateNeedsApplyPass>
251 void applyProperties(StyleResolverState&, 249 void applyProperties(StyleResolverState&,
252 const StylePropertySet* properties, 250 const StylePropertySet* properties,
253 bool isImportant, 251 bool isImportant,
254 bool inheritedOnly, 252 bool inheritedOnly,
255 NeedsApplyPass&, 253 NeedsApplyPass&,
256 PropertyWhitelistType = PropertyWhitelistNone); 254 PropertyWhitelistType = PropertyWhitelistNone);
257 template <CSSPropertyPriority priority> 255 template <CSSPropertyPriority priority>
258 void applyAnimatedProperties(StyleResolverState&, 256 void applyAnimatedProperties(StyleResolverState&,
259 const ActiveInterpolationsMap&); 257 const ActiveInterpolationsMap&);
260 template <CSSPropertyPriority priority> 258 template <CSSPropertyPriority priority>
261 void applyAllProperty(StyleResolverState&, 259 void applyAllProperty(StyleResolverState&,
262 const CSSValue&, 260 const CSSValue&,
263 bool inheritedOnly, 261 bool inheritedOnly,
264 PropertyWhitelistType); 262 PropertyWhitelistType);
265 template <CSSPropertyPriority priority> 263 template <CSSPropertyPriority priority, ShouldUpdateNeedsApplyPass>
266 void applyPropertiesForApplyAtRule(StyleResolverState&, 264 void applyPropertiesForApplyAtRule(StyleResolverState&,
267 const CSSValue&, 265 const CSSValue&,
268 bool isImportant, 266 bool isImportant,
269 NeedsApplyPass&, 267 NeedsApplyPass&,
270 PropertyWhitelistType); 268 PropertyWhitelistType);
271 269
272 bool pseudoStyleForElementInternal(Element&, 270 bool pseudoStyleForElementInternal(Element&,
273 const PseudoStyleRequest&, 271 const PseudoStyleRequest&,
274 const ComputedStyle* parentStyle, 272 const ComputedStyle* parentStyle,
275 StyleResolverState&); 273 StyleResolverState&);
(...skipping 22 matching lines...) Expand all
298 bool m_printMediaType; 296 bool m_printMediaType;
299 297
300 unsigned m_styleSharingDepth; 298 unsigned m_styleSharingDepth;
301 HeapVector<Member<StyleSharingList>, styleSharingMaxDepth> 299 HeapVector<Member<StyleSharingList>, styleSharingMaxDepth>
302 m_styleSharingLists; 300 m_styleSharingLists;
303 }; 301 };
304 302
305 } // namespace blink 303 } // namespace blink
306 304
307 #endif // StyleResolver_h 305 #endif // StyleResolver_h
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/css/resolver/StyleResolver.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698