2 * Copyright (C) 2007 Rob Buis <buis@kde.org>
3 * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org>
4 * Copyright (C) 2007 Eric Seidel <eric@webkit.org>
5 * Copyright (C) 2009 Google, Inc. All rights reserved.
6 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
18 * You should have received a copy of the GNU Library General Public License
19 * along with this library; see the file COPYING.LIB. If not, write to
20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
24 #ifndef SVGRenderSupport_h
25 #define SVGRenderSupport_h
27 #include "core/rendering/svg/RenderSVGResourcePaintServer.h"
31 class AffineTransform;
34 class GraphicsContext;
35 class GraphicsContextStateSaver;
36 class PaintInvalidationState;
40 class RenderGeometryMap;
41 class RenderLayerModelObject;
48 class SVGRenderSupport {
50 // Shares child layouting code between RenderSVGRoot/RenderSVG(Hidden)Container
51 static void layoutChildren(RenderObject*, bool selfNeedsLayout);
53 // Layout resources used by this node.
54 static void layoutResourcesIfNeeded(const RenderObject*);
56 // Helper function determining whether overflow is hidden.
57 static bool isOverflowHidden(const RenderObject*);
59 // Returns true if we're currently within the rendering of a clip-path as a mask.
60 static bool isRenderingClipPathAsMaskImage(const RenderObject&);
62 // Calculates the paintInvalidationRect in combination with filter, clipper and masker in local coordinates.
63 static void intersectPaintInvalidationRectWithResources(const RenderObject*, FloatRect&);
65 // Determines whether a container needs to be laid out because it's filtered and a child is being laid out.
66 static bool filtersForceContainerLayout(RenderObject*);
68 // Determines whether the passed point lies in a clipping area
69 static bool pointInClippingArea(RenderObject*, const FloatPoint&);
71 // Transform |pointInParent| to |object|'s user-space and check if it is
72 // within the clipping area. Returns false if the transform is singular or
73 // the point is outside the clipping area.
74 static bool transformToUserSpaceAndCheckClipping(RenderObject*, const AffineTransform& localTransform, const FloatPoint& pointInParent, FloatPoint& localPoint);
76 static void computeContainerBoundingBoxes(const RenderObject* container, FloatRect& objectBoundingBox, bool& objectBoundingBoxValid, FloatRect& strokeBoundingBox, FloatRect& paintInvalidationBoundingBox);
78 static bool paintInfoIntersectsPaintInvalidationRect(const FloatRect& localPaintInvalidationRect, const AffineTransform& localTransform, const PaintInfo&);
80 // Important functions used by nearly all SVG renderers centralizing coordinate transformations / paint invalidation rect calculations
81 static LayoutRect clippedOverflowRectForPaintInvalidation(const RenderObject*, const RenderLayerModelObject* paintInvalidationContainer, const PaintInvalidationState*);
82 static void computeFloatRectForPaintInvalidation(const RenderObject*, const RenderLayerModelObject* paintInvalidationContainer, FloatRect&, const PaintInvalidationState*);
83 static void mapLocalToContainer(const RenderObject*, const RenderLayerModelObject* paintInvalidationContainer, TransformState&, bool* wasFixed = 0, const PaintInvalidationState* = 0);
84 static const RenderObject* pushMappingToContainer(const RenderObject*, const RenderLayerModelObject* ancestorToStopAt, RenderGeometryMap&);
86 // Shared between SVG renderers and resources.
87 static void applyStrokeStyleToContext(GraphicsContext*, const RenderStyle*, const RenderObject*);
88 static void applyStrokeStyleToStrokeData(StrokeData*, const RenderStyle*, const RenderObject*);
90 // Update the GC state (on |stateSaver.context()|) for painting |renderer|
91 // using |style|. |resourceMode| is used to decide between fill/stroke.
92 // Previous state will be saved (if needed) using |stateSaver|.
93 static bool updateGraphicsContext(GraphicsContextStateSaver&, RenderStyle*, RenderObject&, RenderSVGResourceMode, const AffineTransform* additionalPaintServerTransform = 0);
95 // Determines if any ancestor's transform has changed.
96 static bool transformToRootChanged(RenderObject*);
98 // FIXME: These methods do not belong here.
99 static const RenderSVGRoot* findTreeRootObject(const RenderObject*);
101 // Helper method for determining if a RenderObject marked as text (isText()== true)
102 // can/will be rendered as part of a <text>.
103 static bool isRenderableTextNode(const RenderObject*);
106 static void updateObjectBoundingBox(FloatRect& objectBoundingBox, bool& objectBoundingBoxValid, RenderObject* other, FloatRect otherBoundingBox);
107 static bool layoutSizeOfNearestViewportChanged(const RenderObject* start);
112 #endif // SVGRenderSupport_h