1 /* 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Nikolas Zimmermann <zimmermann (at) kde.org> 3 * Copyright (C) 2004, 2005, 2007 Rob Buis <buis (at) kde.org> 4 * 5 * This library is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU Library General Public 7 * License as published by the Free Software Foundation; either 8 * version 2 of the License, or (at your option) any later version. 9 * 10 * This library is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * Library General Public License for more details. 14 * 15 * You should have received a copy of the GNU Library General Public License 16 * along with this library; see the file COPYING.LIB. If not, write to 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 18 * Boston, MA 02110-1301, USA. 19 */ 20 21 #ifndef SVGStyledElement_h 22 #define SVGStyledElement_h 23 24 #if ENABLE(SVG) 25 #include "SVGAnimatedString.h" 26 #include "SVGLocatable.h" 27 #include "SVGStylable.h" 28 #include <wtf/HashSet.h> 29 30 namespace WebCore { 31 32 void mapAttributeToCSSProperty(HashMap<AtomicStringImpl*, int>* propertyNameToIdMap, const QualifiedName& attrName); 33 34 class SVGStyledElement : public SVGElement, 35 public SVGStylable { 36 public: 37 virtual ~SVGStyledElement(); 38 39 virtual String title() const; 40 41 bool hasRelativeLengths() const { return !m_elementsWithRelativeLengths.isEmpty(); } 42 43 virtual bool supportsMarkers() const { return false; } 44 45 virtual PassRefPtr<CSSValue> getPresentationAttribute(const String& name); 46 47 bool isKnownAttribute(const QualifiedName&); 48 49 // Centralized place to force a manual style resolution. Hacky but needed for now. 50 PassRefPtr<RenderStyle> resolveStyle(RenderStyle* parentStyle); 51 52 bool instanceUpdatesBlocked() const; 53 void setInstanceUpdatesBlocked(bool); 54 55 AnimatedAttributeType animatedPropertyTypeForCSSProperty(const QualifiedName&); 56 static bool isAnimatableCSSProperty(const QualifiedName&); 57 58 virtual AffineTransform localCoordinateSpaceTransform(SVGLocatable::CTMScope) const; 59 60 virtual CSSStyleDeclaration* style() { return StyledElement::style(); } 61 62 protected: 63 SVGStyledElement(const QualifiedName&, Document*); 64 65 virtual bool rendererIsNeeded(RenderStyle*); 66 67 virtual bool mapToEntry(const QualifiedName&, MappedAttributeEntry&) const; 68 virtual void parseMappedAttribute(Attribute*); 69 virtual void svgAttributeChanged(const QualifiedName&); 70 virtual void synchronizeProperty(const QualifiedName&); 71 72 void fillPassedAttributeToPropertyTypeMap(AttributeToPropertyTypeMap&); 73 74 virtual void attach(); 75 virtual void insertedIntoDocument(); 76 virtual void removedFromDocument(); 77 virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0); 78 79 static int cssPropertyIdForSVGAttributeName(const QualifiedName&); 80 void updateRelativeLengthsInformation() { updateRelativeLengthsInformation(selfHasRelativeLengths(), this); } 81 void updateRelativeLengthsInformation(bool hasRelativeLengths, SVGStyledElement*); 82 83 virtual bool selfHasRelativeLengths() const { return false; } 84 85 private: 86 virtual bool isStyled() const { return true; } 87 88 HashSet<SVGStyledElement*> m_elementsWithRelativeLengths; 89 90 // Animated property declarations 91 DECLARE_ANIMATED_STRING(ClassName, className) 92 }; 93 94 } // namespace WebCore 95 96 #endif // ENABLE(SVG) 97 #endif // SVGStyledElement 98