SVGResourcesCache.h [plain text]
#pragma once
#include "RenderStyleConstants.h"
#include <memory>
#include <wtf/HashMap.h>
#include <wtf/Noncopyable.h>
namespace WebCore {
class RenderElement;
class RenderObject;
class RenderStyle;
class RenderSVGResourceContainer;
class SVGResources;
class SVGResourcesCache {
WTF_MAKE_NONCOPYABLE(SVGResourcesCache); WTF_MAKE_FAST_ALLOCATED;
public:
SVGResourcesCache();
~SVGResourcesCache();
static SVGResources* cachedResourcesForRenderer(const RenderElement&);
static void clientWasAddedToTree(RenderObject&);
static void clientWillBeRemovedFromTree(RenderObject&);
static void clientDestroyed(RenderElement&);
static void clientLayoutChanged(RenderElement&);
static void clientStyleChanged(RenderElement&, StyleDifference, const RenderStyle& newStyle);
static void resourceDestroyed(RenderSVGResourceContainer&);
class SetStyleForScope {
WTF_MAKE_NONCOPYABLE(SetStyleForScope);
public:
SetStyleForScope(RenderElement&, const RenderStyle& scopedStyle, const RenderStyle& newStyle);
~SetStyleForScope();
private:
void setStyle(const RenderStyle&);
RenderElement& m_renderer;
const RenderStyle& m_scopedStyle;
bool m_needsNewStyle { false };
};
private:
void addResourcesFromRenderer(RenderElement&, const RenderStyle&);
void removeResourcesFromRenderer(RenderElement&);
typedef HashMap<const RenderElement*, std::unique_ptr<SVGResources>> CacheMap;
CacheMap m_cache;
};
}