OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org> | 2 * Copyright (C) 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org> |
3 * Copyright (C) 2011 Torch Mobile (Beijing) Co. Ltd. All rights reserved. | 3 * Copyright (C) 2011 Torch Mobile (Beijing) Co. Ltd. All rights reserved. |
4 * | 4 * |
5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
9 * | 9 * |
10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 * Library General Public License for more details. | 13 * Library General Public License for more details. |
14 * | 14 * |
15 * You should have received a copy of the GNU Library General Public License | 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 | 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, | 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
18 * Boston, MA 02110-1301, USA. | 18 * Boston, MA 02110-1301, USA. |
19 */ | 19 */ |
20 | 20 |
21 #ifndef SVGElementInstance_h | 21 #ifndef SVGElementInstance_h |
22 #define SVGElementInstance_h | 22 #define SVGElementInstance_h |
23 | 23 |
| 24 #include "bindings/v8/ScriptWrappable.h" |
24 #include "core/dom/EventTarget.h" | 25 #include "core/dom/EventTarget.h" |
25 #include "core/platform/TreeShared.h" | 26 #include "core/platform/TreeShared.h" |
26 #include "core/svg/SVGElement.h" | 27 #include "core/svg/SVGElement.h" |
27 | 28 |
28 namespace WebCore { | 29 namespace WebCore { |
29 | 30 |
30 namespace Private { | 31 namespace Private { |
31 template<class GenericNode, class GenericNodeContainer> | 32 template<class GenericNode, class GenericNodeContainer> |
32 void addChildNodesToDeletionQueue(GenericNode*& head, GenericNode*& tail, Generi
cNodeContainer* container); | 33 void addChildNodesToDeletionQueue(GenericNode*& head, GenericNode*& tail, Generi
cNodeContainer* container); |
33 }; | 34 }; |
34 | 35 |
35 class SVGUseElement; | 36 class SVGUseElement; |
36 class SVGElementInstanceList; | 37 class SVGElementInstanceList; |
37 class SVGStyledElement; | 38 class SVGStyledElement; |
38 | 39 |
39 // SVGElementInstance mimics Node, but without providing all its functionality | 40 // SVGElementInstance mimics Node, but without providing all its functionality |
40 class SVGElementInstance : public EventTarget, public TreeShared<SVGElementInsta
nce> { | 41 class SVGElementInstance : public EventTarget, public ScriptWrappable, public Tr
eeShared<SVGElementInstance> { |
41 public: | 42 public: |
42 static PassRefPtr<SVGElementInstance> create(SVGUseElement* correspondingUse
Element, SVGUseElement* directUseElement, PassRefPtr<SVGElement> originalElement
) | 43 static PassRefPtr<SVGElementInstance> create(SVGUseElement* correspondingUse
Element, SVGUseElement* directUseElement, PassRefPtr<SVGElement> originalElement
) |
43 { | 44 { |
44 return adoptRef(new SVGElementInstance(correspondingUseElement, directUs
eElement, originalElement)); | 45 return adoptRef(new SVGElementInstance(correspondingUseElement, directUs
eElement, originalElement)); |
45 } | 46 } |
46 | 47 |
47 virtual ~SVGElementInstance(); | 48 virtual ~SVGElementInstance(); |
48 | 49 |
49 void setParentOrShadowHostNode(SVGElementInstance* instance) { m_parentInsta
nce = instance; } | 50 void setParentOrShadowHostNode(SVGElementInstance* instance) { m_parentInsta
nce = instance; } |
50 | 51 |
(...skipping 20 matching lines...) Expand all Loading... |
71 SVGElementInstance* previousSibling() const { return m_previousSibling; } | 72 SVGElementInstance* previousSibling() const { return m_previousSibling; } |
72 SVGElementInstance* nextSibling() const { return m_nextSibling; } | 73 SVGElementInstance* nextSibling() const { return m_nextSibling; } |
73 | 74 |
74 SVGElementInstance* firstChild() const { return m_firstChild; } | 75 SVGElementInstance* firstChild() const { return m_firstChild; } |
75 SVGElementInstance* lastChild() const { return m_lastChild; } | 76 SVGElementInstance* lastChild() const { return m_lastChild; } |
76 | 77 |
77 Document* ownerDocument() const { return m_element ? m_element->ownerDocumen
t() : 0; } | 78 Document* ownerDocument() const { return m_element ? m_element->ownerDocumen
t() : 0; } |
78 | 79 |
79 class InvalidationGuard { | 80 class InvalidationGuard { |
80 WTF_MAKE_NONCOPYABLE(InvalidationGuard); | 81 WTF_MAKE_NONCOPYABLE(InvalidationGuard); |
81 public: | 82 public: |
82 InvalidationGuard(SVGElement* element) : m_element(element) { } | 83 InvalidationGuard(SVGElement* element) : m_element(element) { } |
83 ~InvalidationGuard() { SVGElementInstance::invalidateAllInstancesOfEleme
nt(m_element); } | 84 ~InvalidationGuard() { SVGElementInstance::invalidateAllInstancesOfEleme
nt(m_element); } |
84 private: | 85 private: |
85 SVGElement* m_element; | 86 SVGElement* m_element; |
86 }; | 87 }; |
87 | 88 |
88 class InstanceUpdateBlocker { | 89 class InstanceUpdateBlocker { |
89 WTF_MAKE_NONCOPYABLE(InstanceUpdateBlocker); | 90 WTF_MAKE_NONCOPYABLE(InstanceUpdateBlocker); |
90 public: | 91 public: |
91 InstanceUpdateBlocker(SVGElement* targetElement); | 92 InstanceUpdateBlocker(SVGElement* targetElement); |
92 ~InstanceUpdateBlocker(); | 93 ~InstanceUpdateBlocker(); |
93 | 94 |
94 private: | 95 private: |
95 SVGStyledElement* m_targetElement; | 96 SVGStyledElement* m_targetElement; |
96 }; | 97 }; |
97 | 98 |
98 static void invalidateAllInstancesOfElement(SVGElement*); | 99 static void invalidateAllInstancesOfElement(SVGElement*); |
99 | 100 |
100 using TreeShared<SVGElementInstance>::ref; | 101 using TreeShared<SVGElementInstance>::ref; |
101 using TreeShared<SVGElementInstance>::deref; | 102 using TreeShared<SVGElementInstance>::deref; |
102 | 103 |
103 // EventTarget API | 104 // EventTarget API |
104 DEFINE_FORWARDING_ATTRIBUTE_EVENT_LISTENER(correspondingElement(), abort); | 105 DEFINE_FORWARDING_ATTRIBUTE_EVENT_LISTENER(correspondingElement(), abort); |
105 DEFINE_FORWARDING_ATTRIBUTE_EVENT_LISTENER(correspondingElement(), blur); | 106 DEFINE_FORWARDING_ATTRIBUTE_EVENT_LISTENER(correspondingElement(), blur); |
106 DEFINE_FORWARDING_ATTRIBUTE_EVENT_LISTENER(correspondingElement(), change); | 107 DEFINE_FORWARDING_ATTRIBUTE_EVENT_LISTENER(correspondingElement(), change); |
107 DEFINE_FORWARDING_ATTRIBUTE_EVENT_LISTENER(correspondingElement(), click); | 108 DEFINE_FORWARDING_ATTRIBUTE_EVENT_LISTENER(correspondingElement(), click); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 | 165 |
165 template<class GenericNode, class GenericNodeContainer> | 166 template<class GenericNode, class GenericNodeContainer> |
166 friend void Private::addChildNodesToDeletionQueue(GenericNode*& head, Generi
cNode*& tail, GenericNodeContainer* container); | 167 friend void Private::addChildNodesToDeletionQueue(GenericNode*& head, Generi
cNode*& tail, GenericNodeContainer* container); |
167 | 168 |
168 bool hasChildNodes() const { return m_firstChild; } | 169 bool hasChildNodes() const { return m_firstChild; } |
169 | 170 |
170 void setFirstChild(SVGElementInstance* child) { m_firstChild = child; } | 171 void setFirstChild(SVGElementInstance* child) { m_firstChild = child; } |
171 void setLastChild(SVGElementInstance* child) { m_lastChild = child; } | 172 void setLastChild(SVGElementInstance* child) { m_lastChild = child; } |
172 | 173 |
173 void setNextSibling(SVGElementInstance* sibling) { m_nextSibling = sibling;
} | 174 void setNextSibling(SVGElementInstance* sibling) { m_nextSibling = sibling;
} |
174 void setPreviousSibling(SVGElementInstance* sibling) { m_previousSibling = s
ibling; } | 175 void setPreviousSibling(SVGElementInstance* sibling) { m_previousSibling = s
ibling; } |
175 | 176 |
176 virtual void refEventTarget() { ref(); } | 177 virtual void refEventTarget() { ref(); } |
177 virtual void derefEventTarget() { deref(); } | 178 virtual void derefEventTarget() { deref(); } |
178 virtual EventTargetData* eventTargetData(); | 179 virtual EventTargetData* eventTargetData(); |
179 virtual EventTargetData* ensureEventTargetData(); | 180 virtual EventTargetData* ensureEventTargetData(); |
180 | 181 |
181 SVGElementInstance* m_parentInstance; | 182 SVGElementInstance* m_parentInstance; |
182 | 183 |
183 SVGUseElement* m_correspondingUseElement; | 184 SVGUseElement* m_correspondingUseElement; |
184 SVGUseElement* m_directUseElement; | 185 SVGUseElement* m_directUseElement; |
185 RefPtr<SVGElement> m_element; | 186 RefPtr<SVGElement> m_element; |
186 RefPtr<SVGElement> m_shadowTreeElement; | 187 RefPtr<SVGElement> m_shadowTreeElement; |
187 | 188 |
188 SVGElementInstance* m_previousSibling; | 189 SVGElementInstance* m_previousSibling; |
189 SVGElementInstance* m_nextSibling; | 190 SVGElementInstance* m_nextSibling; |
190 | 191 |
191 SVGElementInstance* m_firstChild; | 192 SVGElementInstance* m_firstChild; |
192 SVGElementInstance* m_lastChild; | 193 SVGElementInstance* m_lastChild; |
193 }; | 194 }; |
194 | 195 |
195 } // namespace WebCore | 196 } // namespace WebCore |
196 | 197 |
197 #endif | 198 #endif |
OLD | NEW |