Bug 695763. Part 5. Invalidate background images if they are not decoded and we are asked to do a sync decode. r=matt.woodrow

This commit is contained in:
Timothy Nikkel 2013-06-26 11:43:27 -05:00
parent 43483fb2f5
commit 99526d4aa5
3 changed files with 30 additions and 8 deletions

View File

@ -3036,19 +3036,29 @@ nsCSSRendering::GetBackgroundLayerRect(nsPresContext* aPresContext,
return state.mFillArea;
}
/* static */ bool
nsCSSRendering::IsBackgroundImageDecodedForStyleContextAndLayer(
const nsStyleBackground *aBackground, uint32_t aLayer)
{
const nsStyleImage* image = &aBackground->mLayers[aLayer].mImage;
if (image->GetType() == eStyleImageType_Image) {
nsCOMPtr<imgIContainer> img;
if (NS_SUCCEEDED(image->GetImageData()->GetImage(getter_AddRefs(img)))) {
if (!img->IsDecoded()) {
return false;
}
}
}
return true;
}
/* static */ bool
nsCSSRendering::AreAllBackgroundImagesDecodedForFrame(nsIFrame* aFrame)
{
const nsStyleBackground *bg = aFrame->StyleContext()->StyleBackground();
NS_FOR_VISIBLE_BACKGROUND_LAYERS_BACK_TO_FRONT(i, bg) {
const nsStyleImage* image = &bg->mLayers[i].mImage;
if (image->GetType() == eStyleImageType_Image) {
nsCOMPtr<imgIContainer> img;
if (NS_SUCCEEDED(image->GetImageData()->GetImage(getter_AddRefs(img)))) {
if (!img->IsDecoded()) {
return false;
}
}
if (!IsBackgroundImageDecodedForStyleContextAndLayer(bg, i)) {
return false;
}
}
return true;

View File

@ -396,6 +396,12 @@ struct nsCSSRendering {
const nsStyleBackground::Layer& aLayer,
uint32_t aFlags);
/**
* Checks if image in layer aLayer of aBackground is currently decoded.
*/
static bool IsBackgroundImageDecodedForStyleContextAndLayer(
const nsStyleBackground *aBackground, uint32_t aLayer);
/**
* Checks if all images that are part of the background for aFrame are
* currently decoded.

View File

@ -2193,6 +2193,12 @@ void nsDisplayBackgroundImage::ComputeInvalidationRegion(nsDisplayListBuilder* a
aInvalidRegion->Or(bounds, geometry->mBounds);
return;
}
if (aBuilder->ShouldSyncDecodeImages()) {
if (mBackgroundStyle &&
!nsCSSRendering::IsBackgroundImageDecodedForStyleContextAndLayer(mBackgroundStyle, mLayer)) {
aInvalidRegion->Or(*aInvalidRegion, bounds);
}
}
if (!bounds.IsEqualInterior(geometry->mBounds)) {
// Positioning area is unchanged, so invalidate just the change in the
// painting area.