• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

KHTML

SVGLocatable.cpp

Go to the documentation of this file.
00001 /*
00002     Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org>
00003                   2004, 2005, 2006 Rob Buis <buis@kde.org>
00004 
00005     This file is part of the KDE project
00006 
00007     This library is free software; you can redistribute it and/or
00008     modify it under the terms of the GNU Library General Public
00009     License as published by the Free Software Foundation; either
00010     version 2 of the License, or (at your option) any later version.
00011 
00012     This library is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015     Library General Public License for more details.
00016 
00017     You should have received a copy of the GNU Library General Public License
00018     along with this library; see the file COPYING.LIB.  If not, write to
00019     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00020     Boston, MA 02110-1301, USA.
00021 */
00022 
00023 #include "config.h"
00024 #include "wtf/Platform.h"
00025 
00026 #if ENABLE(SVG)
00027 
00028 #include "SVGLocatable.h"
00029 
00030 #include "AffineTransform.h"
00031 #include "RenderPath.h"
00032 #include "SVGException.h"
00033 #include "SVGSVGElement.h"
00034 
00035 namespace WebCore {
00036 
00037 SVGLocatable::SVGLocatable()
00038 {
00039 }
00040 
00041 SVGLocatable::~SVGLocatable()
00042 {
00043 }
00044 
00045 SVGElement* SVGLocatable::nearestViewportElement(const SVGStyledElement* e)
00046 {
00047     /*
00048     Node* n = e->parentNode();
00049     while (n && !n->isDocumentNode()) {
00050         if (n->hasTagName(SVGNames::svgTag) || n->hasTagName(SVGNames::symbolTag) ||
00051             n->hasTagName(SVGNames::imageTag))
00052             return static_cast<SVGElement*>(n);
00053 #if ENABLE(SVG_FOREIGN_OBJECT)
00054         if (n->hasTagName(SVGNames::foreignObjectTag))
00055             return static_cast<SVGElement*>(n);
00056 #endif
00057 
00058         n = n->parentNode();
00059     }*/
00060 
00061     return 0;
00062 }
00063 
00064 SVGElement* SVGLocatable::farthestViewportElement(const SVGStyledElement* e)
00065 {
00066     // FIXME : likely this will be always the <svg> farthest away.
00067     // If we have a different implementation of documentElement(), one
00068     // that give the documentElement() of the svg fragment, it could be
00069     // used instead. This depends on cdf demands though(Rob.)
00070     SVGElement* farthest = 0;
00071     /*Node* n = e->parentNode();
00072     while (n && !n->isDocumentNode()) {
00073         if (n->hasTagName(SVGNames::svgTag) || n->hasTagName(SVGNames::symbolTag) ||
00074             n->hasTagName(SVGNames::imageTag))
00075             farthest = static_cast<SVGElement*>(n);
00076 #if ENABLE(SVG_FOREIGN_OBJECT)
00077         if (n->hasTagName(SVGNames::foreignObjectTag))
00078             farthest = static_cast<SVGElement*>(n);
00079 #endif
00080 
00081         n = n->parentNode();
00082     }*/
00083 
00084     return farthest;
00085 }
00086 
00087 // Spec:
00088 // http://www.w3.org/TR/2005/WD-SVGMobile12-20050413/svgudom.html#svg::SVGLocatable
00089 FloatRect SVGLocatable::getBBox(const SVGStyledElement* e)
00090 {
00091     FloatRect bboxRect;
00092 
00093     /*if (e && e->renderer()) {
00094         // Need this to make sure we have render object dimensions.
00095         // See bug 11686.
00096         e->document()->updateLayoutIgnorePendingStylesheets();
00097         bboxRect = e->renderer()->relativeBBox(false);
00098     }*/
00099 
00100     return bboxRect;
00101 }
00102 
00103 AffineTransform SVGLocatable::getCTM(const SVGElement* element)
00104 {
00105     if (!element)
00106         return AffineTransform();
00107 
00108     AffineTransform ctm;
00109 
00110     Node* parent = element->parentNode();
00111     if (parent && parent->isSVGElement()) {
00112         SVGElement* parentElement = static_cast<SVGElement*>(parent);
00113         if (parentElement && parentElement->isStyledLocatable()) {
00114             AffineTransform parentCTM = static_cast<SVGStyledLocatableElement*>(parentElement)->getCTM();
00115             ctm = parentCTM * ctm;
00116         }
00117     }
00118 
00119     return ctm;
00120 }
00121 
00122 AffineTransform SVGLocatable::getScreenCTM(const SVGElement* element)
00123 {
00124     if (!element)
00125         return AffineTransform();
00126 
00127     AffineTransform ctm;
00128 
00129     Node* parent = element->parentNode();
00130     if (parent && parent->isSVGElement()) {
00131         SVGElement* parentElement = static_cast<SVGElement*>(parent);
00132         if (parentElement && parentElement->isStyledLocatable()) {
00133             AffineTransform parentCTM = static_cast<SVGStyledLocatableElement*>(parentElement)->getScreenCTM();
00134             ctm = parentCTM * ctm;
00135         }
00136     }
00137 
00138     return ctm;
00139 }
00140 
00141 AffineTransform SVGLocatable::getTransformToElement(SVGElement* target, ExceptionCode& ec) const
00142 {
00143     AffineTransform ctm = getCTM();
00144 
00145     if (target && target->isStyledLocatable()) {
00146         AffineTransform targetCTM = static_cast<SVGStyledLocatableElement*>(target)->getCTM();
00147         if (!targetCTM.isInvertible()) {
00148             //ec = SVGException::SVG_MATRIX_NOT_INVERTABLE;
00149             return ctm;
00150         }
00151         ctm *= targetCTM.inverse();
00152     }
00153 
00154     return ctm;
00155 }
00156 
00157 }
00158 
00159 #endif // ENABLE(SVG)
00160 
00161 // vim:ts=4:noet

KHTML

Skip menu "KHTML"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.7
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal