OLD | NEW |
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/invalidation/StyleInvalidator.h" | 26 #include "core/css/invalidation/StyleInvalidator.h" |
26 #include "wtf/Forward.h" | 27 #include "wtf/Forward.h" |
27 #include "wtf/HashSet.h" | 28 #include "wtf/HashSet.h" |
28 #include "wtf/text/AtomicStringHash.h" | 29 #include "wtf/text/AtomicStringHash.h" |
29 | 30 |
30 namespace WebCore { | 31 namespace WebCore { |
31 | 32 |
32 class CSSSelector; | |
33 class CSSSelectorList; | 33 class CSSSelectorList; |
34 class DescendantInvalidationSet; | 34 class DescendantInvalidationSet; |
35 class Document; | 35 class Document; |
36 class Node; | 36 class Node; |
37 class QualifiedName; | 37 class QualifiedName; |
38 class RuleData; | 38 class RuleData; |
39 class ShadowRoot; | 39 class ShadowRoot; |
40 class SpaceSplitString; | 40 class SpaceSplitString; |
41 class StyleRule; | 41 class StyleRule; |
42 | 42 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 return m_classInvalidationSets.contains(classValue); | 81 return m_classInvalidationSets.contains(classValue); |
82 } | 82 } |
83 | 83 |
84 inline bool hasSelectorForId(const AtomicString& idValue) const | 84 inline bool hasSelectorForId(const AtomicString& idValue) const |
85 { | 85 { |
86 return m_idInvalidationSets.contains(idValue); | 86 return m_idInvalidationSets.contains(idValue); |
87 } | 87 } |
88 | 88 |
89 void scheduleStyleInvalidationForClassChange(const SpaceSplitString& changed
Classes, Element&); | 89 void scheduleStyleInvalidationForClassChange(const SpaceSplitString& changed
Classes, Element&); |
90 void scheduleStyleInvalidationForClassChange(const SpaceSplitString& oldClas
ses, const SpaceSplitString& newClasses, Element&); | 90 void scheduleStyleInvalidationForClassChange(const SpaceSplitString& oldClas
ses, const SpaceSplitString& newClasses, Element&); |
91 | |
92 void scheduleStyleInvalidationForAttributeChange(const QualifiedName& attrib
uteName, Element&); | 91 void scheduleStyleInvalidationForAttributeChange(const QualifiedName& attrib
uteName, Element&); |
93 | |
94 void scheduleStyleInvalidationForIdChange(const AtomicString& oldId, const A
tomicString& newId, Element&); | 92 void scheduleStyleInvalidationForIdChange(const AtomicString& oldId, const A
tomicString& newId, Element&); |
| 93 void scheduleStyleInvalidationForPseudoChange(CSSSelector::PseudoType, Eleme
nt&); |
95 | 94 |
96 bool hasIdsInSelectors() const | 95 bool hasIdsInSelectors() const |
97 { | 96 { |
98 return m_idInvalidationSets.size() > 0; | 97 return m_idInvalidationSets.size() > 0; |
99 } | 98 } |
100 | 99 |
101 // Marks the given attribute name as "appearing in a selector". Used for | 100 // Marks the given attribute name as "appearing in a selector". Used for |
102 // CSS properties such as content: ... attr(...) ... | 101 // CSS properties such as content: ... attr(...) ... |
103 // FIXME: record these internally to this class instead calls from StyleReso
lver to here. | 102 // FIXME: record these internally to this class instead calls from StyleReso
lver to here. |
104 void addContentAttr(const AtomicString& attributeName); | 103 void addContentAttr(const AtomicString& attributeName); |
105 | 104 |
106 StyleInvalidator& styleInvalidator(); | 105 StyleInvalidator& styleInvalidator(); |
107 | 106 |
108 Vector<RuleFeature> siblingRules; | 107 Vector<RuleFeature> siblingRules; |
109 Vector<RuleFeature> uncommonAttributeRules; | 108 Vector<RuleFeature> uncommonAttributeRules; |
110 | 109 |
111 private: | 110 private: |
112 typedef HashMap<AtomicString, RefPtr<DescendantInvalidationSet> > Invalidati
onSetMap; | 111 typedef HashMap<AtomicString, RefPtr<DescendantInvalidationSet> > Invalidati
onSetMap; |
| 112 typedef HashMap<CSSSelector::PseudoType, RefPtr<DescendantInvalidationSet>,
WTF::IntHash<unsigned>, WTF::UnsignedWithZeroKeyHashTraits<unsigned> > PseudoTyp
eInvalidationSetMap; |
113 | 113 |
114 struct FeatureMetadata { | 114 struct FeatureMetadata { |
115 FeatureMetadata() | 115 FeatureMetadata() |
116 : usesFirstLineRules(false) | 116 : usesFirstLineRules(false) |
117 , foundSiblingSelector(false) | 117 , foundSiblingSelector(false) |
118 , maxDirectAdjacentSelectors(0) | 118 , maxDirectAdjacentSelectors(0) |
119 { } | 119 { } |
120 void add(const FeatureMetadata& other); | 120 void add(const FeatureMetadata& other); |
121 void clear(); | 121 void clear(); |
122 | 122 |
123 bool usesFirstLineRules; | 123 bool usesFirstLineRules; |
124 bool foundSiblingSelector; | 124 bool foundSiblingSelector; |
125 unsigned maxDirectAdjacentSelectors; | 125 unsigned maxDirectAdjacentSelectors; |
126 }; | 126 }; |
127 | 127 |
128 enum InvalidationSetMode { | 128 enum InvalidationSetMode { |
129 AddFeatures, | 129 AddFeatures, |
130 UseLocalStyleChange, | 130 UseLocalStyleChange, |
131 UseSubtreeStyleChange | 131 UseSubtreeStyleChange |
132 }; | 132 }; |
133 | 133 |
134 static InvalidationSetMode invalidationSetModeForSelector(const CSSSelector&
); | 134 static InvalidationSetMode invalidationSetModeForSelector(const CSSSelector&
); |
135 | 135 |
136 void collectFeaturesFromSelector(const CSSSelector&, FeatureMetadata&, Inval
idationSetMode); | 136 void collectFeaturesFromSelector(const CSSSelector&, FeatureMetadata&, Inval
idationSetMode); |
137 void collectFeaturesFromSelectorList(const CSSSelectorList*, FeatureMetadata
&, InvalidationSetMode); | 137 void collectFeaturesFromSelectorList(const CSSSelectorList*, FeatureMetadata
&, InvalidationSetMode); |
138 | 138 |
139 DescendantInvalidationSet& ensureClassInvalidationSet(const AtomicString& cl
assName); | 139 DescendantInvalidationSet& ensureClassInvalidationSet(const AtomicString& cl
assName); |
140 DescendantInvalidationSet& ensureAttributeInvalidationSet(const AtomicString
& attributeName); | 140 DescendantInvalidationSet& ensureAttributeInvalidationSet(const AtomicString
& attributeName); |
141 DescendantInvalidationSet& ensureIdInvalidationSet(const AtomicString& attri
buteName); | 141 DescendantInvalidationSet& ensureIdInvalidationSet(const AtomicString& attri
buteName); |
| 142 DescendantInvalidationSet& ensurePseudoInvalidationSet(CSSSelector::PseudoTy
pe); |
142 DescendantInvalidationSet* invalidationSetForSelector(const CSSSelector&); | 143 DescendantInvalidationSet* invalidationSetForSelector(const CSSSelector&); |
143 | 144 |
144 InvalidationSetMode updateInvalidationSets(const CSSSelector&); | 145 InvalidationSetMode updateInvalidationSets(const CSSSelector&); |
145 | 146 |
146 struct InvalidationSetFeatures { | 147 struct InvalidationSetFeatures { |
147 InvalidationSetFeatures() : customPseudoElement(false) { } | 148 InvalidationSetFeatures() : customPseudoElement(false) { } |
148 Vector<AtomicString> classes; | 149 Vector<AtomicString> classes; |
149 Vector<AtomicString> attributes; | 150 Vector<AtomicString> attributes; |
150 AtomicString id; | 151 AtomicString id; |
151 AtomicString tagName; | 152 AtomicString tagName; |
152 bool customPseudoElement; | 153 bool customPseudoElement; |
153 }; | 154 }; |
154 | 155 |
155 static void extractInvalidationSetFeature(const CSSSelector&, InvalidationSe
tFeatures&); | 156 static void extractInvalidationSetFeature(const CSSSelector&, InvalidationSe
tFeatures&); |
156 const CSSSelector* extractInvalidationSetFeatures(const CSSSelector&, Invali
dationSetFeatures&); | 157 const CSSSelector* extractInvalidationSetFeatures(const CSSSelector&, Invali
dationSetFeatures&); |
157 void addFeaturesToInvalidationSets(const CSSSelector&, const InvalidationSet
Features&, bool wholeSubtree); | 158 void addFeaturesToInvalidationSets(const CSSSelector&, const InvalidationSet
Features&, bool wholeSubtree); |
158 | 159 |
159 void addClassToInvalidationSet(const AtomicString& className, Element&); | 160 void addClassToInvalidationSet(const AtomicString& className, Element&); |
160 | 161 |
161 FeatureMetadata m_metadata; | 162 FeatureMetadata m_metadata; |
162 InvalidationSetMap m_classInvalidationSets; | 163 InvalidationSetMap m_classInvalidationSets; |
163 InvalidationSetMap m_attributeInvalidationSets; | 164 InvalidationSetMap m_attributeInvalidationSets; |
164 InvalidationSetMap m_idInvalidationSets; | 165 InvalidationSetMap m_idInvalidationSets; |
| 166 PseudoTypeInvalidationSetMap m_pseudoInvalidationSets; |
165 bool m_targetedStyleRecalcEnabled; | 167 bool m_targetedStyleRecalcEnabled; |
166 StyleInvalidator m_styleInvalidator; | 168 StyleInvalidator m_styleInvalidator; |
167 }; | 169 }; |
168 | 170 |
169 | 171 |
170 } // namespace WebCore | 172 } // namespace WebCore |
171 | 173 |
172 #endif // RuleFeature_h | 174 #endif // RuleFeature_h |
OLD | NEW |