Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(540)

Side by Side Diff: Source/core/svg/SVGElement.h

Issue 21042009: [SVG2] Merge SVGStyledElement into SVGElement (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase on master Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/svg/SVGDescElement.idl ('k') | Source/core/svg/SVGElement.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2 * Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org> 3 * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org>
4 * Copyright (C) 2009 Apple Inc. All rights reserved. 4 * Copyright (C) 2009 Apple Inc. All rights reserved.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
11 * This library is distributed in the hope that it will be useful, 11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details. 14 * Library General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU Library General Public License 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 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, 18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA. 19 * Boston, MA 02110-1301, USA.
20 */ 20 */
21 21
22 #ifndef SVGElement_h 22 #ifndef SVGElement_h
23 #define SVGElement_h 23 #define SVGElement_h
24 24
25 #include "core/dom/Element.h" 25 #include "core/dom/Element.h"
26 #include "core/platform/Timer.h" 26 #include "core/platform/Timer.h"
27 #include "core/svg/SVGAnimatedString.h"
27 #include "core/svg/SVGLangSpace.h" 28 #include "core/svg/SVGLangSpace.h"
28 #include "core/svg/SVGLocatable.h" 29 #include "core/svg/SVGLocatable.h"
29 #include "core/svg/SVGParsingError.h" 30 #include "core/svg/SVGParsingError.h"
31 #include "core/svg/properties/SVGAnimatedPropertyMacros.h"
30 #include "core/svg/properties/SVGPropertyInfo.h" 32 #include "core/svg/properties/SVGPropertyInfo.h"
31 #include "wtf/HashMap.h" 33 #include "wtf/HashMap.h"
32 34
33 namespace WebCore { 35 namespace WebCore {
34 36
35 class AffineTransform; 37 class AffineTransform;
36 class CSSCursorImageValue; 38 class CSSCursorImageValue;
37 class Document; 39 class Document;
38 class SVGAttributeToPropertyMap; 40 class SVGAttributeToPropertyMap;
39 class SVGCursorElement; 41 class SVGCursorElement;
40 class SVGDocumentExtensions; 42 class SVGDocumentExtensions;
41 class SVGElementInstance; 43 class SVGElementInstance;
42 class SVGElementRareData; 44 class SVGElementRareData;
43 class SVGSVGElement; 45 class SVGSVGElement;
44 46
47 void mapAttributeToCSSProperty(HashMap<StringImpl*, CSSPropertyID>* propertyName ToIdMap, const QualifiedName& attrName);
48
45 class SVGElement : public Element, public SVGLangSpace { 49 class SVGElement : public Element, public SVGLangSpace {
46 public: 50 public:
47 static PassRefPtr<SVGElement> create(const QualifiedName&, Document*); 51 static PassRefPtr<SVGElement> create(const QualifiedName&, Document*);
48 virtual ~SVGElement(); 52 virtual ~SVGElement();
49 53
50 bool isOutermostSVGSVGElement() const; 54 bool isOutermostSVGSVGElement() const;
51 55
56 virtual String title() const;
57 bool hasRelativeLengths() const { return !m_elementsWithRelativeLengths.isEm pty(); }
58 virtual bool supportsMarkers() const { return false; }
59 PassRefPtr<CSSValue> getPresentationAttribute(const String& name);
60 bool isKnownAttribute(const QualifiedName&);
61 static bool isAnimatableCSSProperty(const QualifiedName&);
62 virtual AffineTransform localCoordinateSpaceTransform(SVGLocatable::CTMScope ) const;
63 virtual bool needsPendingResourceHandling() const { return true; }
64
65 bool instanceUpdatesBlocked() const;
66 void setInstanceUpdatesBlocked(bool);
67
52 String xmlbase() const; 68 String xmlbase() const;
53 void setXmlbase(const String&); 69 void setXmlbase(const String&);
54 70
55 SVGSVGElement* ownerSVGElement() const; 71 SVGSVGElement* ownerSVGElement() const;
56 SVGElement* viewportElement() const; 72 SVGElement* viewportElement() const;
57 73
58 SVGDocumentExtensions* accessDocumentSVGExtensions(); 74 SVGDocumentExtensions* accessDocumentSVGExtensions();
59 75
60 virtual bool isSVGStyledElement() const { return false; }
61 virtual bool isSVGGraphicsElement() const { return false; } 76 virtual bool isSVGGraphicsElement() const { return false; }
62 virtual bool isSVGSVGElement() const { return false; } 77 virtual bool isSVGSVGElement() const { return false; }
63 virtual bool isFilterEffect() const { return false; } 78 virtual bool isFilterEffect() const { return false; }
64 virtual bool isGradientStop() const { return false; } 79 virtual bool isGradientStop() const { return false; }
65 virtual bool isTextContent() const { return false; } 80 virtual bool isTextContent() const { return false; }
66 81
67 // For SVGTests 82 // For SVGTests
68 virtual bool isValid() const { return true; } 83 virtual bool isValid() const { return true; }
69 84
70 virtual void svgAttributeChanged(const QualifiedName&) { } 85 virtual void svgAttributeChanged(const QualifiedName&);
71 86
72 virtual void animatedPropertyTypeForAttribute(const QualifiedName&, Vector<A nimatedPropertyType>&); 87 virtual void animatedPropertyTypeForAttribute(const QualifiedName&, Vector<A nimatedPropertyType>&);
73 88
74 void sendSVGLoadEventIfPossible(bool sendParentLoadEvents = false); 89 void sendSVGLoadEventIfPossible(bool sendParentLoadEvents = false);
75 void sendSVGLoadEventIfPossibleAsynchronously(); 90 void sendSVGLoadEventIfPossibleAsynchronously();
76 void svgLoadEventTimerFired(Timer<SVGElement>*); 91 void svgLoadEventTimerFired(Timer<SVGElement>*);
77 virtual Timer<SVGElement>* svgLoadEventTimer(); 92 virtual Timer<SVGElement>* svgLoadEventTimer();
78 93
79 virtual AffineTransform* supplementalTransform() { return 0; } 94 virtual AffineTransform* supplementalTransform() { return 0; }
80 95
(...skipping 16 matching lines...) Expand all
97 virtual PassRefPtr<RenderStyle> customStyleForRenderer() OVERRIDE; 112 virtual PassRefPtr<RenderStyle> customStyleForRenderer() OVERRIDE;
98 113
99 static void synchronizeRequiredFeatures(SVGElement* contextElement); 114 static void synchronizeRequiredFeatures(SVGElement* contextElement);
100 static void synchronizeRequiredExtensions(SVGElement* contextElement); 115 static void synchronizeRequiredExtensions(SVGElement* contextElement);
101 static void synchronizeSystemLanguage(SVGElement* contextElement); 116 static void synchronizeSystemLanguage(SVGElement* contextElement);
102 117
103 virtual void synchronizeRequiredFeatures() { } 118 virtual void synchronizeRequiredFeatures() { }
104 virtual void synchronizeRequiredExtensions() { } 119 virtual void synchronizeRequiredExtensions() { }
105 virtual void synchronizeSystemLanguage() { } 120 virtual void synchronizeSystemLanguage() { }
106 121
107 virtual SVGAttributeToPropertyMap& localAttributeToPropertyMap() const;
108
109 #ifndef NDEBUG 122 #ifndef NDEBUG
110 bool isAnimatableAttribute(const QualifiedName&) const; 123 bool isAnimatableAttribute(const QualifiedName&) const;
111 #endif 124 #endif
112 125
113 MutableStylePropertySet* animatedSMILStyleProperties() const; 126 MutableStylePropertySet* animatedSMILStyleProperties() const;
114 MutableStylePropertySet* ensureAnimatedSMILStyleProperties(); 127 MutableStylePropertySet* ensureAnimatedSMILStyleProperties();
115 void setUseOverrideComputedStyle(bool); 128 void setUseOverrideComputedStyle(bool);
116 129
117 virtual bool haveLoadedRequiredResources(); 130 virtual bool haveLoadedRequiredResources();
118 131
119 virtual bool addEventListener(const AtomicString& eventType, PassRefPtr<Even tListener>, bool useCapture) OVERRIDE; 132 virtual bool addEventListener(const AtomicString& eventType, PassRefPtr<Even tListener>, bool useCapture) OVERRIDE;
120 virtual bool removeEventListener(const AtomicString& eventType, EventListene r*, bool useCapture) OVERRIDE; 133 virtual bool removeEventListener(const AtomicString& eventType, EventListene r*, bool useCapture) OVERRIDE;
121 134
122 virtual bool shouldMoveToFlowThread(RenderStyle*) const OVERRIDE; 135 virtual bool shouldMoveToFlowThread(RenderStyle*) const OVERRIDE;
123 136
124 protected: 137 protected:
125 SVGElement(const QualifiedName&, Document*, ConstructionType = CreateSVGElem ent); 138 SVGElement(const QualifiedName&, Document*, ConstructionType = CreateSVGElem ent);
126 139
127 virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERR IDE; 140 virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERR IDE;
128 141
129 virtual void finishParsingChildren(); 142 virtual void finishParsingChildren();
130 virtual void attributeChanged(const QualifiedName&, const AtomicString&, Att ributeModificationReason = ModifiedDirectly) OVERRIDE; 143 virtual void attributeChanged(const QualifiedName&, const AtomicString&, Att ributeModificationReason = ModifiedDirectly) OVERRIDE;
131 virtual bool childShouldCreateRenderer(const NodeRenderingContext&) const OV ERRIDE; 144 virtual bool childShouldCreateRenderer(const NodeRenderingContext&) const OV ERRIDE;
132 145
146 virtual bool isPresentationAttribute(const QualifiedName&) const OVERRIDE;
147 virtual void collectStyleForPresentationAttribute(const QualifiedName&, cons t AtomicString&, MutableStylePropertySet*) OVERRIDE;
148 virtual bool rendererIsNeeded(const NodeRenderingContext&) OVERRIDE { return false; }
149 bool rendererIsNeededInternal(const NodeRenderingContext&);
150
151 virtual InsertionNotificationRequest insertedInto(ContainerNode*) OVERRIDE;
133 virtual void removedFrom(ContainerNode*) OVERRIDE; 152 virtual void removedFrom(ContainerNode*) OVERRIDE;
153 virtual void childrenChanged(bool changedByParser = false, Node* beforeChang e = 0, Node* afterChange = 0, int childCountDelta = 0);
154
155 static CSSPropertyID cssPropertyIdForSVGAttributeName(const QualifiedName&);
156 void updateRelativeLengthsInformation() { updateRelativeLengthsInformation(s elfHasRelativeLengths(), this); }
157 void updateRelativeLengthsInformation(bool hasRelativeLengths, SVGElement*);
158
159 virtual bool selfHasRelativeLengths() const { return false; }
134 160
135 SVGElementRareData* svgRareData() const; 161 SVGElementRareData* svgRareData() const;
136 SVGElementRareData* ensureSVGRareData(); 162 SVGElementRareData* ensureSVGRareData();
137 163
138 void reportAttributeParsingError(SVGParsingError, const QualifiedName&, cons t AtomicString&); 164 void reportAttributeParsingError(SVGParsingError, const QualifiedName&, cons t AtomicString&);
139 bool hasFocusEventListeners() const; 165 bool hasFocusEventListeners() const;
140 166
141 private: 167 private:
142 friend class SVGElementInstance; 168 friend class SVGElementInstance;
143 169
144 // FIXME: Author shadows should be allowed 170 // FIXME: Author shadows should be allowed
145 // https://bugs.webkit.org/show_bug.cgi?id=77938 171 // https://bugs.webkit.org/show_bug.cgi?id=77938
146 virtual bool areAuthorShadowsAllowed() const OVERRIDE { return false; } 172 virtual bool areAuthorShadowsAllowed() const OVERRIDE { return false; }
147 173
148 RenderStyle* computedStyle(PseudoId = NOPSEUDO); 174 RenderStyle* computedStyle(PseudoId = NOPSEUDO);
149 virtual RenderStyle* virtualComputedStyle(PseudoId pseudoElementSpecifier = NOPSEUDO) { return computedStyle(pseudoElementSpecifier); } 175 virtual RenderStyle* virtualComputedStyle(PseudoId pseudoElementSpecifier = NOPSEUDO) { return computedStyle(pseudoElementSpecifier); }
150 virtual void willRecalcStyle(StyleChange) OVERRIDE; 176 virtual void willRecalcStyle(StyleChange) OVERRIDE;
151 virtual bool isKeyboardFocusable(KeyboardEvent*) const OVERRIDE; 177 virtual bool isKeyboardFocusable(KeyboardEvent*) const OVERRIDE;
152 virtual bool rendererIsNeeded(const NodeRenderingContext&) { return false; } 178
179 void buildPendingResourcesIfNeeded();
153 180
154 virtual bool isSupported(StringImpl* feature, StringImpl* version) const; 181 virtual bool isSupported(StringImpl* feature, StringImpl* version) const;
155 182
156 void mapInstanceToElement(SVGElementInstance*); 183 void mapInstanceToElement(SVGElementInstance*);
157 void removeInstanceMapping(SVGElementInstance*); 184 void removeInstanceMapping(SVGElementInstance*);
158 185
186 HashSet<SVGElement*> m_elementsWithRelativeLengths;
187
188 BEGIN_DECLARE_ANIMATED_PROPERTIES(SVGElement)
189 DECLARE_ANIMATED_STRING(ClassName, className)
190 END_DECLARE_ANIMATED_PROPERTIES
159 }; 191 };
160 192
161 struct SVGAttributeHashTranslator { 193 struct SVGAttributeHashTranslator {
162 static unsigned hash(const QualifiedName& key) 194 static unsigned hash(const QualifiedName& key)
163 { 195 {
164 if (key.hasPrefix()) { 196 if (key.hasPrefix()) {
165 QualifiedNameComponents components = { nullAtom.impl(), key.localNam e().impl(), key.namespaceURI().impl() }; 197 QualifiedNameComponents components = { nullAtom.impl(), key.localNam e().impl(), key.namespaceURI().impl() };
166 return hashComponents(components); 198 return hashComponents(components);
167 } 199 }
168 return DefaultHash<QualifiedName>::Hash::hash(key); 200 return DefaultHash<QualifiedName>::Hash::hash(key);
169 } 201 }
170 static bool equal(const QualifiedName& a, const QualifiedName& b) { return a .matches(b); } 202 static bool equal(const QualifiedName& a, const QualifiedName& b) { return a .matches(b); }
171 }; 203 };
172 204
173 inline SVGElement* toSVGElement(Node* node) 205 inline SVGElement* toSVGElement(Node* node)
174 { 206 {
175 ASSERT_WITH_SECURITY_IMPLICATION(!node || node->isSVGElement()); 207 ASSERT_WITH_SECURITY_IMPLICATION(!node || node->isSVGElement());
176 return static_cast<SVGElement*>(node); 208 return static_cast<SVGElement*>(node);
177 } 209 }
178 210
179 inline const SVGElement* toSVGElement(const Node* node) 211 inline const SVGElement* toSVGElement(const Node* node)
180 { 212 {
181 ASSERT_WITH_SECURITY_IMPLICATION(!node || node->isSVGElement()); 213 ASSERT_WITH_SECURITY_IMPLICATION(!node || node->isSVGElement());
182 return static_cast<const SVGElement*>(node); 214 return static_cast<const SVGElement*>(node);
183 } 215 }
184 216
185 } 217 }
186 218
187 #endif 219 #endif
OLDNEW
« no previous file with comments | « Source/core/svg/SVGDescElement.idl ('k') | Source/core/svg/SVGElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698