diff --git a/layout/base/nsCSSRendering.cpp b/layout/base/nsCSSRendering.cpp index 87732c3c8cc4..5be6e1147be5 100644 --- a/layout/base/nsCSSRendering.cpp +++ b/layout/base/nsCSSRendering.cpp @@ -2354,12 +2354,12 @@ nsCSSRendering::PaintBackground(nsIPresContext* aPresContext, // if we are printing, bail for now - nsCOMPtr thePrinterContext = do_QueryInterface(aPresContext); - if (thePrinterContext) { + PRBool canDrawBackground; + aPresContext->GetBackgroundDraw(canDrawBackground); + if(!canDrawBackground){ return; } - // if there is no background image, try a color. if (aColor.mBackgroundImage.IsEmpty()) { // See if there's a background color specified. The background color diff --git a/layout/base/nsPresContext.cpp b/layout/base/nsPresContext.cpp index 0c64f89dee1a..dbb435cf4bd5 100644 --- a/layout/base/nsPresContext.cpp +++ b/layout/base/nsPresContext.cpp @@ -152,6 +152,8 @@ nsPresContext::nsPresContext() mImageAnimationMode = imgIContainer::kNormalAnimMode; mImageAnimationModePref = imgIContainer::kNormalAnimMode; + SetBackgroundDraw(PR_TRUE); // always draw the background + mStopped = PR_FALSE; mStopChrome = PR_TRUE; diff --git a/layout/base/nsPresContext.h b/layout/base/nsPresContext.h index 9f82f2c78afb..8554d97e08e7 100644 --- a/layout/base/nsPresContext.h +++ b/layout/base/nsPresContext.h @@ -508,6 +508,13 @@ public: * Get the document charset */ NS_IMETHOD GetBidiCharset(nsAWritableString &aCharSet) = 0; + + /** + * Set and get methods for controling the background drawing + */ + NS_IMETHOD GetBackgroundDraw(PRBool &aCanDraw)=0; + NS_IMETHOD SetBackgroundDraw(PRBool aCanDraw)=0; + #endif // IBMBIDI /** diff --git a/layout/base/public/nsIPresContext.h b/layout/base/public/nsIPresContext.h index 9f82f2c78afb..8554d97e08e7 100644 --- a/layout/base/public/nsIPresContext.h +++ b/layout/base/public/nsIPresContext.h @@ -508,6 +508,13 @@ public: * Get the document charset */ NS_IMETHOD GetBidiCharset(nsAWritableString &aCharSet) = 0; + + /** + * Set and get methods for controling the background drawing + */ + NS_IMETHOD GetBackgroundDraw(PRBool &aCanDraw)=0; + NS_IMETHOD SetBackgroundDraw(PRBool aCanDraw)=0; + #endif // IBMBIDI /** diff --git a/layout/base/public/nsPresContext.h b/layout/base/public/nsPresContext.h index 9f82f2c78afb..8554d97e08e7 100644 --- a/layout/base/public/nsPresContext.h +++ b/layout/base/public/nsPresContext.h @@ -508,6 +508,13 @@ public: * Get the document charset */ NS_IMETHOD GetBidiCharset(nsAWritableString &aCharSet) = 0; + + /** + * Set and get methods for controling the background drawing + */ + NS_IMETHOD GetBackgroundDraw(PRBool &aCanDraw)=0; + NS_IMETHOD SetBackgroundDraw(PRBool aCanDraw)=0; + #endif // IBMBIDI /** diff --git a/layout/base/src/nsPresContext.cpp b/layout/base/src/nsPresContext.cpp index 0c64f89dee1a..dbb435cf4bd5 100644 --- a/layout/base/src/nsPresContext.cpp +++ b/layout/base/src/nsPresContext.cpp @@ -152,6 +152,8 @@ nsPresContext::nsPresContext() mImageAnimationMode = imgIContainer::kNormalAnimMode; mImageAnimationModePref = imgIContainer::kNormalAnimMode; + SetBackgroundDraw(PR_TRUE); // always draw the background + mStopped = PR_FALSE; mStopChrome = PR_TRUE; diff --git a/layout/base/src/nsPresContext.h b/layout/base/src/nsPresContext.h index 305d2a1c3f16..2f9c72bdae23 100644 --- a/layout/base/src/nsPresContext.h +++ b/layout/base/src/nsPresContext.h @@ -167,6 +167,9 @@ public: NS_IMETHOD SetIsRenderingOnlySelection(PRBool aVal) { mIsRenderingOnlySelection = aVal; return NS_OK; } NS_IMETHOD IsRenderingOnlySelection(PRBool* aResult); + NS_IMETHOD GetBackgroundDraw(PRBool &aCanDraw) { aCanDraw = mDrawBackground; return NS_OK; } + NS_IMETHOD SetBackgroundDraw(PRBool aCanDraw) { mDrawBackground = aCanDraw; return NS_OK; } + #ifdef MOZ_REFLOW_PERF NS_IMETHOD CountReflows(const char * aName, PRUint32 aType, nsIFrame * aFrame); NS_IMETHOD PaintCount(const char * aName, nsIRenderingContext* aRenderingContext, nsIFrame * aFrame, PRUint32 aColor); @@ -244,6 +247,7 @@ protected: nscoord mDefaultBackgroundImageOffsetX; nscoord mDefaultBackgroundImageOffsetY; PRUint8 mDefaultBackgroundImageAttachment; + PRBool mDrawBackground; nsSupportsHashtable mImageLoaders; diff --git a/layout/base/src/nsPrintContext.cpp b/layout/base/src/nsPrintContext.cpp index e59e9e2a42eb..880fb721687e 100644 --- a/layout/base/src/nsPrintContext.cpp +++ b/layout/base/src/nsPrintContext.cpp @@ -71,6 +71,7 @@ protected: PrintContext::PrintContext() : mPageDim(0,0,0,0) { + SetBackgroundDraw(PR_FALSE); } PrintContext::~PrintContext() diff --git a/layout/base/src/nsPrintPreviewContext.cpp b/layout/base/src/nsPrintPreviewContext.cpp index 14cdc48661bf..1ab88a80d5c0 100644 --- a/layout/base/src/nsPrintPreviewContext.cpp +++ b/layout/base/src/nsPrintPreviewContext.cpp @@ -76,6 +76,7 @@ PrintPreviewContext::PrintPreviewContext() : mPageDim(-1,-1,-1,-1), mCanPaginatedScroll(PR_TRUE) { + SetBackgroundDraw(PR_FALSE); } PrintPreviewContext::~PrintPreviewContext() diff --git a/layout/html/style/src/nsCSSRendering.cpp b/layout/html/style/src/nsCSSRendering.cpp index 87732c3c8cc4..5be6e1147be5 100644 --- a/layout/html/style/src/nsCSSRendering.cpp +++ b/layout/html/style/src/nsCSSRendering.cpp @@ -2354,12 +2354,12 @@ nsCSSRendering::PaintBackground(nsIPresContext* aPresContext, // if we are printing, bail for now - nsCOMPtr thePrinterContext = do_QueryInterface(aPresContext); - if (thePrinterContext) { + PRBool canDrawBackground; + aPresContext->GetBackgroundDraw(canDrawBackground); + if(!canDrawBackground){ return; } - // if there is no background image, try a color. if (aColor.mBackgroundImage.IsEmpty()) { // See if there's a background color specified. The background color