#ifndef SharedStyleFinder_h
#define SharedStyleFinder_h
#include "core/css/resolver/ElementResolveContext.h"
#include "core/dom/Element.h"
namespace WebCore {
class Element;
class Node;
class RenderStyle;
class RuleFeatureSet;
class RuleSet;
class SpaceSplitString;
class StyleResolver;
class SharedStyleFinder {
STACK_ALLOCATED();
public:
SharedStyleFinder(const ElementResolveContext& context,
const RuleFeatureSet& features, RuleSet* siblingRuleSet,
RuleSet* uncommonAttributeRuleSet, StyleResolver& styleResolver)
: m_elementAffectedByClassRules(false)
, m_features(features)
, m_siblingRuleSet(siblingRuleSet)
, m_uncommonAttributeRuleSet(uncommonAttributeRuleSet)
, m_styleResolver(styleResolver)
, m_context(context)
{ }
RenderStyle* findSharedStyle();
private:
Element* findElementForStyleSharing() const;
bool documentContainsValidCandidate() const;
bool classNamesAffectedByRules(const SpaceSplitString&) const;
bool canShareStyleWithElement(Element& candidate) const;
bool canShareStyleWithControl(Element& candidate) const;
bool sharingCandidateHasIdenticalStyleAffectingAttributes(Element& candidate) const;
bool sharingCandidateShadowHasSharedStyleSheetContents(Element& candidate) const;
bool sharingCandidateDistributedToSameInsertionPoint(Element& candidate) const;
bool matchesRuleSet(RuleSet*);
Element& element() const { return *m_context.element(); }
Document& document() const { return element().document(); }
bool m_elementAffectedByClassRules;
const RuleFeatureSet& m_features;
RawPtrWillBeMember<RuleSet> m_siblingRuleSet;
RawPtrWillBeMember<RuleSet> m_uncommonAttributeRuleSet;
StyleResolver& m_styleResolver;
const ElementResolveContext& m_context;
};
}
#endif