Chromium Code Reviews| Index: Source/core/svg/SVGDocumentExtensions.cpp |
| diff --git a/Source/core/svg/SVGDocumentExtensions.cpp b/Source/core/svg/SVGDocumentExtensions.cpp |
| index 9593866a5897dfe10268fdcbadfc44d77d359056..549ca3db6331995ee20a19a15ca1bbb519cffa9b 100644 |
| --- a/Source/core/svg/SVGDocumentExtensions.cpp |
| +++ b/Source/core/svg/SVGDocumentExtensions.cpp |
| @@ -24,10 +24,12 @@ |
| #include "XLinkNames.h" |
| #include "core/dom/Document.h" |
| +#include "core/rendering/RenderView.h" |
| #include "core/rendering/svg/SVGResourcesCache.h" |
| -#include "core/svg/SVGElement.h" |
| #include "core/svg/SVGFontFaceElement.h" |
| #include "core/svg/SVGSVGElement.h" |
| +#include "core/svg/SVGViewSpec.h" |
| +#include "core/svg/SVGZoomAndPan.h" |
| #include "core/svg/animation/SMILTimeContainer.h" |
| #include "wtf/TemporaryChange.h" |
| #include "wtf/text/AtomicString.h" |
| @@ -435,4 +437,39 @@ void SVGDocumentExtensions::removePendingSVGFontFaceElementsForRemoval() |
| #endif |
| +bool SVGDocumentExtensions::zoomAndPanEnabled() const |
| +{ |
| + if (SVGSVGElement* svg = rootElement(*m_document)) { |
| + if (svg->useCurrentView()) { |
| + if (svg->currentView()) |
| + return svg->currentView()->zoomAndPan() == SVGZoomAndPanMagnify; |
| + } else { |
| + return svg->zoomAndPan() == SVGZoomAndPanMagnify; |
| + } |
| + } |
| + |
| + return false; |
| +} |
| + |
| +void SVGDocumentExtensions::startPan(const FloatPoint& start) |
| +{ |
| + if (SVGSVGElement* svg = rootElement(*m_document)) |
| + m_translate = FloatPoint(start.x() - svg->currentTranslate().x(), start.y() - svg->currentTranslate().y()); |
| +} |
| + |
| +void SVGDocumentExtensions::updatePan(const FloatPoint& pos) const |
| +{ |
| + if (SVGSVGElement* svg = rootElement(*m_document)) { |
| + svg->setCurrentTranslate(FloatPoint(pos.x() - m_translate.x(), pos.y() - m_translate.y())); |
| + if (m_document->renderer()) |
|
pdr.
2014/05/03 21:35:30
This repaint call can be removed.
|
| + m_document->renderer()->repaint(); |
| + } |
| +} |
| + |
| +SVGSVGElement* SVGDocumentExtensions::rootElement(const Document& document) |
|
pdr.
2014/05/03 21:35:30
Is the document argument necessary here? It is alw
|
| +{ |
| + Element* elem = document.documentElement(); |
| + return isSVGSVGElement(elem) ? toSVGSVGElement(elem) : 0; |
| +} |
| + |
| } |