#ifndef TreeScopeStyleSheetCollection_h
#define TreeScopeStyleSheetCollection_h
#include "core/dom/Document.h"
#include "core/dom/DocumentOrderedList.h"
#include "core/dom/StyleSheetCollection.h"
#include "core/dom/StyleSheetScopingNodeList.h"
#include "core/dom/TreeScope.h"
#include "wtf/FastAllocBase.h"
#include "wtf/HashMap.h"
#include "wtf/ListHashSet.h"
#include "wtf/RefPtr.h"
#include "wtf/Vector.h"
#include "wtf/text/WTFString.h"
namespace WebCore {
class ContainerNode;
class DocumentStyleSheetCollector;
class StyleEngine;
class Node;
class StyleSheetContents;
class StyleSheetList;
class StyleRuleFontFace;
class TreeScopeStyleSheetCollection : public StyleSheetCollection {
public:
void addStyleSheetCandidateNode(Node*, bool createdByParser);
void removeStyleSheetCandidateNode(Node*, ContainerNode* scopingNode);
bool hasStyleSheetCandidateNodes() const { return !m_styleSheetCandidateNodes.isEmpty(); }
bool usesRemUnits() const { return m_usesRemUnits; }
DocumentOrderedList& styleSheetCandidateNodes() { return m_styleSheetCandidateNodes; }
DocumentOrderedList* scopingNodesForStyleScoped() { return m_scopingNodesForStyleScoped.scopingNodes(); }
ListHashSet<Node*, 4>* scopingNodesRemoved() { return m_scopingNodesForStyleScoped.scopingNodesRemoved(); }
void clearMediaQueryRuleSetStyleSheets();
virtual void trace(Visitor* visitor) OVERRIDE
{
StyleSheetCollection::trace(visitor);
}
protected:
explicit TreeScopeStyleSheetCollection(TreeScope&);
Document& document() const { return m_treeScope.document(); }
enum StyleResolverUpdateType {
Reconstruct,
Reset,
Additive
};
class StyleSheetChange {
STACK_ALLOCATED();
public:
StyleResolverUpdateType styleResolverUpdateType;
bool requiresFullStyleRecalc;
WillBeHeapVector<RawPtrWillBeMember<const StyleRuleFontFace> > fontFaceRulesToRemove;
StyleSheetChange()
: styleResolverUpdateType(Reconstruct)
, requiresFullStyleRecalc(true) { }
};
void analyzeStyleSheetChange(StyleResolverUpdateMode, const StyleSheetCollection&, StyleSheetChange&);
void resetAllRuleSetsInTreeScope(StyleResolver*);
void updateUsesRemUnits();
private:
static StyleResolverUpdateType compareStyleSheets(const WillBeHeapVector<RefPtrWillBeMember<CSSStyleSheet> >& oldStyleSheets, const WillBeHeapVector<RefPtrWillBeMember<CSSStyleSheet> >& newStylesheets, WillBeHeapVector<RawPtrWillBeMember<StyleSheetContents> >& addedSheets);
bool activeLoadingStyleSheetLoaded(const WillBeHeapVector<RefPtrWillBeMember<CSSStyleSheet> >& newStyleSheets);
protected:
TreeScope& m_treeScope;
bool m_hadActiveLoadingStylesheet;
bool m_usesRemUnits;
DocumentOrderedList m_styleSheetCandidateNodes;
StyleSheetScopingNodeList m_scopingNodesForStyleScoped;
};
}
#endif