Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1317)

Unified Diff: Source/core/svg/SVGDocumentExtensions.cpp

Issue 268803005: Replace SVGDocument by XMLDocument (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add rootElement() variant Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/svg/SVGDocumentExtensions.h ('k') | Source/core/svg/graphics/SVGImage.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/svg/SVGDocumentExtensions.cpp
diff --git a/Source/core/svg/SVGDocumentExtensions.cpp b/Source/core/svg/SVGDocumentExtensions.cpp
index 9593866a5897dfe10268fdcbadfc44d77d359056..c0cc4bf9b9f4e243e6598e82422110b6c84a113b 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,42 @@ 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()));
+}
+
+SVGSVGElement* SVGDocumentExtensions::rootElement(const Document& document)
+{
+ Element* elem = document.documentElement();
+ return isSVGSVGElement(elem) ? toSVGSVGElement(elem) : 0;
+}
+
+SVGSVGElement* SVGDocumentExtensions::rootElement() const
+{
+ ASSERT(m_document);
+ return rootElement(*m_document);
+}
+
}
« no previous file with comments | « Source/core/svg/SVGDocumentExtensions.h ('k') | Source/core/svg/graphics/SVGImage.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698