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 27namespace blink { 28 29class AffineTransform; 30class FloatPoint; 31class FloatRect; 32class GraphicsContext; 33class PaintInvalidationState; 34class LayoutRect; 35struct PaintInfo; 36class Path; 37class RenderGeometryMap; 38class RenderLayerModelObject; 39class RenderObject; 40class RenderStyle; 41class RenderSVGRoot; 42class StrokeData; 43class TransformState; 44 45class SVGRenderSupport { 46public: 47 // Shares child layouting code between RenderSVGRoot/RenderSVG(Hidden)Container 48 static void layoutChildren(RenderObject*, bool selfNeedsLayout); 49 50 // Layout resources used by this node. 51 static void layoutResourcesIfNeeded(const RenderObject*); 52 53 // Helper function determining wheter overflow is hidden 54 static bool isOverflowHidden(const RenderObject*); 55 56 // Calculates the paintInvalidationRect in combination with filter, clipper and masker in local coordinates. 57 static void intersectPaintInvalidationRectWithResources(const RenderObject*, FloatRect&); 58 59 // Determines whether a container needs to be laid out because it's filtered and a child is being laid out. 60 static bool filtersForceContainerLayout(RenderObject*); 61 62 // Determines whether the passed point lies in a clipping area 63 static bool pointInClippingArea(RenderObject*, const FloatPoint&); 64 65 // Transform |pointInParent| to |object|'s user-space and check if it is 66 // within the clipping area. Returns false if the transform is singular or 67 // the point is outside the clipping area. 68 static bool transformToUserSpaceAndCheckClipping(RenderObject*, const AffineTransform& localTransform, const FloatPoint& pointInParent, FloatPoint& localPoint); 69 70 static void computeContainerBoundingBoxes(const RenderObject* container, FloatRect& objectBoundingBox, bool& objectBoundingBoxValid, FloatRect& strokeBoundingBox, FloatRect& paintInvalidationBoundingBox); 71 72 static bool paintInfoIntersectsPaintInvalidationRect(const FloatRect& localPaintInvalidationRect, const AffineTransform& localTransform, const PaintInfo&); 73 74 // Important functions used by nearly all SVG renderers centralizing coordinate transformations / paint invalidation rect calculations 75 static LayoutRect clippedOverflowRectForPaintInvalidation(const RenderObject*, const RenderLayerModelObject* paintInvalidationContainer, const PaintInvalidationState*); 76 static void computeFloatRectForPaintInvalidation(const RenderObject*, const RenderLayerModelObject* paintInvalidationContainer, FloatRect&, const PaintInvalidationState*); 77 static void mapLocalToContainer(const RenderObject*, const RenderLayerModelObject* paintInvalidationContainer, TransformState&, bool* wasFixed = 0, const PaintInvalidationState* = 0); 78 static const RenderObject* pushMappingToContainer(const RenderObject*, const RenderLayerModelObject* ancestorToStopAt, RenderGeometryMap&); 79 80 // Shared between SVG renderers and resources. 81 static void applyStrokeStyleToContext(GraphicsContext*, const RenderStyle*, const RenderObject*); 82 static void applyStrokeStyleToStrokeData(StrokeData*, const RenderStyle*, const RenderObject*); 83 84 // Fill and/or stroke the provided |path|. 85 static void fillOrStrokePath(GraphicsContext*, unsigned short resourceMode, const Path&); 86 87 // Determines if any ancestor's transform has changed. 88 static bool transformToRootChanged(RenderObject*); 89 90 // FIXME: These methods do not belong here. 91 static const RenderSVGRoot* findTreeRootObject(const RenderObject*); 92 93 // Helper method for determining if a RenderObject marked as text (isText()== true) 94 // can/will be rendered as part of a <text>. 95 static bool isRenderableTextNode(const RenderObject*); 96 97private: 98 static void updateObjectBoundingBox(FloatRect& objectBoundingBox, bool& objectBoundingBoxValid, RenderObject* other, FloatRect otherBoundingBox); 99 static bool layoutSizeOfNearestViewportChanged(const RenderObject* start); 100}; 101 102} // namespace blink 103 104#endif // SVGRenderSupport_h 105