Home | History | Annotate | Download | only in svg
      1 /*
      2  * Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann (at) kde.org>
      3  * Copyright (C) 2004, 2005, 2006 Rob Buis <buis (at) kde.org>
      4  * Copyright (C) 2009 Apple Inc. All rights reserved.
      5  *
      6  * This library is free software; you can redistribute it and/or
      7  * modify it under the terms of the GNU Library General Public
      8  * License as published by the Free Software Foundation; either
      9  * version 2 of the License, or (at your option) any later version.
     10  *
     11  * This library is distributed in the hope that it will be useful,
     12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     14  * Library General Public License for more details.
     15  *
     16  * You should have received a copy of the GNU Library General Public License
     17  * along with this library; see the file COPYING.LIB.  If not, write to
     18  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
     19  * Boston, MA 02110-1301, USA.
     20  */
     21 
     22 #ifndef SVGElement_h
     23 #define SVGElement_h
     24 
     25 #if ENABLE(SVG)
     26 #include "SVGLocatable.h"
     27 #include "StyledElement.h"
     28 #include <wtf/HashMap.h>
     29 
     30 namespace WebCore {
     31 
     32 enum AnimatedAttributeType {
     33     AnimatedAngle,
     34     AnimatedBoolean,
     35     AnimatedColor,
     36     AnimatedEnumeration,
     37     AnimatedInteger,
     38     AnimatedLength,
     39     AnimatedLengthList,
     40     AnimatedNumber,
     41     AnimatedNumberList,
     42     AnimatedNumberOptionalNumber,
     43     AnimatedPath,
     44     AnimatedPoints,
     45     AnimatedPreserveAspectRatio,
     46     AnimatedRect,
     47     AnimatedString,
     48     AnimatedTransformList,
     49     AnimatedUnknown
     50 };
     51 
     52 typedef HashMap<QualifiedName, AnimatedAttributeType> AttributeToPropertyTypeMap;
     53 
     54 class CSSCursorImageValue;
     55 class Document;
     56 class SVGCursorElement;
     57 class SVGDocumentExtensions;
     58 class SVGElementInstance;
     59 class SVGElementRareData;
     60 class SVGSVGElement;
     61 class AffineTransform;
     62 
     63 class SVGElement : public StyledElement {
     64 public:
     65     static PassRefPtr<SVGElement> create(const QualifiedName&, Document*);
     66     virtual ~SVGElement();
     67 
     68     String xmlbase() const;
     69     void setXmlbase(const String&, ExceptionCode&);
     70 
     71     SVGSVGElement* ownerSVGElement() const;
     72     SVGElement* viewportElement() const;
     73 
     74     SVGDocumentExtensions* accessDocumentSVGExtensions() const;
     75 
     76     virtual bool isStyled() const { return false; }
     77     virtual bool isStyledTransformable() const { return false; }
     78     virtual bool isStyledLocatable() const { return false; }
     79     virtual bool isSVG() const { return false; }
     80     virtual bool isFilterEffect() const { return false; }
     81     virtual bool isGradientStop() const { return false; }
     82     virtual bool isTextContent() const { return false; }
     83 
     84     // For SVGTests
     85     virtual bool isValid() const { return true; }
     86 
     87     virtual void svgAttributeChanged(const QualifiedName&) { }
     88     virtual void synchronizeProperty(const QualifiedName&) { }
     89 
     90     virtual AttributeToPropertyTypeMap& attributeToPropertyTypeMap();
     91     AnimatedAttributeType animatedPropertyTypeForAttribute(const QualifiedName&);
     92 
     93     virtual void fillAttributeToPropertyTypeMap() { }
     94 
     95     void sendSVGLoadEventIfPossible(bool sendParentLoadEvents = false);
     96 
     97     virtual AffineTransform* supplementalTransform() { return 0; }
     98 
     99     void invalidateSVGAttributes() { clearAreSVGAttributesValid(); }
    100 
    101     const HashSet<SVGElementInstance*>& instancesForElement() const;
    102 
    103     bool boundingBox(FloatRect&, SVGLocatable::StyleUpdateStrategy = SVGLocatable::AllowStyleUpdate) const;
    104 
    105     void setCursorElement(SVGCursorElement*);
    106     void cursorElementRemoved();
    107     void setCursorImageValue(CSSCursorImageValue*);
    108     void cursorImageValueRemoved();
    109 
    110     virtual void updateAnimatedSVGAttribute(const QualifiedName&) const;
    111 
    112 protected:
    113     SVGElement(const QualifiedName&, Document*);
    114 
    115     virtual void parseMappedAttribute(Attribute*);
    116 
    117     virtual void finishParsingChildren();
    118     virtual void insertedIntoDocument();
    119     virtual void attributeChanged(Attribute*, bool preserveDecls = false);
    120     virtual bool childShouldCreateRenderer(Node*) const;
    121 
    122     virtual void removedFromDocument();
    123 
    124     SVGElementRareData* rareSVGData() const;
    125     SVGElementRareData* ensureRareSVGData();
    126 
    127 private:
    128     friend class SVGElementInstance;
    129 
    130     virtual bool rendererIsNeeded(RenderStyle*) { return false; }
    131 
    132     virtual bool isSupported(StringImpl* feature, StringImpl* version) const;
    133 
    134     virtual bool needsPendingResourceHandling() const { return true; }
    135     virtual void buildPendingResource() { }
    136 
    137     void mapInstanceToElement(SVGElementInstance*);
    138     void removeInstanceMapping(SVGElementInstance*);
    139 
    140     virtual bool haveLoadedRequiredResources();
    141 };
    142 
    143 }
    144 
    145 #endif
    146 #endif
    147