RenderSVGResource.h [plain text]
#pragma once
#include "RenderSVGShape.h"
#include "RenderStyleConstants.h"
#include <wtf/TypeCasts.h>
namespace WebCore {
enum RenderSVGResourceType {
MaskerResourceType,
MarkerResourceType,
PatternResourceType,
LinearGradientResourceType,
RadialGradientResourceType,
SolidColorResourceType,
FilterResourceType,
ClipperResourceType
};
enum class RenderSVGResourceMode {
ApplyToFill = 1 << 0,
ApplyToStroke = 1 << 1,
ApplyToText = 1 << 2 };
class Color;
class FloatRect;
class GraphicsContext;
class Path;
class RenderObject;
class RenderStyle;
class RenderSVGResourceSolidColor;
class RenderSVGResource {
public:
RenderSVGResource() = default;
virtual ~RenderSVGResource() = default;
virtual void removeAllClientsFromCache(bool markForInvalidation = true) = 0;
virtual void removeClientFromCache(RenderElement&, bool markForInvalidation = true) = 0;
virtual bool applyResource(RenderElement&, const RenderStyle&, GraphicsContext*&, OptionSet<RenderSVGResourceMode>) = 0;
virtual void postApplyResource(RenderElement&, GraphicsContext*&, OptionSet<RenderSVGResourceMode>, const Path*, const RenderSVGShape*) { }
virtual FloatRect resourceBoundingBox(const RenderObject&) = 0;
virtual RenderSVGResourceType resourceType() const = 0;
static RenderSVGResource* fillPaintingResource(RenderElement&, const RenderStyle&, Color& fallbackColor);
static RenderSVGResource* strokePaintingResource(RenderElement&, const RenderStyle&, Color& fallbackColor);
static RenderSVGResourceSolidColor* sharedSolidPaintingResource();
static void markForLayoutAndParentResourceInvalidation(RenderObject&, bool needsLayout = true);
};
}
#define SPECIALIZE_TYPE_TRAITS_RENDER_SVG_RESOURCE(ToValueTypeName, ResourceType) \
SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::ToValueTypeName) \
static bool isType(const WebCore::RenderSVGResource& resource) { return resource.resourceType() == WebCore::ResourceType; } \
SPECIALIZE_TYPE_TRAITS_END()