Chromium Code Reviews| 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 // Marks the given attribute name as "appearing in a selector". Used for sel ect: |
|
esprehn
2014/01/23 01:13:29
select: ? I'm not sure what that is.
chrishtr
2014/01/23 01:20:56
Fixed comment.
| |
| 87 HashSet<AtomicString> classesInRules; | 84 // properties where the value of the property contains attr(...) |
| 88 HashSet<AtomicString> attrsInRules; | 85 void addAttributeInASelector(const AtomicString& attributeName); |
| 86 | |
| 89 Vector<RuleFeature> siblingRules; | 87 Vector<RuleFeature> siblingRules; |
| 90 Vector<RuleFeature> uncommonAttributeRules; | 88 Vector<RuleFeature> uncommonAttributeRules; |
| 91 | 89 |
| 92 private: | 90 private: |
| 93 void collectFeaturesFromSelectorList(const CSSSelectorList*); | 91 typedef HashMap<AtomicString, RefPtr<DescendantInvalidationSet> > Invalidati onSetMap; |
| 92 struct FeatureMetadata { | |
| 93 FeatureMetadata() | |
| 94 : usesFirstLineRules(false) | |
| 95 , maxDirectAdjacentSelectors(0) | |
| 96 { } | |
| 97 void add(const FeatureMetadata& other); | |
| 98 void clear(); | |
| 94 | 99 |
| 95 bool m_usesFirstLineRules; | 100 bool usesFirstLineRules; |
| 96 unsigned m_maxDirectAdjacentSelectors; | 101 bool foundSiblingSelector; |
| 102 unsigned maxDirectAdjacentSelectors; | |
| 103 HashSet<AtomicString> idsInRules; | |
| 104 HashSet<AtomicString> classesInRules; | |
| 105 HashSet<AtomicString> attrsInRules; | |
| 106 }; | |
| 97 | 107 |
| 98 typedef HashMap<AtomicString, RefPtr<DescendantInvalidationSet> > Invalidati onSetMap; | 108 void collectFeaturesFromSelector(const CSSSelector*, FeatureMetadata&); |
| 99 | 109 void collectFeaturesFromSelectorList(const CSSSelectorList*, FeatureMetadata &); |
| 100 DescendantInvalidationSet& ensureClassInvalidationSet(const AtomicString& cl assName); | 110 DescendantInvalidationSet& ensureClassInvalidationSet(const AtomicString& cl assName); |
| 101 | |
| 102 bool updateClassInvalidationSets(const CSSSelector*); | 111 bool updateClassInvalidationSets(const CSSSelector*); |
| 103 | 112 |
| 104 InvalidationSetMap m_classInvalidationSets; | 113 InvalidationSetMap m_classInvalidationSets; |
| 114 FeatureMetadata m_metadata; | |
| 105 }; | 115 }; |
| 106 | 116 |
| 107 } // namespace WebCore | 117 } // namespace WebCore |
| 108 | 118 |
| 109 #endif // RuleFeature_h | 119 #endif // RuleFeature_h |
| OLD | NEW |