diff --git a/layout/svg/base/src/nsSVGGFrame.cpp b/layout/svg/base/src/nsSVGGFrame.cpp index 970a3bff2df..faa31a1532c 100644 --- a/layout/svg/base/src/nsSVGGFrame.cpp +++ b/layout/svg/base/src/nsSVGGFrame.cpp @@ -53,9 +53,7 @@ NS_NewSVGGFrame(nsIPresShell* aPresShell, nsIContent* aContent, nsStyleContext* { nsCOMPtr 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; } diff --git a/layout/svg/base/src/nsSVGGFrame.h b/layout/svg/base/src/nsSVGGFrame.h index fda607b38f1..b5633e8f5a5 100644 --- a/layout/svg/base/src/nsSVGGFrame.h +++ b/layout/svg/base/src/nsSVGGFrame.h @@ -45,10 +45,13 @@ 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 * @@ -63,10 +66,6 @@ public: } #endif -protected: - friend nsIFrame* - NS_NewSVGGFrame(nsIPresShell* aPresShell, nsIContent* aContent, nsStyleContext* aContext); - // nsIFrame interface: NS_IMETHOD DidSetStyleContext(); NS_IMETHOD AttributeChanged(PRInt32 aNameSpaceID, diff --git a/layout/svg/base/src/nsSVGGradientFrame.cpp b/layout/svg/base/src/nsSVGGradientFrame.cpp index 1a84515cc0c..6261d70d240 100644 --- a/layout/svg/base/src/nsSVGGradientFrame.cpp +++ b/layout/svg/base/src/nsSVGGradientFrame.cpp @@ -735,9 +735,10 @@ NS_NewSVGLinearGradientFrame(nsIPresShell* aPresShell, nsStyleContext* aContext) { nsCOMPtr 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 aRef = do_QueryInterface(aContent); NS_ASSERTION(aRef, "NS_NewSVGLinearGradientFrame -- Content doesn't support nsIDOMSVGURIReference"); @@ -751,9 +752,10 @@ NS_NewSVGRadialGradientFrame(nsIPresShell* aPresShell, nsStyleContext* aContext) { nsCOMPtr 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 aRef = do_QueryInterface(aContent); NS_ASSERTION(aRef, "NS_NewSVGRadialGradientFrame -- Content doesn't support nsIDOMSVGURIReference"); diff --git a/layout/svg/base/src/nsSVGGradientFrame.h b/layout/svg/base/src/nsSVGGradientFrame.h index 35fe4b02243..dd0e58580fd 100644 --- a/layout/svg/base/src/nsSVGGradientFrame.h +++ b/layout/svg/base/src/nsSVGGradientFrame.h @@ -53,6 +53,12 @@ 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, @@ -128,7 +134,6 @@ private: gfxMatrix GetGradientTransform(nsSVGGeometryFrame *aSource); protected: - virtual already_AddRefed CreateGradient() = 0; // Use these inline methods instead of GetGradientWithAttr(..., aGradType) @@ -159,16 +164,10 @@ protected: // 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 mSourceContent; private: - // href of the other gradient we reference (if any) nsCOMPtr mHref; @@ -197,11 +196,15 @@ 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 @@ -218,10 +221,6 @@ public: #endif // DEBUG protected: - nsSVGLinearGradientFrame(nsStyleContext* aContext, - nsIDOMSVGURIReference *aRef) : - nsSVGLinearGradientFrameBase(aContext, aRef) {} - float GradientLookupAttribute(nsIAtom *aAtomName, PRUint16 aEnumName); virtual already_AddRefed CreateGradient(); }; @@ -234,11 +233,15 @@ 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 @@ -255,10 +258,6 @@ public: #endif // DEBUG protected: - nsSVGRadialGradientFrame(nsStyleContext* aContext, - nsIDOMSVGURIReference *aRef) : - nsSVGRadialGradientFrameBase(aContext, aRef) {} - float GradientLookupAttribute(nsIAtom *aAtomName, PRUint16 aEnumName, nsIContent *aElement = nsnull); virtual already_AddRefed CreateGradient(); diff --git a/layout/svg/base/src/nsSVGInnerSVGFrame.cpp b/layout/svg/base/src/nsSVGInnerSVGFrame.cpp index 90eca0bf791..f747df8f3aa 100644 --- a/layout/svg/base/src/nsSVGInnerSVGFrame.cpp +++ b/layout/svg/base/src/nsSVGInnerSVGFrame.cpp @@ -54,7 +54,8 @@ class nsSVGInnerSVGFrame : public nsSVGInnerSVGFrameBase, 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); @@ -122,15 +123,13 @@ protected: nsIFrame* NS_NewSVGInnerSVGFrame(nsIPresShell* aPresShell, nsIContent* aContent, nsStyleContext* aContext) { - return new (aPresShell) nsSVGInnerSVGFrame(aContext); -} + nsCOMPtr 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); } //---------------------------------------------------------------------- diff --git a/layout/svg/base/src/nsSVGLeafFrame.cpp b/layout/svg/base/src/nsSVGLeafFrame.cpp index 1f974ff944c..34e1c205428 100644 --- a/layout/svg/base/src/nsSVGLeafFrame.cpp +++ b/layout/svg/base/src/nsSVGLeafFrame.cpp @@ -38,6 +38,12 @@ 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)); @@ -50,8 +56,6 @@ class nsSVGLeafFrame : public nsFrame } #endif -public: - nsSVGLeafFrame(nsStyleContext* aContext) : nsFrame(aContext) {} }; nsIFrame* diff --git a/layout/svg/base/src/nsSVGPatternFrame.cpp b/layout/svg/base/src/nsSVGPatternFrame.cpp index 99f91ba2bb8..4cb344544a5 100644 --- a/layout/svg/base/src/nsSVGPatternFrame.cpp +++ b/layout/svg/base/src/nsSVGPatternFrame.cpp @@ -871,10 +871,10 @@ nsIFrame* NS_NewSVGPatternFrame(nsIPresShell* aPresShell, nsStyleContext* aContext) { nsCOMPtr 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 ref = do_QueryInterface(aContent); NS_ASSERTION(ref, diff --git a/layout/svg/base/src/nsSVGStopFrame.cpp b/layout/svg/base/src/nsSVGStopFrame.cpp index 4244433fa66..0bffb713d79 100644 --- a/layout/svg/base/src/nsSVGStopFrame.cpp +++ b/layout/svg/base/src/nsSVGStopFrame.cpp @@ -50,9 +50,13 @@ 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(); @@ -79,11 +83,6 @@ public: return MakeFrameName(NS_LITERAL_STRING("SVGStop"), aResult); } #endif - - friend nsIFrame* NS_NewSVGStopFrame(nsIPresShell* aPresShell, - nsIContent* aContent, - nsIFrame* aParentFrame, - nsStyleContext* aContext); }; //---------------------------------------------------------------------- diff --git a/layout/svg/base/src/nsSVGTSpanFrame.cpp b/layout/svg/base/src/nsSVGTSpanFrame.cpp index bddd8e967c8..adff538c72f 100644 --- a/layout/svg/base/src/nsSVGTSpanFrame.cpp +++ b/layout/svg/base/src/nsSVGTSpanFrame.cpp @@ -58,10 +58,9 @@ NS_NewSVGTSpanFrame(nsIPresShell* aPresShell, nsIContent* aContent, return nsnull; } - nsCOMPtr 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 tspan = do_QueryInterface(aContent); + if (!tspan) { + NS_ERROR("Can't create frame! Content is not an SVG tspan"); return nsnull; } diff --git a/layout/svg/base/src/nsSVGTextPathFrame.cpp b/layout/svg/base/src/nsSVGTextPathFrame.cpp index 0a40329a6a9..fe5b67bcdbb 100644 --- a/layout/svg/base/src/nsSVGTextPathFrame.cpp +++ b/layout/svg/base/src/nsSVGTextPathFrame.cpp @@ -87,10 +87,9 @@ NS_NewSVGTextPathFrame(nsIPresShell* aPresShell, nsIContent* aContent, return nsnull; } - nsCOMPtr 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 textPath = do_QueryInterface(aContent); + if (!textPath) { + NS_ERROR("Can't create frame! Content is not an SVG textPath"); return nsnull; } @@ -186,7 +185,8 @@ nsSVGTextPathFrame::GetDy() // nsSVGTextPathFrame methods: nsIFrame * -nsSVGTextPathFrame::GetPathFrame() { +nsSVGTextPathFrame::GetPathFrame() +{ nsIFrame *path = nsnull; nsAutoString str; @@ -205,7 +205,8 @@ nsSVGTextPathFrame::GetPathFrame() { } already_AddRefed -nsSVGTextPathFrame::GetFlattenedPath() { +nsSVGTextPathFrame::GetFlattenedPath() +{ nsIFrame *path = GetPathFrame(); if (!path) return nsnull; diff --git a/layout/svg/base/src/nsSVGTextPathFrame.h b/layout/svg/base/src/nsSVGTextPathFrame.h index 587185742e7..82805506481 100644 --- a/layout/svg/base/src/nsSVGTextPathFrame.h +++ b/layout/svg/base/src/nsSVGTextPathFrame.h @@ -67,9 +67,13 @@ 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, diff --git a/layout/svg/base/src/nsSVGUseFrame.cpp b/layout/svg/base/src/nsSVGUseFrame.cpp index 8b590570bc4..9693ebc824a 100644 --- a/layout/svg/base/src/nsSVGUseFrame.cpp +++ b/layout/svg/base/src/nsSVGUseFrame.cpp @@ -94,11 +94,9 @@ public: nsIFrame* NS_NewSVGUseFrame(nsIPresShell* aPresShell, nsIContent* aContent, nsStyleContext* aContext) { - nsCOMPtr 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 use = do_QueryInterface(aContent); + if (!use) { + NS_ERROR("Can't create frame! Content is not an SVG use!"); return nsnull; }