Bug 388411 - Improve frame construction: make trivial constructors inline and check that content is what we expect. r+sr=tor
authorlongsonr@gmail.com
Wed, 25 Jul 2007 02:16:02 -0700
changeset 3949 5873762439a89940d2f57aa4607a5bc4a684fade
parent 3948 eb76ecaad4578cd127c319f176032867b7fccc75
child 3950 e112a9199ae664aaa40cd0078df8e1e0d5da0f69
push idunknown
push userunknown
push dateunknown
bugs388411
milestone1.9a7pre
Bug 388411 - Improve frame construction: make trivial constructors inline and check that content is what we expect. r+sr=tor
layout/svg/base/src/nsSVGGFrame.cpp
layout/svg/base/src/nsSVGGFrame.h
layout/svg/base/src/nsSVGGradientFrame.cpp
layout/svg/base/src/nsSVGGradientFrame.h
layout/svg/base/src/nsSVGInnerSVGFrame.cpp
layout/svg/base/src/nsSVGLeafFrame.cpp
layout/svg/base/src/nsSVGPatternFrame.cpp
layout/svg/base/src/nsSVGStopFrame.cpp
layout/svg/base/src/nsSVGTSpanFrame.cpp
layout/svg/base/src/nsSVGTextPathFrame.cpp
layout/svg/base/src/nsSVGTextPathFrame.h
layout/svg/base/src/nsSVGUseFrame.cpp
--- a/layout/svg/base/src/nsSVGGFrame.cpp
+++ b/layout/svg/base/src/nsSVGGFrame.cpp
@@ -48,19 +48,17 @@
 //----------------------------------------------------------------------
 // Implementation
 
 nsIFrame*
 NS_NewSVGGFrame(nsIPresShell* aPresShell, nsIContent* aContent, nsStyleContext* aContext)
 {  
   nsCOMPtr<nsIDOMSVGTransformable> transformable = do_QueryInterface(aContent);
   if (!transformable) {
-#ifdef DEBUG
-    printf("warning: trying to construct an SVGGFrame for a content element that doesn't support the right interfaces\n");
-#endif
+    NS_ERROR("Can't create frame. The element doesn't support the right interface\n");
     return nsnull;
   }
 
   return new (aPresShell) nsSVGGFrame(aContext);
 }
 
 nsIAtom *
 nsSVGGFrame::GetType() const
