Home | History | Annotate | Download | only in rendering
      1 /*
      2     Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann (at) kde.org>
      3                   2004, 2005 Rob Buis <buis (at) kde.org>
      4                   2005 Eric Seidel <eric (at) webkit.org>
      5                   2006 Apple Computer, Inc
      6                   2009 Google, Inc.
      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     aint 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 RenderPath_h
     25 #define RenderPath_h
     26 
     27 #if ENABLE(SVG)
     28 #include "AffineTransform.h"
     29 #include "FloatRect.h"
     30 #include "RenderSVGModelObject.h"
     31 #include "SVGMarkerLayoutInfo.h"
     32 
     33 namespace WebCore {
     34 
     35 class FloatPoint;
     36 class RenderSVGContainer;
     37 class SVGStyledTransformableElement;
     38 
     39 class RenderPath : public RenderSVGModelObject {
     40 public:
     41     RenderPath(SVGStyledTransformableElement*);
     42 
     43     const Path& path() const { return m_path; }
     44 
     45 private:
     46     // Hit-detection seperated for the fill and the stroke
     47     bool fillContains(const FloatPoint&, bool requiresFill = true) const;
     48     bool strokeContains(const FloatPoint&, bool requiresStroke = true) const;
     49 
     50     virtual FloatRect objectBoundingBox() const;
     51     virtual FloatRect strokeBoundingBox() const;
     52     virtual FloatRect markerBoundingBox() const;
     53     virtual FloatRect repaintRectInLocalCoordinates() const;
     54 
     55     virtual const AffineTransform& localToParentTransform() const;
     56 
     57     void setPath(const Path&);
     58 
     59     virtual bool isRenderPath() const { return true; }
     60     virtual const char* renderName() const { return "RenderPath"; }
     61 
     62     virtual void layout();
     63     virtual void paint(PaintInfo&, int parentX, int parentY);
     64     virtual void addFocusRingRects(Vector<IntRect>&, int tx, int ty);
     65 
     66     virtual bool nodeAtFloatPoint(const HitTestRequest&, HitTestResult&, const FloatPoint& pointInParent, HitTestAction);
     67 
     68     void calculateMarkerBoundsIfNeeded() const;
     69 
     70 private:
     71     virtual AffineTransform localTransform() const;
     72 
     73     mutable Path m_path;
     74     mutable FloatRect m_cachedLocalFillBBox;
     75     mutable FloatRect m_cachedLocalStrokeBBox;
     76     mutable FloatRect m_cachedLocalRepaintRect;
     77     mutable FloatRect m_cachedLocalMarkerBBox;
     78     mutable SVGMarkerLayoutInfo m_markerLayoutInfo;
     79     AffineTransform m_localTransform;
     80 };
     81 
     82 inline RenderPath* toRenderPath(RenderObject* object)
     83 {
     84     ASSERT(!object || object->isRenderPath());
     85     return static_cast<RenderPath*>(object);
     86 }
     87 
     88 inline const RenderPath* toRenderPath(const RenderObject* object)
     89 {
     90     ASSERT(!object || object->isRenderPath());
     91     return static_cast<const RenderPath*>(object);
     92 }
     93 
     94 // This will catch anyone doing an unnecessary cast.
     95 void toRenderPath(const RenderPath*);
     96 
     97 }
     98 
     99 #endif // ENABLE(SVG)
    100 #endif
    101