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/invalidation/DescendantInvalidationSet.h" | 25 #include "core/css/invalidation/DescendantInvalidationSet.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 CSSSelector; |
33 class CSSSelectorList; | 34 class CSSSelectorList; |
34 class Document; | 35 class Document; |
35 class Node; | 36 class Node; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 { | 78 { |
78 ASSERT(!classValue.isEmpty()); | 79 ASSERT(!classValue.isEmpty()); |
79 return m_classInvalidationSets.get(classValue); | 80 return m_classInvalidationSets.get(classValue); |
80 } | 81 } |
81 | 82 |
82 inline bool hasSelectorForId(const AtomicString& idValue) const | 83 inline bool hasSelectorForId(const AtomicString& idValue) const |
83 { | 84 { |
84 return m_metadata.idsInRules.contains(idValue); | 85 return m_metadata.idsInRules.contains(idValue); |
85 } | 86 } |
86 | 87 |
87 void scheduleStyleInvalidationForClassChange(const SpaceSplitString& changed
Classes, Element*); | 88 void scheduleStyleInvalidationForClassChange(const SpaceSplitString& changed
Classes, Element&); |
88 void scheduleStyleInvalidationForClassChange(const SpaceSplitString& oldClas
ses, const SpaceSplitString& newClasses, Element*); | 89 void scheduleStyleInvalidationForClassChange(const SpaceSplitString& oldClas
ses, const SpaceSplitString& newClasses, Element&); |
89 | 90 |
90 void scheduleStyleInvalidationForAttributeChange(const QualifiedName& attrib
uteName, Element*); | 91 void scheduleStyleInvalidationForAttributeChange(const QualifiedName& attrib
uteName, Element&); |
91 | |
92 // Clears all style invalidation state for the passed node. | |
93 void clearStyleInvalidation(Node*); | |
94 | 92 |
95 int hasIdsInSelectors() const | 93 int hasIdsInSelectors() const |
96 { | 94 { |
97 return m_metadata.idsInRules.size() > 0; | 95 return m_metadata.idsInRules.size() > 0; |
98 } | 96 } |
99 | 97 |
100 // Marks the given attribute name as "appearing in a selector". Used for | 98 // Marks the given attribute name as "appearing in a selector". Used for |
101 // CSS properties such as content: ... attr(...) ... | 99 // CSS properties such as content: ... attr(...) ... |
102 // FIXME: record these internally to this class instead calls from StyleReso
lver to here. | 100 // FIXME: record these internally to this class instead calls from StyleReso
lver to here. |
103 void addContentAttr(const AtomicString& attributeName); | 101 void addContentAttr(const AtomicString& attributeName); |
104 | 102 |
| 103 StyleInvalidator& styleInvalidator(); |
| 104 |
105 Vector<RuleFeature> siblingRules; | 105 Vector<RuleFeature> siblingRules; |
106 Vector<RuleFeature> uncommonAttributeRules; | 106 Vector<RuleFeature> uncommonAttributeRules; |
107 | 107 |
108 typedef Vector<RefPtr<DescendantInvalidationSet> > InvalidationList; | |
109 typedef HashMap<Element*, OwnPtr<InvalidationList> > PendingInvalidationMap; | |
110 | |
111 PendingInvalidationMap& pendingInvalidationMap(); | |
112 | |
113 private: | 108 private: |
114 typedef HashMap<AtomicString, RefPtr<DescendantInvalidationSet> > Invalidati
onSetMap; | 109 typedef HashMap<AtomicString, RefPtr<DescendantInvalidationSet> > Invalidati
onSetMap; |
115 | 110 |
116 struct FeatureMetadata { | 111 struct FeatureMetadata { |
117 FeatureMetadata() | 112 FeatureMetadata() |
118 : usesFirstLineRules(false) | 113 : usesFirstLineRules(false) |
119 , foundSiblingSelector(false) | 114 , foundSiblingSelector(false) |
120 , maxDirectAdjacentSelectors(0) | 115 , maxDirectAdjacentSelectors(0) |
121 { } | 116 { } |
122 void add(const FeatureMetadata& other); | 117 void add(const FeatureMetadata& other); |
(...skipping 26 matching lines...) Expand all Loading... |
149 Vector<AtomicString> classes; | 144 Vector<AtomicString> classes; |
150 Vector<AtomicString> attributes; | 145 Vector<AtomicString> attributes; |
151 AtomicString id; | 146 AtomicString id; |
152 AtomicString tagName; | 147 AtomicString tagName; |
153 }; | 148 }; |
154 | 149 |
155 static void extractInvalidationSetFeature(const CSSSelector&, InvalidationSe
tFeatures&); | 150 static void extractInvalidationSetFeature(const CSSSelector&, InvalidationSe
tFeatures&); |
156 const CSSSelector* extractInvalidationSetFeatures(const CSSSelector&, Invali
dationSetFeatures&); | 151 const CSSSelector* extractInvalidationSetFeatures(const CSSSelector&, Invali
dationSetFeatures&); |
157 void addFeaturesToInvalidationSets(const CSSSelector&, const InvalidationSet
Features&); | 152 void addFeaturesToInvalidationSets(const CSSSelector&, const InvalidationSet
Features&); |
158 | 153 |
159 void addClassToInvalidationSet(const AtomicString& className, Element*); | 154 void addClassToInvalidationSet(const AtomicString& className, Element&); |
160 | |
161 InvalidationList& ensurePendingInvalidationList(Element*); | |
162 | 155 |
163 FeatureMetadata m_metadata; | 156 FeatureMetadata m_metadata; |
164 InvalidationSetMap m_classInvalidationSets; | 157 InvalidationSetMap m_classInvalidationSets; |
165 InvalidationSetMap m_attributeInvalidationSets; | 158 InvalidationSetMap m_attributeInvalidationSets; |
166 | |
167 PendingInvalidationMap m_pendingInvalidationMap; | |
168 | |
169 bool m_targetedStyleRecalcEnabled; | 159 bool m_targetedStyleRecalcEnabled; |
| 160 StyleInvalidator m_styleInvalidator; |
170 }; | 161 }; |
171 | 162 |
172 | 163 |
173 } // namespace WebCore | 164 } // namespace WebCore |
174 | 165 |
175 #endif // RuleFeature_h | 166 #endif // RuleFeature_h |
OLD | NEW |