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 "PaintInfo.h"
28
29namespace WebCore {
30
31class FloatPoint;
32class FloatRect;
33class ImageBuffer;
34class LayoutRect;
35class RenderBoxModelObject;
36class RenderElement;
37class RenderGeometryMap;
38class RenderLayerModelObject;
39class RenderObject;
40class RenderStyle;
41class RenderSVGRoot;
42class TransformState;
43
44// SVGRendererSupport is a helper class sharing code between all SVG renderers.
45class SVGRenderSupport {
46public:
47    // Shares child layouting code between RenderSVGRoot/RenderSVG(Hidden)Container
48    static void layoutChildren(RenderElement&, bool selfNeedsLayout);
49
50    // Helper function determining wheter overflow is hidden
51    static bool isOverflowHidden(const RenderElement&);
52
53    static void intersectRepaintRectWithShadows(const RenderElement&, FloatRect&);
54
55    // Calculates the repaintRect in combination with filter, clipper and masker in local coordinates.
56    static void intersectRepaintRectWithResources(const RenderElement&, 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(const RenderElement&);
60
61    // Determines whether the passed point lies in a clipping area
62    static bool pointInClippingArea(const RenderElement&, const FloatPoint&);
63
64    static void computeContainerBoundingBoxes(const RenderElement& container, FloatRect& objectBoundingBox, bool& objectBoundingBoxValid, 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 FloatRect repaintRectForRendererInLocalCoordinatesExcludingSVGShadow(const RenderElement&);
69    static LayoutRect clippedOverflowRectForRepaint(const RenderElement&, const RenderLayerModelObject* repaintContainer);
70    static void computeFloatRectForRepaint(const RenderElement&, const RenderLayerModelObject* repaintContainer, FloatRect&, bool fixed);
71    static void mapLocalToContainer(const RenderElement&, const RenderLayerModelObject* repaintContainer, TransformState&, bool* wasFixed = 0);
72    static const RenderElement* pushMappingToContainer(const RenderElement&, const RenderLayerModelObject* ancestorToStopAt, RenderGeometryMap&);
73    static bool checkForSVGRepaintDuringLayout(const RenderElement&);
74
75    // Shared between SVG renderers and resources.
76    static void applyStrokeStyleToContext(GraphicsContext*, const RenderStyle&, const RenderElement&);
77
78    // Determines if any ancestor's transform has changed.
79    static bool transformToRootChanged(RenderElement*);
80
81    // Helper functions to keep track of whether a renderer has an SVG shadow applied.
82    static bool rendererHasSVGShadow(const RenderObject&);
83    static void setRendererHasSVGShadow(RenderObject&, bool hasShadow);
84
85    static void childAdded(RenderElement& parent, RenderObject& child);
86    static void styleChanged(RenderElement&, const RenderStyle*);
87
88#if ENABLE(CSS_COMPOSITING)
89    static bool isolatesBlending(const RenderStyle&);
90    static void updateMaskedAncestorShouldIsolateBlending(const RenderElement&);
91#endif
92
93    // FIXME: These methods do not belong here.
94    static const RenderSVGRoot& findTreeRootObject(const RenderElement&);
95
96private:
97    // This class is not constructable.
98    SVGRenderSupport();
99    ~SVGRenderSupport();
100};
101
102} // namespace WebCore
103
104#endif // SVGRenderSupport_h
105