#include "config.h"
#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)
{
}
SVGSVGElement* SVGDocument::rootElement() const
{
Element* elem = documentElement();
if (elem && elem->hasTagName(SVGNames::svgTag))
return toSVGSVGElement(elem);
return 0;
}
bool SVGDocument::zoomAndPanEnabled() const
{
if (rootElement()) {
if (rootElement()->useCurrentView()) {
if (rootElement()->currentView())
return rootElement()->currentView()->zoomAndPan() == SVGZoomAndPanMagnify;
} else
return rootElement()->zoomAndPan() == SVGZoomAndPanMagnify;
}
return false;
}
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();
}
}
bool SVGDocument::childShouldCreateRenderer(const Node& child) const
{
if (isSVGSVGElement(child))
return toSVGSVGElement(child).isValid();
return true;
}
PassRefPtr<Document> SVGDocument::cloneDocumentWithoutChildren() const
{
return create(nullptr, url());
}
}