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

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

Issue 1111643003: Move StyleInvalidator to StyleEngine. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Avoid calling ensureUpdatedRuleFeatureSet multiple times Created 5 years, 7 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
« no previous file with comments | « no previous file | Source/core/css/RuleFeature.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. 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,
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 21
22 #ifndef RuleFeature_h 22 #ifndef RuleFeature_h
23 #define RuleFeature_h 23 #define RuleFeature_h
24 24
25 #include "core/CoreExport.h" 25 #include "core/CoreExport.h"
26 #include "core/css/CSSSelector.h" 26 #include "core/css/CSSSelector.h"
27 #include "core/css/invalidation/DescendantInvalidationSet.h" 27 #include "core/css/invalidation/DescendantInvalidationSet.h"
28 #include "core/css/invalidation/StyleInvalidator.h"
29 #include "wtf/Forward.h" 28 #include "wtf/Forward.h"
30 #include "wtf/HashSet.h" 29 #include "wtf/HashSet.h"
31 #include "wtf/text/AtomicStringHash.h" 30 #include "wtf/text/AtomicStringHash.h"
32 31
33 namespace blink { 32 namespace blink {
34 33
35 class QualifiedName; 34 class QualifiedName;
36 class RuleData; 35 class RuleData;
37 class SpaceSplitString; 36 class SpaceSplitString;
38 class StyleRule; 37 class StyleRule;
39 38
40 struct RuleFeature { 39 struct RuleFeature {
41 ALLOW_ONLY_INLINE_ALLOCATION(); 40 ALLOW_ONLY_INLINE_ALLOCATION();
42 public: 41 public:
43 RuleFeature(StyleRule* rule, unsigned selectorIndex, bool hasDocumentSecurit yOrigin); 42 RuleFeature(StyleRule* rule, unsigned selectorIndex, bool hasDocumentSecurit yOrigin);
44 43
45 DECLARE_TRACE(); 44 DECLARE_TRACE();
46 45
47 RawPtrWillBeMember<StyleRule> rule; 46 RawPtrWillBeMember<StyleRule> rule;
48 unsigned selectorIndex; 47 unsigned selectorIndex;
49 bool hasDocumentSecurityOrigin; 48 bool hasDocumentSecurityOrigin;
50 }; 49 };
51 50
51 using InvalidationSetVector = WillBeHeapVector<RefPtrWillBeMember<DescendantInva lidationSet>, 8>;
52
52 class CORE_EXPORT RuleFeatureSet { 53 class CORE_EXPORT RuleFeatureSet {
53 DISALLOW_ALLOCATION(); 54 DISALLOW_ALLOCATION();
54 public: 55 public:
55 RuleFeatureSet(); 56 RuleFeatureSet();
56 ~RuleFeatureSet(); 57 ~RuleFeatureSet();
57 58
58 void add(const RuleFeatureSet&); 59 void add(const RuleFeatureSet&);
59 void clear(); 60 void clear();
60 61
61 void collectFeaturesFromRuleData(const RuleData&); 62 void collectFeaturesFromRuleData(const RuleData&);
(...skipping 13 matching lines...) Expand all
75 76
76 bool hasSelectorForClass(const AtomicString& classValue) const 77 bool hasSelectorForClass(const AtomicString& classValue) const
77 { 78 {
78 ASSERT(!classValue.isEmpty()); 79 ASSERT(!classValue.isEmpty());
79 return m_classInvalidationSets.contains(classValue); 80 return m_classInvalidationSets.contains(classValue);
80 } 81 }
81 82
82 bool hasSelectorForId(const AtomicString& idValue) const { return m_idInvali dationSets.contains(idValue); } 83 bool hasSelectorForId(const AtomicString& idValue) const { return m_idInvali dationSets.contains(idValue); }
83 bool hasSelectorForPseudoType(CSSSelector::PseudoType pseudo) const { return m_pseudoInvalidationSets.contains(pseudo); } 84 bool hasSelectorForPseudoType(CSSSelector::PseudoType pseudo) const { return m_pseudoInvalidationSets.contains(pseudo); }
84 85
85 void scheduleStyleInvalidationForClassChange(const SpaceSplitString& changed Classes, Element&); 86 void collectInvalidationSetsForClass(InvalidationSetVector&, Element&, const AtomicString& className) const;
86 void scheduleStyleInvalidationForClassChange(const SpaceSplitString& oldClas ses, const SpaceSplitString& newClasses, Element&); 87 void collectInvalidationSetsForId(InvalidationSetVector&, Element&, const At omicString& id) const;
87 void scheduleStyleInvalidationForAttributeChange(const QualifiedName& attrib uteName, Element&); 88 void collectInvalidationSetsForAttribute(InvalidationSetVector&, Element&, c onst QualifiedName& attributeName) const;
88 void scheduleStyleInvalidationForIdChange(const AtomicString& oldId, const A tomicString& newId, Element&); 89 void collectInvalidationSetsForPseudoClass(InvalidationSetVector&, Element&, CSSSelector::PseudoType) const;
89 void scheduleStyleInvalidationForPseudoChange(CSSSelector::PseudoType, Eleme nt&);
90 90
91 bool hasIdsInSelectors() const 91 bool hasIdsInSelectors() const
92 { 92 {
93 return m_idInvalidationSets.size() > 0; 93 return m_idInvalidationSets.size() > 0;
94 } 94 }
95 95
96 StyleInvalidator& styleInvalidator();
97
98 DECLARE_TRACE(); 96 DECLARE_TRACE();
99 97
100 WillBeHeapVector<RuleFeature> siblingRules; 98 WillBeHeapVector<RuleFeature> siblingRules;
101 WillBeHeapVector<RuleFeature> uncommonAttributeRules; 99 WillBeHeapVector<RuleFeature> uncommonAttributeRules;
102 100
103 protected: 101 protected:
104 DescendantInvalidationSet* invalidationSetForSelector(const CSSSelector&); 102 DescendantInvalidationSet* invalidationSetForSelector(const CSSSelector&);
105 103
106 private: 104 private:
107 typedef WillBeHeapHashMap<AtomicString, RefPtrWillBeMember<DescendantInvalid ationSet>> InvalidationSetMap; 105 using InvalidationSetMap = WillBeHeapHashMap<AtomicString, RefPtrWillBeMembe r<DescendantInvalidationSet>>;
108 typedef WillBeHeapHashMap<CSSSelector::PseudoType, RefPtrWillBeMember<Descen dantInvalidationSet>, WTF::IntHash<unsigned>, WTF::UnsignedWithZeroKeyHashTraits <unsigned>> PseudoTypeInvalidationSetMap; 106 using PseudoTypeInvalidationSetMap = WillBeHeapHashMap<CSSSelector::PseudoTy pe, RefPtrWillBeMember<DescendantInvalidationSet>, WTF::IntHash<unsigned>, WTF:: UnsignedWithZeroKeyHashTraits<unsigned>>;
109 107
110 struct FeatureMetadata { 108 struct FeatureMetadata {
111 FeatureMetadata() 109 FeatureMetadata()
112 : usesFirstLineRules(false) 110 : usesFirstLineRules(false)
113 , usesWindowInactiveSelector(false) 111 , usesWindowInactiveSelector(false)
114 , foundSiblingSelector(false) 112 , foundSiblingSelector(false)
115 , maxDirectAdjacentSelectors(0) 113 , maxDirectAdjacentSelectors(0)
116 { } 114 { }
117 void add(const FeatureMetadata& other); 115 void add(const FeatureMetadata& other);
118 void clear(); 116 void clear();
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 void addFeaturesToInvalidationSet(DescendantInvalidationSet&, const Invalida tionSetFeatures&); 164 void addFeaturesToInvalidationSet(DescendantInvalidationSet&, const Invalida tionSetFeatures&);
167 void addFeaturesToInvalidationSets(const CSSSelector&, InvalidationSetFeatur es&); 165 void addFeaturesToInvalidationSets(const CSSSelector&, InvalidationSetFeatur es&);
168 166
169 void addClassToInvalidationSet(const AtomicString& className, Element&); 167 void addClassToInvalidationSet(const AtomicString& className, Element&);
170 168
171 FeatureMetadata m_metadata; 169 FeatureMetadata m_metadata;
172 InvalidationSetMap m_classInvalidationSets; 170 InvalidationSetMap m_classInvalidationSets;
173 InvalidationSetMap m_attributeInvalidationSets; 171 InvalidationSetMap m_attributeInvalidationSets;
174 InvalidationSetMap m_idInvalidationSets; 172 InvalidationSetMap m_idInvalidationSets;
175 PseudoTypeInvalidationSetMap m_pseudoInvalidationSets; 173 PseudoTypeInvalidationSetMap m_pseudoInvalidationSets;
176 StyleInvalidator m_styleInvalidator;
177 }; 174 };
178 175
179 } // namespace blink 176 } // namespace blink
180 177
181 WTF_ALLOW_MOVE_AND_INIT_WITH_MEM_FUNCTIONS(blink::RuleFeature); 178 WTF_ALLOW_MOVE_AND_INIT_WITH_MEM_FUNCTIONS(blink::RuleFeature);
182 179
183 #endif // RuleFeature_h 180 #endif // RuleFeature_h
OLDNEW
« no previous file with comments | « no previous file | Source/core/css/RuleFeature.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698