KHTML
SVGDocumentExtensions.cpp
Go to the documentation of this file.
00001 /* 00002 Copyright (C) 2006 Apple Computer, Inc. 00003 2006 Nikolas Zimmermann <zimmermann@kde.org> 00004 2007 Rob Buis <buis@kde.org> 00005 00006 This file is part of the WebKit project 00007 00008 This library is free software; you can redistribute it and/or 00009 modify it under the terms of the GNU Library General Public 00010 License as published by the Free Software Foundation; either 00011 version 2 of the License, or (at your option) any later version. 00012 00013 This library is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 Library General Public License for more details. 00017 00018 You should have received a copy of the GNU Library General Public License 00019 along with this library; see the file COPYING.LIB. If not, write to 00020 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00021 Boston, MA 02110-1301, USA. 00022 */ 00023 00024 #include "config.h" 00025 #include <wtf/Platform.h> 00026 00027 #if ENABLE(SVG) 00028 #include "SVGDocumentExtensions.h" 00029 00030 /*#include "AtomicString.h" 00031 #include "Console.h" 00032 #include "DOMWindow.h"*/ 00033 //#include "Document.h" 00034 #include "xml/Document.h" 00035 //#include "EventListener.h" 00036 #include "dom/dom2_events.h" 00037 /*#include "Frame.h" 00038 #include "FrameLoader.h" 00039 #include "Page.h"*/ 00040 #include "SVGSVGElement.h" 00041 /*#include "SMILTimeContainer.h" 00042 #include "XMLTokenizer.h"*/ 00043 #include "kjs_proxy.h" 00044 #include "khtml_part.h" 00045 00046 namespace WebCore { 00047 00048 SVGDocumentExtensions::SVGDocumentExtensions(Document* doc) 00049 : m_doc(doc) 00050 { 00051 } 00052 00053 SVGDocumentExtensions::~SVGDocumentExtensions() 00054 { 00055 /*deleteAllValues(m_pendingResources);*/ 00056 deleteAllValues(m_elementInstances); 00057 } 00058 00059 EventListener* SVGDocumentExtensions::createSVGEventListener(const DOMString& functionName, const DOMString& code, DOM::NodeImpl* node) 00060 { 00061 /*if (Frame* frame = m_doc->frame()) 00062 if (frame->scriptProxy()->isEnabled()) 00063 return frame->scriptProxy()->createSVGEventHandler(functionName, code, node);*/ 00064 if (!m_doc || !m_doc->part()) 00065 return 0; 00066 kDebug() << "create listener: (" << code << functionName << node << ")" << endl; 00067 return m_doc->part()->createHTMLEventListener(code.string(), functionName.string(), node, true/*svg*/); 00068 } 00069 00070 void SVGDocumentExtensions::addTimeContainer(SVGSVGElement* element) 00071 { 00072 Q_UNUSED(element); 00073 /*m_timeContainers.add(element);*/ 00074 } 00075 00076 void SVGDocumentExtensions::removeTimeContainer(SVGSVGElement* element) 00077 { 00078 Q_UNUSED(element); 00079 /*m_timeContainers.remove(element);*/ 00080 } 00081 00082 void SVGDocumentExtensions::startAnimations() 00083 { 00084 // FIXME: Eventually every "Time Container" will need a way to latch on to some global timer 00085 // starting animations for a document will do this "latching" 00086 #if ENABLE(SVG_ANIMATION) 00087 HashSet<SVGSVGElement*>::iterator end = m_timeContainers.end(); 00088 for (HashSet<SVGSVGElement*>::iterator itr = m_timeContainers.begin(); itr != end; ++itr) 00089 (*itr)->timeContainer()->begin(); 00090 #endif 00091 } 00092 00093 void SVGDocumentExtensions::pauseAnimations() 00094 { 00095 HashSet<SVGSVGElement*>::iterator end = m_timeContainers.end(); 00096 for (HashSet<SVGSVGElement*>::iterator itr = m_timeContainers.begin(); itr != end; ++itr) 00097 (*itr)->pauseAnimations(); 00098 } 00099 00100 void SVGDocumentExtensions::unpauseAnimations() 00101 { 00102 HashSet<SVGSVGElement*>::iterator end = m_timeContainers.end(); 00103 for (HashSet<SVGSVGElement*>::iterator itr = m_timeContainers.begin(); itr != end; ++itr) 00104 (*itr)->unpauseAnimations(); 00105 } 00106 00107 void SVGDocumentExtensions::reportWarning(const String& message) 00108 { 00109 Q_UNUSED(message); 00110 /*if (Frame* frame = m_doc->frame()) 00111 frame->domWindow()->console()->addMessage(JSMessageSource, ErrorMessageLevel, "Warning: " + message, m_doc->tokenizer() ? m_doc->tokenizer()->lineNumber() : 1, String());*/ 00112 } 00113 00114 void SVGDocumentExtensions::reportError(const String& message) 00115 { 00116 Q_UNUSED(message); 00117 /*if (Frame* frame = m_doc->frame()) 00118 frame->domWindow()->console()->addMessage(JSMessageSource, ErrorMessageLevel, "Error: " + message, m_doc->tokenizer() ? m_doc->tokenizer()->lineNumber() : 1, String());*/ 00119 } 00120 00121 void SVGDocumentExtensions::addPendingResource(const AtomicString& id, SVGStyledElement* obj) 00122 { 00123 ASSERT(obj); 00124 00125 if (id.isEmpty()) 00126 return; 00127 00128 /*if (m_pendingResources.contains(id)) 00129 m_pendingResources.get(id)->add(obj); 00130 else { 00131 HashSet<SVGStyledElement*>* set = new HashSet<SVGStyledElement*>(); 00132 set->add(obj); 00133 00134 m_pendingResources.add(id, set); 00135 }*/ 00136 } 00137 00138 bool SVGDocumentExtensions::isPendingResource(const AtomicString& id) const 00139 { 00140 Q_UNUSED(id); 00141 /*if (id.isEmpty()) 00142 return false; 00143 00144 return m_pendingResources.contains(id);*/ 00145 ASSERT(false); 00146 return false; 00147 } 00148 00149 std::auto_ptr<HashSet<SVGStyledElement*> > SVGDocumentExtensions::removePendingResource(const AtomicString& id) 00150 { 00151 Q_UNUSED(id); 00152 /*ASSERT(m_pendingResources.contains(id)); 00153 00154 std::auto_ptr<HashSet<SVGStyledElement*> > set(m_pendingResources.get(id)); 00155 m_pendingResources.remove(id); 00156 return set;*/ 00157 ASSERT(false); 00158 return std::auto_ptr<HashSet<SVGStyledElement*> >(); 00159 } 00160 00161 void SVGDocumentExtensions::mapInstanceToElement(SVGElementInstance* instance, SVGElement* element) 00162 { 00163 ASSERT(instance); 00164 ASSERT(element); 00165 00166 if (m_elementInstances.contains(element)) 00167 m_elementInstances.get(element)->add(instance); 00168 else { 00169 HashSet<SVGElementInstance*>* set = new HashSet<SVGElementInstance*>(); 00170 set->add(instance); 00171 00172 m_elementInstances.add(element, set); 00173 } 00174 } 00175 00176 void SVGDocumentExtensions::removeInstanceMapping(SVGElementInstance* instance, SVGElement* element) 00177 { 00178 ASSERT(instance); 00179 00180 if (!m_elementInstances.contains(element)) 00181 return; 00182 00183 m_elementInstances.get(element)->remove(instance); 00184 } 00185 00186 HashSet<SVGElementInstance*>* SVGDocumentExtensions::instancesForElement(SVGElement* element) const 00187 { 00188 ASSERT(element); 00189 return m_elementInstances.get(element); 00190 } 00191 00192 } 00193 00194 #endif
KDE 4.6 API Reference