OSDN Git Service

Merge WebKit at r71558: Initial merge by git.
[android-x86/external-webkit.git] / WebCore / svg / SVGStyledElement.h
1 /*
2  * Copyright (C) 2004, 2005, 2006, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org>
3  * Copyright (C) 2004, 2005, 2007 Rob Buis <buis@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 "SVGAnimatedPropertyMacros.h"
26 #include "HTMLNames.h"
27 #include "SVGLocatable.h"
28 #include "SVGStylable.h"
29 #include <wtf/HashSet.h>
30
31 namespace WebCore {
32
33     void mapAttributeToCSSProperty(HashMap<AtomicStringImpl*, int>* propertyNameToIdMap, const QualifiedName& attrName);
34
35     class SVGStyledElement : public SVGElement,
36                              public SVGStylable {
37     public:
38         virtual ~SVGStyledElement();
39
40         virtual String title() const;
41
42         bool hasRelativeLengths() const { return !m_elementsWithRelativeLengths.isEmpty(); }
43
44         virtual bool supportsMarkers() const { return false; }
45
46         virtual PassRefPtr<CSSValue> getPresentationAttribute(const String& name);
47
48         bool isKnownAttribute(const QualifiedName&);
49
50         // Centralized place to force a manual style resolution. Hacky but needed for now.
51         PassRefPtr<RenderStyle> resolveStyle(RenderStyle* parentStyle);
52
53         bool instanceUpdatesBlocked() const;
54         void setInstanceUpdatesBlocked(bool);
55
56         virtual AffineTransform localCoordinateSpaceTransform(SVGLocatable::CTMScope) const;
57
58         virtual CSSStyleDeclaration* style() { return StyledElement::style(); }
59
60     protected: 
61         SVGStyledElement(const QualifiedName&, Document*);
62
63         virtual bool rendererIsNeeded(RenderStyle*);
64
65         virtual bool mapToEntry(const QualifiedName&, MappedAttributeEntry&) const;
66         virtual void parseMappedAttribute(Attribute*);
67         virtual void svgAttributeChanged(const QualifiedName&);
68         virtual void synchronizeProperty(const QualifiedName&);
69
70         virtual void attach();
71         virtual void insertedIntoDocument();
72         virtual void removedFromDocument();
73         virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0);
74
75         static int cssPropertyIdForSVGAttributeName(const QualifiedName&);
76         void updateRelativeLengthsInformation() { updateRelativeLengthsInformation(selfHasRelativeLengths(), this); }
77         void updateRelativeLengthsInformation(bool hasRelativeLengths, SVGStyledElement*);
78
79         virtual bool selfHasRelativeLengths() const { return false; }
80
81     private:
82         virtual bool isStyled() const { return true; }
83
84         HashSet<SVGStyledElement*> m_elementsWithRelativeLengths;
85
86         DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGStyledElement, HTMLNames::classAttr, String, ClassName, className)
87     };
88
89 } // namespace WebCore
90
91 #endif // ENABLE(SVG)
92 #endif // SVGStyledElement