Home | History | Annotate | Download | only in rendering
      1 /**
      2  * Copyright (C) 2007 Rob Buis <buis (at) kde.org>
      3  *           (C) 2007 Nikolas Zimmermann <zimmermann (at) kde.org>
      4  *           (C) 2007 Eric Seidel <eric (at) webkit.org>
      5  * Copyright (C) 2009 Google, Inc.  All rights reserved.
      6  *
      7  * This library is free software; you can redistribute it and/or
      8  * modify it under the terms of the GNU Library General Public
      9  * License as published by the Free Software Foundation; either
     10  * version 2 of the License, or (at your option) any later version.
     11  *
     12  * This library is distributed in the hope that it will be useful,
     13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     15  * Library General Public License for more details.
     16  *
     17  * You should have received a copy of the GNU Library General Public License
     18  * along with this library; see the file COPYING.LIB.  If not, write to
     19  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
     20  * Boston, MA 02110-1301, USA.
     21  *
     22  */
     23 
     24 #ifndef SVGRenderBase_h
     25 #define SVGRenderBase_h
     26 
     27 #if ENABLE(SVG)
     28 #include "RenderObject.h"
     29 
     30 namespace WebCore {
     31 
     32     class SVGResourceFilter;
     33     class ImageBuffer;
     34 
     35     // SVGRendererBase is an abstract base class which all SVG renderers inherit
     36     // from in order to share SVG renderer code.
     37     // FIXME: This code can all move into RenderSVGModelObject once
     38     // all SVG renderers inherit from RenderSVGModelObject.
     39     class SVGRenderBase {
     40     public:
     41         virtual ~SVGRenderBase();
     42 
     43         virtual const SVGRenderBase* toSVGRenderBase() const { return this; }
     44 
     45         // FIXME: These are only public for SVGRootInlineBox.
     46         // It's unclear if these should be exposed or not.  SVGRootInlineBox may
     47         // pass the wrong RenderObject* and boundingBox to these functions.
     48         static bool prepareToRenderSVGContent(RenderObject*, RenderObject::PaintInfo&, const FloatRect& boundingBox, SVGResourceFilter*&, SVGResourceFilter* rootFilter = 0);
     49         static void finishRenderSVGContent(RenderObject*, RenderObject::PaintInfo&, SVGResourceFilter*&, GraphicsContext* savedContext);
     50 
     51         // Layout all children of the passed render object
     52         static void layoutChildren(RenderObject*, bool selfNeedsLayout);
     53 
     54         // Helper function determining wheter overflow is hidden
     55         static bool isOverflowHidden(const RenderObject*);
     56 
     57         virtual FloatRect strokeBoundingBox() const { return FloatRect(); }
     58         virtual FloatRect markerBoundingBox() const { return FloatRect(); }
     59 
     60         // returns the bounding box of filter, clipper, marker and masker (or the empty rect if no filter) in local coordinates
     61         FloatRect filterBoundingBoxForRenderer(const RenderObject*) const;
     62         FloatRect clipperBoundingBoxForRenderer(const RenderObject*) const;
     63         FloatRect maskerBoundingBoxForRenderer(const RenderObject*) const;
     64 
     65     protected:
     66         static IntRect clippedOverflowRectForRepaint(RenderObject*, RenderBoxModelObject* repaintContainer);
     67         static void computeRectForRepaint(RenderObject*, RenderBoxModelObject* repaintContainer, IntRect&, bool fixed);
     68 
     69         static void mapLocalToContainer(const RenderObject*, RenderBoxModelObject* repaintContainer, bool useTransforms, bool fixed, TransformState&);
     70 
     71         // Used to share the "walk all the children" logic between objectBoundingBox
     72         // and repaintRectInLocalCoordinates in RenderSVGRoot and RenderSVGContainer
     73         static FloatRect computeContainerBoundingBox(const RenderObject* container, bool includeAllPaintedContent);
     74     };
     75 
     76     // FIXME: This should move to RenderObject or PaintInfo
     77     // Used for transforming the GraphicsContext and damage rect before passing PaintInfo to child renderers.
     78     void applyTransformToPaintInfo(RenderObject::PaintInfo&, const AffineTransform& localToChildTransform);
     79 
     80     // This offers a way to render parts of a WebKit rendering tree into a ImageBuffer.
     81     void renderSubtreeToImage(ImageBuffer*, RenderObject*);
     82 
     83     void clampImageBufferSizeToViewport(FrameView*, IntSize& imageBufferSize);
     84 } // namespace WebCore
     85 
     86 #endif // ENABLE(SVG)
     87 
     88 #endif // SVGRenderBase_h
     89