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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006 Apple Inc. All rights reserved. 2 * Copyright (C) 2006 Apple Inc. All rights reserved.
3 * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org> 3 * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
4 * Copyright (C) 2007 Rob Buis <buis@kde.org> 4 * Copyright (C) 2007 Rob Buis <buis@kde.org>
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
11 * This library is distributed in the hope that it will be useful, 11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details. 14 * Library General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU Library General Public License 16 * You should have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB. If not, write to 17 * along with this library; see the file COPYING.LIB. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA. 19 * Boston, MA 02110-1301, USA.
20 */ 20 */
21 21
22 #include "config.h" 22 #include "config.h"
23 #include "core/svg/SVGDocumentExtensions.h" 23 #include "core/svg/SVGDocumentExtensions.h"
24 24
25 #include "XLinkNames.h" 25 #include "XLinkNames.h"
26 #include "core/dom/Document.h" 26 #include "core/dom/Document.h"
27 #include "core/rendering/RenderView.h"
27 #include "core/rendering/svg/SVGResourcesCache.h" 28 #include "core/rendering/svg/SVGResourcesCache.h"
28 #include "core/svg/SVGElement.h"
29 #include "core/svg/SVGFontFaceElement.h" 29 #include "core/svg/SVGFontFaceElement.h"
30 #include "core/svg/SVGSVGElement.h" 30 #include "core/svg/SVGSVGElement.h"
31 #include "core/svg/SVGViewSpec.h"
32 #include "core/svg/SVGZoomAndPan.h"
31 #include "core/svg/animation/SMILTimeContainer.h" 33 #include "core/svg/animation/SMILTimeContainer.h"
32 #include "wtf/TemporaryChange.h" 34 #include "wtf/TemporaryChange.h"
33 #include "wtf/text/AtomicString.h" 35 #include "wtf/text/AtomicString.h"
34 36
35 namespace WebCore { 37 namespace WebCore {
36 38
37 SVGDocumentExtensions::SVGDocumentExtensions(Document* document) 39 SVGDocumentExtensions::SVGDocumentExtensions(Document* document)
38 : m_document(document) 40 : m_document(document)
39 , m_resourcesCache(adoptPtr(new SVGResourcesCache)) 41 , m_resourcesCache(adoptPtr(new SVGResourcesCache))
40 #if !ASSERT_DISABLED 42 #if !ASSERT_DISABLED
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 m_pendingSVGFontFaceElementsForRemoval.add(font); 430 m_pendingSVGFontFaceElementsForRemoval.add(font);
429 } 431 }
430 432
431 void SVGDocumentExtensions::removePendingSVGFontFaceElementsForRemoval() 433 void SVGDocumentExtensions::removePendingSVGFontFaceElementsForRemoval()
432 { 434 {
433 m_pendingSVGFontFaceElementsForRemoval.clear(); 435 m_pendingSVGFontFaceElementsForRemoval.clear();
434 } 436 }
435 437
436 #endif 438 #endif
437 439
440 bool SVGDocumentExtensions::zoomAndPanEnabled() const
441 {
442 if (SVGSVGElement* svg = rootElement(*m_document)) {
443 if (svg->useCurrentView()) {
444 if (svg->currentView())
445 return svg->currentView()->zoomAndPan() == SVGZoomAndPanMagnify;
446 } else {
447 return svg->zoomAndPan() == SVGZoomAndPanMagnify;
448 }
449 }
450
451 return false;
438 } 452 }
453
454 void SVGDocumentExtensions::startPan(const FloatPoint& start)
455 {
456 if (SVGSVGElement* svg = rootElement(*m_document))
457 m_translate = FloatPoint(start.x() - svg->currentTranslate().x(), start. y() - svg->currentTranslate().y());
458 }
459
460 void SVGDocumentExtensions::updatePan(const FloatPoint& pos) const
461 {
462 if (SVGSVGElement* svg = rootElement(*m_document))
463 svg->setCurrentTranslate(FloatPoint(pos.x() - m_translate.x(), pos.y() - m_translate.y()));
464 }
465
466 SVGSVGElement* SVGDocumentExtensions::rootElement(const Document& document)
467 {
468 Element* elem = document.documentElement();
469 return isSVGSVGElement(elem) ? toSVGSVGElement(elem) : 0;
470 }
471
472 SVGSVGElement* SVGDocumentExtensions::rootElement() const
473 {
474 ASSERT(m_document);
475 return rootElement(*m_document);
476 }
477
478 }
OLDNEW
« 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