• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2     Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
3                   2004, 2005, 2007 Rob Buis <buis@kde.org>
4                   2009 Google, Inc.
5     Copyright (C) 2009 Apple 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     aint 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 #ifndef RenderSVGViewportContainer_h
24 #define RenderSVGViewportContainer_h
25 
26 #if ENABLE(SVG)
27 #include "RenderSVGContainer.h"
28 
29 namespace WebCore {
30 
31 // This is used for non-root <svg> elements and <marker> elements, neither of which are SVGTransformable
32 // thus we inherit from RenderSVGContainer instead of RenderSVGTransformableContainer
33 class RenderSVGViewportContainer : public RenderSVGContainer {
34 public:
35     RenderSVGViewportContainer(SVGStyledElement*);
36 
37     // Calculates marker boundaries, mapped to the target element's coordinate space
38     FloatRect markerBoundaries(const AffineTransform& markerTransformation) const;
39 
40     // Generates a transformation matrix usable to render marker content. Handles scaling the marker content
41     // acording to SVGs markerUnits="strokeWidth" concept, when a strokeWidth value != -1 is passed in.
42     AffineTransform markerContentTransformation(const AffineTransform& contentTransformation, const FloatPoint& origin, float strokeWidth = -1) const;
43 
44 private:
isSVGContainer()45     virtual bool isSVGContainer() const { return true; }
renderName()46     virtual const char* renderName() const { return "RenderSVGViewportContainer"; }
47 
48     AffineTransform viewportTransform() const;
49     virtual const AffineTransform& localToParentTransform() const;
50 
51     virtual void calcViewport();
52 
53     virtual void applyViewportClip(PaintInfo&);
54     virtual bool pointIsInsideViewportClip(const FloatPoint& pointInParent);
55 
56     FloatRect m_viewport;
57     mutable AffineTransform m_localToParentTransform;
58 };
59 
toRenderSVGViewportContainer(RenderObject * object)60 inline RenderSVGViewportContainer* toRenderSVGViewportContainer(RenderObject* object)
61 {
62     ASSERT(!object || !strcmp(object->renderName(), "RenderSVGViewportContainer"));
63     return static_cast<RenderSVGViewportContainer*>(object);
64 }
65 
66 // This will catch anyone doing an unnecessary cast.
67 void toRenderSVGViewportContainer(const RenderSVGViewportContainer*);
68 
69 } // namespace WebCore
70 
71 #endif // ENABLE(SVG)
72 #endif // RenderSVGViewportContainer_h
73