Bug 407463 - Skip rendering of invalid filters, masks and clipPaths. r+sr=tor,a1.9=blocking1.9+

This commit is contained in:
longsonr@gmail.com 2008-02-09 06:22:14 -08:00
parent b0a44e937f
commit c56394efba
2 changed files with 44 additions and 20 deletions

View File

@ -93,16 +93,21 @@ nsSVGFilterFrame::FilterPaint(nsSVGRenderState *aContext,
PRUint32 requirements = 0;
PRUint32 count = mContent->GetChildCount();
PRBool filterExists = PR_FALSE;
for (PRUint32 i=0; i<count; ++i) {
nsIContent* child = mContent->GetChildAt(i);
nsCOMPtr<nsISVGFilter> filter = do_QueryInterface(child);
if (filter) {
filterExists = PR_TRUE;
PRUint32 tmp;
filter->GetRequirements(&tmp);
requirements |= tmp;
}
}
if (!filterExists) {
return NS_OK;
}
// check for source requirements that we don't support yet
if (requirements & ~(NS_FE_SOURCEGRAPHIC | NS_FE_SOURCEALPHA)) {
@ -141,8 +146,12 @@ nsSVGFilterFrame::FilterPaint(nsSVGRenderState *aContext,
filter->mEnumAttributes[nsSVGFilterElement::FILTERUNITS].GetAnimValue();
if (units == nsIDOMSVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) {
if (!bbox)
if (!bbox) {
aTarget->SetMatrixPropagation(PR_TRUE);
aTarget->NotifySVGChanged(nsISVGChildFrame::SUPPRESS_INVALIDATION |
nsISVGChildFrame::TRANSFORM_CHANGED);
return NS_OK;
}
bbox->GetX(&x);
x += nsSVGUtils::ObjectSpace(bbox, tmpX);
@ -180,8 +189,12 @@ nsSVGFilterFrame::FilterPaint(nsSVGRenderState *aContext,
// 0 disables rendering, < 0 is error
if (filterRes.width <= 0 || filterRes.height <= 0)
if (filterRes.width <= 0 || filterRes.height <= 0) {
aTarget->SetMatrixPropagation(PR_TRUE);
aTarget->NotifySVGChanged(nsISVGChildFrame::SUPPRESS_INVALIDATION |
nsISVGChildFrame::TRANSFORM_CHANGED);
return NS_OK;
}
#ifdef DEBUG_tor
fprintf(stderr, "filter bbox: %f,%f %fx%f\n", x, y, width, height);

View File

@ -83,7 +83,7 @@
#include "nsIFontMetrics.h"
#include "nsIDOMSVGUnitTypes.h"
static void AddEffectProperties(nsIFrame *aFrame);
static PRBool AddEffectProperties(nsIFrame *aFrame);
class nsSVGPropertyBase : public nsStubMutationObserver {
public:
@ -1158,7 +1158,7 @@ nsSVGUtils::RemoveObserver(nsISupports *aObserver, nsISupports *aTarget)
// ************************************************************
// Effect helper functions
static void
static PRBool
AddEffectProperties(nsIFrame *aFrame)
{
const nsStyleSVGReset *style = aFrame->GetStyleSVGReset();
@ -1166,35 +1166,45 @@ AddEffectProperties(nsIFrame *aFrame)
if (style->mFilter && !(aFrame->GetStateBits() & NS_STATE_SVG_FILTERED)) {
nsIContent *filter = NS_GetSVGFilterElement(style->mFilter,
aFrame->GetContent());
nsSVGPropertyBase *property = nsnull;
if (filter && !(property = new nsSVGFilterProperty(filter, aFrame))) {
NS_ERROR("Could not create filter property");
return;
if (!filter) {
return PR_FALSE;
}
NS_IF_ADDREF(property); // addref to allow QI - SupportsDtorFunc releases
nsSVGPropertyBase *property;
if (!(property = new nsSVGFilterProperty(filter, aFrame))) {
NS_ERROR("Could not create filter property");
return PR_FALSE;
}
NS_ADDREF(property); // addref to allow QI - SupportsDtorFunc releases
}
if (style->mClipPath && !(aFrame->GetStateBits() & NS_STATE_SVG_CLIPPED)) {
nsIContent *clipPath = NS_GetSVGClipPathElement(style->mClipPath,
aFrame->GetContent());
nsSVGPropertyBase *property = nsnull;
if (clipPath && !(property = new nsSVGClipPathProperty(clipPath, aFrame))) {
NS_ERROR("Could not create clipPath property");
return;
if (!clipPath) {
return PR_FALSE;
}
NS_IF_ADDREF(property); // addref to allow QI - SupportsDtorFunc releases
nsSVGPropertyBase *property;
if (!(property = new nsSVGClipPathProperty(clipPath, aFrame))) {
NS_ERROR("Could not create clipPath property");
return PR_FALSE;
}
NS_ADDREF(property); // addref to allow QI - SupportsDtorFunc releases
}
if (style->mMask && !(aFrame->GetStateBits() & NS_STATE_SVG_MASKED)) {
nsIContent *mask = NS_GetSVGMaskElement(style->mMask,
aFrame->GetContent());
nsSVGPropertyBase *property = nsnull;
if (mask && !(property = new nsSVGMaskProperty(mask, aFrame))) {
NS_ERROR("Could not create mask property");
return;
if (!mask) {
return PR_FALSE;
}
NS_IF_ADDREF(property); // addref to allow QI - SupportsDtorFunc releases
nsSVGPropertyBase *property;
if (!(property = new nsSVGMaskProperty(mask, aFrame))) {
NS_ERROR("Could not create mask property");
return PR_FALSE;
}
NS_ADDREF(property); // addref to allow QI - SupportsDtorFunc releases
}
return PR_TRUE;
}
static nsSVGFilterFrame *
@ -1253,7 +1263,8 @@ nsSVGUtils::PaintChildWithEffects(nsSVGRenderState *aContext,
/* Properties are added lazily and may have been removed by a restyle,
so make sure all applicable ones are set again. */
AddEffectProperties(aFrame);
if (!AddEffectProperties(aFrame))
return;
nsFrameState state = aFrame->GetStateBits();
/* Check if we need to draw anything */