tizen beta release
[profile/ivi/webkit-efl.git] / Source / WebCore / rendering / svg / SVGRenderSupport.h
1 /**
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.
7  *
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.
12  *
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.
17  *
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.
22  */
23
24 #ifndef SVGRenderSupport_h
25 #define SVGRenderSupport_h
26
27 #if ENABLE(SVG)
28 #include "LayoutTypes.h"
29 #include "PaintInfo.h"
30
31 namespace WebCore {
32
33 class FloatPoint;
34 class FloatRect;
35 class ImageBuffer;
36 class RenderBoxModelObject;
37 class RenderObject;
38 class RenderStyle;
39 class RenderSVGRoot;
40 class TransformState;
41
42 // SVGRendererSupport is a helper class sharing code between all SVG renderers.
43 class SVGRenderSupport {
44 public:
45     // Used by all SVG renderers who apply clip/filter/etc. resources to the renderer content
46     static bool prepareToRenderSVGContent(RenderObject*, PaintInfo&);
47     static void finishRenderSVGContent(RenderObject*, PaintInfo&, GraphicsContext* savedContext);
48
49     // Shares child layouting code between RenderSVGRoot/RenderSVG(Hidden)Container
50     static void layoutChildren(RenderObject*, bool selfNeedsLayout);
51
52     // Helper function determining wheter overflow is hidden
53     static bool isOverflowHidden(const RenderObject*);
54
55     // Calculates the repaintRect in combination with filter, clipper and masker in local coordinates.
56     static void intersectRepaintRectWithResources(const RenderObject*, FloatRect&);
57
58     // Determines whether a container needs to be laid out because it's filtered and a child is being laid out.
59     static bool filtersForceContainerLayout(RenderObject*);
60
61     // Determines whether the passed point lies in a clipping area
62     static bool pointInClippingArea(RenderObject*, const FloatPoint&);
63
64     static void computeContainerBoundingBoxes(const RenderObject* container, FloatRect& objectBoundingBox, FloatRect& strokeBoundingBox, FloatRect& repaintBoundingBox);
65     static bool paintInfoIntersectsRepaintRect(const FloatRect& localRepaintRect, const AffineTransform& localTransform, const PaintInfo&);
66
67     // Important functions used by nearly all SVG renderers centralizing coordinate transformations / repaint rect calculations
68     static LayoutRect clippedOverflowRectForRepaint(const RenderObject*, RenderBoxModelObject* repaintContainer);
69     static void computeFloatRectForRepaint(const RenderObject*, RenderBoxModelObject* repaintContainer, FloatRect&, bool fixed);
70     static void mapLocalToContainer(const RenderObject*, RenderBoxModelObject* repaintContainer, TransformState&, bool* wasFixed = 0);
71
72     // Shared between SVG renderers and resources.
73     static void applyStrokeStyleToContext(GraphicsContext*, const RenderStyle*, const RenderObject*);
74
75     // FIXME: These methods do not belong here.
76     static const RenderSVGRoot* findTreeRootObject(const RenderObject*);
77
78 private:
79     // This class is not constructable.
80     SVGRenderSupport();
81     ~SVGRenderSupport();
82 };
83
84 } // namespace WebCore
85
86 #endif // ENABLE(SVG)
87 #endif // SVGRenderSupport_h