• Skip to content
  • Skip to link menu
KDE 4.6 API Reference
  • KDE API Reference
  • kdelibs
  • KDE Home
  • 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     Q_UNUSED(e);
00048     /*
00049     Node* n = e->parentNode();
00050     while (n && !n->isDocumentNode()) {
00051         if (n->hasTagName(SVGNames::svgTag) || n->hasTagName(SVGNames::symbolTag) ||
00052             n->hasTagName(SVGNames::imageTag))
00053             return static_cast<SVGElement*>(n);
00054 #if ENABLE(SVG_FOREIGN_OBJECT)
00055         if (n->hasTagName(SVGNames::foreignObjectTag))
00056             return static_cast<SVGElement*>(n);
00057 #endif
00058 
00059         n = n->parentNode();
00060     }*/
00061 
00062     return 0;
00063 }
00064 
00065 SVGElement* SVGLocatable::farthestViewportElement(const SVGStyledElement* e)
00066 {
00067     Q_UNUSED(e);
00068     // FIXME : likely this will be always the <svg> farthest away.
00069     // If we have a different implementation of documentElement(), one
00070     // that give the documentElement() of the svg fragment, it could be
00071     // used instead. This depends on cdf demands though(Rob.)
00072     SVGElement* farthest = 0;
00073     /*Node* n = e->parentNode();
00074     while (n && !n->isDocumentNode()) {
00075         if (n->hasTagName(SVGNames::svgTag) || n->hasTagName(SVGNames::symbolTag) ||
00076             n->hasTagName(SVGNames::imageTag))
00077             farthest = static_cast<SVGElement*>(n);
00078 #if ENABLE(SVG_FOREIGN_OBJECT)
00079         if (n->hasTagName(SVGNames::foreignObjectTag))
00080             farthest = static_cast<SVGElement*>(n);
00081 #endif
00082 
00083         n = n->parentNode();
00084     }*/
00085 
00086     return farthest;
00087 }
00088 
00089 // Spec:
00090 // http://www.w3.org/TR/2005/WD-SVGMobile12-20050413/svgudom.html#svg::SVGLocatable
00091 FloatRect SVGLocatable::getBBox(const SVGStyledElement* e)
00092 {
00093     Q_UNUSED(e);
00094     FloatRect bboxRect;
00095 
00096     /*if (e && e->renderer()) {
00097         // Need this to make sure we have render object dimensions.
00098         // See bug 11686.
00099         e->document()->updateLayoutIgnorePendingStylesheets();
00100         bboxRect = e->renderer()->relativeBBox(false);
00101     }*/
00102 
00103     return bboxRect;
00104 }
00105 
00106 AffineTransform SVGLocatable::getCTM(const SVGElement* element)
00107 {
00108     if (!element)
00109         return AffineTransform();
00110 
00111     AffineTransform ctm;
00112 
00113     Node* parent = element->parentNode();
00114     if (parent && parent->isSVGElement()) {
00115         SVGElement* parentElement = static_cast<SVGElement*>(parent);
00116         if (parentElement && parentElement->isStyledLocatable()) {
00117             AffineTransform parentCTM = static_cast<SVGStyledLocatableElement*>(parentElement)->getCTM();
00118             ctm = parentCTM * ctm;
00119         }
00120     }
00121 
00122     return ctm;
00123 }
00124 
00125 AffineTransform SVGLocatable::getScreenCTM(const SVGElement* element)
00126 {
00127     if (!element)
00128         return AffineTransform();
00129 
00130     AffineTransform ctm;
00131 
00132     Node* parent = element->parentNode();
00133     if (parent && parent->isSVGElement()) {
00134         SVGElement* parentElement = static_cast<SVGElement*>(parent);
00135         if (parentElement && parentElement->isStyledLocatable()) {
00136             AffineTransform parentCTM = static_cast<SVGStyledLocatableElement*>(parentElement)->getScreenCTM();
00137             ctm = parentCTM * ctm;
00138         }
00139     }
00140 
00141     return ctm;
00142 }
00143 
00144 AffineTransform SVGLocatable::getTransformToElement(SVGElement* target, ExceptionCode& ec) const
00145 {
00146     Q_UNUSED(ec);
00147     AffineTransform ctm = getCTM();
00148 
00149     if (target && target->isStyledLocatable()) {
00150         AffineTransform targetCTM = static_cast<SVGStyledLocatableElement*>(target)->getCTM();
00151         if (!targetCTM.isInvertible()) {
00152             //ec = SVGException::SVG_MATRIX_NOT_INVERTABLE;
00153             return ctm;
00154         }
00155         ctm *= targetCTM.inverse();
00156     }
00157 
00158     return ctm;
00159 }
00160 
00161 }
00162 
00163 #endif // ENABLE(SVG)
00164 
00165 // 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
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.7.3
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