--- a/layout/svg/base/src/nsSVGGFrame.h
+++ b/layout/svg/base/src/nsSVGGFrame.h
@@ -40,38 +40,37 @@
 #define NSSVGGFRAME_H
 
 #include "nsSVGContainerFrame.h"
 
 typedef nsSVGDisplayContainerFrame nsSVGGFrameBase;
 
 class nsSVGGFrame : public nsSVGGFrameBase
 {
-public:
+  friend nsIFrame*
+  NS_NewSVGGFrame(nsIPresShell* aPresShell, nsIContent* aContent, nsStyleContext* aContext);
+protected:
   nsSVGGFrame(nsStyleContext* aContext) :
     nsSVGGFrameBase(aContext), mPropagateTransform(PR_TRUE) {}
 
+public:
   /**
    * Get the "type" of the frame
    *
    * @see nsGkAtoms::svgGFrame
    */
   virtual nsIAtom* GetType() const;
 
 #ifdef DEBUG
   NS_IMETHOD GetFrameName(nsAString& aResult) const
   {
     return MakeFrameName(NS_LITERAL_STRING("SVGG"), aResult);
   }
 #endif
 
-protected:
-  friend nsIFrame*
-  NS_NewSVGGFrame(nsIPresShell* aPresShell, nsIContent* aContent, nsStyleContext* aContext);
-
   // nsIFrame interface:
   NS_IMETHOD DidSetStyleContext();
   NS_IMETHOD AttributeChanged(PRInt32         aNameSpaceID,
                               nsIAtom*        aAttribute,
                               PRInt32         aModType);
 
   // nsISVGChildFrame interface:
   NS_IMETHOD NotifyCanvasTMChanged(PRBool suppressInvalidation);
--- a/layout/svg/base/src/nsSVGGradientFrame.cpp
+++ b/layout/svg/base/src/nsSVGGradientFrame.cpp
@@ -730,33 +730,35 @@ nsSVGRadialGradientFrame::CreateGradient
 // -------------------------------------------------------------------------
 
 nsIFrame* 
 NS_NewSVGLinearGradientFrame(nsIPresShell*   aPresShell,
                              nsIContent*     aContent,
                              nsStyleContext* aContext)
 {
   nsCOMPtr<nsIDOMSVGLinearGradientElement> grad = do_QueryInterface(aContent);
-  NS_ASSERTION(grad, "NS_NewSVGLinearGradientFrame -- Content doesn't support nsIDOMSVGLinearGradient");
-  if (!grad)
+  if (!grad) {
+    NS_ERROR("Can't create frame! Content is not an SVG linearGradient");
     return nsnull;
+  }
   
   nsCOMPtr<nsIDOMSVGURIReference> aRef = do_QueryInterface(aContent);
   NS_ASSERTION(aRef, "NS_NewSVGLinearGradientFrame -- Content doesn't support nsIDOMSVGURIReference");
 
   return new (aPresShell) nsSVGLinearGradientFrame(aContext, aRef);
 }
 
 nsIFrame*
 NS_NewSVGRadialGradientFrame(nsIPresShell*   aPresShell,
                              nsIContent*     aContent,
                              nsStyleContext* aContext)
 {
   nsCOMPtr<nsIDOMSVGRadialGradientElement> grad = do_QueryInterface(aContent);
-  NS_ASSERTION(grad, "NS_NewSVGRadialGradientFrame -- Content doesn't support nsIDOMSVGRadialGradient");
-  if (!grad)
+  if (!grad) {
+    NS_ERROR("Can't create frame! Content is not an SVG radialGradient");
     return nsnull;
+  }
   
   nsCOMPtr<nsIDOMSVGURIReference> aRef = do_QueryInterface(aContent);
   NS_ASSERTION(aRef, "NS_NewSVGRadialGradientFrame -- Content doesn't support nsIDOMSVGURIReference");
 
   return new (aPresShell) nsSVGRadialGradientFrame(aContext, aRef);
 }
--- a/layout/svg/base/src/nsSVGGradientFrame.h
+++ b/layout/svg/base/src/nsSVGGradientFrame.h
@@ -48,16 +48,22 @@
 
 class nsIDOMSVGStopElement;
 
 typedef nsSVGPaintServerFrame  nsSVGGradientFrameBase;
 
 class nsSVGGradientFrame : public nsSVGGradientFrameBase,
                            public nsISVGValueObserver
 {
+protected:
+  nsSVGGradientFrame(nsStyleContext* aContext,
+                     nsIDOMSVGURIReference *aRef);
+
+  virtual ~nsSVGGradientFrame();
+
 public:
   // nsSVGPaintServerFrame methods:
   virtual PRBool SetupPaintServer(gfxContext *aContext,
                                   nsSVGGeometryFrame *aSource,
                                   float aGraphicOpacity,
                                   void **aClosure);
 
   // nsISupports interface:
@@ -123,17 +129,16 @@ private:
 
   PRUint16 GetSpreadMethod();
   PRUint32 GetStopCount();
   void GetStopInformation(PRInt32 aIndex,
                           float *aOffset, nscolor *aColor, float *aStopOpacity);
   gfxMatrix GetGradientTransform(nsSVGGeometryFrame *aSource);
 
 protected:
-
   virtual already_AddRefed<gfxPattern> CreateGradient() = 0;
 
   // Use these inline methods instead of GetGradientWithAttr(..., aGradType)
   nsIContent* GetLinearGradientWithAttr(nsIAtom *aAttrName)
   {
     return GetGradientWithAttr(aAttrName, nsGkAtoms::svgLinearGradientFrame);
   }
   nsIContent* GetRadialGradientWithAttr(nsIAtom *aAttrName)
@@ -154,26 +159,20 @@ protected:
     mLoopFlag = PR_TRUE;
     nsSVGValue::DidModify(aModType);
     mLoopFlag = PR_FALSE;
   }
 
   // Get the value of our gradientUnits attribute
   PRUint16 GetGradientUnits();
 
-  nsSVGGradientFrame(nsStyleContext* aContext,
-                     nsIDOMSVGURIReference *aRef);
-
-  virtual ~nsSVGGradientFrame();
-
   // The graphic element our gradient is (currently) being applied to
   nsRefPtr<nsSVGElement>                 mSourceContent;
 
 private:
-
   // href of the other gradient we reference (if any)
   nsCOMPtr<nsIDOMSVGAnimatedString>      mHref;
 
   // Frame of the gradient we reference (if any). Do NOT use this directly.
   // Use Get[Xxx]GradientWithAttr instead to ensure proper loop checking.
   nsSVGGradientFrame                    *mNextGrad;
 
   // Flag to mark this frame as "in use" during recursive calls along our
@@ -192,77 +191,77 @@ private:
 // -------------------------------------------------------------------------
 // Linear Gradients
 // -------------------------------------------------------------------------
 
 typedef nsSVGGradientFrame nsSVGLinearGradientFrameBase;
 
 class nsSVGLinearGradientFrame : public nsSVGLinearGradientFrameBase
 {
-public:
   friend nsIFrame* NS_NewSVGLinearGradientFrame(nsIPresShell* aPresShell, 
                                                 nsIContent*   aContent,
                                                 nsStyleContext* aContext);
+protected:
+  nsSVGLinearGradientFrame(nsStyleContext* aContext,
+                           nsIDOMSVGURIReference *aRef) :
+    nsSVGLinearGradientFrameBase(aContext, aRef) {}
 
+public:
   // nsIFrame interface:
   virtual nsIAtom* GetType() const;  // frame type: nsGkAtoms::svgLinearGradientFrame
 
   NS_IMETHOD AttributeChanged(PRInt32         aNameSpaceID,
                               nsIAtom*        aAttribute,
                               PRInt32         aModType);
 
 #ifdef DEBUG
   // nsIFrameDebug interface:
   NS_IMETHOD GetFrameName(nsAString& aResult) const
   {
     return MakeFrameName(NS_LITERAL_STRING("SVGLinearGradient"), aResult);
   }
 #endif // DEBUG
 
 protected:
-  nsSVGLinearGradientFrame(nsStyleContext* aContext,
-                           nsIDOMSVGURIReference *aRef) :
-    nsSVGLinearGradientFrameBase(aContext, aRef) {}
-
   float GradientLookupAttribute(nsIAtom *aAtomName, PRUint16 aEnumName);
   virtual already_AddRefed<gfxPattern> CreateGradient();
 };
 
 // -------------------------------------------------------------------------
 // Radial Gradients
 // -------------------------------------------------------------------------
 
 typedef nsSVGGradientFrame nsSVGRadialGradientFrameBase;
 
 class nsSVGRadialGradientFrame : public nsSVGRadialGradientFrameBase
 {
-public:
   friend nsIFrame* NS_NewSVGRadialGradientFrame(nsIPresShell* aPresShell, 
                                                 nsIContent*   aContent,
                                                 nsStyleContext* aContext);
+protected:
+  nsSVGRadialGradientFrame(nsStyleContext* aContext,
+                           nsIDOMSVGURIReference *aRef) :
+    nsSVGRadialGradientFrameBase(aContext, aRef) {}
 
+public:
   // nsIFrame interface:
   virtual nsIAtom* GetType() const;  // frame type: nsGkAtoms::svgRadialGradientFrame
 
   NS_IMETHOD AttributeChanged(PRInt32         aNameSpaceID,
                               nsIAtom*        aAttribute,
                               PRInt32         aModType);
 
 #ifdef DEBUG
   // nsIFrameDebug interface:
   NS_IMETHOD GetFrameName(nsAString& aResult) const
   {
     return MakeFrameName(NS_LITERAL_STRING("SVGRadialGradient"), aResult);
   }
 #endif // DEBUG
 
 protected:
-  nsSVGRadialGradientFrame(nsStyleContext* aContext,
-                           nsIDOMSVGURIReference *aRef) :
-    nsSVGRadialGradientFrameBase(aContext, aRef) {}
-
   float GradientLookupAttribute(nsIAtom *aAtomName, PRUint16 aEnumName,
                                 nsIContent *aElement = nsnull);
   virtual already_AddRefed<gfxPattern> CreateGradient();
 };
 
 #endif // __NS_SVGGRADIENTFRAME_H__
 
--- a/layout/svg/base/src/nsSVGInnerSVGFrame.cpp
+++ b/layout/svg/base/src/nsSVGInnerSVGFrame.cpp
@@ -49,17 +49,18 @@ typedef nsSVGDisplayContainerFrame nsSVG
 
 class nsSVGInnerSVGFrame : public nsSVGInnerSVGFrameBase,
                            public nsISVGValueObserver,
                            public nsISVGSVGFrame
 {
   friend nsIFrame*
   NS_NewSVGInnerSVGFrame(nsIPresShell* aPresShell, nsIContent* aContent, nsStyleContext* aContext);
 protected:
-  nsSVGInnerSVGFrame(nsStyleContext* aContext);
+  nsSVGInnerSVGFrame(nsStyleContext* aContext) :
+    nsSVGInnerSVGFrameBase(aContext), mPropagateTransform(PR_TRUE) {}
   
    // nsISupports interface:
   NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
 private:
   NS_IMETHOD_(nsrefcnt) AddRef() { return 1; }
   NS_IMETHOD_(nsrefcnt) Release() { return 1; }
 
 public:
@@ -117,25 +118,23 @@ protected:
 };
 
 //----------------------------------------------------------------------
 // Implementation
 
 nsIFrame*
 NS_NewSVGInnerSVGFrame(nsIPresShell* aPresShell, nsIContent* aContent, nsStyleContext* aContext)
 {
-  return new (aPresShell) nsSVGInnerSVGFrame(aContext);
-}
+  nsCOMPtr<nsIDOMSVGSVGElement> svg = do_QueryInterface(aContent);
+  if (!svg) {
+    NS_ERROR("Can't create frame! Content is not an SVG 'svg' element!");
+    return nsnull;
+  }
 
-nsSVGInnerSVGFrame::nsSVGInnerSVGFrame(nsStyleContext* aContext) :
-  nsSVGInnerSVGFrameBase(aContext), mPropagateTransform(PR_TRUE)
-{
-#ifdef DEBUG
-//  printf("nsSVGInnerSVGFrame CTOR\n");
-#endif
+  return new (aPresShell) nsSVGInnerSVGFrame(aContext);
 }
 
 //----------------------------------------------------------------------
 // nsISupports methods
 
 NS_INTERFACE_MAP_BEGIN(nsSVGInnerSVGFrame)
   NS_INTERFACE_MAP_ENTRY(nsISVGValueObserver)
   NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
--- a/layout/svg/base/src/nsSVGLeafFrame.cpp
+++ b/layout/svg/base/src/nsSVGLeafFrame.cpp
@@ -33,29 +33,33 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsFrame.h"
 
 class nsSVGLeafFrame : public nsFrame
 {
+  friend nsIFrame*
+  NS_NewSVGLeafFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
+protected:
+  nsSVGLeafFrame(nsStyleContext* aContext) : nsFrame(aContext) {}
+
+public:
   virtual PRBool IsFrameOfType(PRUint32 aFlags) const
   {
     return nsFrame::IsFrameOfType(aFlags & ~(nsIFrame::eSVG));
   }
 
 #ifdef DEBUG
   NS_IMETHOD GetFrameName(nsAString& aResult) const
   {
     return MakeFrameName(NS_LITERAL_STRING("SVGLeaf"), aResult);
   }
 #endif
 
-public:
-  nsSVGLeafFrame(nsStyleContext* aContext) : nsFrame(aContext) {}
 };
 
 nsIFrame*
 NS_NewSVGLeafFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
 {
   return new (aPresShell) nsSVGLeafFrame(aContext);
 }
--- a/layout/svg/base/src/nsSVGPatternFrame.cpp
+++ b/layout/svg/base/src/nsSVGPatternFrame.cpp
@@ -866,20 +866,20 @@ nsSVGPatternFrame::SetupPaintServer(gfxC
 // Public functions
 // -------------------------------------------------------------------------
 
 nsIFrame* NS_NewSVGPatternFrame(nsIPresShell*   aPresShell,
                                 nsIContent*     aContent,
                                 nsStyleContext* aContext)
 {
   nsCOMPtr<nsIDOMSVGPatternElement> patternElement = do_QueryInterface(aContent);
-  NS_ASSERTION(patternElement, 
-               "NS_NewSVGPatternFrame -- Content doesn't support nsIDOMSVGPattern");
-  if (!patternElement)
+  if (!patternElement) {
+    NS_ERROR("Can't create frame! Content is not an SVG pattern");
     return nsnull;
+  }
 
   nsCOMPtr<nsIDOMSVGURIReference> ref = do_QueryInterface(aContent);
   NS_ASSERTION(ref, 
                "NS_NewSVGPatternFrame -- Content doesn't support nsIDOMSVGURIReference");
 
 #ifdef DEBUG_scooter
   printf("NS_NewSVGPatternFrame\n");
 #endif
--- a/layout/svg/base/src/nsSVGStopFrame.cpp
+++ b/layout/svg/base/src/nsSVGStopFrame.cpp
@@ -45,19 +45,23 @@
 // This is a very simple frame whose only purpose is to capture style change
 // events and propagate them to the parent.  Most of the heavy lifting is done
 // within the nsSVGGradientFrame, which is the parent for this frame
 
 typedef nsFrame  nsSVGStopFrameBase;
 
 class nsSVGStopFrame : public nsSVGStopFrameBase
 {
-public:
+  friend nsIFrame*
+  NS_NewSVGStopFrame(nsIPresShell*   aPresShell, nsIContent*     aContent,
+                     nsIFrame*       aParentFrame, nsStyleContext* aContext);
+protected:
   nsSVGStopFrame(nsStyleContext* aContext) : nsSVGStopFrameBase(aContext) {}
 
+public:
   // nsIFrame interface:
   NS_IMETHOD DidSetStyleContext();
 
   NS_IMETHOD AttributeChanged(PRInt32         aNameSpaceID,
                               nsIAtom*        aAttribute,
                               PRInt32         aModType);
 
   /**
@@ -74,21 +78,16 @@ public:
 
 #ifdef DEBUG
   // nsIFrameDebug interface:
   NS_IMETHOD GetFrameName(nsAString& aResult) const
   {
     return MakeFrameName(NS_LITERAL_STRING("SVGStop"), aResult);
   }
 #endif
-
-  friend nsIFrame* NS_NewSVGStopFrame(nsIPresShell*   aPresShell,
-                                      nsIContent*     aContent,
-                                      nsIFrame*       aParentFrame,
-                                      nsStyleContext* aContext);
 };
 
 //----------------------------------------------------------------------
 // Implementation
 
 //----------------------------------------------------------------------
 // nsIFrame methods:
 
--- a/layout/svg/base/src/nsSVGTSpanFrame.cpp
+++ b/layout/svg/base/src/nsSVGTSpanFrame.cpp
@@ -53,20 +53,19 @@ NS_NewSVGTSpanFrame(nsIPresShell* aPresS
   NS_ASSERTION(parentFrame, "null parent");
   nsISVGTextContentMetrics *metrics;
   CallQueryInterface(parentFrame, &metrics);
   if (!metrics) {
     NS_ERROR("trying to construct an SVGTSpanFrame for an invalid container");
     return nsnull;
   }
   
-  nsCOMPtr<nsIDOMSVGTSpanElement> tspan_elem = do_QueryInterface(aContent);
-  if (!tspan_elem) {
-    NS_ERROR("Trying to construct an SVGTSpanFrame for a "
-             "content element that doesn't support the right interfaces");
+  nsCOMPtr<nsIDOMSVGTSpanElement> tspan = do_QueryInterface(aContent);
+  if (!tspan) {
+    NS_ERROR("Can't create frame! Content is not an SVG tspan");
     return nsnull;
   }
 
   return new (aPresShell) nsSVGTSpanFrame(aContext);
 }
 
 nsIAtom *
 nsSVGTSpanFrame::GetType() const
--- a/layout/svg/base/src/nsSVGTextPathFrame.cpp
+++ b/layout/svg/base/src/nsSVGTextPathFrame.cpp
@@ -82,20 +82,19 @@ NS_NewSVGTextPathFrame(nsIPresShell* aPr
                        nsIFrame* parentFrame, nsStyleContext* aContext)
 {
   NS_ASSERTION(parentFrame, "null parent");
   if (parentFrame->GetType() != nsGkAtoms::svgTextFrame) {
     NS_ERROR("trying to construct an SVGTextPathFrame for an invalid container");
     return nsnull;
   }
   
-  nsCOMPtr<nsIDOMSVGTextPathElement> tpath_elem = do_QueryInterface(aContent);
-  if (!tpath_elem) {
-    NS_ERROR("Trying to construct an SVGTextPathFrame for a "
-             "content element that doesn't support the right interfaces");
+  nsCOMPtr<nsIDOMSVGTextPathElement> textPath = do_QueryInterface(aContent);
+  if (!textPath) {
+    NS_ERROR("Can't create frame! Content is not an SVG textPath");
     return nsnull;
   }
 
   return new (aPresShell) nsSVGTextPathFrame(aContext);
 }
 
 NS_IMETHODIMP
 nsSVGTextPathFrame::Init(nsIContent*      aContent,
@@ -181,17 +180,18 @@ nsSVGTextPathFrame::GetDy()
 {
   return nsnull;
 }
 
 //----------------------------------------------------------------------
 // nsSVGTextPathFrame methods:
 
 nsIFrame *
-nsSVGTextPathFrame::GetPathFrame() {
+nsSVGTextPathFrame::GetPathFrame()
+{
   nsIFrame *path = nsnull;
 
   nsAutoString str;
   mHref->GetAnimVal(str);
 
   nsCOMPtr<nsIURI> targetURI;
   nsCOMPtr<nsIURI> base = mContent->GetBaseURI();
   nsContentUtils::NewURIWithDocumentCharset(getter_AddRefs(targetURI), str,
@@ -200,17 +200,18 @@ nsSVGTextPathFrame::GetPathFrame() {
   nsSVGUtils::GetReferencedFrame(&path, targetURI, mContent,
                                  PresContext()->PresShell());
   if (!path || (path->GetType() != nsGkAtoms::svgPathGeometryFrame))
     return nsnull;
   return path;
 }
 
 already_AddRefed<gfxFlattenedPath>
-nsSVGTextPathFrame::GetFlattenedPath() {
+nsSVGTextPathFrame::GetFlattenedPath()
+{
   nsIFrame *path = GetPathFrame();
   if (!path)
     return nsnull;
 
   nsSVGPathGeometryElement *element = static_cast<nsSVGPathGeometryElement*>
                                                  (path->GetContent());
 
   if (!mPathListener) {
--- a/layout/svg/base/src/nsSVGTextPathFrame.h
+++ b/layout/svg/base/src/nsSVGTextPathFrame.h
@@ -62,19 +62,23 @@ private:
   nsWeakPtr mObservedPath;
   nsSVGTextPathFrame *mTextPathFrame;
 };
 
 typedef nsSVGTSpanFrame nsSVGTextPathFrameBase;
 
 class nsSVGTextPathFrame : public nsSVGTextPathFrameBase
 {
-public:
+  friend nsIFrame*
+  NS_NewSVGTextPathFrame(nsIPresShell* aPresShell, nsIContent* aContent,
+                         nsIFrame* parentFrame, nsStyleContext* aContext);
+protected:
   nsSVGTextPathFrame(nsStyleContext* aContext) : nsSVGTextPathFrameBase(aContext) {}
 
+public:
   // nsIFrame:
   NS_IMETHOD Init(nsIContent*      aContent,
                   nsIFrame*        aParent,
                   nsIFrame*        aPrevInFlow);
   NS_IMETHOD  AttributeChanged(PRInt32         aNameSpaceID,
                                nsIAtom*        aAttribute,
                                PRInt32         aModType);
   /**
--- a/layout/svg/base/src/nsSVGUseFrame.cpp
+++ b/layout/svg/base/src/nsSVGUseFrame.cpp
@@ -89,21 +89,19 @@ public:
 };
 
 //----------------------------------------------------------------------
 // Implementation
 
 nsIFrame*
 NS_NewSVGUseFrame(nsIPresShell* aPresShell, nsIContent* aContent, nsStyleContext* aContext)
 {
-  nsCOMPtr<nsIDOMSVGTransformable> transformable = do_QueryInterface(aContent);
-  if (!transformable) {
-#ifdef DEBUG
-    printf("warning: trying to construct an SVGUseFrame for a content element that doesn't support the right interfaces\n");
-#endif
+  nsCOMPtr<nsIDOMSVGUseElement> use = do_QueryInterface(aContent);
+  if (!use) {
+    NS_ERROR("Can't create frame! Content is not an SVG use!");
     return nsnull;
   }
 
   return new (aPresShell) nsSVGUseFrame(aContext);
 }
 
 nsIAtom *
 nsSVGUseFrame::GetType() const