Bug 600574 part 2: Check for SVG images with viewBox in nsStyleBackground::Layer::RenderingMightDependOnFrameSize. r=bz r=longsonr a=blocking-betaN+

This commit is contained in:
Daniel Holbert
2010-10-06 15:18:52 -07:00
parent 3a9110b475
commit 079b3fce84
12 changed files with 147 additions and 6 deletions

View File

@@ -62,6 +62,7 @@
#include "nsHTMLReflowState.h"
#include "prenv.h"
#include "nsSVGUtils.h"
#include "nsBidiUtils.h"
#include "imgIRequest.h"
@@ -378,11 +379,11 @@ nsChangeHint nsStylePadding::MaxDifference()
nsStyleBorder::nsStyleBorder(nsPresContext* aPresContext)
: mHaveBorderImageWidth(PR_FALSE)
, mComputedBorder(0, 0, 0, 0)
, mBorderImage(nsnull)
#ifdef DEBUG
, mImageTracked(false)
#endif
, mComputedBorder(0, 0, 0, 0)
, mBorderImage(nsnull)
{
MOZ_COUNT_CTOR(nsStyleBorder);
nscoord medium =
@@ -1868,9 +1869,32 @@ nsStyleBackground::Layer::SetInitialValues()
PRBool
nsStyleBackground::Layer::RenderingMightDependOnFrameSize() const
{
return (!mImage.IsEmpty() &&
(mPosition.DependsOnFrameSize() ||
mSize.DependsOnFrameSize(mImage.GetType())));
// Do we even have an image?
if (mImage.IsEmpty()) {
return PR_FALSE;
}
// Does our position or size depend on frame size?
if (mPosition.DependsOnFrameSize() ||
mSize.DependsOnFrameSize(mImage.GetType())) {
return PR_TRUE;
}
// Are we an SVG image with a viewBox attribute?
if (mImage.GetType() == eStyleImageType_Image) {
nsCOMPtr<imgIContainer> imageContainer;
mImage.GetImageData()->GetImage(getter_AddRefs(imageContainer));
if (imageContainer &&
imageContainer->GetType() == imgIContainer::TYPE_VECTOR) {
nsIFrame* rootFrame = imageContainer->GetRootLayoutFrame();
if (rootFrame &&
nsSVGUtils::RootSVGElementHasViewbox(rootFrame->GetContent())) {
return PR_TRUE;
}
}
}
return PR_FALSE;
}
PRBool