mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 388411 - Improve frame construction: make trivial constructors inline and check that content is what we expect. r+sr=tor
This commit is contained in:
parent
0b135acaad
commit
bc1440c080
@ -53,9 +53,7 @@ NS_NewSVGGFrame(nsIPresShell* aPresShell, nsIContent* aContent, nsStyleContext*
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -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,
|
||||
|
@ -735,9 +735,10 @@ NS_NewSVGLinearGradientFrame(nsIPresShell* aPresShell,
|
||||
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");
|
||||
@ -751,9 +752,10 @@ NS_NewSVGRadialGradientFrame(nsIPresShell* aPresShell,
|
||||
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");
|
||||
|
@ -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<gfxPattern> 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<nsSVGElement> mSourceContent;
|
||||
|
||||
private:
|
||||
|
||||
// href of the other gradient we reference (if any)
|
||||
nsCOMPtr<nsIDOMSVGAnimatedString> 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<gfxPattern> 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<gfxPattern> CreateGradient();
|
||||
|
@ -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<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);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -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*
|
||||
|
@ -871,10 +871,10 @@ nsIFrame* NS_NewSVGPatternFrame(nsIPresShell* aPresShell,
|
||||
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,
|
||||
|
@ -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);
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -58,10 +58,9 @@ NS_NewSVGTSpanFrame(nsIPresShell* aPresShell, nsIContent* aContent,
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -87,10 +87,9 @@ NS_NewSVGTextPathFrame(nsIPresShell* aPresShell, nsIContent* aContent,
|
||||
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;
|
||||
}
|
||||
|
||||
@ -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<gfxFlattenedPath>
|
||||
nsSVGTextPathFrame::GetFlattenedPath() {
|
||||
nsSVGTextPathFrame::GetFlattenedPath()
|
||||
{
|
||||
nsIFrame *path = GetPathFrame();
|
||||
if (!path)
|
||||
return nsnull;
|
||||
|
@ -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,
|
||||
|
@ -94,11 +94,9 @@ public:
|
||||
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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user