23 #include "wtf/Platform.h"
33 #include <wtf/Assertions.h>
37 SVGElementInstance::SVGElementInstance(SVGUseElement* useElement, PassRefPtr<SVGElement> originalElement)
40 , m_useElement(useElement)
41 , m_element(originalElement)
42 , m_shadowTreeElement(0)
43 , m_previousSibling(0)
52 m_element->document()->accessSVGExtensions()->mapInstanceToElement(
this, m_element.get());
55 SVGElementInstance::~SVGElementInstance()
57 for (RefPtr<SVGElementInstance> child = m_firstChild; child; child = child->m_nextSibling)
61 m_element->document()->accessSVGExtensions()->removeInstanceMapping(
this, m_element.get());
64 SVGElement* SVGElementInstance::correspondingElement()
const
66 return m_element.get();
69 SVGUseElement* SVGElementInstance::correspondingUseElement()
const
74 SVGElementInstance* SVGElementInstance::parentNode()
const
79 PassRefPtr<SVGElementInstanceList> SVGElementInstance::childNodes()
81 return SVGElementInstanceList::create(
this);
84 SVGElementInstance* SVGElementInstance::previousSibling()
const
86 return m_previousSibling;
89 SVGElementInstance* SVGElementInstance::nextSibling()
const
94 SVGElementInstance* SVGElementInstance::firstChild()
const
99 SVGElementInstance* SVGElementInstance::lastChild()
const
104 SVGElement* SVGElementInstance::shadowTreeElement()
const
106 return m_shadowTreeElement;
109 void SVGElementInstance::setShadowTreeElement(SVGElement* element)
112 m_shadowTreeElement = element;
115 void SVGElementInstance::appendChild(PassRefPtr<SVGElementInstance> child)
117 child->setParent(
this);
120 child->m_previousSibling = m_lastChild;
121 m_lastChild->m_nextSibling = child.get();
123 m_firstChild = child.get();
125 m_lastChild = child.get();
129 static bool containsUseChildNode(Node* start)
134 for (Node* current = start->firstChild(); current; current = current->nextSibling()) {
135 if (containsUseChildNode(current))
142 void SVGElementInstance::updateInstance(SVGElement* element)
144 ASSERT(element == m_element);
145 ASSERT(m_shadowTreeElement);
160 containsUseChildNode(m_element.get())) {
161 m_useElement->buildPendingResource();
166 WTF::PassRefPtr<Node> clone = m_element->cloneNode(
true);
167 SVGUseElement::removeDisallowedElementsFromSubtree(clone.get());
168 SVGElement* svgClone = 0;
169 if (clone && clone->isSVGElement())
170 svgClone = static_cast<SVGElement*>(clone.get());
175 m_shadowTreeElement->parentNode()->replaceChild(clone.releaseRef(), m_shadowTreeElement, ec);
178 m_shadowTreeElement = svgClone;
181 SVGElementInstance* SVGElementInstance::toSVGElementInstance()
186 EventTargetNode* SVGElementInstance::toNode()
188 return m_element.get();
191 void SVGElementInstance::addEventListener(
const AtomicString& eventType, PassRefPtr<EventListener> eventListener,
bool useCapture)
194 Q_UNUSED(eventListener);
195 Q_UNUSED(useCapture);
199 void SVGElementInstance::removeEventListener(
const AtomicString& eventType, EventListener* eventListener,
bool useCapture)
202 Q_UNUSED(eventListener);
203 Q_UNUSED(useCapture);
207 bool SVGElementInstance::dispatchEvent(PassRefPtr<Event>, ExceptionCode& ec,
bool tempEvent)
217 #endif // ENABLE(SVG)
DOM::QualifiedName useTag
DOM::QualifiedName svgTag
DOM::QualifiedName symbolTag