KHtml

SVGDocumentExtensions.cpp
1 /*
2  Copyright (C) 2006 Apple Computer, Inc.
3  2006 Nikolas Zimmermann <[email protected]>
4  2007 Rob Buis <[email protected]>
5 
6  This file is part of the WebKit project
7 
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.
12 
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.
17 
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.
22 */
23 
24 #include <wtf/Platform.h>
25 
26 #if ENABLE(SVG)
27 #include "SVGDocumentExtensions.h"
28 
29 /*#include "AtomicString.h"
30 #include "Console.h"
31 #include "DOMWindow.h"*/
32 //#include "Document.h"
33 //#include "EventListener.h"
34 #include "dom/dom2_events.h"
35 /*#include "Frame.h"
36 #include "FrameLoader.h"
37 #include "Page.h"*/
38 #include "SVGSVGElement.h"
39 /*#include "SMILTimeContainer.h"
40 #include "XMLTokenizer.h"*/
41 #include "kjs_proxy.h"
42 #include "khtml_part.h"
43 
44 namespace WebCore
45 {
46 
47 SVGDocumentExtensions::SVGDocumentExtensions(Document *doc)
48  : m_doc(doc)
49 {
50 }
51 
52 SVGDocumentExtensions::~SVGDocumentExtensions()
53 {
54  /*deleteAllValues(m_pendingResources);*/
55  deleteAllValues(m_elementInstances);
56 }
57 
58 EventListener *SVGDocumentExtensions::createSVGEventListener(const DOMString &functionName, const DOMString &code, DOM::NodeImpl *node)
59 {
60  /*if (Frame* frame = m_doc->frame())
61  if (frame->scriptProxy()->isEnabled())
62  return frame->scriptProxy()->createSVGEventHandler(functionName, code, node);*/
63  if (!m_doc || !m_doc->part()) {
64  return nullptr;
65  }
66  // qCDebug(KHTML_LOG) << "create listener: (" << code << functionName << node << ")";
67  return m_doc->part()->createHTMLEventListener(code.string(), functionName.string(), node, true/*svg*/);
68 }
69 
70 void SVGDocumentExtensions::addTimeContainer(SVGSVGElement *element)
71 {
72  Q_UNUSED(element);
73  /*m_timeContainers.add(element);*/
74 }
75 
76 void SVGDocumentExtensions::removeTimeContainer(SVGSVGElement *element)
77 {
78  Q_UNUSED(element);
79  /*m_timeContainers.remove(element);*/
80 }
81 
82 void SVGDocumentExtensions::startAnimations()
83 {
84  // FIXME: Eventually every "Time Container" will need a way to latch on to some global timer
85  // starting animations for a document will do this "latching"
86 #if ENABLE(SVG_ANIMATION)
87  HashSet<SVGSVGElement *>::iterator end = m_timeContainers.end();
88  for (HashSet<SVGSVGElement *>::iterator itr = m_timeContainers.begin(); itr != end; ++itr) {
89  (*itr)->timeContainer()->begin();
90  }
91 #endif
92 }
93 
94 void SVGDocumentExtensions::pauseAnimations()
95 {
96  HashSet<SVGSVGElement *>::iterator end = m_timeContainers.end();
97  for (HashSet<SVGSVGElement *>::iterator itr = m_timeContainers.begin(); itr != end; ++itr) {
98  (*itr)->pauseAnimations();
99  }
100 }
101 
102 void SVGDocumentExtensions::unpauseAnimations()
103 {
104  HashSet<SVGSVGElement *>::iterator end = m_timeContainers.end();
105  for (HashSet<SVGSVGElement *>::iterator itr = m_timeContainers.begin(); itr != end; ++itr) {
106  (*itr)->unpauseAnimations();
107  }
108 }
109 
110 void SVGDocumentExtensions::reportWarning(const String &message)
111 {
112  Q_UNUSED(message);
113  /*if (Frame* frame = m_doc->frame())
114  frame->domWindow()->console()->addMessage(JSMessageSource, ErrorMessageLevel, "Warning: " + message, m_doc->tokenizer() ? m_doc->tokenizer()->lineNumber() : 1, String());*/
115 }
116 
117 void SVGDocumentExtensions::reportError(const String &message)
118 {
119  Q_UNUSED(message);
120  /*if (Frame* frame = m_doc->frame())
121  frame->domWindow()->console()->addMessage(JSMessageSource, ErrorMessageLevel, "Error: " + message, m_doc->tokenizer() ? m_doc->tokenizer()->lineNumber() : 1, String());*/
122 }
123 
124 void SVGDocumentExtensions::addPendingResource(const AtomicString &id, SVGStyledElement *obj)
125 {
126  ASSERT(obj);
127  Q_UNUSED(obj);
128 
129  if (id.isEmpty()) {
130  return;
131  }
132 
133  /*if (m_pendingResources.contains(id))
134  m_pendingResources.get(id)->add(obj);
135  else {
136  HashSet<SVGStyledElement*>* set = new HashSet<SVGStyledElement*>();
137  set->add(obj);
138 
139  m_pendingResources.add(id, set);
140  }*/
141 }
142 
143 bool SVGDocumentExtensions::isPendingResource(const AtomicString &id) const
144 {
145  Q_UNUSED(id);
146  /*if (id.isEmpty())
147  return false;
148 
149  return m_pendingResources.contains(id);*/
150  ASSERT(false);
151  return false;
152 }
153 
154 std::unique_ptr<HashSet<SVGStyledElement *> > SVGDocumentExtensions::removePendingResource(const AtomicString &id)
155 {
156  Q_UNUSED(id);
157  /*ASSERT(m_pendingResources.contains(id));
158 
159  std::unique_ptr<HashSet<SVGStyledElement*> > set(m_pendingResources.get(id));
160  m_pendingResources.remove(id);
161  return set;*/
162  ASSERT(false);
163  return std::unique_ptr<HashSet<SVGStyledElement *> >();
164 }
165 
166 void SVGDocumentExtensions::mapInstanceToElement(SVGElementInstance *instance, SVGElement *element)
167 {
168  ASSERT(instance);
169  ASSERT(element);
170 
171  if (m_elementInstances.contains(element)) {
172  m_elementInstances.get(element)->add(instance);
173  } else {
174  HashSet<SVGElementInstance *> *set = new HashSet<SVGElementInstance *>();
175  set->add(instance);
176 
177  m_elementInstances.add(element, set);
178  }
179 }
180 
181 void SVGDocumentExtensions::removeInstanceMapping(SVGElementInstance *instance, SVGElement *element)
182 {
183  ASSERT(instance);
184 
185  if (!m_elementInstances.contains(element)) {
186  return;
187  }
188 
189  m_elementInstances.get(element)->remove(instance);
190 }
191 
192 HashSet<SVGElementInstance *> *SVGDocumentExtensions::instancesForElement(SVGElement *element) const
193 {
194  ASSERT(element);
195  return m_elementInstances.get(element);
196 }
197 
198 }
199 
200 #endif
const QList< QKeySequence > & end()
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Tue Oct 26 2021 22:48:09 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.