[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    branches/work/khtml-svg
From:       Nikolas Zimmermann <wildfox () kde ! org>
Date:       2006-03-30 21:58:35
Message-ID: 1143755915.527699.4524.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 524669 by wildfox:

Remove dynamic_cast usage in getResourceById


 M  +13 -10    rendering/kcanvas/KCanvasResources.cpp  
 M  +1 -0      svg/SVGElementImpl.h  
 M  +2 -2      svg/SVGStyledElementImpl.h  


--- branches/work/khtml-svg/rendering/kcanvas/KCanvasResources.cpp #524668:524669
@@ -255,10 +255,12 @@
 {
     ts << "[type=MARKER]"
        << " [angle=";
-    if (angle() == -1) 
+
+    if(angle() == -1)
         ts << "auto" << "]";
-    else 
-        ts << angle() << "]";        
+    else
+        ts << angle() << "]";
+
     ts << " [ref x=" << refX() << " y=" << refY() << "]";
     return ts;
 }
@@ -269,23 +271,24 @@
         return 0;
 
     DOM::ElementImpl *element = document->getElementById(id);
-    if(element)
-        kDebug() << k_funcinfo << " Found: " << element->nodeName() << endl;
 
-    KSVG::SVGElementImpl *svgElement = dynamic_cast<KSVG::SVGElementImpl *>(element);
-    if (svgElement)// && svgElement->isStyled())
+    KSVG::SVGElementImpl *svgElement = 0;
+    if(element && element->isSVGElement())
+        svgElement = static_cast<KSVG::SVGElementImpl *>(element);
+
+    if(svgElement && svgElement->isStyled())
         return static_cast<KSVG::SVGStyledElementImpl *>(svgElement)->canvasResource();
-    else
-        fprintf(stderr, "Failed to find resource with id: %s\n", qPrintable(id.string()));
 
+    kError() << "Failed to find resource with id: " << id.string() << endl;
     return 0;
 }
 
 KRenderingPaintServer *getPaintServerById(DOM::DocumentImpl *document, const DOM::DOMString &id)
 {
     KCanvasResource *resource = getResourceById(document, id);
-    if (resource && resource->isPaintServer())
+    if(resource && resource->isPaintServer())
         return static_cast<KRenderingPaintServer *>(resource);
+
     return 0;
 }
 
--- branches/work/khtml-svg/svg/SVGElementImpl.h #524668:524669
@@ -35,6 +35,7 @@
         SVGElementImpl(DOM::DocumentPtr *doc);
         virtual ~SVGElementImpl();
 
+        virtual bool isStyled() const { return false; }
         virtual bool isSupported(const DOM::DOMString &feature, const DOM::DOMString &version) const;
 
         // khtml DOM integration
--- branches/work/khtml-svg/svg/SVGStyledElementImpl.h #524668:524669
@@ -45,14 +45,14 @@
         SVGStyledElementImpl(DOM::DocumentPtr *doc);
         virtual ~SVGStyledElementImpl();
 
+        virtual bool isStyled() const { return true; }
+
         // 'SVGStylable' functions
         virtual SVGAnimatedStringImpl *className() const;
         virtual DOM::CSSStyleDeclarationImpl *style();
         virtual DOM::CSSStyleDeclarationImpl *pa() const;
         virtual DOM::CSSValueImpl *getPresentationAttribute(const DOM::DOMString &name);
 
-        virtual bool allowAttachChildren(DOM::ElementImpl *) const { return true; }
-
         // This needs to be implemented.
         virtual bool rendererIsNeeded(khtml::RenderStyle *) { return false; }
         virtual KCanvasPath *toPathData() const { return 0; }
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic