Fixing bug 385246. Negative width attribute on <svg:foreignObject> causes "ASSERTION: reflow state made child wrong size" and more. r=tor@acm.org, sr=roc@ocallahan.org

This commit is contained in:
jwatt@jwatt.org 2007-06-25 01:31:31 -07:00
parent 94d39f1feb
commit 45c2fb8d64
2 changed files with 21 additions and 1 deletions

View File

@ -243,6 +243,9 @@ NS_IMETHODIMP
nsSVGForeignObjectFrame::PaintSVG(nsSVGRenderState *aContext,
nsRect *aDirtyRect)
{
if (IsDisabled())
return NS_OK;
nsIFrame* kid = GetFirstChild(nsnull);
if (!kid)
return NS_OK;
@ -302,9 +305,13 @@ nsSVGForeignObjectFrame::TransformPointFromOuterPx(float aX, float aY, nsPoint*
NS_IMETHODIMP
nsSVGForeignObjectFrame::GetFrameForPointSVG(float x, float y, nsIFrame** hit)
{
*hit = nsnull;
if (IsDisabled())
return NS_OK;
nsIFrame* kid = GetFirstChild(nsnull);
if (!kid) {
*hit = nsnull;
return NS_OK;
}
nsPoint pt;
@ -345,6 +352,10 @@ nsSVGForeignObjectFrame::UpdateCoveredRegion()
NS_STATIC_CAST(nsSVGForeignObjectElement*, mContent)->
GetAnimatedLengthValues(&x, &y, &w, &h, nsnull);
// If mRect's width or height are negative, reflow blows up! We must clamp!
if (w < 0.0f) w = 0.0f;
if (h < 0.0f) h = 0.0f;
// XXXjwatt: _this_ is where we should reflow _if_ mRect.width has changed!
// we should not unconditionally reflow in AttributeChanged
mRect = GetTransformedRegion(x, y, w, h, ctm);
@ -426,6 +437,9 @@ nsSVGForeignObjectFrame::GetBBox(nsIDOMSVGRect **_retval)
NS_STATIC_CAST(nsSVGForeignObjectElement*, mContent)->
GetAnimatedLengthValues(&x, &y, &w, &h, nsnull);
if (w < 0.0f) w = 0.0f;
if (h < 0.0f) h = 0.0f;
return NS_NewSVGRect(_retval, x, y, w, h);
}
@ -546,6 +560,9 @@ nsSVGForeignObjectFrame::DoReflow()
printf("**nsSVGForeignObjectFrame::DoReflow()\n");
#endif
if (IsDisabled())
return;
if (mParent->GetStateBits() & NS_STATE_SVG_NONDISPLAY_CHILD)
return;

View File

@ -143,6 +143,9 @@ protected:
nsresult TransformPointFromOuterPx(float aX, float aY, nsPoint* aOut);
void FlushDirtyRegion();
// If width or height is less than or equal to zero we must disable rendering
PRBool IsDisabled() const { return mRect.width <= 0 || mRect.height <= 0; }
nsCOMPtr<nsIDOMSVGMatrix> mCanvasTM;
nsCOMPtr<nsIDOMSVGMatrix> mOverrideCTM;
nsRegion mDirtyRegion;