| Index: Source/core/css/RuleFeature.h
|
| diff --git a/Source/core/css/RuleFeature.h b/Source/core/css/RuleFeature.h
|
| index b4d0963f4e013cbb40e97bcb26f8ac5008003408..88f1486dded581679dbfc23eaf5179628ecd2566 100644
|
| --- a/Source/core/css/RuleFeature.h
|
| +++ b/Source/core/css/RuleFeature.h
|
| @@ -24,7 +24,7 @@
|
|
|
| #include "core/CoreExport.h"
|
| #include "core/css/CSSSelector.h"
|
| -#include "core/css/invalidation/DescendantInvalidationSet.h"
|
| +#include "core/css/invalidation/InvalidationData.h"
|
| #include "wtf/Forward.h"
|
| #include "wtf/HashSet.h"
|
| #include "wtf/text/AtomicStringHash.h"
|
| @@ -48,8 +48,6 @@ public:
|
| bool hasDocumentSecurityOrigin;
|
| };
|
|
|
| -using InvalidationSetVector = WillBeHeapVector<RefPtrWillBeMember<DescendantInvalidationSet>, 8>;
|
| -
|
| class CORE_EXPORT RuleFeatureSet {
|
| DISALLOW_ALLOCATION();
|
| public:
|
| @@ -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(InvalidationSetVector&, InvalidationSetVector&, Element&, const AtomicString& className) const;
|
| + void collectInvalidationSetsForId(InvalidationSetVector&, InvalidationSetVector&, Element&, const AtomicString& id) const;
|
| + void collectInvalidationSetsForAttribute(InvalidationSetVector&, InvalidationSetVector&, Element&, const QualifiedName& attributeName) const;
|
| + void collectInvalidationSetsForPseudoClass(InvalidationSetVector&, InvalidationSetVector&, Element&, CSSSelector::PseudoType) const;
|
|
|
| bool hasIdsInSelectors() const
|
| {
|
| @@ -98,11 +97,11 @@ public:
|
| WillBeHeapVector<RuleFeature> uncommonAttributeRules;
|
|
|
| protected:
|
| - DescendantInvalidationSet* invalidationSetForSelector(const CSSSelector&);
|
| + DescendantInvalidationSet* invalidationSetForSelector(const CSSSelector&, InvalidateType);
|
|
|
| private:
|
| - using InvalidationSetMap = WillBeHeapHashMap<AtomicString, RefPtrWillBeMember<DescendantInvalidationSet>>;
|
| - using PseudoTypeInvalidationSetMap = WillBeHeapHashMap<CSSSelector::PseudoType, RefPtrWillBeMember<DescendantInvalidationSet>, 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&);
|
|
|
| - DescendantInvalidationSet& ensureClassInvalidationSet(const AtomicString& className);
|
| - DescendantInvalidationSet& ensureAttributeInvalidationSet(const AtomicString& attributeName);
|
| - DescendantInvalidationSet& ensureIdInvalidationSet(const AtomicString& attributeName);
|
| - DescendantInvalidationSet& 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); }
|
| +
|
| + DescendantInvalidationSet& ensureClassInvalidationSet(const AtomicString& className, InvalidateType type) { return ensureClassInvalidationData(className).ensureInvalidationSet(type); }
|
| + DescendantInvalidationSet& ensureAttributeInvalidationSet(const AtomicString& attributeName, InvalidateType type) { return ensureAttributeInvalidationData(attributeName).ensureInvalidationSet(type); }
|
| + DescendantInvalidationSet& ensureIdInvalidationSet(const AtomicString& id, InvalidateType type) { return ensureIdInvalidationData(id).ensureInvalidationSet(type); }
|
| + DescendantInvalidationSet& ensurePseudoInvalidationSet(CSSSelector::PseudoType pseudoType, InvalidateType 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(DescendantInvalidationSet&, const InvalidationSetFeatures&);
|
| - void addFeaturesToInvalidationSets(const CSSSelector&, InvalidationSetFeatures&);
|
| + void addFeaturesToInvalidationSets(const CSSSelector*, InvalidationSetFeatures*, InvalidationSetFeatures&);
|
|
|
| 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)
|
| +{
|
| + 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);
|
|
|