| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (C) 2004, 2005 Nikolas Zimmermann <zimmermann@kde.org> | |
| 3 * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> | |
| 4 * | |
| 5 * This library is free software; you can redistribute it and/or | |
| 6 * modify it under the terms of the GNU Library General Public | |
| 7 * License as published by the Free Software Foundation; either | |
| 8 * version 2 of the License, or (at your option) any later version. | |
| 9 * | |
| 10 * This library is distributed in the hope that it will be useful, | |
| 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 13 * Library General Public License for more details. | |
| 14 * | |
| 15 * You should have received a copy of the GNU Library General Public License | |
| 16 * along with this library; see the file COPYING.LIB. If not, write to | |
| 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | |
| 18 * Boston, MA 02110-1301, USA. | |
| 19 */ | |
| 20 | |
| 21 #include "config.h" | |
| 22 #include "core/svg/SVGDocument.h" | |
| 23 | |
| 24 #include "SVGNames.h" | |
| 25 #include "bindings/v8/ExceptionStatePlaceholder.h" | |
| 26 #include "core/frame/FrameView.h" | |
| 27 #include "core/rendering/RenderView.h" | |
| 28 #include "core/svg/SVGElement.h" | |
| 29 #include "core/svg/SVGSVGElement.h" | |
| 30 #include "core/svg/SVGViewSpec.h" | |
| 31 #include "core/svg/SVGZoomAndPan.h" | |
| 32 #include "core/svg/SVGZoomEvent.h" | |
| 33 | |
| 34 namespace WebCore { | |
| 35 | |
| 36 SVGDocument::SVGDocument(const DocumentInit& initializer) | |
| 37 : XMLDocument(initializer, XMLDocumentClass | SVGDocumentClass) | |
| 38 { | |
| 39 } | |
| 40 | |
| 41 SVGSVGElement* SVGDocument::rootElement(const Document& document) | |
| 42 { | |
| 43 Element* elem = document.documentElement(); | |
| 44 return isSVGSVGElement(elem) ? toSVGSVGElement(elem) : 0; | |
| 45 } | |
| 46 | |
| 47 SVGSVGElement* SVGDocument::rootElement() const | |
| 48 { | |
| 49 return rootElement(*this); | |
| 50 } | |
| 51 | |
| 52 bool SVGDocument::zoomAndPanEnabled() const | |
| 53 { | |
| 54 if (SVGSVGElement* svg = rootElement()) { | |
| 55 if (svg->useCurrentView()) { | |
| 56 if (svg->currentView()) | |
| 57 return svg->currentView()->zoomAndPan() == SVGZoomAndPanMagnify; | |
| 58 } else { | |
| 59 return svg->zoomAndPan() == SVGZoomAndPanMagnify; | |
| 60 } | |
| 61 } | |
| 62 | |
| 63 return false; | |
| 64 } | |
| 65 | |
| 66 void SVGDocument::startPan(const FloatPoint& start) | |
| 67 { | |
| 68 if (SVGSVGElement* svg = rootElement()) | |
| 69 m_translate = FloatPoint(start.x() - svg->currentTranslate().x(), start.
y() - svg->currentTranslate().y()); | |
| 70 } | |
| 71 | |
| 72 void SVGDocument::updatePan(const FloatPoint& pos) const | |
| 73 { | |
| 74 if (SVGSVGElement* svg = rootElement()) { | |
| 75 svg->setCurrentTranslate(FloatPoint(pos.x() - m_translate.x(), pos.y() -
m_translate.y())); | |
| 76 if (renderer()) | |
| 77 renderer()->repaint(); | |
| 78 } | |
| 79 } | |
| 80 | |
| 81 PassRefPtr<Document> SVGDocument::cloneDocumentWithoutChildren() | |
| 82 { | |
| 83 return create(DocumentInit(url())); | |
| 84 } | |
| 85 | |
| 86 } | |
| OLD | NEW |