From 99526d4aa570e56da2ec9ba7bdd08ca46027ced1 Mon Sep 17 00:00:00 2001 From: Timothy Nikkel Date: Wed, 26 Jun 2013 11:43:27 -0500 Subject: [PATCH] Bug 695763. Part 5. Invalidate background images if they are not decoded and we are asked to do a sync decode. r=matt.woodrow --- layout/base/nsCSSRendering.cpp | 26 ++++++++++++++++++-------- layout/base/nsCSSRendering.h | 6 ++++++ layout/base/nsDisplayList.cpp | 6 ++++++ 3 files changed, 30 insertions(+), 8 deletions(-) diff --git a/layout/base/nsCSSRendering.cpp b/layout/base/nsCSSRendering.cpp index 5fdd560a573..41c96324ead 100644 --- a/layout/base/nsCSSRendering.cpp +++ b/layout/base/nsCSSRendering.cpp @@ -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 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 img; - if (NS_SUCCEEDED(image->GetImageData()->GetImage(getter_AddRefs(img)))) { - if (!img->IsDecoded()) { - return false; - } - } + if (!IsBackgroundImageDecodedForStyleContextAndLayer(bg, i)) { + return false; } } return true; diff --git a/layout/base/nsCSSRendering.h b/layout/base/nsCSSRendering.h index 9661b75cbe9..fa1ae2231cb 100644 --- a/layout/base/nsCSSRendering.h +++ b/layout/base/nsCSSRendering.h @@ -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. diff --git a/layout/base/nsDisplayList.cpp b/layout/base/nsDisplayList.cpp index 4776ac141ca..7cd3800d207 100644 --- a/layout/base/nsDisplayList.cpp +++ b/layout/base/nsDisplayList.cpp @@ -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.