Fix nsDisplayCanvasBackgroundColor to invalidate on color changes. (bug 1205970 part 1, r=mattwoodrow)

This commit is contained in:
David Anderson 2015-09-18 18:45:05 -07:00
parent fad84e640d
commit c058902747
2 changed files with 45 additions and 66 deletions

View File

@ -2411,40 +2411,11 @@ protected:
* is not yet a frame tree to go in the frame/iframe so we use the subdoc
* frame of the parent document as a standin.
*/
class nsDisplaySolidColor : public nsDisplayItem {
class nsDisplaySolidColorBase : public nsDisplayItem {
public:
nsDisplaySolidColor(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame,
const nsRect& aBounds, nscolor aColor)
: nsDisplayItem(aBuilder, aFrame), mBounds(aBounds), mColor(aColor)
{
NS_ASSERTION(NS_GET_A(aColor) > 0, "Don't create invisible nsDisplaySolidColors!");
MOZ_COUNT_CTOR(nsDisplaySolidColor);
}
#ifdef NS_BUILD_REFCNT_LOGGING
virtual ~nsDisplaySolidColor() {
MOZ_COUNT_DTOR(nsDisplaySolidColor);
}
#endif
virtual nsRect GetBounds(nsDisplayListBuilder* aBuilder, bool* aSnap) override;
virtual nsRegion GetOpaqueRegion(nsDisplayListBuilder* aBuilder,
bool* aSnap) override {
*aSnap = false;
nsRegion result;
if (NS_GET_A(mColor) == 255) {
result = GetBounds(aBuilder, aSnap);
}
return result;
}
virtual bool IsUniform(nsDisplayListBuilder* aBuilder, nscolor* aColor) override
{
*aColor = mColor;
return true;
}
virtual void Paint(nsDisplayListBuilder* aBuilder, nsRenderingContext* aCtx) override;
nsDisplaySolidColorBase(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame, nscolor aColor)
: nsDisplayItem(aBuilder, aFrame), mColor(aColor)
{}
virtual nsDisplayItemGeometry* AllocateGeometry(nsDisplayListBuilder* aBuilder) override
{
@ -2465,13 +2436,51 @@ public:
ComputeInvalidationRegionDifference(aBuilder, geometry, aInvalidRegion);
}
virtual nsRegion GetOpaqueRegion(nsDisplayListBuilder* aBuilder,
bool* aSnap) override {
*aSnap = false;
nsRegion result;
if (NS_GET_A(mColor) == 255) {
result = GetBounds(aBuilder, aSnap);
}
return result;
}
virtual bool IsUniform(nsDisplayListBuilder* aBuilder, nscolor* aColor) override
{
*aColor = mColor;
return true;
}
protected:
nscolor mColor;
};
class nsDisplaySolidColor : public nsDisplaySolidColorBase {
public:
nsDisplaySolidColor(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame,
const nsRect& aBounds, nscolor aColor)
: nsDisplaySolidColorBase(aBuilder, aFrame, aColor), mBounds(aBounds)
{
NS_ASSERTION(NS_GET_A(aColor) > 0, "Don't create invisible nsDisplaySolidColors!");
MOZ_COUNT_CTOR(nsDisplaySolidColor);
}
#ifdef NS_BUILD_REFCNT_LOGGING
virtual ~nsDisplaySolidColor() {
MOZ_COUNT_DTOR(nsDisplaySolidColor);
}
#endif
virtual nsRect GetBounds(nsDisplayListBuilder* aBuilder, bool* aSnap) override;
virtual void Paint(nsDisplayListBuilder* aBuilder, nsRenderingContext* aCtx) override;
virtual void WriteDebugInfo(std::stringstream& aStream) override;
NS_DISPLAY_DECL_NAME("SolidColor", TYPE_SOLID_COLOR)
private:
nsRect mBounds;
nscolor mColor;
};
/**

View File

@ -195,11 +195,10 @@ protected:
* We can also paint an "extra background color" behind the normal
* background.
*/
class nsDisplayCanvasBackgroundColor : public nsDisplayItem {
class nsDisplayCanvasBackgroundColor : public nsDisplaySolidColorBase {
public:
nsDisplayCanvasBackgroundColor(nsDisplayListBuilder* aBuilder, nsIFrame *aFrame)
: nsDisplayItem(aBuilder, aFrame)
, mColor(NS_RGBA(0,0,0,0))
: nsDisplaySolidColorBase(aBuilder, aFrame, NS_RGBA(0,0,0,0))
{
}
@ -208,19 +207,6 @@ public:
{
return NS_GET_A(mColor) > 0;
}
virtual nsRegion GetOpaqueRegion(nsDisplayListBuilder* aBuilder,
bool* aSnap) override
{
if (NS_GET_A(mColor) == 255) {
return nsRegion(GetBounds(aBuilder, aSnap));
}
return nsRegion();
}
virtual bool IsUniform(nsDisplayListBuilder* aBuilder, nscolor* aColor) override
{
*aColor = mColor;
return true;
}
virtual nsRect GetBounds(nsDisplayListBuilder* aBuilder, bool* aSnap) override
{
nsCanvasFrame* frame = static_cast<nsCanvasFrame*>(mFrame);
@ -234,19 +220,6 @@ public:
aOutFrames->AppendElement(mFrame);
}
virtual nsDisplayItemGeometry* AllocateGeometry(nsDisplayListBuilder* aBuilder) override
{
return new nsDisplayItemBoundsGeometry(this, aBuilder);
}
virtual void ComputeInvalidationRegion(nsDisplayListBuilder* aBuilder,
const nsDisplayItemGeometry* aGeometry,
nsRegion* aInvalidRegion) override
{
const nsDisplayItemBoundsGeometry* geometry = static_cast<const nsDisplayItemBoundsGeometry*>(aGeometry);
ComputeInvalidationRegionDifference(aBuilder, geometry, aInvalidRegion);
}
virtual void Paint(nsDisplayListBuilder* aBuilder,
nsRenderingContext* aCtx) override;
@ -259,9 +232,6 @@ public:
#ifdef MOZ_DUMP_PAINTING
virtual void WriteDebugInfo(std::stringstream& aStream) override;
#endif
private:
nscolor mColor;
};
class nsDisplayCanvasBackgroundImage : public nsDisplayBackgroundImage {