File indexing completed on 2024-04-28 15:24:29

0001 /*
0002     Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org>
0003                   2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
0004 
0005     This file is part of the KDE project
0006 
0007     This library is free software; you can redistribute it and/or
0008     modify it under the terms of the GNU Library General Public
0009     License as published by the Free Software Foundation; either
0010     version 2 of the License, or (at your option) any later version.
0011 
0012     This library is distributed in the hope that it will be useful,
0013     but WITHOUT ANY WARRANTY; without even the implied warranty of
0014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0015     Library General Public License for more details.
0016 
0017     You should have received a copy of the GNU Library General Public License
0018     along with this library; see the file COPYING.LIB.  If not, write to
0019     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0020     Boston, MA 02110-1301, USA.
0021 */
0022 
0023 #include "SVGDocument.h"
0024 #if ENABLE(SVG)
0025 
0026 /*#include "EventNames.h"
0027 #include "ExceptionCode.h"
0028 #include "FrameView.h"*/
0029 #include "RenderView.h"
0030 #include "SVGElement.h"
0031 #include "SVGNames.h"
0032 #include "SVGSVGElement.h"
0033 /*#include "SVGViewSpec.h"
0034 #include "SVGZoomEvent.h"
0035 #include "SVGZoomAndPan.h"*/
0036 
0037 namespace WebCore
0038 {
0039 
0040 SVGDocument::SVGDocument(Frame *frame)
0041     : Document(frame)
0042 {
0043 }
0044 
0045 SVGDocument::~SVGDocument()
0046 {
0047 }
0048 
0049 SVGSVGElement *SVGDocument::rootElement() const
0050 {
0051     Element *elem = documentElement();
0052     if (elem && elem->hasTagName(SVGNames::svgTag)) {
0053         return static_cast<SVGSVGElement *>(elem);
0054     }
0055 
0056     return nullptr;
0057 }
0058 
0059 void SVGDocument::dispatchZoomEvent(float prevScale, float newScale)
0060 {
0061     Q_UNUSED(prevScale);
0062     Q_UNUSED(newScale);
0063 
0064     /*ExceptionCode ec = 0;
0065     RefPtr<SVGZoomEvent> event = static_pointer_cast<SVGZoomEvent>(createEvent("SVGZoomEvents", ec));
0066     event->initEvent(EventNames::zoomEvent, true, false);
0067     event->setPreviousScale(prevScale);
0068     event->setNewScale(newScale);
0069     rootElement()->dispatchEvent(event.release(), ec);*/
0070 }
0071 
0072 void SVGDocument::dispatchScrollEvent()
0073 {
0074     /*ExceptionCode ec = 0;
0075     RefPtr<Event> event = createEvent("SVGEvents", ec);
0076     event->initEvent(EventNames::scrollEvent, true, false);
0077     rootElement()->dispatchEvent(event.release(), ec);*/
0078 }
0079 
0080 bool SVGDocument::zoomAndPanEnabled() const
0081 {
0082     /*if (rootElement()) {
0083         if (rootElement()->useCurrentView()) {
0084             if (rootElement()->currentView())
0085                 return rootElement()->currentView()->zoomAndPan() == SVGZoomAndPan::SVG_ZOOMANDPAN_MAGNIFY;
0086         } else
0087             return rootElement()->zoomAndPan() == SVGZoomAndPan::SVG_ZOOMANDPAN_MAGNIFY;
0088     }*/
0089 
0090     return false;
0091 }
0092 
0093 void SVGDocument::startPan(const FloatPoint &start)
0094 {
0095     Q_UNUSED(start);
0096     /*if (rootElement())
0097         m_translate = FloatPoint(start.x() - rootElement()->currentTranslate().x(), rootElement()->currentTranslate().y() + start.y());*/
0098 }
0099 
0100 void SVGDocument::updatePan(const FloatPoint &pos) const
0101 {
0102     Q_UNUSED(pos);
0103     if (rootElement()) {
0104         /*rootElement()->setCurrentTranslate(FloatPoint(pos.x() - m_translate.x(), m_translate.y() - pos.y()));
0105         if (renderer())
0106             renderer()->repaint();*/
0107     }
0108 }
0109 
0110 void SVGDocument::close()
0111 {
0112     bool doload = !parsing() && m_tokenizer;
0113 
0114     DocumentImpl::close();
0115 
0116     if (doload) {
0117         document()->dispatchWindowEvent(DOM::EventImpl::LOAD_EVENT, false, false);
0118     }
0119 }
0120 
0121 }
0122 
0123 #endif // ENABLE(SVG)