Index: Source/core/css/RuleFeature.h |
diff --git a/Source/core/css/RuleFeature.h b/Source/core/css/RuleFeature.h |
index fc89ae7331f956176b10e943d99e499710c8695f..8f63f6dbbc8488b56bbdea7504913c74fb95d8ef 100644 |
--- a/Source/core/css/RuleFeature.h |
+++ b/Source/core/css/RuleFeature.h |
@@ -24,13 +24,14 @@ |
#include "core/CoreExport.h" |
#include "core/css/CSSSelector.h" |
-#include "core/css/invalidation/InvalidationSet.h" |
+#include "core/css/invalidation/InvalidationData.h" |
#include "wtf/Forward.h" |
#include "wtf/HashSet.h" |
#include "wtf/text/AtomicStringHash.h" |
namespace blink { |
+struct InvalidationLists; |
class QualifiedName; |
class RuleData; |
class SpaceSplitString; |
@@ -48,8 +49,6 @@ public: |
bool hasDocumentSecurityOrigin; |
}; |
-using InvalidationSetVector = WillBeHeapVector<RefPtrWillBeMember<InvalidationSet>, 8>; |
- |
class CORE_EXPORT RuleFeatureSet { |
DISALLOW_ALLOCATION(); |
public: |
@@ -66,7 +65,6 @@ public: |
bool usesWindowInactiveSelector() const { return m_metadata.usesWindowInactiveSelector; } |
unsigned maxDirectAdjacentSelectors() const { return m_metadata.maxDirectAdjacentSelectors; } |
- void setMaxDirectAdjacentSelectors(unsigned value) { m_metadata.maxDirectAdjacentSelectors = std::max(value, m_metadata.maxDirectAdjacentSelectors); } |
bool hasSelectorForAttribute(const AtomicString& attributeName) const |
{ |
@@ -82,10 +80,11 @@ public: |
bool hasSelectorForId(const AtomicString& idValue) const { return m_idInvalidationSets.contains(idValue); } |
- void collectInvalidationSetsForClass(InvalidationSetVector&, Element&, const AtomicString& className) const; |
- void collectInvalidationSetsForId(InvalidationSetVector&, Element&, const AtomicString& id) const; |
- void collectInvalidationSetsForAttribute(InvalidationSetVector&, Element&, const QualifiedName& attributeName) const; |
- void collectInvalidationSetsForPseudoClass(InvalidationSetVector&, Element&, CSSSelector::PseudoType) const; |
+ // Collect descendant and sibling invalidation sets. |
+ void collectInvalidationSetsForClass(InvalidationLists&, Element&, const AtomicString& className) const; |
+ void collectInvalidationSetsForId(InvalidationLists&, Element&, const AtomicString& id) const; |
+ void collectInvalidationSetsForAttribute(InvalidationLists&, Element&, const QualifiedName& attributeName) const; |
+ void collectInvalidationSetsForPseudoClass(InvalidationLists&, Element&, CSSSelector::PseudoType) const; |
bool hasIdsInSelectors() const |
{ |
@@ -98,11 +97,11 @@ public: |
WillBeHeapVector<RuleFeature> uncommonAttributeRules; |
protected: |
- InvalidationSet* invalidationSetForSelector(const CSSSelector&); |
+ InvalidationSet* invalidationSetForSelector(const CSSSelector&, InvalidationType); |
private: |
- using InvalidationSetMap = WillBeHeapHashMap<AtomicString, RefPtrWillBeMember<InvalidationSet>>; |
- using PseudoTypeInvalidationSetMap = WillBeHeapHashMap<CSSSelector::PseudoType, RefPtrWillBeMember<InvalidationSet>, WTF::IntHash<unsigned>, WTF::UnsignedWithZeroKeyHashTraits<unsigned>>; |
+ using InvalidationSetMap = WillBeHeapHashMap<AtomicString, RefPtrWillBeMember<InvalidationData>>; |
+ using PseudoTypeInvalidationSetMap = WillBeHeapHashMap<CSSSelector::PseudoType, RefPtrWillBeMember<InvalidationData>, WTF::IntHash<unsigned>, WTF::UnsignedWithZeroKeyHashTraits<unsigned>>; |
struct FeatureMetadata { |
DISALLOW_ALLOCATION(); |
@@ -123,10 +122,18 @@ private: |
void collectFeaturesFromSelector(const CSSSelector&, FeatureMetadata&); |
- InvalidationSet& ensureClassInvalidationSet(const AtomicString& className); |
- InvalidationSet& ensureAttributeInvalidationSet(const AtomicString& attributeName); |
- InvalidationSet& ensureIdInvalidationSet(const AtomicString& attributeName); |
- InvalidationSet& ensurePseudoInvalidationSet(CSSSelector::PseudoType); |
+ template<class Map> |
+ static InvalidationData& ensureInvalidationData(Map&, const typename Map::KeyType&); |
+ |
+ InvalidationData& ensureClassInvalidationData(const AtomicString& className) { return ensureInvalidationData(m_classInvalidationSets, className); } |
+ InvalidationData& ensureAttributeInvalidationData(const AtomicString& attributeName) { return ensureInvalidationData(m_attributeInvalidationSets, attributeName); } |
+ InvalidationData& ensureIdInvalidationData(const AtomicString& id) { return ensureInvalidationData(m_idInvalidationSets, id); } |
+ InvalidationData& ensurePseudoInvalidationData(CSSSelector::PseudoType pseudoType) { return ensureInvalidationData(m_pseudoInvalidationSets, pseudoType); } |
+ |
+ InvalidationSet& ensureClassInvalidationSet(const AtomicString& className, InvalidationType type) { return ensureClassInvalidationData(className).ensureInvalidationSet(type); } |
+ InvalidationSet& ensureAttributeInvalidationSet(const AtomicString& attributeName, InvalidationType type) { return ensureAttributeInvalidationData(attributeName).ensureInvalidationSet(type); } |
+ InvalidationSet& ensureIdInvalidationSet(const AtomicString& id, InvalidationType type) { return ensureIdInvalidationData(id).ensureInvalidationSet(type); } |
+ InvalidationSet& ensurePseudoInvalidationSet(CSSSelector::PseudoType pseudoType, InvalidationType type) { return ensurePseudoInvalidationData(pseudoType).ensureInvalidationSet(type); } |
void updateInvalidationSets(const RuleData&); |
void updateInvalidationSetsForContentAttribute(const RuleData&); |
@@ -134,7 +141,8 @@ private: |
struct InvalidationSetFeatures { |
DISALLOW_ALLOCATION(); |
InvalidationSetFeatures() |
- : customPseudoElement(false) |
+ : maxDirectAdjacentSelectors(std::numeric_limits<unsigned>::max()) |
+ , customPseudoElement(false) |
, hasBeforeOrAfter(false) |
, treeBoundaryCrossing(false) |
, adjacent(false) |
@@ -142,12 +150,11 @@ private: |
, forceSubtree(false) |
{ } |
- bool useSubtreeInvalidation() const { return forceSubtree || adjacent; } |
- |
Vector<AtomicString> classes; |
Vector<AtomicString> attributes; |
AtomicString id; |
AtomicString tagName; |
+ unsigned maxDirectAdjacentSelectors; |
bool customPseudoElement; |
bool hasBeforeOrAfter; |
bool treeBoundaryCrossing; |
@@ -163,7 +170,7 @@ private: |
std::pair<const CSSSelector*, UseFeaturesType> extractInvalidationSetFeatures(const CSSSelector&, InvalidationSetFeatures&, bool negated); |
void addFeaturesToInvalidationSet(InvalidationSet&, const InvalidationSetFeatures&); |
- void addFeaturesToInvalidationSets(const CSSSelector&, InvalidationSetFeatures&); |
+ void addFeaturesToInvalidationSets(const CSSSelector*, InvalidationSetFeatures*, InvalidationSetFeatures&); |
rune
2015/10/02 13:17:58
You should name the two InvalidationSetFeatures pa
Eric Willigers
2015/10/14 00:25:40
Done.
|
void addClassToInvalidationSet(const AtomicString& className, Element&); |
@@ -172,8 +179,19 @@ private: |
InvalidationSetMap m_attributeInvalidationSets; |
InvalidationSetMap m_idInvalidationSets; |
PseudoTypeInvalidationSetMap m_pseudoInvalidationSets; |
+ |
+ friend class RuleFeatureSetTest; |
}; |
+template<class Map> |
+InvalidationData& RuleFeatureSet::ensureInvalidationData(Map& map, const typename Map::KeyType& key) |
rune
2015/10/02 13:17:58
This method does not need to be a member of RuleFe
Eric Willigers
2015/10/14 00:25:40
Done.
|
+{ |
+ typename Map::AddResult addResult = map.add(key, nullptr); |
+ if (addResult.isNewEntry) |
+ addResult.storedValue->value = InvalidationData::create(); |
+ return *addResult.storedValue->value; |
+} |
+ |
} // namespace blink |
WTF_ALLOW_MOVE_AND_INIT_WITH_MEM_FUNCTIONS(blink::RuleFeature); |