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

Side by Side Diff: sky/engine/core/css/RuleFeature.h

Issue 712173002: Remove StyleInvalidator machinery. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 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 | « sky/engine/core/core.gni ('k') | sky/engine/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/css/CSSSelector.h" 25 #include "core/css/CSSSelector.h"
26 #include "core/css/invalidation/StyleInvalidator.h"
27 #include "wtf/Forward.h" 26 #include "wtf/Forward.h"
28 #include "wtf/HashSet.h" 27 #include "wtf/HashSet.h"
29 #include "wtf/text/AtomicStringHash.h" 28 #include "wtf/text/AtomicStringHash.h"
30 29
31 namespace blink { 30 namespace blink {
32 31
33 class CSSSelectorList; 32 class CSSSelectorList;
34 class DescendantInvalidationSet; 33 class Element;
35 class Document;
36 class Node;
37 class QualifiedName; 34 class QualifiedName;
38 class RuleData; 35 class RuleData;
39 class ShadowRoot;
40 class SpaceSplitString; 36 class SpaceSplitString;
41 class StyleRule; 37 class StyleRule;
42 38
43 struct RuleFeature { 39 struct RuleFeature {
44 ALLOW_ONLY_INLINE_ALLOCATION(); 40 RuleFeature(StyleRule* rule, unsigned selectorIndex)
45 public: 41 : rule(rule)
46 RuleFeature(StyleRule* rule, unsigned selectorIndex); 42 , selectorIndex(selectorIndex)
43 {
44 }
47 45
48 void trace(Visitor*); 46 StyleRule* rule;
49
50 RawPtr<StyleRule> rule;
51 unsigned selectorIndex; 47 unsigned selectorIndex;
52 }; 48 };
53 49
54 class RuleFeatureSet { 50 class RuleFeatureSet {
55 DISALLOW_ALLOCATION();
56 public: 51 public:
57 RuleFeatureSet(); 52 RuleFeatureSet();
58 ~RuleFeatureSet(); 53 ~RuleFeatureSet();
59 54
60 void add(const RuleFeatureSet&); 55 void add(const RuleFeatureSet&);
61 void clear(); 56 void clear();
62 57
63 void collectFeaturesFromSelector(const CSSSelector&); 58 void collectFeaturesFromSelector(const CSSSelector&);
64 void collectFeaturesFromRuleData(const RuleData&); 59 void collectFeaturesFromRuleData(const RuleData&);
65 60
66 inline bool hasSelectorForAttribute(const AtomicString& attributeName) const 61 inline bool hasSelectorForAttribute(const AtomicString& attributeName) const
67 { 62 {
68 ASSERT(!attributeName.isEmpty()); 63 ASSERT(!attributeName.isEmpty());
69 return m_attributeInvalidationSets.contains(attributeName); 64 return m_attributeNames.contains(attributeName);
70 } 65 }
71 66
72 inline bool hasSelectorForClass(const AtomicString& classValue) const 67 inline bool hasSelectorForClass(const AtomicString& classValue) const
73 { 68 {
74 ASSERT(!classValue.isEmpty()); 69 ASSERT(!classValue.isEmpty());
75 return m_classInvalidationSets.contains(classValue); 70 return m_classNames.contains(classValue);
76 } 71 }
77 72
78 inline bool hasSelectorForId(const AtomicString& idValue) const 73 inline bool hasSelectorForId(const AtomicString& idValue) const
79 { 74 {
80 return m_idInvalidationSets.contains(idValue); 75 ASSERT(!idValue.isEmpty());
76 return m_idNames.contains(idValue);
81 } 77 }
82 78
83 void scheduleStyleInvalidationForClassChange(const SpaceSplitString& changed Classes, Element&); 79 void scheduleStyleInvalidationForClassChange(const SpaceSplitString& changed Classes, Element&);
84 void scheduleStyleInvalidationForClassChange(const SpaceSplitString& oldClas ses, const SpaceSplitString& newClasses, Element&); 80 void scheduleStyleInvalidationForClassChange(const SpaceSplitString& oldClas ses, const SpaceSplitString& newClasses, Element&);
81
82 void scheduleStyleInvalidationForClassChange(const AtomicString& className, Element& element);
85 void scheduleStyleInvalidationForAttributeChange(const QualifiedName& attrib uteName, Element&); 83 void scheduleStyleInvalidationForAttributeChange(const QualifiedName& attrib uteName, Element&);
86 void scheduleStyleInvalidationForIdChange(const AtomicString& oldId, const A tomicString& newId, Element&); 84 void scheduleStyleInvalidationForIdChange(const AtomicString& oldId, const A tomicString& newId, Element&);
87 void scheduleStyleInvalidationForPseudoChange(CSSSelector::PseudoType, Eleme nt&);
88
89 bool hasIdsInSelectors() const
90 {
91 return m_idInvalidationSets.size() > 0;
92 }
93
94 // Marks the given attribute name as "appearing in a selector". Used for
95 // CSS properties such as content: ... attr(...) ...
96 // FIXME: record these internally to this class instead calls from StyleReso lver to here.
97 void addContentAttr(const AtomicString& attributeName);
98
99 StyleInvalidator& styleInvalidator();
100
101 void trace(Visitor*);
102 85
103 Vector<RuleFeature> attributeRules; 86 Vector<RuleFeature> attributeRules;
104 87
105 private: 88 private:
106 typedef HashMap<AtomicString, RefPtr<DescendantInvalidationSet> > Invalidati onSetMap; 89 void addSelectorFeatures(const CSSSelector&);
107 typedef HashMap<CSSSelector::PseudoType, RefPtr<DescendantInvalidationSet>, WTF::IntHash<unsigned>, WTF::UnsignedWithZeroKeyHashTraits<unsigned> > PseudoTyp eInvalidationSetMap; 90 void collectFeaturesFromSelectorList(const CSSSelectorList*);
108 91
109 enum InvalidationSetMode { 92 HashSet<AtomicString> m_classNames;
110 AddFeatures, 93 HashSet<AtomicString> m_attributeNames;
111 UseLocalStyleChange, 94 HashSet<AtomicString> m_idNames;
112 UseSubtreeStyleChange
113 };
114
115 static InvalidationSetMode invalidationSetModeForSelector(const CSSSelector& );
116
117 void collectFeaturesFromSelector(const CSSSelector&, InvalidationSetMode);
118 void collectFeaturesFromSelectorList(const CSSSelectorList*, InvalidationSet Mode);
119
120 DescendantInvalidationSet& ensureClassInvalidationSet(const AtomicString& cl assName);
121 DescendantInvalidationSet& ensureAttributeInvalidationSet(const AtomicString & attributeName);
122 DescendantInvalidationSet& ensureIdInvalidationSet(const AtomicString& attri buteName);
123 DescendantInvalidationSet& ensurePseudoInvalidationSet(CSSSelector::PseudoTy pe);
124 DescendantInvalidationSet* invalidationSetForSelector(const CSSSelector&);
125
126 InvalidationSetMode updateInvalidationSets(const CSSSelector&);
127
128 struct InvalidationSetFeatures {
129 InvalidationSetFeatures()
130 : customPseudoElement(false)
131 , treeBoundaryCrossing(false)
132 , wholeSubtree(false)
133 { }
134 Vector<AtomicString> classes;
135 Vector<AtomicString> attributes;
136 AtomicString id;
137 AtomicString tagName;
138 bool customPseudoElement;
139 bool treeBoundaryCrossing;
140 bool wholeSubtree;
141 };
142
143 static void extractInvalidationSetFeature(const CSSSelector&, InvalidationSe tFeatures&);
144 const CSSSelector* extractInvalidationSetFeatures(const CSSSelector&, Invali dationSetFeatures&, bool negated);
145 void addFeaturesToInvalidationSets(const CSSSelector&, InvalidationSetFeatur es&);
146
147 void addClassToInvalidationSet(const AtomicString& className, Element&);
148
149 InvalidationSetMap m_classInvalidationSets;
150 InvalidationSetMap m_attributeInvalidationSets;
151 InvalidationSetMap m_idInvalidationSets;
152 PseudoTypeInvalidationSetMap m_pseudoInvalidationSets;
153 bool m_targetedStyleRecalcEnabled;
154 StyleInvalidator m_styleInvalidator;
155 }; 95 };
156 96
157 97
158 } // namespace blink 98 } // namespace blink
159 99
160 namespace WTF { 100 namespace WTF {
161 101
162 template <> struct VectorTraits<blink::RuleFeature> : VectorTraitsBase<blink::Ru leFeature> { 102 template <> struct VectorTraits<blink::RuleFeature> : VectorTraitsBase<blink::Ru leFeature> {
163 static const bool needsDestruction = false; 103 static const bool needsDestruction = false;
164 static const bool canInitializeWithMemset = true; 104 static const bool canInitializeWithMemset = true;
165 static const bool canMoveWithMemcpy = true; 105 static const bool canMoveWithMemcpy = true;
166 }; 106 };
167 107
168 } // namespace WTF 108 } // namespace WTF
169 109
170 #endif // RuleFeature_h 110 #endif // RuleFeature_h
OLDNEW
« no previous file with comments | « sky/engine/core/core.gni ('k') | sky/engine/core/css/RuleFeature.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698