Home | History | Annotate | Download | only in svg
      1 /**
      2  * Copyright (C) 2007 Rob Buis <buis (at) kde.org>
      3  * Copyright (C) 2007 Nikolas Zimmermann <zimmermann (at) kde.org>
      4  * Copyright (C) 2007 Eric Seidel <eric (at) 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 namespace WebCore {
     28 
     29 class AffineTransform;
     30 class FloatPoint;
     31 class FloatRect;
     32 class GraphicsContext;
     33 class LayoutRect;
     34 struct PaintInfo;
     35 class RenderGeometryMap;
     36 class RenderLayerModelObject;
     37 class RenderObject;
     38 class RenderStyle;
     39 class RenderSVGRoot;
     40 class StrokeData;
     41 class TransformState;
     42 
     43 class SVGRenderSupport {
     44 public:
     45     // Shares child layouting code between RenderSVGRoot/RenderSVG(Hidden)Container
     46     static void layoutChildren(RenderObject*, bool selfNeedsLayout);
     47 
     48     // Layout resources used by this node.
     49     static void layoutResourcesIfNeeded(const RenderObject*);
     50 
     51     // Helper function determining wheter overflow is hidden
     52     static bool isOverflowHidden(const RenderObject*);
     53 
     54     // Calculates the repaintRect in combination with filter, clipper and masker in local coordinates.
     55     static void intersectRepaintRectWithResources(const RenderObject*, FloatRect&);
     56 
     57     // Determines whether a container needs to be laid out because it's filtered and a child is being laid out.
     58     static bool filtersForceContainerLayout(RenderObject*);
     59 
     60     // Determines whether the passed point lies in a clipping area
     61     static bool pointInClippingArea(RenderObject*, const FloatPoint&);
     62 
     63     static void computeContainerBoundingBoxes(const RenderObject* container, FloatRect& objectBoundingBox, bool& objectBoundingBoxValid, FloatRect& strokeBoundingBox, FloatRect& repaintBoundingBox);
     64 
     65     static bool paintInfoIntersectsRepaintRect(const FloatRect& localRepaintRect, const AffineTransform& localTransform, const PaintInfo&);
     66 
     67     static bool parentTransformDidChange(RenderObject*);
     68 
     69     // Important functions used by nearly all SVG renderers centralizing coordinate transformations / repaint rect calculations
     70     static LayoutRect clippedOverflowRectForRepaint(const RenderObject*, const RenderLayerModelObject* repaintContainer);
     71     static void computeFloatRectForRepaint(const RenderObject*, const RenderLayerModelObject* repaintContainer, FloatRect&, bool fixed);
     72     static void mapLocalToContainer(const RenderObject*, const RenderLayerModelObject* repaintContainer, TransformState&, bool* wasFixed = 0);
     73     static const RenderObject* pushMappingToContainer(const RenderObject*, const RenderLayerModelObject* ancestorToStopAt, RenderGeometryMap&);
     74     static bool checkForSVGRepaintDuringLayout(RenderObject*);
     75 
     76     // Shared between SVG renderers and resources.
     77     static void applyStrokeStyleToContext(GraphicsContext*, const RenderStyle*, const RenderObject*);
     78     static void applyStrokeStyleToStrokeData(StrokeData*, const RenderStyle*, const RenderObject*);
     79 
     80     // Determines if any ancestor's transform has changed.
     81     static bool transformToRootChanged(RenderObject*);
     82 
     83     // FIXME: These methods do not belong here.
     84     static const RenderSVGRoot* findTreeRootObject(const RenderObject*);
     85 
     86     // Helper method for determining if a RenderObject marked as text (isText()== true)
     87     // can/will be rendered as part of a <text>.
     88     static bool isRenderableTextNode(const RenderObject*);
     89 
     90 private:
     91     static void updateObjectBoundingBox(FloatRect& objectBoundingBox, bool& objectBoundingBoxValid, RenderObject* other, FloatRect otherBoundingBox);
     92     static void invalidateResourcesOfChildren(RenderObject* start);
     93     static bool layoutSizeOfNearestViewportChanged(const RenderObject* start);
     94 };
     95 
     96 } // namespace WebCore
     97 
     98 #endif // SVGRenderSupport_h
     99