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

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

Issue 42543007: StyleResolver should update RuleSets lazily. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebased Created 7 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 | Annotate | Revision Log
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. All rights reserved. 3 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 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 18 matching lines...) Expand all
29 #include "wtf/HashMap.h" 29 #include "wtf/HashMap.h"
30 #include "wtf/LinkedStack.h" 30 #include "wtf/LinkedStack.h"
31 31
32 namespace WebCore { 32 namespace WebCore {
33 33
34 enum AddRuleFlags { 34 enum AddRuleFlags {
35 RuleHasNoSpecialState = 0, 35 RuleHasNoSpecialState = 0,
36 RuleHasDocumentSecurityOrigin = 1, 36 RuleHasDocumentSecurityOrigin = 1,
37 RuleCanUseFastCheckSelector = 1 << 1, 37 RuleCanUseFastCheckSelector = 1 << 1,
38 RuleIsInRegionRule = 1 << 2, 38 RuleIsInRegionRule = 1 << 2,
39 ViewportRuleIsProcessed = 1 << 3
39 }; 40 };
40 41
41 enum PropertyWhitelistType { 42 enum PropertyWhitelistType {
42 PropertyWhitelistNone = 0, 43 PropertyWhitelistNone = 0,
43 PropertyWhitelistRegion, 44 PropertyWhitelistRegion,
44 PropertyWhitelistCue 45 PropertyWhitelistCue
45 }; 46 };
46 47
47 class CSSSelector; 48 class CSSSelector;
48 class ContainerNode; 49 class ContainerNode;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 unsigned d[4]; 103 unsigned d[4];
103 }; 104 };
104 105
105 COMPILE_ASSERT(sizeof(RuleData) == sizeof(SameSizeAsRuleData), RuleData_should_s tay_small); 106 COMPILE_ASSERT(sizeof(RuleData) == sizeof(SameSizeAsRuleData), RuleData_should_s tay_small);
106 107
107 class RuleSet { 108 class RuleSet {
108 WTF_MAKE_NONCOPYABLE(RuleSet); WTF_MAKE_FAST_ALLOCATED; 109 WTF_MAKE_NONCOPYABLE(RuleSet); WTF_MAKE_FAST_ALLOCATED;
109 public: 110 public:
110 static PassOwnPtr<RuleSet> create() { return adoptPtr(new RuleSet); } 111 static PassOwnPtr<RuleSet> create() { return adoptPtr(new RuleSet); }
111 112
112 void addRulesFromSheet(StyleSheetContents*, const MediaQueryEvaluator&, Styl eResolver* = 0, const ContainerNode* = 0); 113 void addRulesFromSheet(StyleSheetContents*, const MediaQueryEvaluator&, Styl eResolver* = 0, const ContainerNode* = 0, bool viewportRuleIsProcessed = false);
dglazkov 2013/11/13 16:29:22 Let's avoid bools as params. Enums are teh cool.
tasak 2013/11/14 11:25:46 Done.
113 void addStyleRule(StyleRule*, AddRuleFlags); 114 void addStyleRule(StyleRule*, AddRuleFlags);
114 void addRule(StyleRule*, unsigned selectorIndex, AddRuleFlags); 115 void addRule(StyleRule*, unsigned selectorIndex, AddRuleFlags);
116 void addViewportRule(StyleRuleViewport*);
115 117
116 const RuleFeatureSet& features() const { return m_features; } 118 const RuleFeatureSet& features() const { return m_features; }
117 119
118 const RuleData* idRules(StringImpl* key) const { ASSERT(!m_pendingRules); re turn m_idRules.get(key); } 120 const RuleData* idRules(StringImpl* key) const { ASSERT(!m_pendingRules); re turn m_idRules.get(key); }
119 const RuleData* classRules(StringImpl* key) const { ASSERT(!m_pendingRules); return m_classRules.get(key); } 121 const RuleData* classRules(StringImpl* key) const { ASSERT(!m_pendingRules); return m_classRules.get(key); }
120 const RuleData* tagRules(StringImpl* key) const { ASSERT(!m_pendingRules); r eturn m_tagRules.get(key); } 122 const RuleData* tagRules(StringImpl* key) const { ASSERT(!m_pendingRules); r eturn m_tagRules.get(key); }
121 const RuleData* shadowPseudoElementRules(StringImpl* key) const { ASSERT(!m_ pendingRules); return m_shadowPseudoElementRules.get(key); } 123 const RuleData* shadowPseudoElementRules(StringImpl* key) const { ASSERT(!m_ pendingRules); return m_shadowPseudoElementRules.get(key); }
122 const Vector<RuleData>* linkPseudoClassRules() const { ASSERT(!m_pendingRule s); return &m_linkPseudoClassRules; } 124 const Vector<RuleData>* linkPseudoClassRules() const { ASSERT(!m_pendingRule s); return &m_linkPseudoClassRules; }
123 const Vector<RuleData>* cuePseudoRules() const { ASSERT(!m_pendingRules); re turn &m_cuePseudoRules; } 125 const Vector<RuleData>* cuePseudoRules() const { ASSERT(!m_pendingRules); re turn &m_cuePseudoRules; }
124 const Vector<RuleData>* focusPseudoClassRules() const { ASSERT(!m_pendingRul es); return &m_focusPseudoClassRules; } 126 const Vector<RuleData>* focusPseudoClassRules() const { ASSERT(!m_pendingRul es); return &m_focusPseudoClassRules; }
(...skipping 27 matching lines...) Expand all
152 typedef HashMap<StringImpl*, OwnPtr<LinkedStack<RuleData> > > PendingRuleMap ; 154 typedef HashMap<StringImpl*, OwnPtr<LinkedStack<RuleData> > > PendingRuleMap ;
153 typedef HashMap<StringImpl*, OwnPtr<RuleData> > CompactRuleMap; 155 typedef HashMap<StringImpl*, OwnPtr<RuleData> > CompactRuleMap;
154 156
155 RuleSet() 157 RuleSet()
156 : m_ruleCount(0) 158 : m_ruleCount(0)
157 { 159 {
158 } 160 }
159 161
160 void addToRuleSet(StringImpl* key, PendingRuleMap&, const RuleData&); 162 void addToRuleSet(StringImpl* key, PendingRuleMap&, const RuleData&);
161 void addPageRule(StyleRulePage*); 163 void addPageRule(StyleRulePage*);
162 void addViewportRule(StyleRuleViewport*);
163 void addFontFaceRule(StyleRuleFontFace*); 164 void addFontFaceRule(StyleRuleFontFace*);
164 void addKeyframesRule(StyleRuleKeyframes*); 165 void addKeyframesRule(StyleRuleKeyframes*);
165 void addHostRule(StyleRuleHost*); 166 void addHostRule(StyleRuleHost*);
166 void addRegionRule(StyleRuleRegion*, bool hasDocumentSecurityOrigin); 167 void addRegionRule(StyleRuleRegion*, bool hasDocumentSecurityOrigin);
167 168
168 void addChildRules(const Vector<RefPtr<StyleRuleBase> >&, const MediaQueryEv aluator& medium, StyleResolver*, const ContainerNode* scope, bool hasDocumentSec urityOrigin, AddRuleFlags); 169 void addChildRules(const Vector<RefPtr<StyleRuleBase> >&, const MediaQueryEv aluator& medium, StyleResolver*, const ContainerNode* scope, bool hasDocumentSec urityOrigin, AddRuleFlags);
169 bool findBestRuleSetAndAdd(const CSSSelector*, RuleData&); 170 bool findBestRuleSetAndAdd(const CSSSelector*, RuleData&);
170 171
171 void compactRules(); 172 void compactRules();
172 static void compactPendingRules(PendingRuleMap&, CompactRuleMap&); 173 static void compactPendingRules(PendingRuleMap&, CompactRuleMap&);
(...skipping 27 matching lines...) Expand all
200 Vector<StyleRuleKeyframes*> m_keyframesRules; 201 Vector<StyleRuleKeyframes*> m_keyframesRules;
201 Vector<StyleRuleHost*> m_hostRules; 202 Vector<StyleRuleHost*> m_hostRules;
202 203
203 unsigned m_ruleCount; 204 unsigned m_ruleCount;
204 OwnPtr<PendingRuleMaps> m_pendingRules; 205 OwnPtr<PendingRuleMaps> m_pendingRules;
205 }; 206 };
206 207
207 } // namespace WebCore 208 } // namespace WebCore
208 209
209 #endif // RuleSet_h 210 #endif // RuleSet_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698