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 30 matching lines...) Expand all Loading... |
41 , hasDocumentSecurityOrigin(hasDocumentSecurityOrigin) | 41 , hasDocumentSecurityOrigin(hasDocumentSecurityOrigin) |
42 { | 42 { |
43 } | 43 } |
44 StyleRule* rule; | 44 StyleRule* rule; |
45 unsigned selectorIndex; | 45 unsigned selectorIndex; |
46 bool hasDocumentSecurityOrigin; | 46 bool hasDocumentSecurityOrigin; |
47 }; | 47 }; |
48 | 48 |
49 class RuleFeatureSet { | 49 class RuleFeatureSet { |
50 public: | 50 public: |
51 RuleFeatureSet() | 51 RuleFeatureSet() { } |
52 : m_usesFirstLineRules(false) | |
53 , m_maxDirectAdjacentSelectors(0) | |
54 { } | |
55 | 52 |
56 void add(const RuleFeatureSet&); | 53 void add(const RuleFeatureSet&); |
57 void clear(); | 54 void clear(); |
58 | 55 |
59 void collectFeaturesFromSelector(const CSSSelector*); | 56 void collectFeaturesFromSelector(const CSSSelector*); |
60 void collectFeaturesFromRuleData(const RuleData&); | 57 void collectFeaturesFromRuleData(const RuleData&); |
61 | 58 |
62 bool usesSiblingRules() const { return !siblingRules.isEmpty(); } | 59 bool usesSiblingRules() const { return !siblingRules.isEmpty(); } |
63 bool usesFirstLineRules() const { return m_usesFirstLineRules; } | 60 bool usesFirstLineRules() const { return m_metadata.usesFirstLineRules; } |
64 | 61 |
65 unsigned maxDirectAdjacentSelectors() const { return m_maxDirectAdjacentSele
ctors; } | 62 unsigned maxDirectAdjacentSelectors() const { return m_metadata.maxDirectAdj
acentSelectors; } |
66 void setMaxDirectAdjacentSelectors(unsigned value) { m_maxDirectAdjacentSel
ectors = std::max(value, m_maxDirectAdjacentSelectors); } | 63 void setMaxDirectAdjacentSelectors(unsigned value) { m_metadata.maxDirectAd
jacentSelectors = std::max(value, m_metadata.maxDirectAdjacentSelectors); } |
67 | 64 |
68 inline bool hasSelectorForAttribute(const AtomicString& attributeName) const | 65 inline bool hasSelectorForAttribute(const AtomicString& attributeName) const |
69 { | 66 { |
70 ASSERT(!attributeName.isEmpty()); | 67 ASSERT(!attributeName.isEmpty()); |
71 return attrsInRules.contains(attributeName); | 68 return m_metadata.attrsInRules.contains(attributeName); |
72 } | 69 } |
73 | 70 |
74 inline bool hasSelectorForClass(const AtomicString& classValue) const | 71 inline bool hasSelectorForClass(const AtomicString& classValue) const |
75 { | 72 { |
76 ASSERT(!classValue.isEmpty()); | 73 ASSERT(!classValue.isEmpty()); |
77 return classesInRules.contains(classValue); | 74 return m_metadata.classesInRules.contains(classValue); |
78 } | 75 } |
79 | 76 |
80 inline bool hasSelectorForId(const AtomicString& idValue) const | 77 inline bool hasSelectorForId(const AtomicString& idValue) const |
81 { | 78 { |
82 ASSERT(!idValue.isEmpty()); | 79 return m_metadata.idsInRules.contains(idValue); |
83 return idsInRules.contains(idValue); | |
84 } | 80 } |
85 | 81 |
86 HashSet<AtomicString> idsInRules; | 82 int hasIdsInSelectors() const |
87 HashSet<AtomicString> classesInRules; | 83 { |
88 HashSet<AtomicString> attrsInRules; | 84 return m_metadata.idsInRules.size() > 0; |
| 85 } |
| 86 |
| 87 // Marks the given attribute name as "appearing in a selector". Used for |
| 88 // CSS properties such as content: ... attr(...) ... |
| 89 void addAttributeInASelector(const AtomicString& attributeName); |
| 90 |
89 Vector<RuleFeature> siblingRules; | 91 Vector<RuleFeature> siblingRules; |
90 Vector<RuleFeature> uncommonAttributeRules; | 92 Vector<RuleFeature> uncommonAttributeRules; |
91 | 93 |
92 private: | 94 private: |
93 void collectFeaturesFromSelectorList(const CSSSelectorList*); | 95 typedef HashMap<AtomicString, RefPtr<DescendantInvalidationSet> > Invalidati
onSetMap; |
| 96 struct FeatureMetadata { |
| 97 FeatureMetadata() |
| 98 : usesFirstLineRules(false) |
| 99 , foundSiblingSelector(false) |
| 100 , maxDirectAdjacentSelectors(0) |
| 101 { } |
| 102 void add(const FeatureMetadata& other); |
| 103 void clear(); |
94 | 104 |
95 bool m_usesFirstLineRules; | 105 bool usesFirstLineRules; |
96 unsigned m_maxDirectAdjacentSelectors; | 106 bool foundSiblingSelector; |
| 107 unsigned maxDirectAdjacentSelectors; |
| 108 HashSet<AtomicString> idsInRules; |
| 109 HashSet<AtomicString> classesInRules; |
| 110 HashSet<AtomicString> attrsInRules; |
| 111 }; |
97 | 112 |
98 typedef HashMap<AtomicString, RefPtr<DescendantInvalidationSet> > Invalidati
onSetMap; | 113 void collectFeaturesFromSelector(const CSSSelector*, FeatureMetadata&); |
99 | 114 void collectFeaturesFromSelectorList(const CSSSelectorList*, FeatureMetadata
&); |
100 DescendantInvalidationSet& ensureClassInvalidationSet(const AtomicString& cl
assName); | 115 DescendantInvalidationSet& ensureClassInvalidationSet(const AtomicString& cl
assName); |
101 | |
102 bool updateClassInvalidationSets(const CSSSelector*); | 116 bool updateClassInvalidationSets(const CSSSelector*); |
103 | 117 |
104 InvalidationSetMap m_classInvalidationSets; | 118 InvalidationSetMap m_classInvalidationSets; |
| 119 FeatureMetadata m_metadata; |
105 }; | 120 }; |
106 | 121 |
107 } // namespace WebCore | 122 } // namespace WebCore |
108 | 123 |
109 #endif // RuleFeature_h | 124 #endif // RuleFeature_h |
OLD | NEW |