#ifndef MatchedPropertiesCache_h
#define MatchedPropertiesCache_h
#include "core/css/resolver/MatchResult.h"
#include "platform/Timer.h"
#include "wtf/Forward.h"
#include "wtf/HashMap.h"
#include "wtf/Noncopyable.h"
namespace WebCore {
class RenderStyle;
class StyleResolverState;
struct CachedMatchedProperties {
Vector<MatchedProperties> matchedProperties;
MatchRanges ranges;
RefPtr<RenderStyle> renderStyle;
RefPtr<RenderStyle> parentRenderStyle;
void set(const RenderStyle*, const RenderStyle* parentStyle, const MatchResult&);
void clear();
};
class MatchedPropertiesCache {
WTF_MAKE_NONCOPYABLE(MatchedPropertiesCache);
public:
MatchedPropertiesCache();
const CachedMatchedProperties* find(unsigned hash, const StyleResolverState&, const MatchResult&);
void add(const RenderStyle*, const RenderStyle* parentStyle, unsigned hash, const MatchResult&);
void clear();
void clearViewportDependent();
static bool isCacheable(const Element*, const RenderStyle*, const RenderStyle* parentStyle);
private:
void sweep(Timer<MatchedPropertiesCache>*);
unsigned m_additionsSinceLastSweep;
typedef HashMap<unsigned, OwnPtr<CachedMatchedProperties> > Cache;
Cache m_cache;
Timer<MatchedPropertiesCache> m_sweepTimer;
};
}
#endif