#ifndef ScopedStyleResolver_h
#define ScopedStyleResolver_h
#include "core/css/ElementRuleCollector.h"
#include "core/css/RuleSet.h"
#include "core/dom/ContainerNode.h"
#include "wtf/HashMap.h"
#include "wtf/HashSet.h"
#include "wtf/OwnPtr.h"
#include "wtf/PassOwnPtr.h"
namespace WebCore {
class MediaQueryEvaluator;
class PageRuleCollector;
class ShadowRoot;
class StyleSheetContents;
class ScopedStyleResolver {
WTF_MAKE_NONCOPYABLE(ScopedStyleResolver); WTF_MAKE_FAST_ALLOCATED;
public:
static PassOwnPtr<ScopedStyleResolver> create(ContainerNode& scopingNode) { return adoptPtr(new ScopedStyleResolver(scopingNode)); }
static ContainerNode* scopingNodeFor(Document&, const CSSStyleSheet*);
const ContainerNode& scopingNode() const { return m_scopingNode; }
const TreeScope& treeScope() const { return m_scopingNode.treeScope(); }
void setParent(ScopedStyleResolver* newParent) { m_parent = newParent; }
ScopedStyleResolver* parent() { return m_parent; }
public:
const StyleRuleKeyframes* keyframeStylesForAnimation(const StringImpl* animationName);
void addKeyframeStyle(PassRefPtrWillBeRawPtr<StyleRuleKeyframes>);
void collectMatchingAuthorRules(ElementRuleCollector&, bool includeEmptyRules, bool applyAuthorStyles, CascadeScope, CascadeOrder = ignoreCascadeOrder);
void matchPageRules(PageRuleCollector&);
void addRulesFromSheet(CSSStyleSheet*, const MediaQueryEvaluator&, StyleResolver*);
void collectFeaturesTo(RuleFeatureSet&, HashSet<const StyleSheetContents*>& visitedSharedStyleSheetContents);
void resetAuthorStyle();
void collectViewportRulesTo(StyleResolver*) const;
private:
explicit ScopedStyleResolver(ContainerNode& scopingNode) : m_scopingNode(scopingNode), m_parent(0) { }
ContainerNode& m_scopingNode;
ScopedStyleResolver* m_parent;
WillBePersistentHeapVector<RawPtrWillBeMember<CSSStyleSheet> > m_authorStyleSheets;
typedef WillBePersistentHeapHashMap<const StringImpl*, RefPtrWillBeMember<StyleRuleKeyframes> > KeyframesRuleMap;
KeyframesRuleMap m_keyframesRuleMap;
};
}
#endif