18e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project/**
28e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Copyright (C) 2007 Rob Buis <buis@kde.org>
38e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *           (C) 2007 Nikolas Zimmermann <zimmermann@kde.org>
48e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *           (C) 2007 Eric Seidel <eric@webkit.org>
55f1ab04193ad0130ca8204aadaceae083aca9881Feng Qian * Copyright (C) 2009 Google, Inc.  All rights reserved.
68e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
78e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * This library is free software; you can redistribute it and/or
88e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * modify it under the terms of the GNU Library General Public
98e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * License as published by the Free Software Foundation; either
108e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * version 2 of the License, or (at your option) any later version.
118e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
128e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * This library is distributed in the hope that it will be useful,
138e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * but WITHOUT ANY WARRANTY; without even the implied warranty of
148e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
158e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Library General Public License for more details.
168e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
178e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * You should have received a copy of the GNU Library General Public License
188e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * along with this library; see the file COPYING.LIB.  If not, write to
198e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
208e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Boston, MA 02110-1301, USA.
218e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
228e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project */
238e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
245f1ab04193ad0130ca8204aadaceae083aca9881Feng Qian#ifndef SVGRenderBase_h
255f1ab04193ad0130ca8204aadaceae083aca9881Feng Qian#define SVGRenderBase_h
265f1ab04193ad0130ca8204aadaceae083aca9881Feng Qian
278e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#if ENABLE(SVG)
288e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include "RenderObject.h"
298e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
308e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Projectnamespace WebCore {
318e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
325f1ab04193ad0130ca8204aadaceae083aca9881Feng Qian    class SVGResourceFilter;
335f1ab04193ad0130ca8204aadaceae083aca9881Feng Qian    class ImageBuffer;
345f1ab04193ad0130ca8204aadaceae083aca9881Feng Qian
355f1ab04193ad0130ca8204aadaceae083aca9881Feng Qian    // SVGRendererBase is an abstract base class which all SVG renderers inherit
365f1ab04193ad0130ca8204aadaceae083aca9881Feng Qian    // from in order to share SVG renderer code.
375f1ab04193ad0130ca8204aadaceae083aca9881Feng Qian    // FIXME: This code can all move into RenderSVGModelObject once
385f1ab04193ad0130ca8204aadaceae083aca9881Feng Qian    // all SVG renderers inherit from RenderSVGModelObject.
395f1ab04193ad0130ca8204aadaceae083aca9881Feng Qian    class SVGRenderBase {
405f1ab04193ad0130ca8204aadaceae083aca9881Feng Qian    public:
41d0825bca7fe65beaee391d30da42e937db621564Steve Block        virtual ~SVGRenderBase();
42d0825bca7fe65beaee391d30da42e937db621564Steve Block
43d0825bca7fe65beaee391d30da42e937db621564Steve Block        virtual const SVGRenderBase* toSVGRenderBase() const { return this; }
44d0825bca7fe65beaee391d30da42e937db621564Steve Block
455f1ab04193ad0130ca8204aadaceae083aca9881Feng Qian        // FIXME: These are only public for SVGRootInlineBox.
465f1ab04193ad0130ca8204aadaceae083aca9881Feng Qian        // It's unclear if these should be exposed or not.  SVGRootInlineBox may
475f1ab04193ad0130ca8204aadaceae083aca9881Feng Qian        // pass the wrong RenderObject* and boundingBox to these functions.
48d0825bca7fe65beaee391d30da42e937db621564Steve Block        static bool prepareToRenderSVGContent(RenderObject*, RenderObject::PaintInfo&, const FloatRect& boundingBox, SVGResourceFilter*&, SVGResourceFilter* rootFilter = 0);
495f1ab04193ad0130ca8204aadaceae083aca9881Feng Qian        static void finishRenderSVGContent(RenderObject*, RenderObject::PaintInfo&, SVGResourceFilter*&, GraphicsContext* savedContext);
505f1ab04193ad0130ca8204aadaceae083aca9881Feng Qian
51d0825bca7fe65beaee391d30da42e937db621564Steve Block        // Layout all children of the passed render object
52d0825bca7fe65beaee391d30da42e937db621564Steve Block        static void layoutChildren(RenderObject*, bool selfNeedsLayout);
53d0825bca7fe65beaee391d30da42e937db621564Steve Block
548a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block        // Helper function determining wheter overflow is hidden
558a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block        static bool isOverflowHidden(const RenderObject*);
568a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block
57d0825bca7fe65beaee391d30da42e937db621564Steve Block        virtual FloatRect strokeBoundingBox() const { return FloatRect(); }
58d0825bca7fe65beaee391d30da42e937db621564Steve Block        virtual FloatRect markerBoundingBox() const { return FloatRect(); }
59d0825bca7fe65beaee391d30da42e937db621564Steve Block
60d0825bca7fe65beaee391d30da42e937db621564Steve Block        // returns the bounding box of filter, clipper, marker and masker (or the empty rect if no filter) in local coordinates
61d0825bca7fe65beaee391d30da42e937db621564Steve Block        FloatRect filterBoundingBoxForRenderer(const RenderObject*) const;
62d0825bca7fe65beaee391d30da42e937db621564Steve Block        FloatRect clipperBoundingBoxForRenderer(const RenderObject*) const;
63d0825bca7fe65beaee391d30da42e937db621564Steve Block        FloatRect maskerBoundingBoxForRenderer(const RenderObject*) const;
64d0825bca7fe65beaee391d30da42e937db621564Steve Block
655f1ab04193ad0130ca8204aadaceae083aca9881Feng Qian    protected:
665f1ab04193ad0130ca8204aadaceae083aca9881Feng Qian        static IntRect clippedOverflowRectForRepaint(RenderObject*, RenderBoxModelObject* repaintContainer);
675f1ab04193ad0130ca8204aadaceae083aca9881Feng Qian        static void computeRectForRepaint(RenderObject*, RenderBoxModelObject* repaintContainer, IntRect&, bool fixed);
685f1ab04193ad0130ca8204aadaceae083aca9881Feng Qian
695f1ab04193ad0130ca8204aadaceae083aca9881Feng Qian        static void mapLocalToContainer(const RenderObject*, RenderBoxModelObject* repaintContainer, bool useTransforms, bool fixed, TransformState&);
705f1ab04193ad0130ca8204aadaceae083aca9881Feng Qian
715f1ab04193ad0130ca8204aadaceae083aca9881Feng Qian        // Used to share the "walk all the children" logic between objectBoundingBox
725f1ab04193ad0130ca8204aadaceae083aca9881Feng Qian        // and repaintRectInLocalCoordinates in RenderSVGRoot and RenderSVGContainer
735f1ab04193ad0130ca8204aadaceae083aca9881Feng Qian        static FloatRect computeContainerBoundingBox(const RenderObject* container, bool includeAllPaintedContent);
745f1ab04193ad0130ca8204aadaceae083aca9881Feng Qian    };
755f1ab04193ad0130ca8204aadaceae083aca9881Feng Qian
765f1ab04193ad0130ca8204aadaceae083aca9881Feng Qian    // FIXME: This should move to RenderObject or PaintInfo
775f1ab04193ad0130ca8204aadaceae083aca9881Feng Qian    // Used for transforming the GraphicsContext and damage rect before passing PaintInfo to child renderers.
788a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block    void applyTransformToPaintInfo(RenderObject::PaintInfo&, const AffineTransform& localToChildTransform);
798e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
805f1ab04193ad0130ca8204aadaceae083aca9881Feng Qian    // This offers a way to render parts of a WebKit rendering tree into a ImageBuffer.
815f1ab04193ad0130ca8204aadaceae083aca9881Feng Qian    void renderSubtreeToImage(ImageBuffer*, RenderObject*);
828e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
835f1ab04193ad0130ca8204aadaceae083aca9881Feng Qian    void clampImageBufferSizeToViewport(FrameView*, IntSize& imageBufferSize);
845f1ab04193ad0130ca8204aadaceae083aca9881Feng Qian} // namespace WebCore
858e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
865f1ab04193ad0130ca8204aadaceae083aca9881Feng Qian#endif // ENABLE(SVG)
878e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
885f1ab04193ad0130ca8204aadaceae083aca9881Feng Qian#endif // SVGRenderBase_h
89