Home | History | Annotate | Download | only in svg
      1 /*
      2  * Copyright (C) 2007 Nikolas Zimmermann <zimmermann (at) kde.org>
      3  *
      4  * This library is free software; you can redistribute it and/or
      5  * modify it under the terms of the GNU Library General Public
      6  * License as published by the Free Software Foundation; either
      7  * version 2 of the License, or (at your option) any later version.
      8  *
      9  * This library is distributed in the hope that it will be useful,
     10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     12  * Library General Public License for more details.
     13  *
     14  * You should have received a copy of the GNU Library General Public License
     15  * along with this library; see the file COPYING.LIB.  If not, write to
     16  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
     17  * Boston, MA 02110-1301, USA.
     18  */
     19 
     20 #ifndef SVGTextPathElement_h
     21 #define SVGTextPathElement_h
     22 
     23 #include "core/SVGNames.h"
     24 #include "core/svg/SVGTextContentElement.h"
     25 #include "core/svg/SVGURIReference.h"
     26 
     27 namespace blink {
     28 
     29 enum SVGTextPathMethodType {
     30     SVGTextPathMethodUnknown = 0,
     31     SVGTextPathMethodAlign,
     32     SVGTextPathMethodStretch
     33 };
     34 
     35 enum SVGTextPathSpacingType {
     36     SVGTextPathSpacingUnknown = 0,
     37     SVGTextPathSpacingAuto,
     38     SVGTextPathSpacingExact
     39 };
     40 
     41 template<> const SVGEnumerationStringEntries& getStaticStringEntries<SVGTextPathMethodType>();
     42 template<> const SVGEnumerationStringEntries& getStaticStringEntries<SVGTextPathSpacingType>();
     43 
     44 class SVGTextPathElement FINAL : public SVGTextContentElement,
     45                                  public SVGURIReference {
     46     DEFINE_WRAPPERTYPEINFO();
     47 public:
     48     // Forward declare enumerations in the W3C naming scheme, for IDL generation.
     49     enum {
     50         TEXTPATH_METHODTYPE_UNKNOWN = SVGTextPathMethodUnknown,
     51         TEXTPATH_METHODTYPE_ALIGN = SVGTextPathMethodAlign,
     52         TEXTPATH_METHODTYPE_STRETCH = SVGTextPathMethodStretch,
     53         TEXTPATH_SPACINGTYPE_UNKNOWN = SVGTextPathSpacingUnknown,
     54         TEXTPATH_SPACINGTYPE_AUTO = SVGTextPathSpacingAuto,
     55         TEXTPATH_SPACINGTYPE_EXACT = SVGTextPathSpacingExact
     56     };
     57 
     58     DECLARE_NODE_FACTORY(SVGTextPathElement);
     59 
     60     SVGAnimatedLength* startOffset() const { return m_startOffset.get(); }
     61     SVGAnimatedEnumeration<SVGTextPathMethodType>* method() { return m_method.get(); }
     62     SVGAnimatedEnumeration<SVGTextPathSpacingType>* spacing() { return m_spacing.get(); }
     63 
     64 private:
     65     explicit SVGTextPathElement(Document&);
     66 
     67     virtual ~SVGTextPathElement();
     68 
     69     void clearResourceReferences();
     70 
     71     virtual void buildPendingResource() OVERRIDE;
     72     virtual InsertionNotificationRequest insertedInto(ContainerNode*) OVERRIDE;
     73     virtual void removedFrom(ContainerNode*) OVERRIDE;
     74 
     75     bool isSupportedAttribute(const QualifiedName&);
     76     virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERRIDE;
     77     virtual void svgAttributeChanged(const QualifiedName&) OVERRIDE;
     78 
     79     virtual RenderObject* createRenderer(RenderStyle*) OVERRIDE;
     80     virtual bool rendererIsNeeded(const RenderStyle&) OVERRIDE;
     81 
     82     virtual bool selfHasRelativeLengths() const OVERRIDE;
     83 
     84     RefPtr<SVGAnimatedLength> m_startOffset;
     85     RefPtr<SVGAnimatedEnumeration<SVGTextPathMethodType> > m_method;
     86     RefPtr<SVGAnimatedEnumeration<SVGTextPathSpacingType> > m_spacing;
     87 };
     88 
     89 } // namespace blink
     90 
     91 #endif // SVGTextPathElement_h
     92