Bug 593604. Part 5: Mark CSS gradient images as opaque when all their stops are opaque. r=dbaron,a=blocking

This commit is contained in:
Robert O'Callahan 2011-01-03 14:48:09 +13:00
parent 1afaa01821
commit 7684e2b15c
2 changed files with 14 additions and 4 deletions

View File

@ -1373,6 +1373,16 @@ nsStyleGradient::nsStyleGradient(void)
{ {
} }
PRBool
nsStyleGradient::IsOpaque()
{
for (PRUint32 i = 0; i < mStops.Length(); i++) {
if (NS_GET_A(mStops[i].mColor) < 255)
return PR_FALSE;
}
return PR_TRUE;
}
// -------------------- // --------------------
// nsStyleImage // nsStyleImage
// //
@ -1608,10 +1618,8 @@ nsStyleImage::IsOpaque() const
if (!IsComplete()) if (!IsComplete())
return PR_FALSE; return PR_FALSE;
if (mType == eStyleImageType_Gradient) { if (mType == eStyleImageType_Gradient)
// We could check if every stop color of the gradient is non-transparent. return mGradient->IsOpaque();
return PR_FALSE;
}
if (mType == eStyleImageType_Element) if (mType == eStyleImageType_Element)
return PR_FALSE; return PR_FALSE;

View File

@ -173,6 +173,8 @@ public:
return !(*this == aOther); return !(*this == aOther);
}; };
PRBool IsOpaque();
NS_INLINE_DECL_REFCOUNTING(nsStyleGradient) NS_INLINE_DECL_REFCOUNTING(nsStyleGradient)
private: private: