#ifndef SVGRenderSupport_h
#define SVGRenderSupport_h
-#include "core/rendering/PaintInfo.h"
+#include "core/rendering/svg/RenderSVGResourcePaintServer.h"
-namespace WebCore {
+namespace blink {
+class AffineTransform;
class FloatPoint;
class FloatRect;
-class ImageBuffer;
+class GraphicsContext;
+class GraphicsContextStateSaver;
+class PaintInvalidationState;
class LayoutRect;
-class RenderBoxModelObject;
+struct PaintInfo;
+class Path;
class RenderGeometryMap;
class RenderLayerModelObject;
class RenderObject;
class RenderStyle;
class RenderSVGRoot;
+class StrokeData;
class TransformState;
-namespace SVGRenderSupport {
-// Shares child layouting code between RenderSVGRoot/RenderSVG(Hidden)Container
-void layoutChildren(RenderObject*, bool selfNeedsLayout);
+class SVGRenderSupport {
+public:
+ // Shares child layouting code between RenderSVGRoot/RenderSVG(Hidden)Container
+ static void layoutChildren(RenderObject*, bool selfNeedsLayout);
-// Layout resources used by this node.
-void layoutResourcesIfNeeded(const RenderObject*);
+ // Layout resources used by this node.
+ static void layoutResourcesIfNeeded(const RenderObject*);
-// Helper function determining wheter overflow is hidden
-bool isOverflowHidden(const RenderObject*);
+ // Helper function determining whether overflow is hidden.
+ static bool isOverflowHidden(const RenderObject*);
-// Calculates the repaintRect in combination with filter, clipper and masker in local coordinates.
-void intersectRepaintRectWithResources(const RenderObject*, FloatRect&);
+ // Returns true if we're currently within the rendering of a clip-path as a mask.
+ static bool isRenderingClipPathAsMaskImage(const RenderObject&);
-// Determines whether a container needs to be laid out because it's filtered and a child is being laid out.
-bool filtersForceContainerLayout(RenderObject*);
+ // Calculates the paintInvalidationRect in combination with filter, clipper and masker in local coordinates.
+ static void intersectPaintInvalidationRectWithResources(const RenderObject*, FloatRect&);
-// Determines whether the passed point lies in a clipping area
-bool pointInClippingArea(RenderObject*, const FloatPoint&);
+ // Determines whether a container needs to be laid out because it's filtered and a child is being laid out.
+ static bool filtersForceContainerLayout(RenderObject*);
-void computeContainerBoundingBoxes(const RenderObject* container, FloatRect& objectBoundingBox, bool& objectBoundingBoxValid, FloatRect& strokeBoundingBox, FloatRect& repaintBoundingBox);
-bool paintInfoIntersectsRepaintRect(const FloatRect& localRepaintRect, const AffineTransform& localTransform, const PaintInfo&);
+ // Determines whether the passed point lies in a clipping area
+ static bool pointInClippingArea(RenderObject*, const FloatPoint&);
-// Important functions used by nearly all SVG renderers centralizing coordinate transformations / repaint rect calculations
-LayoutRect clippedOverflowRectForRepaint(const RenderObject*, const RenderLayerModelObject* repaintContainer);
-void computeFloatRectForRepaint(const RenderObject*, const RenderLayerModelObject* repaintContainer, FloatRect&, bool fixed);
-void mapLocalToContainer(const RenderObject*, const RenderLayerModelObject* repaintContainer, TransformState&, bool* wasFixed = 0);
-const RenderObject* pushMappingToContainer(const RenderObject*, const RenderLayerModelObject* ancestorToStopAt, RenderGeometryMap&);
-bool checkForSVGRepaintDuringLayout(RenderObject*);
+ // Transform |pointInParent| to |object|'s user-space and check if it is
+ // within the clipping area. Returns false if the transform is singular or
+ // the point is outside the clipping area.
+ static bool transformToUserSpaceAndCheckClipping(RenderObject*, const AffineTransform& localTransform, const FloatPoint& pointInParent, FloatPoint& localPoint);
-// Shared between SVG renderers and resources.
-void applyStrokeStyleToContext(GraphicsContext*, const RenderStyle*, const RenderObject*);
-void applyStrokeStyleToStrokeData(StrokeData*, const RenderStyle*, const RenderObject*);
+ static void computeContainerBoundingBoxes(const RenderObject* container, FloatRect& objectBoundingBox, bool& objectBoundingBoxValid, FloatRect& strokeBoundingBox, FloatRect& paintInvalidationBoundingBox);
-// Determines if any ancestor's transform has changed.
-bool transformToRootChanged(RenderObject*);
+ static bool paintInfoIntersectsPaintInvalidationRect(const FloatRect& localPaintInvalidationRect, const AffineTransform& localTransform, const PaintInfo&);
-// FIXME: These methods do not belong here.
-const RenderSVGRoot* findTreeRootObject(const RenderObject*);
+ // Important functions used by nearly all SVG renderers centralizing coordinate transformations / paint invalidation rect calculations
+ static LayoutRect clippedOverflowRectForPaintInvalidation(const RenderObject*, const RenderLayerModelObject* paintInvalidationContainer, const PaintInvalidationState*);
+ static void computeFloatRectForPaintInvalidation(const RenderObject*, const RenderLayerModelObject* paintInvalidationContainer, FloatRect&, const PaintInvalidationState*);
+ static void mapLocalToContainer(const RenderObject*, const RenderLayerModelObject* paintInvalidationContainer, TransformState&, bool* wasFixed = 0, const PaintInvalidationState* = 0);
+ static const RenderObject* pushMappingToContainer(const RenderObject*, const RenderLayerModelObject* ancestorToStopAt, RenderGeometryMap&);
-// Helper method for determining if a RenderObject marked as text (isText()== true)
-// can/will be rendered as part of a <text>.
-bool isRenderableTextNode(const RenderObject*);
+ // Shared between SVG renderers and resources.
+ static void applyStrokeStyleToContext(GraphicsContext*, const RenderStyle*, const RenderObject*);
+ static void applyStrokeStyleToStrokeData(StrokeData*, const RenderStyle*, const RenderObject*);
-} // namespace SVGRenderSupport
+ // Update the GC state (on |stateSaver.context()|) for painting |renderer|
+ // using |style|. |resourceMode| is used to decide between fill/stroke.
+ // Previous state will be saved (if needed) using |stateSaver|.
+ static bool updateGraphicsContext(GraphicsContextStateSaver&, RenderStyle*, RenderObject&, RenderSVGResourceMode, const AffineTransform* additionalPaintServerTransform = 0);
-} // namespace WebCore
+ // Determines if any ancestor's transform has changed.
+ static bool transformToRootChanged(RenderObject*);
+
+ // FIXME: These methods do not belong here.
+ static const RenderSVGRoot* findTreeRootObject(const RenderObject*);
+
+ // Helper method for determining if a RenderObject marked as text (isText()== true)
+ // can/will be rendered as part of a <text>.
+ static bool isRenderableTextNode(const RenderObject*);
+
+private:
+ static void updateObjectBoundingBox(FloatRect& objectBoundingBox, bool& objectBoundingBoxValid, RenderObject* other, FloatRect otherBoundingBox);
+ static bool layoutSizeOfNearestViewportChanged(const RenderObject* start);
+};
+
+} // namespace blink
#endif // SVGRenderSupport_h