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

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

Issue 1686483002: Oilpan: Remove most WillBe types from the code base (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 public: 57 public:
58 MinimalRuleData(StyleRule* rule, unsigned selectorIndex, AddRuleFlags flags) 58 MinimalRuleData(StyleRule* rule, unsigned selectorIndex, AddRuleFlags flags)
59 : m_rule(rule) 59 : m_rule(rule)
60 , m_selectorIndex(selectorIndex) 60 , m_selectorIndex(selectorIndex)
61 , m_flags(flags) 61 , m_flags(flags)
62 { 62 {
63 } 63 }
64 64
65 DECLARE_TRACE(); 65 DECLARE_TRACE();
66 66
67 RawPtrWillBeMember<StyleRule> m_rule; 67 Member<StyleRule> m_rule;
68 unsigned m_selectorIndex; 68 unsigned m_selectorIndex;
69 AddRuleFlags m_flags; 69 AddRuleFlags m_flags;
70 }; 70 };
71 71
72 class CORE_EXPORT RuleData { 72 class CORE_EXPORT RuleData {
73 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); 73 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW();
74 public: 74 public:
75 RuleData(StyleRule*, unsigned selectorIndex, unsigned position, AddRuleFlags ); 75 RuleData(StyleRule*, unsigned selectorIndex, unsigned position, AddRuleFlags );
76 76
77 unsigned position() const { return m_position; } 77 unsigned position() const { return m_position; }
78 StyleRule* rule() const { return m_rule; } 78 StyleRule* rule() const { return m_rule; }
79 const CSSSelector& selector() const { return m_rule->selectorList().selector At(m_selectorIndex); } 79 const CSSSelector& selector() const { return m_rule->selectorList().selector At(m_selectorIndex); }
80 unsigned selectorIndex() const { return m_selectorIndex; } 80 unsigned selectorIndex() const { return m_selectorIndex; }
81 81
82 bool isLastInArray() const { return m_isLastInArray; } 82 bool isLastInArray() const { return m_isLastInArray; }
83 void setLastInArray(bool flag) { m_isLastInArray = flag; } 83 void setLastInArray(bool flag) { m_isLastInArray = flag; }
84 84
85 bool containsUncommonAttributeSelector() const { return m_containsUncommonAt tributeSelector; } 85 bool containsUncommonAttributeSelector() const { return m_containsUncommonAt tributeSelector; }
86 unsigned specificity() const { return m_specificity; } 86 unsigned specificity() const { return m_specificity; }
87 unsigned linkMatchType() const { return m_linkMatchType; } 87 unsigned linkMatchType() const { return m_linkMatchType; }
88 bool hasDocumentSecurityOrigin() const { return m_hasDocumentSecurityOrigin; } 88 bool hasDocumentSecurityOrigin() const { return m_hasDocumentSecurityOrigin; }
89 PropertyWhitelistType propertyWhitelistType(bool isMatchingUARules = false) const { return isMatchingUARules ? PropertyWhitelistNone : static_cast<PropertyW hitelistType>(m_propertyWhitelistType); } 89 PropertyWhitelistType propertyWhitelistType(bool isMatchingUARules = false) const { return isMatchingUARules ? PropertyWhitelistNone : static_cast<PropertyW hitelistType>(m_propertyWhitelistType); }
90 // Try to balance between memory usage (there can be lots of RuleData object s) and good filtering performance. 90 // Try to balance between memory usage (there can be lots of RuleData object s) and good filtering performance.
91 static const unsigned maximumIdentifierCount = 4; 91 static const unsigned maximumIdentifierCount = 4;
92 const unsigned* descendantSelectorIdentifierHashes() const { return m_descen dantSelectorIdentifierHashes; } 92 const unsigned* descendantSelectorIdentifierHashes() const { return m_descen dantSelectorIdentifierHashes; }
93 93
94 DECLARE_TRACE(); 94 DECLARE_TRACE();
95 95
96 private: 96 private:
97 RawPtrWillBeMember<StyleRule> m_rule; 97 Member<StyleRule> m_rule;
98 unsigned m_selectorIndex : 13; 98 unsigned m_selectorIndex : 13;
99 unsigned m_isLastInArray : 1; // We store an array of RuleData objects in a primitive array. 99 unsigned m_isLastInArray : 1; // We store an array of RuleData objects in a primitive array.
100 // This number was picked fairly arbitrarily. We can probably lower it if we need to. 100 // This number was picked fairly arbitrarily. We can probably lower it if we need to.
101 // Some simple testing showed <100,000 RuleData's on large sites. 101 // Some simple testing showed <100,000 RuleData's on large sites.
102 unsigned m_position : 18; 102 unsigned m_position : 18;
103 unsigned m_specificity : 24; 103 unsigned m_specificity : 24;
104 unsigned m_containsUncommonAttributeSelector : 1; 104 unsigned m_containsUncommonAttributeSelector : 1;
105 unsigned m_linkMatchType : 2; // CSSSelector::LinkMatchMask 105 unsigned m_linkMatchType : 2; // CSSSelector::LinkMatchMask
106 unsigned m_hasDocumentSecurityOrigin : 1; 106 unsigned m_hasDocumentSecurityOrigin : 1;
107 unsigned m_propertyWhitelistType : 2; 107 unsigned m_propertyWhitelistType : 2;
108 // Use plain array instead of a Vector to minimize memory overhead. 108 // Use plain array instead of a Vector to minimize memory overhead.
109 unsigned m_descendantSelectorIdentifierHashes[maximumIdentifierCount]; 109 unsigned m_descendantSelectorIdentifierHashes[maximumIdentifierCount];
110 }; 110 };
111 111
112 struct SameSizeAsRuleData { 112 struct SameSizeAsRuleData {
113 DISALLOW_NEW(); 113 DISALLOW_NEW();
114 RawPtrWillBeMember<void*> a; 114 Member<void*> a;
115 unsigned b; 115 unsigned b;
116 unsigned c; 116 unsigned c;
117 unsigned d[4]; 117 unsigned d[4];
118 }; 118 };
119 119
120 static_assert(sizeof(RuleData) == sizeof(SameSizeAsRuleData), "RuleData should s tay small"); 120 static_assert(sizeof(RuleData) == sizeof(SameSizeAsRuleData), "RuleData should s tay small");
121 121
122 class CORE_EXPORT RuleSet : public NoBaseWillBeGarbageCollectedFinalized<RuleSet > { 122 class CORE_EXPORT RuleSet : public GarbageCollectedFinalized<RuleSet> {
123 WTF_MAKE_NONCOPYABLE(RuleSet); 123 WTF_MAKE_NONCOPYABLE(RuleSet);
124 USING_FAST_MALLOC_WILL_BE_REMOVED(RuleSet);
125 public: 124 public:
126 static PassOwnPtrWillBeRawPtr<RuleSet> create() { return adoptPtrWillBeNoop( new RuleSet); } 125 static RawPtr<RuleSet> create() { return (new RuleSet); }
127 126
128 void addRulesFromSheet(StyleSheetContents*, const MediaQueryEvaluator&, AddR uleFlags = RuleHasNoSpecialState); 127 void addRulesFromSheet(StyleSheetContents*, const MediaQueryEvaluator&, AddR uleFlags = RuleHasNoSpecialState);
129 void addStyleRule(StyleRule*, AddRuleFlags); 128 void addStyleRule(StyleRule*, AddRuleFlags);
130 void addRule(StyleRule*, unsigned selectorIndex, AddRuleFlags); 129 void addRule(StyleRule*, unsigned selectorIndex, AddRuleFlags);
131 130
132 const RuleFeatureSet& features() const { return m_features; } 131 const RuleFeatureSet& features() const { return m_features; }
133 132
134 const WillBeHeapTerminatedArray<RuleData>* idRules(const AtomicString& key) const { ASSERT(!m_pendingRules); return m_idRules.get(key); } 133 const HeapTerminatedArray<RuleData>* idRules(const AtomicString& key) const { ASSERT(!m_pendingRules); return m_idRules.get(key); }
135 const WillBeHeapTerminatedArray<RuleData>* classRules(const AtomicString& ke y) const { ASSERT(!m_pendingRules); return m_classRules.get(key); } 134 const HeapTerminatedArray<RuleData>* classRules(const AtomicString& key) con st { ASSERT(!m_pendingRules); return m_classRules.get(key); }
136 const WillBeHeapTerminatedArray<RuleData>* tagRules(const AtomicString& key) const { ASSERT(!m_pendingRules); return m_tagRules.get(key); } 135 const HeapTerminatedArray<RuleData>* tagRules(const AtomicString& key) const { ASSERT(!m_pendingRules); return m_tagRules.get(key); }
137 const WillBeHeapTerminatedArray<RuleData>* shadowPseudoElementRules(const At omicString& key) const { ASSERT(!m_pendingRules); return m_shadowPseudoElementRu les.get(key); } 136 const HeapTerminatedArray<RuleData>* shadowPseudoElementRules(const AtomicSt ring& key) const { ASSERT(!m_pendingRules); return m_shadowPseudoElementRules.ge t(key); }
138 const WillBeHeapVector<RuleData>* linkPseudoClassRules() const { ASSERT(!m_p endingRules); return &m_linkPseudoClassRules; } 137 const HeapVector<RuleData>* linkPseudoClassRules() const { ASSERT(!m_pending Rules); return &m_linkPseudoClassRules; }
139 const WillBeHeapVector<RuleData>* cuePseudoRules() const { ASSERT(!m_pending Rules); return &m_cuePseudoRules; } 138 const HeapVector<RuleData>* cuePseudoRules() const { ASSERT(!m_pendingRules) ; return &m_cuePseudoRules; }
140 const WillBeHeapVector<RuleData>* focusPseudoClassRules() const { ASSERT(!m_ pendingRules); return &m_focusPseudoClassRules; } 139 const HeapVector<RuleData>* focusPseudoClassRules() const { ASSERT(!m_pendin gRules); return &m_focusPseudoClassRules; }
141 const WillBeHeapVector<RuleData>* universalRules() const { ASSERT(!m_pending Rules); return &m_universalRules; } 140 const HeapVector<RuleData>* universalRules() const { ASSERT(!m_pendingRules) ; return &m_universalRules; }
142 const WillBeHeapVector<RuleData>* shadowHostRules() const { ASSERT(!m_pendin gRules); return &m_shadowHostRules; } 141 const HeapVector<RuleData>* shadowHostRules() const { ASSERT(!m_pendingRules ); return &m_shadowHostRules; }
143 const WillBeHeapVector<RawPtrWillBeMember<StyleRulePage>>& pageRules() const { ASSERT(!m_pendingRules); return m_pageRules; } 142 const HeapVector<Member<StyleRulePage>>& pageRules() const { ASSERT(!m_pendi ngRules); return m_pageRules; }
144 const WillBeHeapVector<RawPtrWillBeMember<StyleRuleViewport>>& viewportRules () const { ASSERT(!m_pendingRules); return m_viewportRules; } 143 const HeapVector<Member<StyleRuleViewport>>& viewportRules() const { ASSERT( !m_pendingRules); return m_viewportRules; }
145 const WillBeHeapVector<RawPtrWillBeMember<StyleRuleFontFace>>& fontFaceRules () const { return m_fontFaceRules; } 144 const HeapVector<Member<StyleRuleFontFace>>& fontFaceRules() const { return m_fontFaceRules; }
146 const WillBeHeapVector<RawPtrWillBeMember<StyleRuleKeyframes>>& keyframesRul es() const { return m_keyframesRules; } 145 const HeapVector<Member<StyleRuleKeyframes>>& keyframesRules() const { retur n m_keyframesRules; }
147 const WillBeHeapVector<MinimalRuleData>& deepCombinatorOrShadowPseudoRules() const { return m_deepCombinatorOrShadowPseudoRules; } 146 const HeapVector<MinimalRuleData>& deepCombinatorOrShadowPseudoRules() const { return m_deepCombinatorOrShadowPseudoRules; }
148 const WillBeHeapVector<MinimalRuleData>& contentPseudoElementRules() const { return m_contentPseudoElementRules; } 147 const HeapVector<MinimalRuleData>& contentPseudoElementRules() const { retur n m_contentPseudoElementRules; }
149 const WillBeHeapVector<MinimalRuleData>& slottedPseudoElementRules() const { return m_slottedPseudoElementRules; } 148 const HeapVector<MinimalRuleData>& slottedPseudoElementRules() const { retur n m_slottedPseudoElementRules; }
150 const MediaQueryResultList& viewportDependentMediaQueryResults() const { ret urn m_viewportDependentMediaQueryResults; } 149 const MediaQueryResultList& viewportDependentMediaQueryResults() const { ret urn m_viewportDependentMediaQueryResults; }
151 const MediaQueryResultList& deviceDependentMediaQueryResults() const { retur n m_deviceDependentMediaQueryResults; } 150 const MediaQueryResultList& deviceDependentMediaQueryResults() const { retur n m_deviceDependentMediaQueryResults; }
152 151
153 unsigned ruleCount() const { return m_ruleCount; } 152 unsigned ruleCount() const { return m_ruleCount; }
154 153
155 void compactRulesIfNeeded() 154 void compactRulesIfNeeded()
156 { 155 {
157 if (!m_pendingRules) 156 if (!m_pendingRules)
158 return; 157 return;
159 compactRules(); 158 compactRules();
160 } 159 }
161 160
162 #ifndef NDEBUG 161 #ifndef NDEBUG
163 void show() const; 162 void show() const;
164 #endif 163 #endif
165 164
166 DECLARE_TRACE(); 165 DECLARE_TRACE();
167 166
168 private: 167 private:
169 using PendingRuleMap = WillBeHeapHashMap<AtomicString, OwnPtrWillBeMember<Wi llBeHeapLinkedStack<RuleData>>>; 168 using PendingRuleMap = HeapHashMap<AtomicString, Member<HeapLinkedStack<Rule Data>>>;
170 using CompactRuleMap = WillBeHeapHashMap<AtomicString, OwnPtrWillBeMember<Wi llBeHeapTerminatedArray<RuleData>>>; 169 using CompactRuleMap = HeapHashMap<AtomicString, Member<HeapTerminatedArray< RuleData>>>;
171 170
172 RuleSet() 171 RuleSet()
173 : m_ruleCount(0) 172 : m_ruleCount(0)
174 { 173 {
175 } 174 }
176 175
177 void addToRuleSet(const AtomicString& key, PendingRuleMap&, const RuleData&) ; 176 void addToRuleSet(const AtomicString& key, PendingRuleMap&, const RuleData&) ;
178 void addPageRule(StyleRulePage*); 177 void addPageRule(StyleRulePage*);
179 void addViewportRule(StyleRuleViewport*); 178 void addViewportRule(StyleRuleViewport*);
180 void addFontFaceRule(StyleRuleFontFace*); 179 void addFontFaceRule(StyleRuleFontFace*);
181 void addKeyframesRule(StyleRuleKeyframes*); 180 void addKeyframesRule(StyleRuleKeyframes*);
182 181
183 void addChildRules(const WillBeHeapVector<RefPtrWillBeMember<StyleRuleBase>> &, const MediaQueryEvaluator& medium, AddRuleFlags); 182 void addChildRules(const HeapVector<Member<StyleRuleBase>>&, const MediaQuer yEvaluator& medium, AddRuleFlags);
184 bool findBestRuleSetAndAdd(const CSSSelector&, RuleData&); 183 bool findBestRuleSetAndAdd(const CSSSelector&, RuleData&);
185 184
186 void compactRules(); 185 void compactRules();
187 static void compactPendingRules(PendingRuleMap&, CompactRuleMap&); 186 static void compactPendingRules(PendingRuleMap&, CompactRuleMap&);
188 187
189 class PendingRuleMaps : public NoBaseWillBeGarbageCollected<PendingRuleMaps> { 188 class PendingRuleMaps : public GarbageCollected<PendingRuleMaps> {
190 public: 189 public:
191 static PassOwnPtrWillBeRawPtr<PendingRuleMaps> create() { return adoptPt rWillBeNoop(new PendingRuleMaps); } 190 static RawPtr<PendingRuleMaps> create() { return (new PendingRuleMaps); }
192 191
193 PendingRuleMap idRules; 192 PendingRuleMap idRules;
194 PendingRuleMap classRules; 193 PendingRuleMap classRules;
195 PendingRuleMap tagRules; 194 PendingRuleMap tagRules;
196 PendingRuleMap shadowPseudoElementRules; 195 PendingRuleMap shadowPseudoElementRules;
197 196
198 DECLARE_TRACE(); 197 DECLARE_TRACE();
199 198
200 private: 199 private:
201 PendingRuleMaps() { } 200 PendingRuleMaps() { }
202 }; 201 };
203 202
204 PendingRuleMaps* ensurePendingRules() 203 PendingRuleMaps* ensurePendingRules()
205 { 204 {
206 if (!m_pendingRules) 205 if (!m_pendingRules)
207 m_pendingRules = PendingRuleMaps::create(); 206 m_pendingRules = PendingRuleMaps::create();
208 return m_pendingRules.get(); 207 return m_pendingRules.get();
209 } 208 }
210 209
211 CompactRuleMap m_idRules; 210 CompactRuleMap m_idRules;
212 CompactRuleMap m_classRules; 211 CompactRuleMap m_classRules;
213 CompactRuleMap m_tagRules; 212 CompactRuleMap m_tagRules;
214 CompactRuleMap m_shadowPseudoElementRules; 213 CompactRuleMap m_shadowPseudoElementRules;
215 WillBeHeapVector<RuleData> m_linkPseudoClassRules; 214 HeapVector<RuleData> m_linkPseudoClassRules;
216 WillBeHeapVector<RuleData> m_cuePseudoRules; 215 HeapVector<RuleData> m_cuePseudoRules;
217 WillBeHeapVector<RuleData> m_focusPseudoClassRules; 216 HeapVector<RuleData> m_focusPseudoClassRules;
218 WillBeHeapVector<RuleData> m_universalRules; 217 HeapVector<RuleData> m_universalRules;
219 WillBeHeapVector<RuleData> m_shadowHostRules; 218 HeapVector<RuleData> m_shadowHostRules;
220 RuleFeatureSet m_features; 219 RuleFeatureSet m_features;
221 WillBeHeapVector<RawPtrWillBeMember<StyleRulePage>> m_pageRules; 220 HeapVector<Member<StyleRulePage>> m_pageRules;
222 WillBeHeapVector<RawPtrWillBeMember<StyleRuleViewport>> m_viewportRules; 221 HeapVector<Member<StyleRuleViewport>> m_viewportRules;
223 WillBeHeapVector<RawPtrWillBeMember<StyleRuleFontFace>> m_fontFaceRules; 222 HeapVector<Member<StyleRuleFontFace>> m_fontFaceRules;
224 WillBeHeapVector<RawPtrWillBeMember<StyleRuleKeyframes>> m_keyframesRules; 223 HeapVector<Member<StyleRuleKeyframes>> m_keyframesRules;
225 WillBeHeapVector<MinimalRuleData> m_deepCombinatorOrShadowPseudoRules; 224 HeapVector<MinimalRuleData> m_deepCombinatorOrShadowPseudoRules;
226 WillBeHeapVector<MinimalRuleData> m_contentPseudoElementRules; 225 HeapVector<MinimalRuleData> m_contentPseudoElementRules;
227 WillBeHeapVector<MinimalRuleData> m_slottedPseudoElementRules; 226 HeapVector<MinimalRuleData> m_slottedPseudoElementRules;
228 227
229 MediaQueryResultList m_viewportDependentMediaQueryResults; 228 MediaQueryResultList m_viewportDependentMediaQueryResults;
230 MediaQueryResultList m_deviceDependentMediaQueryResults; 229 MediaQueryResultList m_deviceDependentMediaQueryResults;
231 230
232 unsigned m_ruleCount; 231 unsigned m_ruleCount;
233 OwnPtrWillBeMember<PendingRuleMaps> m_pendingRules; 232 Member<PendingRuleMaps> m_pendingRules;
234 233
235 #ifndef NDEBUG 234 #ifndef NDEBUG
236 WillBeHeapVector<RuleData> m_allRules; 235 HeapVector<RuleData> m_allRules;
237 #endif 236 #endif
238 }; 237 };
239 238
240 } // namespace blink 239 } // namespace blink
241 240
242 WTF_ALLOW_MOVE_AND_INIT_WITH_MEM_FUNCTIONS(blink::RuleData); 241 WTF_ALLOW_MOVE_AND_INIT_WITH_MEM_FUNCTIONS(blink::RuleData);
243 WTF_ALLOW_MOVE_AND_INIT_WITH_MEM_FUNCTIONS(blink::MinimalRuleData); 242 WTF_ALLOW_MOVE_AND_INIT_WITH_MEM_FUNCTIONS(blink::MinimalRuleData);
244 243
245 #endif // RuleSet_h 244 #endif // RuleSet_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698