summaryrefslogtreecommitdiff
path: root/Source/WebCore/svg/SVGDocument.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/svg/SVGDocument.cpp')
-rw-r--r--Source/WebCore/svg/SVGDocument.cpp81
1 files changed, 21 insertions, 60 deletions
diff --git a/Source/WebCore/svg/SVGDocument.cpp b/Source/WebCore/svg/SVGDocument.cpp
index d735da465..391e0494f 100644
--- a/Source/WebCore/svg/SVGDocument.cpp
+++ b/Source/WebCore/svg/SVGDocument.cpp
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2004, 2005 Nikolas Zimmermann <zimmermann@kde.org>
* Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
+ * Copyright (C) 2015 Apple Inc. All right reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -19,93 +20,53 @@
*/
#include "config.h"
-#if ENABLE(SVG)
#include "SVGDocument.h"
-#include "EventNames.h"
-#include "ExceptionCode.h"
-#include "FrameView.h"
-#include "RenderView.h"
-#include "SVGElement.h"
-#include "SVGNames.h"
#include "SVGSVGElement.h"
#include "SVGViewSpec.h"
-#include "SVGZoomAndPan.h"
-#include "SVGZoomEvent.h"
namespace WebCore {
SVGDocument::SVGDocument(Frame* frame, const URL& url)
- : Document(frame, url, SVGDocumentClass)
+ : XMLDocument(frame, url, SVGDocumentClass)
{
}
-SVGSVGElement* SVGDocument::rootElement() const
+SVGSVGElement* SVGDocument::rootElement(const Document& document)
{
- Element* elem = documentElement();
- if (elem && elem->hasTagName(SVGNames::svgTag))
- return toSVGSVGElement(elem);
-
- return 0;
-}
-
-void SVGDocument::dispatchZoomEvent(float prevScale, float newScale)
-{
- RefPtr<SVGZoomEvent> event = static_pointer_cast<SVGZoomEvent>(createEvent("SVGZoomEvents", IGNORE_EXCEPTION));
- event->initEvent(eventNames().zoomEvent, true, false);
- event->setPreviousScale(prevScale);
- event->setNewScale(newScale);
- rootElement()->dispatchEvent(event.release(), IGNORE_EXCEPTION);
-}
-
-void SVGDocument::dispatchScrollEvent()
-{
- RefPtr<Event> event = createEvent("SVGEvents", IGNORE_EXCEPTION);
- event->initEvent(eventNames().scrollEvent, true, false);
- rootElement()->dispatchEvent(event.release(), IGNORE_EXCEPTION);
+ auto* element = document.documentElement();
+ if (!is<SVGSVGElement>(element))
+ return nullptr;
+ return downcast<SVGSVGElement>(element);
}
bool SVGDocument::zoomAndPanEnabled() const
{
- if (rootElement()) {
- if (rootElement()->useCurrentView()) {
- if (rootElement()->currentView())
- return rootElement()->currentView()->zoomAndPan() == SVGZoomAndPanMagnify;
- } else
- return rootElement()->zoomAndPan() == SVGZoomAndPanMagnify;
- }
-
- return false;
+ auto* element = rootElement(*this);
+ if (!element)
+ return false;
+ return (element->useCurrentView() ? element->currentView().zoomAndPan() : element->zoomAndPan()) == SVGZoomAndPanMagnify;
}
void SVGDocument::startPan(const FloatPoint& start)
{
- if (rootElement())
- m_translate = FloatPoint(start.x() - rootElement()->currentTranslate().x(), start.y() - rootElement()->currentTranslate().y());
-}
-
-void SVGDocument::updatePan(const FloatPoint& pos) const
-{
- if (rootElement()) {
- rootElement()->setCurrentTranslate(FloatPoint(pos.x() - m_translate.x(), pos.y() - m_translate.y()));
- if (renderView())
- renderView()->repaint();
- }
+ auto* element = rootElement(*this);
+ if (!element)
+ return;
+ m_panningOffset = start - element->currentTranslateValue();
}
-bool SVGDocument::childShouldCreateRenderer(const Node& child) const
+void SVGDocument::updatePan(const FloatPoint& position) const
{
- if (isSVGSVGElement(child))
- return toSVGSVGElement(child).isValid();
- return true;
+ auto* element = rootElement(*this);
+ if (!element)
+ return;
+ element->setCurrentTranslate(position - m_panningOffset);
}
-PassRefPtr<Document> SVGDocument::cloneDocumentWithoutChildren() const
+Ref<Document> SVGDocument::cloneDocumentWithoutChildren() const
{
return create(nullptr, url());
}
}
-
-// vim:ts=4:noet
-#endif // ENABLE(SVG)