Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(339)

Unified Diff: Source/core/css/RuleFeature.h

Issue 143653010: Refactor RuleFeatureSet to simplify iteration over CSS Selectors when collecting data. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Merged. Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/css/CSSDefaultStyleSheets.cpp ('k') | Source/core/css/RuleFeature.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/css/RuleFeature.h
diff --git a/Source/core/css/RuleFeature.h b/Source/core/css/RuleFeature.h
index 6018c8e5b5dd86d1b68cb959b623045b19041735..e90bab40ff1ed459d444d0a65beff1ddd7b934c5 100644
--- a/Source/core/css/RuleFeature.h
+++ b/Source/core/css/RuleFeature.h
@@ -48,10 +48,7 @@ struct RuleFeature {
class RuleFeatureSet {
public:
- RuleFeatureSet()
- : m_usesFirstLineRules(false)
- , m_maxDirectAdjacentSelectors(0)
- { }
+ RuleFeatureSet() { }
void add(const RuleFeatureSet&);
void clear();
@@ -60,48 +57,66 @@ public:
void collectFeaturesFromRuleData(const RuleData&);
bool usesSiblingRules() const { return !siblingRules.isEmpty(); }
- bool usesFirstLineRules() const { return m_usesFirstLineRules; }
+ bool usesFirstLineRules() const { return m_metadata.usesFirstLineRules; }
- unsigned maxDirectAdjacentSelectors() const { return m_maxDirectAdjacentSelectors; }
- void setMaxDirectAdjacentSelectors(unsigned value) { m_maxDirectAdjacentSelectors = std::max(value, m_maxDirectAdjacentSelectors); }
+ unsigned maxDirectAdjacentSelectors() const { return m_metadata.maxDirectAdjacentSelectors; }
+ void setMaxDirectAdjacentSelectors(unsigned value) { m_metadata.maxDirectAdjacentSelectors = std::max(value, m_metadata.maxDirectAdjacentSelectors); }
inline bool hasSelectorForAttribute(const AtomicString& attributeName) const
{
ASSERT(!attributeName.isEmpty());
- return attrsInRules.contains(attributeName);
+ return m_metadata.attrsInRules.contains(attributeName);
}
inline bool hasSelectorForClass(const AtomicString& classValue) const
{
ASSERT(!classValue.isEmpty());
- return classesInRules.contains(classValue);
+ return m_metadata.classesInRules.contains(classValue);
}
inline bool hasSelectorForId(const AtomicString& idValue) const
{
- ASSERT(!idValue.isEmpty());
- return idsInRules.contains(idValue);
+ return m_metadata.idsInRules.contains(idValue);
}
- HashSet<AtomicString> idsInRules;
- HashSet<AtomicString> classesInRules;
- HashSet<AtomicString> attrsInRules;
+ int hasIdsInSelectors() const
+ {
+ return m_metadata.idsInRules.size() > 0;
+ }
+
+ // Marks the given attribute name as "appearing in a selector". Used for
+ // CSS properties such as content: ... attr(...) ...
+ void addAttributeInASelector(const AtomicString& attributeName);
+
Vector<RuleFeature> siblingRules;
Vector<RuleFeature> uncommonAttributeRules;
private:
- void collectFeaturesFromSelectorList(const CSSSelectorList*);
-
- bool m_usesFirstLineRules;
- unsigned m_maxDirectAdjacentSelectors;
-
typedef HashMap<AtomicString, RefPtr<DescendantInvalidationSet> > InvalidationSetMap;
-
+ struct FeatureMetadata {
+ FeatureMetadata()
+ : usesFirstLineRules(false)
+ , foundSiblingSelector(false)
+ , maxDirectAdjacentSelectors(0)
+ { }
+ void add(const FeatureMetadata& other);
+ void clear();
+
+ bool usesFirstLineRules;
+ bool foundSiblingSelector;
+ unsigned maxDirectAdjacentSelectors;
+ HashSet<AtomicString> idsInRules;
+ HashSet<AtomicString> classesInRules;
+ HashSet<AtomicString> attrsInRules;
+ };
+
+ void collectFeaturesFromSelector(const CSSSelector*, FeatureMetadata&);
+ void collectFeaturesFromSelectorList(const CSSSelectorList*, FeatureMetadata&);
DescendantInvalidationSet& ensureClassInvalidationSet(const AtomicString& className);
-
bool updateClassInvalidationSets(const CSSSelector*);
InvalidationSetMap m_classInvalidationSets;
+ FeatureMetadata m_metadata;
};
} // namespace WebCore
« no previous file with comments | « Source/core/css/CSSDefaultStyleSheets.cpp ('k') | Source/core/css/RuleFeature.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698