File indexing completed on 2024-04-28 15:24:17

0001 /*
0002     Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
0003                   2004, 2005, 2007 Rob Buis <buis@kde.org>
0004 
0005     This file is part of the KDE project
0006 
0007     This library is free software; you can redistribute it and/or
0008     modify it under the terms of the GNU Library General Public
0009     License as published by the Free Software Foundation; either
0010     version 2 of the License, or (at your option) any later version.
0011 
0012     This library is distributed in the hope that it will be useful,
0013     but WITHOUT ANY WARRANTY; without even the implied warranty of
0014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0015     Library General Public License for more details.
0016 
0017     You should have received a copy of the GNU Library General Public License
0018     aint with this library; see the file COPYING.LIB.  If not, write to
0019     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0020     Boston, MA 02110-1301, USA.
0021 */
0022 
0023 #ifndef RenderSVGContainer_h
0024 #define RenderSVGContainer_h
0025 
0026 #if ENABLE(SVG)
0027 
0028 #include "RenderPath.h"
0029 #include "SVGPreserveAspectRatio.h"
0030 
0031 namespace WebCore
0032 {
0033 
0034 class SVGElement;
0035 
0036 class RenderSVGContainer : public RenderObject
0037 {
0038 public:
0039     RenderSVGContainer(SVGStyledElement *);
0040     ~RenderSVGContainer();
0041 
0042     RenderObject *firstChild() const override
0043     {
0044         return m_firstChild;
0045     }
0046     RenderObject *lastChild() const override
0047     {
0048         return m_lastChild;
0049     }
0050 
0051     short/*khtml*/ int width() const override
0052     {
0053         return m_width;
0054     }
0055     int height() const override
0056     {
0057         return m_height;
0058     }
0059 
0060     virtual bool canHaveChildren() const;
0061     void addChild(RenderObject *newChild, RenderObject *beforeChild = nullptr) override;
0062     void removeChild(RenderObject *) override;
0063 
0064     virtual void destroy();
0065     void destroyLeftoverChildren();
0066 
0067     // uncomment if you know how line 64' ambiguoty should be solved in that case.
0068     // using khtml::RenderObject::removeChildNode;
0069     RenderObject *removeChildNode(RenderObject *) override;
0070     // uncomment if you know how line 64' ambiguoty should be solved in that case.
0071     // using khtml::RenderObject::appendChildNode;
0072     void appendChildNode(RenderObject *) override;
0073     // uncomment if you know how line 62' of the implementation ambiguoty should be solved in that case.
0074     // using khtml::RenderObject::insertChildNode;
0075     void insertChildNode(RenderObject *child, RenderObject *before) override;
0076 
0077     // Designed for speed.  Don't waste time doing a bunch of work like layer updating and repainting when we know that our
0078     // change in parentage is not going to affect anything.
0079     virtual void moveChildNode(RenderObject *child)
0080     {
0081         appendChildNode(child->parent()->removeChildNode(child));
0082     }
0083 
0084     void calcMinMaxWidth() override
0085     {
0086         setMinMaxKnown();
0087     }
0088 
0089     // Some containers do not want it's children
0090     // to be drawn, because they may be 'referenced'
0091     // Example: <marker> children in SVG
0092     void setDrawsContents(bool);
0093     bool drawsContents() const;
0094 
0095     bool isSVGContainer() const override
0096     {
0097         return true;
0098     }
0099     const char *renderName() const override
0100     {
0101         return "RenderSVGContainer";
0102     }
0103 
0104     bool requiresLayer() const override;
0105     short lineHeight(bool b) const override;
0106     short baselinePosition(bool b) const override;
0107 
0108     void layout() override;
0109     void paint(PaintInfo &, int parentX, int parentY) override;
0110 
0111     virtual IntRect absoluteClippedOverflowRect();
0112     virtual void absoluteRects(Vector<IntRect> &rects, int tx, int ty, bool topLevel = true);
0113 
0114     FloatRect relativeBBox(bool includeStroke = true) const override;
0115 
0116     virtual bool calculateLocalTransform();
0117     AffineTransform localTransform() const override;
0118     virtual AffineTransform viewportTransform() const;
0119 
0120     /*virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, int x, int y, int tx, int ty, HitTestAction);*/
0121 
0122     bool childAllowed() const override
0123     {
0124         return true;
0125     }
0126 
0127 protected:
0128     virtual void applyContentTransforms(PaintInfo &);
0129     virtual void applyAdditionalTransforms(PaintInfo &);
0130 
0131     void calcBounds();
0132 
0133 private:
0134     int calcReplacedWidth() const;
0135     int calcReplacedHeight() const;
0136 
0137     RenderObject *m_firstChild;
0138     RenderObject *m_lastChild;
0139 
0140     int m_width;
0141     int m_height;
0142 
0143     bool selfWillPaint() const;
0144 
0145     bool m_drawsContents : 1;
0146 
0147 protected:
0148     IntRect m_absoluteBounds;
0149     AffineTransform m_localTransform;
0150 };
0151 
0152 } // namespace WebCore
0153 
0154 #endif // ENABLE(SVG)
0155 #endif // RenderSVGContainer_h
0156