summaryrefslogtreecommitdiff
path: root/Source/WebCore/css/ElementRuleCollector.h
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/css/ElementRuleCollector.h')
-rw-r--r--Source/WebCore/css/ElementRuleCollector.h85
1 files changed, 46 insertions, 39 deletions
diff --git a/Source/WebCore/css/ElementRuleCollector.h b/Source/WebCore/css/ElementRuleCollector.h
index bc735d6cc..3874c8bfb 100644
--- a/Source/WebCore/css/ElementRuleCollector.h
+++ b/Source/WebCore/css/ElementRuleCollector.h
@@ -1,6 +1,6 @@
/*
* Copyright (C) 1999 Lars Knoll (knoll@kde.org)
- * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2013, 2014 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -19,8 +19,7 @@
*
*/
-#ifndef ElementRuleCollector_h
-#define ElementRuleCollector_h
+#pragma once
#include "MediaQueryEvaluator.h"
#include "SelectorChecker.h"
@@ -37,23 +36,17 @@ class RenderRegion;
class RuleData;
class RuleSet;
class SelectorFilter;
-class StyleScopeResolver;
+
+struct MatchedRule {
+ const RuleData* ruleData;
+ unsigned specificity;
+ Style::ScopeOrdinal styleScopeOrdinal;
+};
class ElementRuleCollector {
public:
- ElementRuleCollector(StyleResolver* styleResolver, const StyleResolver::State& state)
- : m_state(state)
- , m_ruleSets(styleResolver->ruleSets())
- , m_selectorFilter(styleResolver->selectorFilter())
- , m_scopeResolver(styleResolver->scopeResolver())
- , m_isPrintStyle(false)
- , m_regionForStyling(0)
- , m_pseudoStyleRequest(NOPSEUDO)
- , m_sameOriginOnly(false)
- , m_mode(SelectorChecker::ResolvingStyle)
- , m_canUseFastReject(m_selectorFilter.parentStackIsConsistent(state.parentNode()))
- {
- }
+ ElementRuleCollector(const Element&, const DocumentRuleSets&, const SelectorFilter*);
+ ElementRuleCollector(const Element&, const RuleSet& authorStyle, const SelectorFilter*);
void matchAllRules(bool matchAuthorAndUserStyles, bool includeSMILProperties);
void matchUARules();
@@ -63,50 +56,64 @@ public:
void setMode(SelectorChecker::Mode mode) { m_mode = mode; }
void setPseudoStyleRequest(const PseudoStyleRequest& request) { m_pseudoStyleRequest = request; }
void setSameOriginOnly(bool f) { m_sameOriginOnly = f; }
- void setRegionForStyling(RenderRegion* regionForStyling) { m_regionForStyling = regionForStyling; }
+ void setRegionForStyling(const RenderRegion* regionForStyling) { m_regionForStyling = regionForStyling; }
void setMedium(const MediaQueryEvaluator* medium) { m_isPrintStyle = medium->mediaTypeMatchSpecific("print"); }
- bool hasAnyMatchingRules(RuleSet*);
+ bool hasAnyMatchingRules(const RuleSet*);
StyleResolver::MatchResult& matchedResult();
- const Vector<RefPtr<StyleRuleBase>>& matchedRuleList() const;
+ const Vector<RefPtr<StyleRule>>& matchedRuleList() const;
+
+ bool hasMatchedRules() const { return !m_matchedRules.isEmpty(); }
+ void clearMatchedRules();
+
+ const PseudoIdSet& matchedPseudoElementIds() const { return m_matchedPseudoElementIds; }
+ const Style::Relations& styleRelations() const { return m_styleRelations; }
+ bool didMatchUncommonAttributeSelector() const { return m_didMatchUncommonAttributeSelector; }
private:
- Document& document() { return m_state.document(); }
void addElementStyleProperties(const StyleProperties*, bool isCacheable = true);
void matchUARules(RuleSet*);
+ void matchAuthorShadowPseudoElementRules(bool includeEmptyRules, StyleResolver::RuleRange&);
+ void matchHostPseudoClassRules(bool includeEmptyRules, StyleResolver::RuleRange&);
+ void matchSlottedPseudoElementRules(bool includeEmptyRules, StyleResolver::RuleRange&);
+
+ void collectMatchingShadowPseudoElementRules(const MatchRequest&, StyleResolver::RuleRange&);
+ std::unique_ptr<RuleSet::RuleDataVector> collectSlottedPseudoElementRulesForSlot(bool includeEmptyRules);
void collectMatchingRules(const MatchRequest&, StyleResolver::RuleRange&);
void collectMatchingRulesForRegion(const MatchRequest&, StyleResolver::RuleRange&);
- void collectMatchingRulesForList(const Vector<RuleData>*, const MatchRequest&, StyleResolver::RuleRange&);
- bool ruleMatches(const RuleData&, PseudoId&);
+ void collectMatchingRulesForList(const RuleSet::RuleDataVector*, const MatchRequest&, StyleResolver::RuleRange&);
+ bool ruleMatches(const RuleData&, unsigned &specificity);
void sortMatchedRules();
void sortAndTransferMatchedRules();
- void addMatchedRule(const RuleData*);
- void clearMatchedRules();
+ void addMatchedRule(const RuleData&, unsigned specificity, Style::ScopeOrdinal, StyleResolver::RuleRange&);
- const StyleResolver::State& m_state;
- DocumentRuleSets& m_ruleSets;
- SelectorFilter& m_selectorFilter;
- StyleScopeResolver* m_scopeResolver;
+ const Element& m_element;
+ const RuleSet& m_authorStyle;
+ const RuleSet* m_userStyle { nullptr };
+ const SelectorFilter* m_selectorFilter { nullptr };
- bool m_isPrintStyle;
- RenderRegion* m_regionForStyling;
- PseudoStyleRequest m_pseudoStyleRequest;
- bool m_sameOriginOnly;
- SelectorChecker::Mode m_mode;
- bool m_canUseFastReject;
+ bool m_isPrintStyle { false };
+ const RenderRegion* m_regionForStyling { nullptr };
+ PseudoStyleRequest m_pseudoStyleRequest { NOPSEUDO };
+ bool m_sameOriginOnly { false };
+ SelectorChecker::Mode m_mode { SelectorChecker::Mode::ResolvingStyle };
+ bool m_isMatchingSlottedPseudoElements { false };
+ bool m_isMatchingHostPseudoClass { false };
+ Vector<std::unique_ptr<RuleSet::RuleDataVector>> m_keepAliveSlottedPseudoElementRules;
- std::unique_ptr<Vector<const RuleData*, 32>> m_matchedRules;
+ Vector<MatchedRule, 64> m_matchedRules;
// Output.
- Vector<RefPtr<StyleRuleBase>> m_matchedRuleList;
+ Vector<RefPtr<StyleRule>> m_matchedRuleList;
+ bool m_didMatchUncommonAttributeSelector { false };
StyleResolver::MatchResult m_result;
+ Style::Relations m_styleRelations;
+ PseudoIdSet m_matchedPseudoElementIds;
};
} // namespace WebCore
-
-#endif // ElementRuleCollector_h