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, |
(...skipping 11 matching lines...) Expand all Loading... |
22 #ifndef RuleFeature_h | 22 #ifndef RuleFeature_h |
23 #define RuleFeature_h | 23 #define RuleFeature_h |
24 | 24 |
25 #include "core/css/analyzer/DescendantInvalidationSet.h" | 25 #include "core/css/analyzer/DescendantInvalidationSet.h" |
26 #include "wtf/Forward.h" | 26 #include "wtf/Forward.h" |
27 #include "wtf/HashSet.h" | 27 #include "wtf/HashSet.h" |
28 #include "wtf/text/AtomicStringHash.h" | 28 #include "wtf/text/AtomicStringHash.h" |
29 | 29 |
30 namespace WebCore { | 30 namespace WebCore { |
31 | 31 |
| 32 class Document; |
| 33 class ShadowRoot; |
32 class StyleRule; | 34 class StyleRule; |
33 class CSSSelector; | 35 class CSSSelector; |
34 class CSSSelectorList; | 36 class CSSSelectorList; |
35 class RuleData; | 37 class RuleData; |
| 38 class SpaceSplitString; |
36 | 39 |
37 struct RuleFeature { | 40 struct RuleFeature { |
38 RuleFeature(StyleRule* rule, unsigned selectorIndex, bool hasDocumentSecurit
yOrigin) | 41 RuleFeature(StyleRule* rule, unsigned selectorIndex, bool hasDocumentSecurit
yOrigin) |
39 : rule(rule) | 42 : rule(rule) |
40 , selectorIndex(selectorIndex) | 43 , selectorIndex(selectorIndex) |
41 , hasDocumentSecurityOrigin(hasDocumentSecurityOrigin) | 44 , hasDocumentSecurityOrigin(hasDocumentSecurityOrigin) |
42 { | 45 { |
43 } | 46 } |
44 StyleRule* rule; | 47 StyleRule* rule; |
45 unsigned selectorIndex; | 48 unsigned selectorIndex; |
46 bool hasDocumentSecurityOrigin; | 49 bool hasDocumentSecurityOrigin; |
47 }; | 50 }; |
48 | 51 |
49 class RuleFeatureSet { | 52 class RuleFeatureSet { |
50 public: | 53 public: |
51 RuleFeatureSet() { } | 54 RuleFeatureSet(); |
52 | 55 |
53 void add(const RuleFeatureSet&); | 56 void add(const RuleFeatureSet&); |
54 void clear(); | 57 void clear(); |
55 | 58 |
56 void collectFeaturesFromSelector(const CSSSelector&); | 59 void collectFeaturesFromSelector(const CSSSelector&); |
57 void collectFeaturesFromRuleData(const RuleData&); | 60 void collectFeaturesFromRuleData(const RuleData&); |
58 | 61 |
59 bool usesSiblingRules() const { return !siblingRules.isEmpty(); } | 62 bool usesSiblingRules() const { return !siblingRules.isEmpty(); } |
60 bool usesFirstLineRules() const { return m_metadata.usesFirstLineRules; } | 63 bool usesFirstLineRules() const { return m_metadata.usesFirstLineRules; } |
61 | 64 |
(...skipping 10 matching lines...) Expand all Loading... |
72 { | 75 { |
73 ASSERT(!classValue.isEmpty()); | 76 ASSERT(!classValue.isEmpty()); |
74 return m_metadata.classesInRules.contains(classValue); | 77 return m_metadata.classesInRules.contains(classValue); |
75 } | 78 } |
76 | 79 |
77 inline bool hasSelectorForId(const AtomicString& idValue) const | 80 inline bool hasSelectorForId(const AtomicString& idValue) const |
78 { | 81 { |
79 return m_metadata.idsInRules.contains(idValue); | 82 return m_metadata.idsInRules.contains(idValue); |
80 } | 83 } |
81 | 84 |
| 85 void scheduleStyleInvalidationForClassChange(const SpaceSplitString& changed
Classes, Element*); |
| 86 void scheduleStyleInvalidationForClassChange(const SpaceSplitString& oldClas
ses, const SpaceSplitString& newClasses, Element*); |
| 87 |
| 88 void computeStyleInvalidation(Document&); |
| 89 |
82 int hasIdsInSelectors() const | 90 int hasIdsInSelectors() const |
83 { | 91 { |
84 return m_metadata.idsInRules.size() > 0; | 92 return m_metadata.idsInRules.size() > 0; |
85 } | 93 } |
86 | 94 |
87 // Marks the given attribute name as "appearing in a selector". Used for | 95 // Marks the given attribute name as "appearing in a selector". Used for |
88 // CSS properties such as content: ... attr(...) ... | 96 // CSS properties such as content: ... attr(...) ... |
89 void addAttributeInASelector(const AtomicString& attributeName); | 97 void addAttributeInASelector(const AtomicString& attributeName); |
90 | 98 |
91 Vector<RuleFeature> siblingRules; | 99 Vector<RuleFeature> siblingRules; |
92 Vector<RuleFeature> uncommonAttributeRules; | 100 Vector<RuleFeature> uncommonAttributeRules; |
93 | 101 |
94 private: | 102 private: |
95 typedef HashMap<AtomicString, RefPtr<DescendantInvalidationSet> > Invalidati
onSetMap; | 103 typedef HashMap<AtomicString, RefPtr<DescendantInvalidationSet> > Invalidati
onSetMap; |
| 104 typedef Vector<DescendantInvalidationSet*> InvalidationList; |
| 105 typedef HashMap<Element*, InvalidationList*> PendingInvalidationMap; |
96 struct FeatureMetadata { | 106 struct FeatureMetadata { |
97 FeatureMetadata() | 107 FeatureMetadata() |
98 : usesFirstLineRules(false) | 108 : usesFirstLineRules(false) |
99 , foundSiblingSelector(false) | 109 , foundSiblingSelector(false) |
100 , maxDirectAdjacentSelectors(0) | 110 , maxDirectAdjacentSelectors(0) |
101 { } | 111 { } |
102 void add(const FeatureMetadata& other); | 112 void add(const FeatureMetadata& other); |
103 void clear(); | 113 void clear(); |
104 | 114 |
105 bool usesFirstLineRules; | 115 bool usesFirstLineRules; |
106 bool foundSiblingSelector; | 116 bool foundSiblingSelector; |
107 unsigned maxDirectAdjacentSelectors; | 117 unsigned maxDirectAdjacentSelectors; |
108 HashSet<AtomicString> idsInRules; | 118 HashSet<AtomicString> idsInRules; |
109 HashSet<AtomicString> classesInRules; | 119 HashSet<AtomicString> classesInRules; |
110 HashSet<AtomicString> attrsInRules; | 120 HashSet<AtomicString> attrsInRules; |
111 }; | 121 }; |
112 | 122 |
| 123 // These return true if setNeedsStyleRecalc() should be run on the Element,
as a fallback. |
| 124 bool computeInvalidationSetsForClassChange(const SpaceSplitString& changedCl
asses, Element*); |
| 125 bool computeInvalidationSetsForClassChange(const SpaceSplitString& oldClasse
s, const SpaceSplitString& newClasses, Element*); |
| 126 |
113 void collectFeaturesFromSelector(const CSSSelector&, FeatureMetadata&); | 127 void collectFeaturesFromSelector(const CSSSelector&, FeatureMetadata&); |
114 void collectFeaturesFromSelectorList(const CSSSelectorList*, FeatureMetadata
&); | 128 void collectFeaturesFromSelectorList(const CSSSelectorList*, FeatureMetadata
&); |
| 129 |
115 DescendantInvalidationSet& ensureClassInvalidationSet(const AtomicString& cl
assName); | 130 DescendantInvalidationSet& ensureClassInvalidationSet(const AtomicString& cl
assName); |
116 bool updateClassInvalidationSets(const CSSSelector&); | 131 bool updateClassInvalidationSets(const CSSSelector&); |
117 | 132 |
| 133 void addClassToInvalidationSet(const AtomicString& className, Element*); |
| 134 |
| 135 bool invalidateStyleForClassChange(Element*, Vector<AtomicString>&, bool fou
ndInvalidationSet); |
| 136 bool invalidateStyleForClassChangeOnChildren(Element*, Vector<AtomicString>&
invalidationClasses, bool foundInvalidationSet); |
| 137 |
| 138 InvalidationList& ensurePendingInvalidationList(Element*); |
| 139 |
| 140 FeatureMetadata m_metadata; |
118 InvalidationSetMap m_classInvalidationSets; | 141 InvalidationSetMap m_classInvalidationSets; |
119 FeatureMetadata m_metadata; | 142 PendingInvalidationMap m_pendingInvalidationMap; |
| 143 |
| 144 bool m_targetedStyleRecalcEnabled; |
120 }; | 145 }; |
121 | 146 |
122 } // namespace WebCore | 147 } // namespace WebCore |
123 | 148 |
124 #endif // RuleFeature_h | 149 #endif // RuleFeature_h |
OLD | NEW |