Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / 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 #include "core/rendering/svg/RenderSVGResourcePaintServer.h"
28
29 namespace blink {
30
31 class AffineTransform;
32 class FloatPoint;
33 class FloatRect;
34 class GraphicsContext;
35 class GraphicsContextStateSaver;
36 class PaintInvalidationState;
37 class LayoutRect;
38 struct PaintInfo;
39 class Path;
40 class RenderGeometryMap;
41 class RenderLayerModelObject;
42 class RenderObject;
43 class RenderStyle;
44 class RenderSVGRoot;
45 class StrokeData;
46 class TransformState;
47
48 class SVGRenderSupport {
49 public:
50     // Shares child layouting code between RenderSVGRoot/RenderSVG(Hidden)Container
51     static void layoutChildren(RenderObject*, bool selfNeedsLayout);
52
53     // Layout resources used by this node.
54     static void layoutResourcesIfNeeded(const RenderObject*);
55
56     // Helper function determining whether overflow is hidden.
57     static bool isOverflowHidden(const RenderObject*);
58
59     // Returns true if we're currently within the rendering of a clip-path as a mask.
60     static bool isRenderingClipPathAsMaskImage(const RenderObject&);
61
62     // Calculates the paintInvalidationRect in combination with filter, clipper and masker in local coordinates.
63     static void intersectPaintInvalidationRectWithResources(const RenderObject*, FloatRect&);
64
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*);
67
68     // Determines whether the passed point lies in a clipping area
69     static bool pointInClippingArea(RenderObject*, const FloatPoint&);
70
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);
75
76     static void computeContainerBoundingBoxes(const RenderObject* container, FloatRect& objectBoundingBox, bool& objectBoundingBoxValid, FloatRect& strokeBoundingBox, FloatRect& paintInvalidationBoundingBox);
77
78     static bool paintInfoIntersectsPaintInvalidationRect(const FloatRect& localPaintInvalidationRect, const AffineTransform& localTransform, const PaintInfo&);
79
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&);
85
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*);
89
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);
94
95     // Determines if any ancestor's transform has changed.
96     static bool transformToRootChanged(RenderObject*);
97
98     // FIXME: These methods do not belong here.
99     static const RenderSVGRoot* findTreeRootObject(const RenderObject*);
100
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*);
104
105 private:
106     static void updateObjectBoundingBox(FloatRect& objectBoundingBox, bool& objectBoundingBoxValid, RenderObject* other, FloatRect otherBoundingBox);
107     static bool layoutSizeOfNearestViewportChanged(const RenderObject* start);
108 };
109
110 } // namespace blink
111
112 #endif // SVGRenderSupport_h