Fixing bug 272885. Disable rendering of some elements when their width or height is zero. r=tor@acm.org, sr=vladimir@pobox.com, a1.9=mtschrep@gmail.com

This commit is contained in:
jwatt@jwatt.org 2008-01-27 12:39:27 -08:00
Родитель 48cd9701f5
Коммит 30ec885b7d
2 изменённых файлов: 44 добавлений и 18 удалений

Просмотреть файл

@ -581,4 +581,35 @@ private:
PRInt32 mFlags;
};
/**
* Sentry helper class for functions with multiple return points that need to
* call Save() on a gfxContext and have Restore() called automatically on the
* gfxContext before they return.
*/
class THEBES_API gfxContextAutoSaveRestore
{
public:
gfxContextAutoSaveRestore() : mContext(nsnull) {}
gfxContextAutoSaveRestore(gfxContext *aContext) : mContext(aContext) {
mContext->Save();
}
~gfxContextAutoSaveRestore() {
if (mContext) {
mContext->Restore();
}
}
void SetContext(gfxContext *aContext) {
NS_ASSERTION(!mContext, "Not going to call Restore() on some context!!!");
mContext = aContext;
mContext->Save();
}
private:
gfxContext *mContext;
};
#endif /* GFX_CONTEXT_H */

Просмотреть файл

@ -158,37 +158,32 @@ nsSVGInnerSVGFrame::GetType() const
NS_IMETHODIMP
nsSVGInnerSVGFrame::PaintSVG(nsSVGRenderState *aContext, nsRect *aDirtyRect)
{
nsresult rv = NS_OK;
gfxContext *gfx = aContext->GetGfxContext();
gfx->Save();
gfxContextAutoSaveRestore autoSR;
if (GetStyleDisplay()->IsScrollableOverflow()) {
float x, y, width, height;
static_cast<nsSVGSVGElement*>(mContent)->
GetAnimatedLengthValues(&x, &y, &width, &height, nsnull);
if (width <= 0 || height <= 0) {
return NS_OK;
}
nsCOMPtr<nsIDOMSVGMatrix> clipTransform;
if (!mPropagateTransform) {
NS_NewSVGMatrix(getter_AddRefs(clipTransform));
} else {
nsSVGContainerFrame *parent = static_cast<nsSVGContainerFrame*>
(mParent);
clipTransform = parent->GetCanvasTM();
clipTransform = static_cast<nsSVGContainerFrame*>(mParent)->GetCanvasTM();
}
if (clipTransform) {
nsSVGSVGElement *svg = static_cast<nsSVGSVGElement*>(mContent);
float x, y, width, height;
svg->GetAnimatedLengthValues(&x, &y, &width, &height, nsnull);
gfxContext *gfx = aContext->GetGfxContext();
autoSR.SetContext(gfx);
nsSVGUtils::SetClipRect(gfx, clipTransform, x, y, width, height);
}
}
rv = nsSVGInnerSVGFrameBase::PaintSVG(aContext, aDirtyRect);
gfx->Restore();
return rv;
return nsSVGInnerSVGFrameBase::PaintSVG(aContext, aDirtyRect);
}
void