b=96870 r=rods sr=attinasi Fixed printing so backgrounds can be turned on and off.

This commit is contained in:
dcone@netscape.com
2002-02-15 14:48:12 +00:00
parent 75711addd0
commit 9938bc4eee
32 changed files with 254 additions and 109 deletions

View File

@@ -3160,6 +3160,15 @@ DocumentViewerImpl::ReflowPrintObject(PrintObject * aPO)
printcon->SetPrintSettings(mPrt->mPrintSettings);
}
// set the presentation context to the value in the print settings
PRBool printBGColors;
mPrt->mPrintSettings->GetPrintBGColors(&printBGColors);
aPO->mPresContext->SetBackgroundColorDraw(printBGColors);
mPrt->mPrintSettings->GetPrintBGImages(&printBGColors);
aPO->mPresContext->SetBackgroundImageDraw(printBGColors);
// init it with the DC
(aPO->mPresContext)->Init(mPrt->mPrintDocDC);

View File

@@ -2425,6 +2425,30 @@ FindCanvasBackground(nsIPresContext* aPresContext,
if (firstChild) {
const nsStyleBackground *result;
GetStyleData(firstChild, &result);
// for printing and print preview.. this should be a pageContentFrame
nsCOMPtr<nsIAtom> frameType;
nsCOMPtr<nsIStyleContext> parentContext;
firstChild->GetFrameType(getter_AddRefs(frameType));
if ( (frameType == nsLayoutAtoms::pageContentFrame) ){
// we have to find the background style ourselves.. since the
// pageContentframe does not have content
while(firstChild){
for (nsIFrame* kidFrame = firstChild; nsnull != kidFrame; ) {
kidFrame->GetStyleContext(getter_AddRefs(parentContext));
result = (nsStyleBackground*)parentContext->GetStyleData(eStyleStruct_Background);
if (!result->BackgroundIsTransparent()){
GetStyleData(kidFrame, aBackground);
return PR_TRUE;
} else {
kidFrame->GetNextSibling(&kidFrame);
}
}
firstChild->FirstChild(aPresContext, nsnull, &firstChild);
}
return PR_FALSE; // nothing found for this
}
// Check if we need to do propagation from BODY rather than HTML.
if (result->BackgroundIsTransparent()) {
@@ -2514,18 +2538,19 @@ nsCSSRendering::PaintBackground(nsIPresContext* aPresContext,
const nsRect& aBorderArea,
const nsStyleBorder& aBorder,
nscoord aDX,
nscoord aDY)
nscoord aDY,PRBool aUsePrintSettings)
{
NS_PRECONDITION(aForFrame,
"Frame is expected to be provided to PaintBackground");
PRBool isCanvas;
const nsStyleBackground *color;
if (!FindBackground(aPresContext, aForFrame, &color, &isCanvas))
return;
if (!isCanvas) {
PaintBackgroundWithSC(aPresContext, aRenderingContext, aForFrame,
aDirtyRect, aBorderArea, *color, aBorder, aDX, aDY);
aDirtyRect, aBorderArea, *color, aBorder, aDX, aDY, aUsePrintSettings);
return;
}
@@ -2556,7 +2581,7 @@ nsCSSRendering::PaintBackground(nsIPresContext* aPresContext,
PaintBackgroundWithSC(aPresContext, aRenderingContext, aForFrame,
aDirtyRect, aBorderArea, canvasColor,
aBorder, aDX, aDY);
aBorder, aDX, aDY, aUsePrintSettings);
}
void
@@ -2568,7 +2593,8 @@ nsCSSRendering::PaintBackgroundWithSC(nsIPresContext* aPresContext,
const nsStyleBackground& aColor,
const nsStyleBorder& aBorder,
nscoord aDX,
nscoord aDY)
nscoord aDY,
PRBool aUsePrintSettings)
{
NS_PRECONDITION(aForFrame,
"Frame is expected to be provided to PaintBackground");
@@ -2576,22 +2602,22 @@ nsCSSRendering::PaintBackgroundWithSC(nsIPresContext* aPresContext,
PRBool transparentBG =
NS_STYLE_BG_COLOR_TRANSPARENT ==
(aColor.mBackgroundFlags & NS_STYLE_BG_COLOR_TRANSPARENT);
PRBool canDrawBackgroundImage=PR_TRUE,canDrawBackgroundColor=PR_TRUE;
float percent;
nsStyleCoord bordStyleRadius[4];
PRInt16 borderRadii[4],i;
// if we are printing, bail for now
PRBool canDrawBackground;
aPresContext->GetBackgroundDraw(canDrawBackground);
nsCOMPtr<nsIPrintContext> thePrinterContext = do_QueryInterface(aPresContext);
if(aUsePrintSettings){
aPresContext->GetBackgroundImageDraw(canDrawBackgroundImage);
aPresContext->GetBackgroundColorDraw(canDrawBackgroundColor);
// only turn off background printing if we are currently printing.
if(!canDrawBackground && thePrinterContext){
return;
// only turn off background printing if we are currently printing.
if(!canDrawBackgroundImage && !canDrawBackgroundColor){
return;
}
}
// Check to see if we have an appearance defined. If so, we let the theme
// renderer draw the background.
const nsStyleDisplay* displayData;
@@ -2606,8 +2632,8 @@ nsCSSRendering::PaintBackgroundWithSC(nsIPresContext* aPresContext,
}
}
// if there is no background image, try a color.
if (aColor.mBackgroundImage.IsEmpty()) {
// if there is no background image or background images are turned off, try a color.
if (aColor.mBackgroundImage.IsEmpty() || (canDrawBackgroundColor && !canDrawBackgroundImage)) {
// See if there's a background color specified. The background color
// is rendered over the 'border' 'padding' and 'content' areas
if (!transparentBG) {

View File

@@ -130,7 +130,8 @@ public:
const nsRect& aBorderArea,
const nsStyleBorder& aBorder,
nscoord aDX,
nscoord aDY);
nscoord aDY,
PRBool aUsePrintSettings=PR_FALSE);
/**
* Same as |PaintBackground|, except using the provided style context
@@ -145,7 +146,8 @@ public:
const nsStyleBackground& aColor,
const nsStyleBorder& aBorder,
nscoord aDX,
nscoord aDY);
nscoord aDY,
PRBool aUsePrintSettings=PR_FALSE);
static void DrawDashedSides(PRIntn startSide,
nsIRenderingContext& aContext,

View File

@@ -3160,6 +3160,15 @@ DocumentViewerImpl::ReflowPrintObject(PrintObject * aPO)
printcon->SetPrintSettings(mPrt->mPrintSettings);
}
// set the presentation context to the value in the print settings
PRBool printBGColors;
mPrt->mPrintSettings->GetPrintBGColors(&printBGColors);
aPO->mPresContext->SetBackgroundColorDraw(printBGColors);
mPrt->mPrintSettings->GetPrintBGImages(&printBGColors);
aPO->mPresContext->SetBackgroundImageDraw(printBGColors);
// init it with the DC
(aPO->mPresContext)->Init(mPrt->mPrintDocDC);

View File

@@ -157,7 +157,8 @@ nsPresContext::nsPresContext()
mImageAnimationMode = imgIContainer::kNormalAnimMode;
mImageAnimationModePref = imgIContainer::kNormalAnimMode;
SetBackgroundDraw(PR_TRUE); // always draw the background
SetBackgroundImageDraw(PR_TRUE); // always draw the background
SetBackgroundColorDraw(PR_TRUE);
mStopped = PR_FALSE;
mStopChrome = PR_TRUE;

View File

@@ -426,8 +426,10 @@ public:
/**
* Set and get methods for controling the background drawing
*/
NS_IMETHOD GetBackgroundDraw(PRBool &aCanDraw)=0;
NS_IMETHOD SetBackgroundDraw(PRBool aCanDraw)=0;
NS_IMETHOD GetBackgroundImageDraw(PRBool &aCanDraw)=0;
NS_IMETHOD SetBackgroundImageDraw(PRBool aCanDraw)=0;
NS_IMETHOD GetBackgroundColorDraw(PRBool &aCanDraw)=0;
NS_IMETHOD SetBackgroundColorDraw(PRBool aCanDraw)=0;
#ifdef IBMBIDI
/**

View File

@@ -426,8 +426,10 @@ public:
/**
* Set and get methods for controling the background drawing
*/
NS_IMETHOD GetBackgroundDraw(PRBool &aCanDraw)=0;
NS_IMETHOD SetBackgroundDraw(PRBool aCanDraw)=0;
NS_IMETHOD GetBackgroundImageDraw(PRBool &aCanDraw)=0;
NS_IMETHOD SetBackgroundImageDraw(PRBool aCanDraw)=0;
NS_IMETHOD GetBackgroundColorDraw(PRBool &aCanDraw)=0;
NS_IMETHOD SetBackgroundColorDraw(PRBool aCanDraw)=0;
#ifdef IBMBIDI
/**

View File

@@ -426,8 +426,10 @@ public:
/**
* Set and get methods for controling the background drawing
*/
NS_IMETHOD GetBackgroundDraw(PRBool &aCanDraw)=0;
NS_IMETHOD SetBackgroundDraw(PRBool aCanDraw)=0;
NS_IMETHOD GetBackgroundImageDraw(PRBool &aCanDraw)=0;
NS_IMETHOD SetBackgroundImageDraw(PRBool aCanDraw)=0;
NS_IMETHOD GetBackgroundColorDraw(PRBool &aCanDraw)=0;
NS_IMETHOD SetBackgroundColorDraw(PRBool aCanDraw)=0;
#ifdef IBMBIDI
/**

View File

@@ -157,7 +157,8 @@ nsPresContext::nsPresContext()
mImageAnimationMode = imgIContainer::kNormalAnimMode;
mImageAnimationModePref = imgIContainer::kNormalAnimMode;
SetBackgroundDraw(PR_TRUE); // always draw the background
SetBackgroundImageDraw(PR_TRUE); // always draw the background
SetBackgroundColorDraw(PR_TRUE);
mStopped = PR_FALSE;
mStopChrome = PR_TRUE;

View File

@@ -168,8 +168,10 @@ 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; }
NS_IMETHOD GetBackgroundImageDraw(PRBool &aCanDraw) { aCanDraw = mDrawImageBackground; return NS_OK; }
NS_IMETHOD SetBackgroundImageDraw(PRBool aCanDraw) { mDrawImageBackground = aCanDraw; return NS_OK; }
NS_IMETHOD GetBackgroundColorDraw(PRBool &aCanDraw) { aCanDraw = mDrawColorBackground; return NS_OK; }
NS_IMETHOD SetBackgroundColorDraw(PRBool aCanDraw) { mDrawColorBackground = aCanDraw; return NS_OK; }
#ifdef MOZ_REFLOW_PERF
NS_IMETHOD CountReflows(const char * aName, PRUint32 aType, nsIFrame * aFrame);
@@ -250,7 +252,8 @@ protected:
PRUint8 mFocusRingWidth; // set in GetUserPrefs
PRPackedBool mFocusRingOnAnything; // set in GetUserPrefs
PRPackedBool mDrawBackground;
PRPackedBool mDrawImageBackground;
PRPackedBool mDrawColorBackground;
PRUint8 mDefaultBackgroundImageAttachment;
PRUint8 mDefaultBackgroundImageRepeat;

View File

@@ -76,7 +76,8 @@ protected:
PrintContext::PrintContext() :
mPageDim(0,0,0,0)
{
SetBackgroundDraw(PR_FALSE);
SetBackgroundImageDraw(PR_FALSE);
SetBackgroundColorDraw(PR_FALSE);
}
PrintContext::~PrintContext()

View File

@@ -74,7 +74,8 @@ PrintPreviewContext::PrintPreviewContext() :
mPageDim(-1,-1,-1,-1),
mCanPaginatedScroll(PR_TRUE)
{
SetBackgroundDraw(PR_FALSE);
SetBackgroundImageDraw(PR_FALSE);
SetBackgroundColorDraw(PR_FALSE);
}
PrintPreviewContext::~PrintPreviewContext()

View File

@@ -602,19 +602,9 @@ nsGfxScrollFrame::Paint(nsIPresContext* aPresContext,
{
nsresult result;
// there are some mechanisms to turn off background painting for print and print preview, these
// need to be turned on for the time being.. just for this paint.. then reset to the
// original values before this routine returns.
PRBool canDraw;
aPresContext->GetBackgroundDraw(canDraw);
aPresContext->SetBackgroundDraw(PR_TRUE);
// Paint our children
result = nsBoxFrame::Paint(aPresContext, aRenderingContext, aDirtyRect,
aWhichLayer);
aPresContext->SetBackgroundDraw(canDraw);
result = nsBoxFrame::Paint(aPresContext, aRenderingContext, aDirtyRect,aWhichLayer);
return result;
}

View File

@@ -750,7 +750,7 @@ nsPageFrame::DrawBackground(nsIPresContext* aPresContext,
mStyleContext->GetStyleData(eStyleStruct_Border));
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *border, 0, 0);
aDirtyRect, rect, *border, 0, 0, PR_TRUE);
}
}

View File

@@ -128,6 +128,29 @@ static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
//----------------------------------------
// checks to see if the text can be lightened..
// text is darkend
inline PRBool CanDarken(nsIPresContext* aPresContext)
{
PRBool darken,haveBackground;
aPresContext->GetBackgroundColorDraw(haveBackground);
if(PR_TRUE == haveBackground){
darken = PR_FALSE;
} else {
aPresContext->GetBackgroundImageDraw(haveBackground);
if(PR_TRUE == haveBackground){
darken = PR_FALSE;
} else {
darken = PR_TRUE;
}
}
return darken;
}
struct nsAutoIndexBuffer {
nsAutoIndexBuffer();
~nsAutoIndexBuffer();
@@ -2184,7 +2207,7 @@ nsTextFrame::PaintUnicodeText(nsIPresContext* aPresContext,
{
nsCOMPtr<nsISelectionController> selCon;
nsCOMPtr<nsIPresShell> shell;
PRBool displaySelection;
PRBool displaySelection,canDarkenColor;
PRBool isPaginated;
PRBool isSelected;
PRInt16 selectionValue;
@@ -2192,6 +2215,8 @@ nsTextFrame::PaintUnicodeText(nsIPresContext* aPresContext,
#ifdef IBMBIDI
PRUint8 level = 0;
#endif
if (NS_FAILED(GetTextInfoForPainting(aPresContext,
aRenderingContext,
getter_AddRefs(shell),
@@ -2203,6 +2228,11 @@ nsTextFrame::PaintUnicodeText(nsIPresContext* aPresContext,
getter_AddRefs(lb)))) {
return;
}
if(isPaginated){
canDarkenColor = CanDarken(aPresContext);
}
// Make enough space to transform
nsAutoTextBuffer paintBuffer;
nsAutoIndexBuffer indexBuffer;
@@ -2269,7 +2299,8 @@ nsTextFrame::PaintUnicodeText(nsIPresContext* aPresContext,
{
// When there is no selection showing, use the fastest and
// simplest rendering approach
aRenderingContext.SetColor(nsCSSRendering::TransformColor(aTextStyle.mColor->mColor,isPaginated));
aRenderingContext.SetColor(nsCSSRendering::TransformColor(aTextStyle.mColor->mColor,canDarkenColor));
aRenderingContext.DrawString(text, PRUint32(textLength), dx, dy + mAscent);
PaintTextDecorations(aRenderingContext, aStyleContext, aTextStyle,
dx, dy, width);
@@ -2380,10 +2411,10 @@ nsTextFrame::PaintUnicodeText(nsIPresContext* aPresContext,
newWidth =0;
if (isPaginated && !iter.IsBeforeOrAfter()) {
aRenderingContext.SetColor(nsCSSRendering::TransformColor(aTextStyle.mColor->mColor,isPaginated));
aRenderingContext.SetColor(nsCSSRendering::TransformColor(aTextStyle.mColor->mColor,canDarkenColor));
aRenderingContext.DrawString(currenttext, currentlength, currentX, dy + mAscent);
} else if (!isPaginated) {
aRenderingContext.SetColor(nsCSSRendering::TransformColor(currentFGColor,isPaginated));
aRenderingContext.SetColor(nsCSSRendering::TransformColor(currentFGColor,canDarkenColor));
aRenderingContext.DrawString(currenttext, currentlength, currentX, dy + mAscent);
}
@@ -2397,7 +2428,7 @@ nsTextFrame::PaintUnicodeText(nsIPresContext* aPresContext,
}
else if (!isPaginated)
{
aRenderingContext.SetColor(nsCSSRendering::TransformColor(aTextStyle.mColor->mColor,isPaginated));
aRenderingContext.SetColor(nsCSSRendering::TransformColor(aTextStyle.mColor->mColor,canDarkenColor));
aRenderingContext.DrawString(text, PRUint32(textLength), dx, dy + mAscent);
}
PaintTextDecorations(aRenderingContext, aStyleContext,
@@ -2860,7 +2891,7 @@ nsTextFrame::PaintTextSlowly(nsIPresContext* aPresContext,
nsCOMPtr<nsISelectionController> selCon;
nsCOMPtr<nsIPresShell> shell;
PRBool displaySelection;
PRBool isPaginated;
PRBool isPaginated,canDarkenColor;
PRBool isSelected;
PRInt16 selectionValue;
nsCOMPtr<nsILineBreaker> lb;
@@ -2877,6 +2908,10 @@ nsTextFrame::PaintTextSlowly(nsIPresContext* aPresContext,
}
if(isPaginated){
canDarkenColor = CanDarken(aPresContext);
}
// Make enough space to transform
nsAutoTextBuffer paintBuffer;
nsAutoIndexBuffer indexBuffer;
@@ -2923,7 +2958,7 @@ nsTextFrame::PaintTextSlowly(nsIPresContext* aPresContext,
if (!displaySelection || !isSelected) {
// When there is no selection showing, use the fastest and
// simplest rendering approach
aRenderingContext.SetColor(nsCSSRendering::TransformColor(aTextStyle.mColor->mColor,isPaginated));
aRenderingContext.SetColor(nsCSSRendering::TransformColor(aTextStyle.mColor->mColor,canDarkenColor));
RenderString(aRenderingContext, aStyleContext, aTextStyle,
text, textLength, dx, dy, width);
}
@@ -2985,11 +3020,11 @@ nsTextFrame::PaintTextSlowly(nsIPresContext* aPresContext,
}
if (isPaginated && !iter.IsBeforeOrAfter()) {
aRenderingContext.SetColor(nsCSSRendering::TransformColor(aTextStyle.mColor->mColor,isPaginated));
aRenderingContext.SetColor(nsCSSRendering::TransformColor(aTextStyle.mColor->mColor,canDarkenColor));
RenderString(aRenderingContext,aStyleContext, aTextStyle, currenttext,
currentlength, currentX, dy, width, details);
} else if (!isPaginated) {
aRenderingContext.SetColor(nsCSSRendering::TransformColor(currentFGColor,isPaginated));
aRenderingContext.SetColor(nsCSSRendering::TransformColor(currentFGColor,canDarkenColor));
RenderString(aRenderingContext,aStyleContext, aTextStyle, currenttext,
currentlength, currentX, dy, width, details);
}
@@ -3002,7 +3037,7 @@ nsTextFrame::PaintTextSlowly(nsIPresContext* aPresContext,
}
else if (!isPaginated)
{
aRenderingContext.SetColor(nsCSSRendering::TransformColor(aTextStyle.mColor->mColor,isPaginated));
aRenderingContext.SetColor(nsCSSRendering::TransformColor(aTextStyle.mColor->mColor,canDarkenColor));
RenderString(aRenderingContext,aStyleContext, aTextStyle, text,
PRUint32(textLength), dx, dy, width, details);
}
@@ -3032,7 +3067,7 @@ nsTextFrame::PaintAsciiText(nsIPresContext* aPresContext,
nsCOMPtr<nsISelectionController> selCon;
nsCOMPtr<nsIPresShell> shell;
PRBool displaySelection;
PRBool displaySelection,canDarkenColor;
PRBool isPaginated;
PRBool isSelected;
PRInt16 selectionValue;
@@ -3049,6 +3084,10 @@ nsTextFrame::PaintAsciiText(nsIPresContext* aPresContext,
return;
}
if(isPaginated){
canDarkenColor = CanDarken(aPresContext);
}
// Get the text fragment
nsCOMPtr<nsITextContent> tc = do_QueryInterface(mContent);
const nsTextFragment* frag = nsnull;
@@ -3140,7 +3179,7 @@ nsTextFrame::PaintAsciiText(nsIPresContext* aPresContext,
//if selection is > content length then selection has "slid off"
// When there is no selection showing, use the fastest and
// simplest rendering approach
aRenderingContext.SetColor(nsCSSRendering::TransformColor(aTextStyle.mColor->mColor,isPaginated));
aRenderingContext.SetColor(nsCSSRendering::TransformColor(aTextStyle.mColor->mColor,canDarkenColor));
aRenderingContext.DrawString(text, PRUint32(textLength), dx, dy + mAscent);
PaintTextDecorations(aRenderingContext, aStyleContext, aTextStyle,
dx, dy, width);
@@ -3198,7 +3237,7 @@ nsTextFrame::PaintAsciiText(nsIPresContext* aPresContext,
newWidth =0;
if (isPaginated && !iter.IsBeforeOrAfter()) {
aRenderingContext.SetColor(nsCSSRendering::TransformColor(aTextStyle.mColor->mColor,isPaginated));
aRenderingContext.SetColor(nsCSSRendering::TransformColor(aTextStyle.mColor->mColor,canDarkenColor));
aRenderingContext.DrawString(currenttext, currentlength, currentX, dy + mAscent);
} else if (!isPaginated) {
aRenderingContext.SetColor(nsCSSRendering::TransformColor(currentFGColor,isPaginated));
@@ -3212,7 +3251,7 @@ nsTextFrame::PaintAsciiText(nsIPresContext* aPresContext,
}
else if (!isPaginated)
{
aRenderingContext.SetColor(nsCSSRendering::TransformColor(aTextStyle.mColor->mColor,isPaginated));
aRenderingContext.SetColor(nsCSSRendering::TransformColor(aTextStyle.mColor->mColor,canDarkenColor));
aRenderingContext.DrawString(text, PRUint32(textLength), dx, dy + mAscent);
}
PaintTextDecorations(aRenderingContext, aStyleContext,

View File

@@ -602,19 +602,9 @@ nsGfxScrollFrame::Paint(nsIPresContext* aPresContext,
{
nsresult result;
// there are some mechanisms to turn off background painting for print and print preview, these
// need to be turned on for the time being.. just for this paint.. then reset to the
// original values before this routine returns.
PRBool canDraw;
aPresContext->GetBackgroundDraw(canDraw);
aPresContext->SetBackgroundDraw(PR_TRUE);
// Paint our children
result = nsBoxFrame::Paint(aPresContext, aRenderingContext, aDirtyRect,
aWhichLayer);
aPresContext->SetBackgroundDraw(canDraw);
result = nsBoxFrame::Paint(aPresContext, aRenderingContext, aDirtyRect,aWhichLayer);
return result;
}

View File

@@ -750,7 +750,7 @@ nsPageFrame::DrawBackground(nsIPresContext* aPresContext,
mStyleContext->GetStyleData(eStyleStruct_Border));
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *border, 0, 0);
aDirtyRect, rect, *border, 0, 0, PR_TRUE);
}
}

View File

@@ -128,6 +128,29 @@ static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
//----------------------------------------
// checks to see if the text can be lightened..
// text is darkend
inline PRBool CanDarken(nsIPresContext* aPresContext)
{
PRBool darken,haveBackground;
aPresContext->GetBackgroundColorDraw(haveBackground);
if(PR_TRUE == haveBackground){
darken = PR_FALSE;
} else {
aPresContext->GetBackgroundImageDraw(haveBackground);
if(PR_TRUE == haveBackground){
darken = PR_FALSE;
} else {
darken = PR_TRUE;
}
}
return darken;
}
struct nsAutoIndexBuffer {
nsAutoIndexBuffer();
~nsAutoIndexBuffer();
@@ -2184,7 +2207,7 @@ nsTextFrame::PaintUnicodeText(nsIPresContext* aPresContext,
{
nsCOMPtr<nsISelectionController> selCon;
nsCOMPtr<nsIPresShell> shell;
PRBool displaySelection;
PRBool displaySelection,canDarkenColor;
PRBool isPaginated;
PRBool isSelected;
PRInt16 selectionValue;
@@ -2192,6 +2215,8 @@ nsTextFrame::PaintUnicodeText(nsIPresContext* aPresContext,
#ifdef IBMBIDI
PRUint8 level = 0;
#endif
if (NS_FAILED(GetTextInfoForPainting(aPresContext,
aRenderingContext,
getter_AddRefs(shell),
@@ -2203,6 +2228,11 @@ nsTextFrame::PaintUnicodeText(nsIPresContext* aPresContext,
getter_AddRefs(lb)))) {
return;
}
if(isPaginated){
canDarkenColor = CanDarken(aPresContext);
}
// Make enough space to transform
nsAutoTextBuffer paintBuffer;
nsAutoIndexBuffer indexBuffer;
@@ -2269,7 +2299,8 @@ nsTextFrame::PaintUnicodeText(nsIPresContext* aPresContext,
{
// When there is no selection showing, use the fastest and
// simplest rendering approach
aRenderingContext.SetColor(nsCSSRendering::TransformColor(aTextStyle.mColor->mColor,isPaginated));
aRenderingContext.SetColor(nsCSSRendering::TransformColor(aTextStyle.mColor->mColor,canDarkenColor));
aRenderingContext.DrawString(text, PRUint32(textLength), dx, dy + mAscent);
PaintTextDecorations(aRenderingContext, aStyleContext, aTextStyle,
dx, dy, width);
@@ -2380,10 +2411,10 @@ nsTextFrame::PaintUnicodeText(nsIPresContext* aPresContext,
newWidth =0;
if (isPaginated && !iter.IsBeforeOrAfter()) {
aRenderingContext.SetColor(nsCSSRendering::TransformColor(aTextStyle.mColor->mColor,isPaginated));
aRenderingContext.SetColor(nsCSSRendering::TransformColor(aTextStyle.mColor->mColor,canDarkenColor));
aRenderingContext.DrawString(currenttext, currentlength, currentX, dy + mAscent);
} else if (!isPaginated) {
aRenderingContext.SetColor(nsCSSRendering::TransformColor(currentFGColor,isPaginated));
aRenderingContext.SetColor(nsCSSRendering::TransformColor(currentFGColor,canDarkenColor));
aRenderingContext.DrawString(currenttext, currentlength, currentX, dy + mAscent);
}
@@ -2397,7 +2428,7 @@ nsTextFrame::PaintUnicodeText(nsIPresContext* aPresContext,
}
else if (!isPaginated)
{
aRenderingContext.SetColor(nsCSSRendering::TransformColor(aTextStyle.mColor->mColor,isPaginated));
aRenderingContext.SetColor(nsCSSRendering::TransformColor(aTextStyle.mColor->mColor,canDarkenColor));
aRenderingContext.DrawString(text, PRUint32(textLength), dx, dy + mAscent);
}
PaintTextDecorations(aRenderingContext, aStyleContext,
@@ -2860,7 +2891,7 @@ nsTextFrame::PaintTextSlowly(nsIPresContext* aPresContext,
nsCOMPtr<nsISelectionController> selCon;
nsCOMPtr<nsIPresShell> shell;
PRBool displaySelection;
PRBool isPaginated;
PRBool isPaginated,canDarkenColor;
PRBool isSelected;
PRInt16 selectionValue;
nsCOMPtr<nsILineBreaker> lb;
@@ -2877,6 +2908,10 @@ nsTextFrame::PaintTextSlowly(nsIPresContext* aPresContext,
}
if(isPaginated){
canDarkenColor = CanDarken(aPresContext);
}
// Make enough space to transform
nsAutoTextBuffer paintBuffer;
nsAutoIndexBuffer indexBuffer;
@@ -2923,7 +2958,7 @@ nsTextFrame::PaintTextSlowly(nsIPresContext* aPresContext,
if (!displaySelection || !isSelected) {
// When there is no selection showing, use the fastest and
// simplest rendering approach
aRenderingContext.SetColor(nsCSSRendering::TransformColor(aTextStyle.mColor->mColor,isPaginated));
aRenderingContext.SetColor(nsCSSRendering::TransformColor(aTextStyle.mColor->mColor,canDarkenColor));
RenderString(aRenderingContext, aStyleContext, aTextStyle,
text, textLength, dx, dy, width);
}
@@ -2985,11 +3020,11 @@ nsTextFrame::PaintTextSlowly(nsIPresContext* aPresContext,
}
if (isPaginated && !iter.IsBeforeOrAfter()) {
aRenderingContext.SetColor(nsCSSRendering::TransformColor(aTextStyle.mColor->mColor,isPaginated));
aRenderingContext.SetColor(nsCSSRendering::TransformColor(aTextStyle.mColor->mColor,canDarkenColor));
RenderString(aRenderingContext,aStyleContext, aTextStyle, currenttext,
currentlength, currentX, dy, width, details);
} else if (!isPaginated) {
aRenderingContext.SetColor(nsCSSRendering::TransformColor(currentFGColor,isPaginated));
aRenderingContext.SetColor(nsCSSRendering::TransformColor(currentFGColor,canDarkenColor));
RenderString(aRenderingContext,aStyleContext, aTextStyle, currenttext,
currentlength, currentX, dy, width, details);
}
@@ -3002,7 +3037,7 @@ nsTextFrame::PaintTextSlowly(nsIPresContext* aPresContext,
}
else if (!isPaginated)
{
aRenderingContext.SetColor(nsCSSRendering::TransformColor(aTextStyle.mColor->mColor,isPaginated));
aRenderingContext.SetColor(nsCSSRendering::TransformColor(aTextStyle.mColor->mColor,canDarkenColor));
RenderString(aRenderingContext,aStyleContext, aTextStyle, text,
PRUint32(textLength), dx, dy, width, details);
}
@@ -3032,7 +3067,7 @@ nsTextFrame::PaintAsciiText(nsIPresContext* aPresContext,
nsCOMPtr<nsISelectionController> selCon;
nsCOMPtr<nsIPresShell> shell;
PRBool displaySelection;
PRBool displaySelection,canDarkenColor;
PRBool isPaginated;
PRBool isSelected;
PRInt16 selectionValue;
@@ -3049,6 +3084,10 @@ nsTextFrame::PaintAsciiText(nsIPresContext* aPresContext,
return;
}
if(isPaginated){
canDarkenColor = CanDarken(aPresContext);
}
// Get the text fragment
nsCOMPtr<nsITextContent> tc = do_QueryInterface(mContent);
const nsTextFragment* frag = nsnull;
@@ -3140,7 +3179,7 @@ nsTextFrame::PaintAsciiText(nsIPresContext* aPresContext,
//if selection is > content length then selection has "slid off"
// When there is no selection showing, use the fastest and
// simplest rendering approach
aRenderingContext.SetColor(nsCSSRendering::TransformColor(aTextStyle.mColor->mColor,isPaginated));
aRenderingContext.SetColor(nsCSSRendering::TransformColor(aTextStyle.mColor->mColor,canDarkenColor));
aRenderingContext.DrawString(text, PRUint32(textLength), dx, dy + mAscent);
PaintTextDecorations(aRenderingContext, aStyleContext, aTextStyle,
dx, dy, width);
@@ -3198,7 +3237,7 @@ nsTextFrame::PaintAsciiText(nsIPresContext* aPresContext,
newWidth =0;
if (isPaginated && !iter.IsBeforeOrAfter()) {
aRenderingContext.SetColor(nsCSSRendering::TransformColor(aTextStyle.mColor->mColor,isPaginated));
aRenderingContext.SetColor(nsCSSRendering::TransformColor(aTextStyle.mColor->mColor,canDarkenColor));
aRenderingContext.DrawString(currenttext, currentlength, currentX, dy + mAscent);
} else if (!isPaginated) {
aRenderingContext.SetColor(nsCSSRendering::TransformColor(currentFGColor,isPaginated));
@@ -3212,7 +3251,7 @@ nsTextFrame::PaintAsciiText(nsIPresContext* aPresContext,
}
else if (!isPaginated)
{
aRenderingContext.SetColor(nsCSSRendering::TransformColor(aTextStyle.mColor->mColor,isPaginated));
aRenderingContext.SetColor(nsCSSRendering::TransformColor(aTextStyle.mColor->mColor,canDarkenColor));
aRenderingContext.DrawString(text, PRUint32(textLength), dx, dy + mAscent);
}
PaintTextDecorations(aRenderingContext, aStyleContext,

View File

@@ -2425,6 +2425,30 @@ FindCanvasBackground(nsIPresContext* aPresContext,
if (firstChild) {
const nsStyleBackground *result;
GetStyleData(firstChild, &result);
// for printing and print preview.. this should be a pageContentFrame
nsCOMPtr<nsIAtom> frameType;
nsCOMPtr<nsIStyleContext> parentContext;
firstChild->GetFrameType(getter_AddRefs(frameType));
if ( (frameType == nsLayoutAtoms::pageContentFrame) ){
// we have to find the background style ourselves.. since the
// pageContentframe does not have content
while(firstChild){
for (nsIFrame* kidFrame = firstChild; nsnull != kidFrame; ) {
kidFrame->GetStyleContext(getter_AddRefs(parentContext));
result = (nsStyleBackground*)parentContext->GetStyleData(eStyleStruct_Background);
if (!result->BackgroundIsTransparent()){
GetStyleData(kidFrame, aBackground);
return PR_TRUE;
} else {
kidFrame->GetNextSibling(&kidFrame);
}
}
firstChild->FirstChild(aPresContext, nsnull, &firstChild);
}
return PR_FALSE; // nothing found for this
}
// Check if we need to do propagation from BODY rather than HTML.
if (result->BackgroundIsTransparent()) {
@@ -2514,18 +2538,19 @@ nsCSSRendering::PaintBackground(nsIPresContext* aPresContext,
const nsRect& aBorderArea,
const nsStyleBorder& aBorder,
nscoord aDX,
nscoord aDY)
nscoord aDY,PRBool aUsePrintSettings)
{
NS_PRECONDITION(aForFrame,
"Frame is expected to be provided to PaintBackground");
PRBool isCanvas;
const nsStyleBackground *color;
if (!FindBackground(aPresContext, aForFrame, &color, &isCanvas))
return;
if (!isCanvas) {
PaintBackgroundWithSC(aPresContext, aRenderingContext, aForFrame,
aDirtyRect, aBorderArea, *color, aBorder, aDX, aDY);
aDirtyRect, aBorderArea, *color, aBorder, aDX, aDY, aUsePrintSettings);
return;
}
@@ -2556,7 +2581,7 @@ nsCSSRendering::PaintBackground(nsIPresContext* aPresContext,
PaintBackgroundWithSC(aPresContext, aRenderingContext, aForFrame,
aDirtyRect, aBorderArea, canvasColor,
aBorder, aDX, aDY);
aBorder, aDX, aDY, aUsePrintSettings);
}
void
@@ -2568,7 +2593,8 @@ nsCSSRendering::PaintBackgroundWithSC(nsIPresContext* aPresContext,
const nsStyleBackground& aColor,
const nsStyleBorder& aBorder,
nscoord aDX,
nscoord aDY)
nscoord aDY,
PRBool aUsePrintSettings)
{
NS_PRECONDITION(aForFrame,
"Frame is expected to be provided to PaintBackground");
@@ -2576,22 +2602,22 @@ nsCSSRendering::PaintBackgroundWithSC(nsIPresContext* aPresContext,
PRBool transparentBG =
NS_STYLE_BG_COLOR_TRANSPARENT ==
(aColor.mBackgroundFlags & NS_STYLE_BG_COLOR_TRANSPARENT);
PRBool canDrawBackgroundImage=PR_TRUE,canDrawBackgroundColor=PR_TRUE;
float percent;
nsStyleCoord bordStyleRadius[4];
PRInt16 borderRadii[4],i;
// if we are printing, bail for now
PRBool canDrawBackground;
aPresContext->GetBackgroundDraw(canDrawBackground);
nsCOMPtr<nsIPrintContext> thePrinterContext = do_QueryInterface(aPresContext);
if(aUsePrintSettings){
aPresContext->GetBackgroundImageDraw(canDrawBackgroundImage);
aPresContext->GetBackgroundColorDraw(canDrawBackgroundColor);
// only turn off background printing if we are currently printing.
if(!canDrawBackground && thePrinterContext){
return;
// only turn off background printing if we are currently printing.
if(!canDrawBackgroundImage && !canDrawBackgroundColor){
return;
}
}
// Check to see if we have an appearance defined. If so, we let the theme
// renderer draw the background.
const nsStyleDisplay* displayData;
@@ -2606,8 +2632,8 @@ nsCSSRendering::PaintBackgroundWithSC(nsIPresContext* aPresContext,
}
}
// if there is no background image, try a color.
if (aColor.mBackgroundImage.IsEmpty()) {
// if there is no background image or background images are turned off, try a color.
if (aColor.mBackgroundImage.IsEmpty() || (canDrawBackgroundColor && !canDrawBackgroundImage)) {
// See if there's a background color specified. The background color
// is rendered over the 'border' 'padding' and 'content' areas
if (!transparentBG) {

View File

@@ -130,7 +130,8 @@ public:
const nsRect& aBorderArea,
const nsStyleBorder& aBorder,
nscoord aDX,
nscoord aDY);
nscoord aDY,
PRBool aUsePrintSettings=PR_FALSE);
/**
* Same as |PaintBackground|, except using the provided style context
@@ -145,7 +146,8 @@ public:
const nsStyleBackground& aColor,
const nsStyleBorder& aBorder,
nscoord aDX,
nscoord aDY);
nscoord aDY,
PRBool aUsePrintSettings=PR_FALSE);
static void DrawDashedSides(PRIntn startSide,
nsIRenderingContext& aContext,

View File

@@ -428,7 +428,7 @@ nsTableCellFrame::Paint(nsIPresContext* aPresContext,
NS_STYLE_TABLE_EMPTY_CELLS_SHOW == cellTableStyle->mEmptyCells ||
NS_STYLE_TABLE_EMPTY_CELLS_SHOW_BACKGROUND == cellTableStyle->mEmptyCells) {
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *myBorder, 0, 0);
aDirtyRect, rect, *myBorder, 0, 0, PR_TRUE);
}
// draw the border except when the cell is empty and 'empty-cells: hide || -moz-show-background' is set
if (!GetContentEmpty() ||

View File

@@ -158,7 +158,7 @@ nsTableColFrame::Paint(nsIPresContext* aPresContext,
(const nsStyleBorder*)mStyleContext->GetStyleData(eStyleStruct_Border);
nsRect rect(0, 0, mRect.width, mRect.height);
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *border, 0, 0);
aDirtyRect, rect, *border, 0, 0, PR_TRUE);
}
}
}

View File

@@ -444,7 +444,7 @@ nsTableColGroupFrame::Paint(nsIPresContext* aPresContext,
(const nsStyleBorder*)mStyleContext->GetStyleData(eStyleStruct_Border);
nsRect rect(0, 0, mRect.width, mRect.height);
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *border, 0, 0);
aDirtyRect, rect, *border, 0, 0, PR_TRUE);
}
}
}

View File

@@ -1469,7 +1469,7 @@ nsTableFrame::Paint(nsIPresContext* aPresContext,
nsRect rect(0, 0, mRect.width, mRect.height);
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *border, 0, 0);
aDirtyRect, rect, *border, 0, 0, PR_TRUE);
// paint the column groups and columns
nsIFrame* colGroupFrame = mColGroups.FirstChild();

View File

@@ -590,7 +590,7 @@ NS_METHOD nsTableRowFrame::Paint(nsIPresContext* aPresContext,
(const nsStyleBorder*)mStyleContext->GetStyleData(eStyleStruct_Border);
nsRect rect(0, 0, mRect.width, mRect.height);
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *border, 0, 0);
aDirtyRect, rect, *border, 0, 0, PR_TRUE);
}
}
}

View File

@@ -232,7 +232,7 @@ NS_METHOD nsTableRowGroupFrame::Paint(nsIPresContext* aPresContext,
(const nsStyleBorder*)mStyleContext->GetStyleData(eStyleStruct_Border);
nsRect rect(0,0,mRect.width, mRect.height);
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *border, 0, 0);
aDirtyRect, rect, *border, 0, 0, PR_TRUE);
}
}

View File

@@ -428,7 +428,7 @@ nsTableCellFrame::Paint(nsIPresContext* aPresContext,
NS_STYLE_TABLE_EMPTY_CELLS_SHOW == cellTableStyle->mEmptyCells ||
NS_STYLE_TABLE_EMPTY_CELLS_SHOW_BACKGROUND == cellTableStyle->mEmptyCells) {
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *myBorder, 0, 0);
aDirtyRect, rect, *myBorder, 0, 0, PR_TRUE);
}
// draw the border except when the cell is empty and 'empty-cells: hide || -moz-show-background' is set
if (!GetContentEmpty() ||

View File

@@ -158,7 +158,7 @@ nsTableColFrame::Paint(nsIPresContext* aPresContext,
(const nsStyleBorder*)mStyleContext->GetStyleData(eStyleStruct_Border);
nsRect rect(0, 0, mRect.width, mRect.height);
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *border, 0, 0);
aDirtyRect, rect, *border, 0, 0, PR_TRUE);
}
}
}

View File

@@ -444,7 +444,7 @@ nsTableColGroupFrame::Paint(nsIPresContext* aPresContext,
(const nsStyleBorder*)mStyleContext->GetStyleData(eStyleStruct_Border);
nsRect rect(0, 0, mRect.width, mRect.height);
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *border, 0, 0);
aDirtyRect, rect, *border, 0, 0, PR_TRUE);
}
}
}

View File

@@ -1469,7 +1469,7 @@ nsTableFrame::Paint(nsIPresContext* aPresContext,
nsRect rect(0, 0, mRect.width, mRect.height);
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *border, 0, 0);
aDirtyRect, rect, *border, 0, 0, PR_TRUE);
// paint the column groups and columns
nsIFrame* colGroupFrame = mColGroups.FirstChild();

View File

@@ -590,7 +590,7 @@ NS_METHOD nsTableRowFrame::Paint(nsIPresContext* aPresContext,
(const nsStyleBorder*)mStyleContext->GetStyleData(eStyleStruct_Border);
nsRect rect(0, 0, mRect.width, mRect.height);
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *border, 0, 0);
aDirtyRect, rect, *border, 0, 0, PR_TRUE);
}
}
}

View File

@@ -232,7 +232,7 @@ NS_METHOD nsTableRowGroupFrame::Paint(nsIPresContext* aPresContext,
(const nsStyleBorder*)mStyleContext->GetStyleData(eStyleStruct_Border);
nsRect rect(0,0,mRect.width, mRect.height);
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *border, 0, 0);
aDirtyRect, rect, *border, 0, 0, PR_TRUE);
}
}