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 ASSERT(!idValue.isEmpty()); |
83 return idsInRules.contains(idValue); | 80 return m_metadata.idsInRules.contains(idValue); |
84 } | 81 } |
85 | 82 |
86 HashSet<AtomicString> idsInRules; | 83 void addSelectorForAttribute(const AtomicString& attributeName); |
87 HashSet<AtomicString> classesInRules; | 84 |
88 HashSet<AtomicString> attrsInRules; | |
89 Vector<RuleFeature> siblingRules; | 85 Vector<RuleFeature> siblingRules; |
90 Vector<RuleFeature> uncommonAttributeRules; | 86 Vector<RuleFeature> uncommonAttributeRules; |
91 | 87 |
92 private: | 88 private: |
93 void collectFeaturesFromSelectorList(const CSSSelectorList*); | 89 typedef HashMap<AtomicString, RefPtr<DescendantInvalidationSet> > Invalidati
onSetMap; |
| 90 struct FeatureMetadata { |
| 91 FeatureMetadata() |
| 92 : usesFirstLineRules(false) |
| 93 , maxDirectAdjacentSelectors(0) |
| 94 { } |
| 95 void add(const FeatureMetadata& other); |
| 96 void clear(); |
94 | 97 |
95 bool m_usesFirstLineRules; | 98 bool usesFirstLineRules; |
96 unsigned m_maxDirectAdjacentSelectors; | 99 bool foundSiblingSelector; |
| 100 unsigned maxDirectAdjacentSelectors; |
| 101 HashSet<AtomicString> idsInRules; |
| 102 HashSet<AtomicString> classesInRules; |
| 103 HashSet<AtomicString> attrsInRules; |
| 104 }; |
97 | 105 |
98 typedef HashMap<AtomicString, RefPtr<DescendantInvalidationSet> > Invalidati
onSetMap; | 106 void collectFeaturesFromSelector(const CSSSelector*, FeatureMetadata&); |
99 | 107 void collectFeaturesFromSelectorList(const CSSSelectorList*, FeatureMetadata
&); |
100 DescendantInvalidationSet& ensureClassInvalidationSet(const AtomicString& cl
assName); | 108 DescendantInvalidationSet& ensureClassInvalidationSet(const AtomicString& cl
assName); |
101 | |
102 bool updateClassInvalidationSets(const CSSSelector*); | 109 bool updateClassInvalidationSets(const CSSSelector*); |
103 | 110 |
104 InvalidationSetMap m_classInvalidationSets; | 111 InvalidationSetMap m_classInvalidationSets; |
| 112 FeatureMetadata m_metadata; |
105 }; | 113 }; |
106 | 114 |
107 } // namespace WebCore | 115 } // namespace WebCore |
108 | 116 |
109 #endif // RuleFeature_h | 117 #endif // RuleFeature_h |
OLD | NEW |