2 Copyright (C) 2006 Apple Computer, Inc.
3 2006 Nikolas Zimmermann <zimmermann@kde.org>
4 2007 Rob Buis <buis@kde.org>
6 This file is part of the WebKit project
8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Library General Public
10 License as published by the Free Software Foundation; either
11 version 2 of the License, or (at your option) any later version.
13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Library General Public License for more details.
18 You should have received a copy of the GNU Library General Public License
19 along with this library; see the file COPYING.LIB. If not, write to
20 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 Boston, MA 02110-1301, USA.
25 #include <wtf/Platform.h>
28 #include "SVGDocumentExtensions.h"
30 /*#include "AtomicString.h"
32 #include "DOMWindow.h"*/
33 //#include "Document.h"
34 #include "xml/Document.h"
35 //#include "EventListener.h"
36 #include "dom/dom2_events.h"
38 #include "FrameLoader.h"
40 #include "SVGSVGElement.h"
41 /*#include "SMILTimeContainer.h"
42 #include "XMLTokenizer.h"*/
43 #include "kjs_proxy.h"
44 #include "khtml_part.h"
48 SVGDocumentExtensions::SVGDocumentExtensions(Document
* doc
)
53 SVGDocumentExtensions::~SVGDocumentExtensions()
55 /*deleteAllValues(m_pendingResources);*/
56 deleteAllValues(m_elementInstances
);
59 EventListener
* SVGDocumentExtensions::createSVGEventListener(const String
& functionName
, const String
& code
, Node
*node
)
61 /*if (Frame* frame = m_doc->frame())
62 if (frame->scriptProxy()->isEnabled())
63 return frame->scriptProxy()->createSVGEventHandler(functionName, code, node);*/
64 if (!m_doc
|| !m_doc
->part())
66 kDebug() << "create listener: (" << code
<< functionName
<< node
<< ")" << endl
;
67 return m_doc
->part()->createHTMLEventListener(code
.string(), functionName
.string(), node
, true/*svg*/);
70 void SVGDocumentExtensions::addTimeContainer(SVGSVGElement
* element
)
72 /*m_timeContainers.add(element);*/
75 void SVGDocumentExtensions::removeTimeContainer(SVGSVGElement
* element
)
77 /*m_timeContainers.remove(element);*/
80 void SVGDocumentExtensions::startAnimations()
82 // FIXME: Eventually every "Time Container" will need a way to latch on to some global timer
83 // starting animations for a document will do this "latching"
84 #if ENABLE(SVG_ANIMATION)
85 HashSet
<SVGSVGElement
*>::iterator end
= m_timeContainers
.end();
86 for (HashSet
<SVGSVGElement
*>::iterator itr
= m_timeContainers
.begin(); itr
!= end
; ++itr
)
87 (*itr
)->timeContainer()->begin();
91 void SVGDocumentExtensions::pauseAnimations()
93 HashSet
<SVGSVGElement
*>::iterator end
= m_timeContainers
.end();
94 for (HashSet
<SVGSVGElement
*>::iterator itr
= m_timeContainers
.begin(); itr
!= end
; ++itr
)
95 (*itr
)->pauseAnimations();
98 void SVGDocumentExtensions::unpauseAnimations()
100 HashSet
<SVGSVGElement
*>::iterator end
= m_timeContainers
.end();
101 for (HashSet
<SVGSVGElement
*>::iterator itr
= m_timeContainers
.begin(); itr
!= end
; ++itr
)
102 (*itr
)->unpauseAnimations();
105 void SVGDocumentExtensions::reportWarning(const String
& message
)
107 /*if (Frame* frame = m_doc->frame())
108 frame->domWindow()->console()->addMessage(JSMessageSource, ErrorMessageLevel, "Warning: " + message, m_doc->tokenizer() ? m_doc->tokenizer()->lineNumber() : 1, String());*/
111 void SVGDocumentExtensions::reportError(const String
& message
)
113 /*if (Frame* frame = m_doc->frame())
114 frame->domWindow()->console()->addMessage(JSMessageSource, ErrorMessageLevel, "Error: " + message, m_doc->tokenizer() ? m_doc->tokenizer()->lineNumber() : 1, String());*/
117 void SVGDocumentExtensions::addPendingResource(const AtomicString
& id
, SVGStyledElement
* obj
)
124 /*if (m_pendingResources.contains(id))
125 m_pendingResources.get(id)->add(obj);
127 HashSet<SVGStyledElement*>* set = new HashSet<SVGStyledElement*>();
130 m_pendingResources.add(id, set);
134 bool SVGDocumentExtensions::isPendingResource(const AtomicString
& id
) const
139 return m_pendingResources.contains(id);*/
144 std::auto_ptr
<HashSet
<SVGStyledElement
*> > SVGDocumentExtensions::removePendingResource(const AtomicString
& id
)
146 /*ASSERT(m_pendingResources.contains(id));
148 std::auto_ptr<HashSet<SVGStyledElement*> > set(m_pendingResources.get(id));
149 m_pendingResources.remove(id);
152 return std::auto_ptr
<HashSet
<SVGStyledElement
*> >();
155 void SVGDocumentExtensions::mapInstanceToElement(SVGElementInstance
* instance
, SVGElement
* element
)
160 if (m_elementInstances
.contains(element
))
161 m_elementInstances
.get(element
)->add(instance
);
163 HashSet
<SVGElementInstance
*>* set
= new HashSet
<SVGElementInstance
*>();
166 m_elementInstances
.add(element
, set
);
170 void SVGDocumentExtensions::removeInstanceMapping(SVGElementInstance
* instance
, SVGElement
* element
)
174 if (!m_elementInstances
.contains(element
))
177 m_elementInstances
.get(element
)->remove(instance
);
180 HashSet
<SVGElementInstance
*>* SVGDocumentExtensions::instancesForElement(SVGElement
* element
) const
183 return m_elementInstances
.get(element
);