Bug 191938. 'Dont print backgrounds' by setting background to white. also clean up unused params and make background-attachment:fixed work in printing/printpreview. r+sr=bzbarsky

This commit is contained in:
roc+%cs.cmu.edu 2003-02-23 02:49:22 +00:00
Родитель 49dfc64596
Коммит 77e5c960ef
34 изменённых файлов: 163 добавлений и 145 удалений

Просмотреть файл

@ -133,6 +133,7 @@ static const char* kPrintingPromptService = "@mozilla.org/embedcomp/printingprom
#include "nsLayoutCID.h"
#include "nsGenericHTMLElement.h"
#include "nsIPresShell.h"
#include "nsLayoutUtils.h"
#include "nsViewsCID.h"
#include "nsWidgetsCID.h"
@ -3687,25 +3688,6 @@ nsPrintEngine::DoProgressForSeparateFrames()
}
}
/** ---------------------------------------------------
* Giving a child frame it searches "up" the tree until it
* finds a "Page" frame.
*/
static nsIFrame * GetPageFrame(nsIFrame * aFrame)
{
nsIFrame * frame = aFrame;
while (frame != nsnull) {
nsCOMPtr<nsIAtom> type;
frame->GetFrameType(getter_AddRefs(type));
if (type.get() == nsLayoutAtoms::pageFrame) {
return frame;
}
frame->GetParent(&frame);
}
return nsnull;
}
/** ---------------------------------------------------
* Find by checking content's tag type
*/
@ -3900,12 +3882,12 @@ nsPrintEngine::GetPageRangeForSelection(nsIPresShell * aPresShell,
// the FindSelectionBounds step, but walking up to find
// the parent of a child frame isn't expensive and it makes
// FindSelectionBounds a little easier to understand
startPageFrame = GetPageFrame(startFrame);
startPageFrame = nsLayoutUtils::GetPageFrame(startFrame);
endPageFrame = startPageFrame;
aEndRect = aStartRect;
} else {
startPageFrame = GetPageFrame(startFrame);
endPageFrame = GetPageFrame(endFrame);
startPageFrame = nsLayoutUtils::GetPageFrame(startFrame);
endPageFrame = nsLayoutUtils::GetPageFrame(endFrame);
}
} else {
return NS_ERROR_FAILURE;

Просмотреть файл

@ -63,6 +63,7 @@
#include "nsIServiceManager.h"
#include "nsIDOMHTMLBodyElement.h"
#include "nsIDOMHTMLDocument.h"
#include "nsLayoutUtils.h"
#define BORDER_FULL 0 //entire side
#define BORDER_INSIDE 1 //inside half
@ -2749,8 +2750,7 @@ nsCSSRendering::PaintBackground(nsIPresContext* aPresContext,
const nsRect& aBorderArea,
const nsStyleBorder& aBorder,
const nsStylePadding& aPadding,
nscoord aDX,
nscoord aDY,PRBool aUsePrintSettings)
PRBool aUsePrintSettings)
{
NS_PRECONDITION(aForFrame,
"Frame is expected to be provided to PaintBackground");
@ -2786,7 +2786,7 @@ nsCSSRendering::PaintBackground(nsIPresContext* aPresContext,
if (!isCanvas) {
PaintBackgroundWithSC(aPresContext, aRenderingContext, aForFrame,
aDirtyRect, aBorderArea, *color, aBorder,
aPadding, aDX, aDY, aUsePrintSettings);
aPadding, aUsePrintSettings);
return;
}
@ -2827,7 +2827,7 @@ nsCSSRendering::PaintBackground(nsIPresContext* aPresContext,
PaintBackgroundWithSC(aPresContext, aRenderingContext, aForFrame,
aDirtyRect, aBorderArea, canvasColor,
aBorder, aPadding, aDX, aDY, aUsePrintSettings);
aBorder, aPadding, aUsePrintSettings);
}
void
@ -2839,24 +2839,19 @@ nsCSSRendering::PaintBackgroundWithSC(nsIPresContext* aPresContext,
const nsStyleBackground& aColor,
const nsStyleBorder& aBorder,
const nsStylePadding& aPadding,
nscoord aDX,
nscoord aDY,
PRBool aUsePrintSettings)
{
NS_PRECONDITION(aForFrame,
"Frame is expected to be provided to PaintBackground");
// if we are printing, bail for now
PRBool canDrawBackgroundImage=PR_TRUE,canDrawBackgroundColor=PR_TRUE;
if(aUsePrintSettings){
PRBool canDrawBackgroundImage = PR_TRUE;
PRBool canDrawBackgroundColor = PR_TRUE;
if (aUsePrintSettings) {
aPresContext->GetBackgroundImageDraw(canDrawBackgroundImage);
aPresContext->GetBackgroundColorDraw(canDrawBackgroundColor);
// 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 and bail out.
const nsStyleDisplay* displayData;
@ -2890,9 +2885,9 @@ nsCSSRendering::PaintBackgroundWithSC(nsIPresContext* aPresContext,
}
// if there is no background image or background images are turned off, try a color.
if (aColor.mBackgroundImage.IsEmpty() || (canDrawBackgroundColor && !canDrawBackgroundImage)) {
if (aColor.mBackgroundImage.IsEmpty() || !canDrawBackgroundImage) {
PaintBackgroundColor(aPresContext, aRenderingContext, aForFrame, bgClipArea,
aColor, aBorder, aPadding, aDX, aDY);
aColor, aBorder, aPadding, canDrawBackgroundColor);
return;
}
@ -2915,7 +2910,7 @@ nsCSSRendering::PaintBackgroundWithSC(nsIPresContext* aPresContext,
if (NS_FAILED(rv) || !req || !(status & imgIRequest::STATUS_FRAME_COMPLETE) || !(status & imgIRequest::STATUS_SIZE_AVAILABLE)) {
PaintBackgroundColor(aPresContext, aRenderingContext, aForFrame, bgClipArea,
aColor, aBorder, aPadding, aDX, aDY);
aColor, aBorder, aPadding, canDrawBackgroundColor);
return;
}
@ -3011,7 +3006,7 @@ nsCSSRendering::PaintBackgroundWithSC(nsIPresContext* aPresContext,
// The background color is rendered over the 'background-clip' area
if (needBackgroundColor) {
PaintBackgroundColor(aPresContext, aRenderingContext, aForFrame, bgClipArea,
aColor, aBorder, aPadding, aDX, aDY);
aColor, aBorder, aPadding, canDrawBackgroundColor);
}
if ((tileWidth == 0) || (tileHeight == 0) || dirtyRect.IsEmpty()) {
@ -3057,6 +3052,14 @@ nsCSSRendering::PaintBackgroundWithSC(nsIPresContext* aPresContext,
presShell->GetRootFrame(&rootFrame);
NS_ASSERTION(rootFrame, "no root frame");
PRBool isPaginated = PR_FALSE;
aPresContext->IsPaginated(&isPaginated);
if (isPaginated) {
nsIFrame* page = nsLayoutUtils::GetPageFrame(aForFrame);
NS_ASSERTION(page, "no page");
rootFrame = page;
}
rootFrame->GetView(aPresContext, &viewportView);
NS_ASSERTION(viewportView, "no viewport view");
viewportView->GetBounds(viewportArea);
@ -3321,8 +3324,7 @@ nsCSSRendering::PaintBackgroundColor(nsIPresContext* aPresContext,
const nsStyleBackground& aColor,
const nsStyleBorder& aBorder,
const nsStylePadding& aPadding,
nscoord aDX,
nscoord aDY)
PRBool aCanPaintNonWhite)
{
if (aColor.mBackgroundFlags & NS_STYLE_BG_COLOR_TRANSPARENT) {
// nothing to paint
@ -3364,7 +3366,8 @@ nsCSSRendering::PaintBackgroundColor(nsIPresContext* aPresContext,
for (side = 0; side < 4; ++side) {
if (borderRadii[side] > 0) {
PaintRoundedBackground(aPresContext, aRenderingContext, aForFrame,
bgClipArea, aColor, aBorder, aDX, aDY, borderRadii);
bgClipArea, aColor, aBorder, borderRadii,
aCanPaintNonWhite);
return;
}
}
@ -3379,7 +3382,11 @@ nsCSSRendering::PaintBackgroundColor(nsIPresContext* aPresContext,
bgClipArea.Deflate(border);
}
aRenderingContext.SetColor(aColor.mBackgroundColor);
nscolor color = aColor.mBackgroundColor;
if (!aCanPaintNonWhite) {
color = NS_RGB(255, 255, 255);
}
aRenderingContext.SetColor(color);
aRenderingContext.FillRect(bgClipArea);
}
@ -3394,9 +3401,8 @@ nsCSSRendering::PaintRoundedBackground(nsIPresContext* aPresContext,
const nsRect& aBgClipArea,
const nsStyleBackground& aColor,
const nsStyleBorder& aBorder,
nscoord aDX,
nscoord aDY,
PRInt16 aTheRadius[4])
PRInt16 aTheRadius[4],
PRBool aCanPaintNonWhite)
{
RoundedRect outerPath;
QBCurve cr1,cr2,cr3,cr4;
@ -3412,7 +3418,11 @@ nsCSSRendering::PaintRoundedBackground(nsIPresContext* aPresContext,
aPresContext->GetPixelsToTwips(&p2t);
twipsPerPixel = NSToCoordRound(p2t);
aRenderingContext.SetColor(aColor.mBackgroundColor);
nscolor color = aColor.mBackgroundColor;
if (!aCanPaintNonWhite) {
color = NS_RGB(255, 255, 255);
}
aRenderingContext.SetColor(color);
// Adjust for background-clip, if necessary
if (aColor.mBackgroundClip != NS_STYLE_BG_CLIP_BORDER) {

Просмотреть файл

@ -140,8 +140,6 @@ public:
const nsRect& aBorderArea,
const nsStyleBorder& aBorder,
const nsStylePadding& aPadding,
nscoord aDX,
nscoord aDY,
PRBool aUsePrintSettings);
/**
@ -157,8 +155,6 @@ public:
const nsStyleBackground& aColor,
const nsStyleBorder& aBorder,
const nsStylePadding& aPadding,
nscoord aDX,
nscoord aDY,
PRBool aUsePrintSettings=PR_FALSE);
/**
* Called by the presShell when painting is finished, so we can clear our
@ -249,8 +245,7 @@ protected:
const nsStyleBackground& aColor,
const nsStyleBorder& aBorder,
const nsStylePadding& aPadding,
nscoord aDX,
nscoord aDY);
PRBool aCanPaintNonWhite);
static void PaintRoundedBackground(nsIPresContext* aPresContext,
nsIRenderingContext& aRenderingContext,
@ -258,9 +253,8 @@ protected:
const nsRect& aBorderArea,
const nsStyleBackground& aColor,
const nsStyleBorder& aBorder,
nscoord aDX,
nscoord aDY,
PRInt16 aTheRadius[4]);
PRInt16 aTheRadius[4],
PRBool aCanPaintNonWhite);
static nscolor MakeBevelColor(PRIntn whichSide, PRUint8 style,
nscolor aBackgroundColor,

Просмотреть файл

@ -40,6 +40,7 @@
#include "nsIPresContext.h"
#include "nsIContent.h"
#include "nsFrameList.h"
#include "nsLayoutAtoms.h"
/**
* A namespace class for static layout utilities.
@ -161,3 +162,18 @@ nsLayoutUtils::GetAfterFrame(nsIFrame* aFrame, nsIPresContext* aPresContext)
return nsnull;
}
nsIFrame*
nsLayoutUtils::GetPageFrame(nsIFrame* aFrame)
{
nsIFrame* frame = aFrame;
while (frame) {
nsCOMPtr<nsIAtom> type;
frame->GetFrameType(getter_AddRefs(type));
if (type.get() == nsLayoutAtoms::pageFrame) {
return frame;
}
frame->GetParent(&frame);
}
return nsnull;
}

Просмотреть файл

@ -72,6 +72,11 @@ public:
*/
static nsIFrame* GetAfterFrame(nsIFrame* aFrame, nsIPresContext* aPresContext);
/** ---------------------------------------------------
* Giving a child frame it searches "up" the tree until it
* finds a "Page" frame.
*/
static nsIFrame* GetPageFrame(nsIFrame* aFrame);
};
#endif // nsLayoutUtils_h__

Просмотреть файл

@ -72,6 +72,11 @@ public:
*/
static nsIFrame* GetAfterFrame(nsIFrame* aFrame, nsIPresContext* aPresContext);
/** ---------------------------------------------------
* Giving a child frame it searches "up" the tree until it
* finds a "Page" frame.
*/
static nsIFrame* GetPageFrame(nsIFrame* aFrame);
};
#endif // nsLayoutUtils_h__

Просмотреть файл

@ -40,6 +40,7 @@
#include "nsIPresContext.h"
#include "nsIContent.h"
#include "nsFrameList.h"
#include "nsLayoutAtoms.h"
/**
* A namespace class for static layout utilities.
@ -161,3 +162,18 @@ nsLayoutUtils::GetAfterFrame(nsIFrame* aFrame, nsIPresContext* aPresContext)
return nsnull;
}
nsIFrame*
nsLayoutUtils::GetPageFrame(nsIFrame* aFrame)
{
nsIFrame* frame = aFrame;
while (frame) {
nsCOMPtr<nsIAtom> type;
frame->GetFrameType(getter_AddRefs(type));
if (type.get() == nsLayoutAtoms::pageFrame) {
return frame;
}
frame->GetParent(&frame);
}
return nsnull;
}

Просмотреть файл

@ -183,7 +183,7 @@ nsButtonFrameRenderer::PaintBorderAndBackground(nsIPresContext* aPresContext,
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, mFrame,
aDirtyRect, buttonRect, *border, *padding,
0, 0, PR_FALSE);
PR_FALSE);
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, mFrame,
aDirtyRect, buttonRect, *border, context, 0);
}

Просмотреть файл

@ -217,7 +217,7 @@ nsFieldSetFrame::Paint(nsIPresContext* aPresContext,
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *borderStyle,
*paddingStyle, 0, 0, PR_TRUE);
*paddingStyle, PR_TRUE);
if (mLegendFrame) {

Просмотреть файл

@ -250,7 +250,7 @@ nsGfxCheckboxControlFrame::Paint(nsIPresContext* aPresContext,
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *myBorder, *myPadding,
0, 0, PR_FALSE);
PR_FALSE);
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *myBorder, mCheckButtonFaceStyle, 0);
doDefaultPainting = PR_FALSE;

Просмотреть файл

@ -213,8 +213,7 @@ nsGfxRadioControlFrame::PaintRadioButton(nsIPresContext* aPresContext,
tmpColor.mBackgroundColor = color->mColor;
nsCSSRendering::PaintBackgroundWithSC(aPresContext, aRenderingContext,
this, aDirtyRect, rect,
tmpColor, *myBorder, *myPadding,
0, 0);
tmpColor, *myBorder, *myPadding, PR_FALSE);
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *myBorder, mRadioButtonFaceStyle, 0);
}

Просмотреть файл

@ -943,7 +943,8 @@ void
nsFrame::PaintSelf(nsIPresContext* aPresContext,
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
PRIntn aSkipSides)
PRIntn aSkipSides,
PRBool aUsePrintBackgroundSettings)
{
// The visibility check belongs here since child elements have the
// opportunity to override the visibility property and display even if
@ -968,7 +969,7 @@ nsFrame::PaintSelf(nsIPresContext* aPresContext,
nsRect rect(0, 0, mRect.width, mRect.height);
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *border, *padding,
0, 0, PR_TRUE);
aUsePrintBackgroundSettings);
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *border, mStyleContext,
aSkipSides);

Просмотреть файл

@ -478,7 +478,8 @@ protected:
void PaintSelf(nsIPresContext* aPresContext,
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
PRIntn aSkipSides = 0);
PRIntn aSkipSides = 0,
PRBool aUsePrintBackgroundSettings = PR_TRUE);
PRInt16 DisplaySelection(nsIPresContext* aPresContext, PRBool isOkToTurnOn = PR_FALSE);

Просмотреть файл

@ -758,7 +758,7 @@ nsPageFrame::DrawBackground(nsIPresContext* aPresContext,
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *border, *padding,
0, 0, PR_TRUE);
PR_TRUE);
}
}

Просмотреть файл

@ -943,7 +943,8 @@ void
nsFrame::PaintSelf(nsIPresContext* aPresContext,
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
PRIntn aSkipSides)
PRIntn aSkipSides,
PRBool aUsePrintBackgroundSettings)
{
// The visibility check belongs here since child elements have the
// opportunity to override the visibility property and display even if
@ -968,7 +969,7 @@ nsFrame::PaintSelf(nsIPresContext* aPresContext,
nsRect rect(0, 0, mRect.width, mRect.height);
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *border, *padding,
0, 0, PR_TRUE);
aUsePrintBackgroundSettings);
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *border, mStyleContext,
aSkipSides);

Просмотреть файл

@ -478,7 +478,8 @@ protected:
void PaintSelf(nsIPresContext* aPresContext,
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
PRIntn aSkipSides = 0);
PRIntn aSkipSides = 0,
PRBool aUsePrintBackgroundSettings = PR_TRUE);
PRInt16 DisplaySelection(nsIPresContext* aPresContext, PRBool isOkToTurnOn = PR_FALSE);

Просмотреть файл

@ -70,6 +70,8 @@ public:
PRUint32 aFlags);
NS_IMETHOD GetFrameType(nsIAtom** aType) const;
virtual PRBool CanPaintBackground() { return PR_FALSE; }
protected:
PRBool GetNoShade();
@ -194,7 +196,7 @@ HRuleFrame::Paint(nsIPresContext* aPresContext,
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext,
this,aDirtyRect, rect,
*border, *padding, 0, 0, PR_FALSE);
*border, *padding, PR_FALSE);
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext,
this,aDirtyRect, rect, *border,
mStyleContext, 0);

Просмотреть файл

@ -758,7 +758,7 @@ nsPageFrame::DrawBackground(nsIPresContext* aPresContext,
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *border, *padding,
0, 0, PR_TRUE);
PR_TRUE);
}
}

Просмотреть файл

@ -183,7 +183,7 @@ nsButtonFrameRenderer::PaintBorderAndBackground(nsIPresContext* aPresContext,
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, mFrame,
aDirtyRect, buttonRect, *border, *padding,
0, 0, PR_FALSE);
PR_FALSE);
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, mFrame,
aDirtyRect, buttonRect, *border, context, 0);
}

Просмотреть файл

@ -217,7 +217,7 @@ nsFieldSetFrame::Paint(nsIPresContext* aPresContext,
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *borderStyle,
*paddingStyle, 0, 0, PR_TRUE);
*paddingStyle, PR_TRUE);
if (mLegendFrame) {

Просмотреть файл

@ -250,7 +250,7 @@ nsGfxCheckboxControlFrame::Paint(nsIPresContext* aPresContext,
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *myBorder, *myPadding,
0, 0, PR_FALSE);
PR_FALSE);
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *myBorder, mCheckButtonFaceStyle, 0);
doDefaultPainting = PR_FALSE;

Просмотреть файл

@ -213,8 +213,7 @@ nsGfxRadioControlFrame::PaintRadioButton(nsIPresContext* aPresContext,
tmpColor.mBackgroundColor = color->mColor;
nsCSSRendering::PaintBackgroundWithSC(aPresContext, aRenderingContext,
this, aDirtyRect, rect,
tmpColor, *myBorder, *myPadding,
0, 0);
tmpColor, *myBorder, *myPadding, PR_FALSE);
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *myBorder, mRadioButtonFaceStyle, 0);
}

Просмотреть файл

@ -63,6 +63,7 @@
#include "nsIServiceManager.h"
#include "nsIDOMHTMLBodyElement.h"
#include "nsIDOMHTMLDocument.h"
#include "nsLayoutUtils.h"
#define BORDER_FULL 0 //entire side
#define BORDER_INSIDE 1 //inside half
@ -2749,8 +2750,7 @@ nsCSSRendering::PaintBackground(nsIPresContext* aPresContext,
const nsRect& aBorderArea,
const nsStyleBorder& aBorder,
const nsStylePadding& aPadding,
nscoord aDX,
nscoord aDY,PRBool aUsePrintSettings)
PRBool aUsePrintSettings)
{
NS_PRECONDITION(aForFrame,
"Frame is expected to be provided to PaintBackground");
@ -2786,7 +2786,7 @@ nsCSSRendering::PaintBackground(nsIPresContext* aPresContext,
if (!isCanvas) {
PaintBackgroundWithSC(aPresContext, aRenderingContext, aForFrame,
aDirtyRect, aBorderArea, *color, aBorder,
aPadding, aDX, aDY, aUsePrintSettings);
aPadding, aUsePrintSettings);
return;
}
@ -2827,7 +2827,7 @@ nsCSSRendering::PaintBackground(nsIPresContext* aPresContext,
PaintBackgroundWithSC(aPresContext, aRenderingContext, aForFrame,
aDirtyRect, aBorderArea, canvasColor,
aBorder, aPadding, aDX, aDY, aUsePrintSettings);
aBorder, aPadding, aUsePrintSettings);
}
void
@ -2839,24 +2839,19 @@ nsCSSRendering::PaintBackgroundWithSC(nsIPresContext* aPresContext,
const nsStyleBackground& aColor,
const nsStyleBorder& aBorder,
const nsStylePadding& aPadding,
nscoord aDX,
nscoord aDY,
PRBool aUsePrintSettings)
{
NS_PRECONDITION(aForFrame,
"Frame is expected to be provided to PaintBackground");
// if we are printing, bail for now
PRBool canDrawBackgroundImage=PR_TRUE,canDrawBackgroundColor=PR_TRUE;
if(aUsePrintSettings){
PRBool canDrawBackgroundImage = PR_TRUE;
PRBool canDrawBackgroundColor = PR_TRUE;
if (aUsePrintSettings) {
aPresContext->GetBackgroundImageDraw(canDrawBackgroundImage);
aPresContext->GetBackgroundColorDraw(canDrawBackgroundColor);
// 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 and bail out.
const nsStyleDisplay* displayData;
@ -2890,9 +2885,9 @@ nsCSSRendering::PaintBackgroundWithSC(nsIPresContext* aPresContext,
}
// if there is no background image or background images are turned off, try a color.
if (aColor.mBackgroundImage.IsEmpty() || (canDrawBackgroundColor && !canDrawBackgroundImage)) {
if (aColor.mBackgroundImage.IsEmpty() || !canDrawBackgroundImage) {
PaintBackgroundColor(aPresContext, aRenderingContext, aForFrame, bgClipArea,
aColor, aBorder, aPadding, aDX, aDY);
aColor, aBorder, aPadding, canDrawBackgroundColor);
return;
}
@ -2915,7 +2910,7 @@ nsCSSRendering::PaintBackgroundWithSC(nsIPresContext* aPresContext,
if (NS_FAILED(rv) || !req || !(status & imgIRequest::STATUS_FRAME_COMPLETE) || !(status & imgIRequest::STATUS_SIZE_AVAILABLE)) {
PaintBackgroundColor(aPresContext, aRenderingContext, aForFrame, bgClipArea,
aColor, aBorder, aPadding, aDX, aDY);
aColor, aBorder, aPadding, canDrawBackgroundColor);
return;
}
@ -3011,7 +3006,7 @@ nsCSSRendering::PaintBackgroundWithSC(nsIPresContext* aPresContext,
// The background color is rendered over the 'background-clip' area
if (needBackgroundColor) {
PaintBackgroundColor(aPresContext, aRenderingContext, aForFrame, bgClipArea,
aColor, aBorder, aPadding, aDX, aDY);
aColor, aBorder, aPadding, canDrawBackgroundColor);
}
if ((tileWidth == 0) || (tileHeight == 0) || dirtyRect.IsEmpty()) {
@ -3057,6 +3052,14 @@ nsCSSRendering::PaintBackgroundWithSC(nsIPresContext* aPresContext,
presShell->GetRootFrame(&rootFrame);
NS_ASSERTION(rootFrame, "no root frame");
PRBool isPaginated = PR_FALSE;
aPresContext->IsPaginated(&isPaginated);
if (isPaginated) {
nsIFrame* page = nsLayoutUtils::GetPageFrame(aForFrame);
NS_ASSERTION(page, "no page");
rootFrame = page;
}
rootFrame->GetView(aPresContext, &viewportView);
NS_ASSERTION(viewportView, "no viewport view");
viewportView->GetBounds(viewportArea);
@ -3321,8 +3324,7 @@ nsCSSRendering::PaintBackgroundColor(nsIPresContext* aPresContext,
const nsStyleBackground& aColor,
const nsStyleBorder& aBorder,
const nsStylePadding& aPadding,
nscoord aDX,
nscoord aDY)
PRBool aCanPaintNonWhite)
{
if (aColor.mBackgroundFlags & NS_STYLE_BG_COLOR_TRANSPARENT) {
// nothing to paint
@ -3364,7 +3366,8 @@ nsCSSRendering::PaintBackgroundColor(nsIPresContext* aPresContext,
for (side = 0; side < 4; ++side) {
if (borderRadii[side] > 0) {
PaintRoundedBackground(aPresContext, aRenderingContext, aForFrame,
bgClipArea, aColor, aBorder, aDX, aDY, borderRadii);
bgClipArea, aColor, aBorder, borderRadii,
aCanPaintNonWhite);
return;
}
}
@ -3379,7 +3382,11 @@ nsCSSRendering::PaintBackgroundColor(nsIPresContext* aPresContext,
bgClipArea.Deflate(border);
}
aRenderingContext.SetColor(aColor.mBackgroundColor);
nscolor color = aColor.mBackgroundColor;
if (!aCanPaintNonWhite) {
color = NS_RGB(255, 255, 255);
}
aRenderingContext.SetColor(color);
aRenderingContext.FillRect(bgClipArea);
}
@ -3394,9 +3401,8 @@ nsCSSRendering::PaintRoundedBackground(nsIPresContext* aPresContext,
const nsRect& aBgClipArea,
const nsStyleBackground& aColor,
const nsStyleBorder& aBorder,
nscoord aDX,
nscoord aDY,
PRInt16 aTheRadius[4])
PRInt16 aTheRadius[4],
PRBool aCanPaintNonWhite)
{
RoundedRect outerPath;
QBCurve cr1,cr2,cr3,cr4;
@ -3412,7 +3418,11 @@ nsCSSRendering::PaintRoundedBackground(nsIPresContext* aPresContext,
aPresContext->GetPixelsToTwips(&p2t);
twipsPerPixel = NSToCoordRound(p2t);
aRenderingContext.SetColor(aColor.mBackgroundColor);
nscolor color = aColor.mBackgroundColor;
if (!aCanPaintNonWhite) {
color = NS_RGB(255, 255, 255);
}
aRenderingContext.SetColor(color);
// Adjust for background-clip, if necessary
if (aColor.mBackgroundClip != NS_STYLE_BG_CLIP_BORDER) {

Просмотреть файл

@ -140,8 +140,6 @@ public:
const nsRect& aBorderArea,
const nsStyleBorder& aBorder,
const nsStylePadding& aPadding,
nscoord aDX,
nscoord aDY,
PRBool aUsePrintSettings);
/**
@ -157,8 +155,6 @@ public:
const nsStyleBackground& aColor,
const nsStyleBorder& aBorder,
const nsStylePadding& aPadding,
nscoord aDX,
nscoord aDY,
PRBool aUsePrintSettings=PR_FALSE);
/**
* Called by the presShell when painting is finished, so we can clear our
@ -249,8 +245,7 @@ protected:
const nsStyleBackground& aColor,
const nsStyleBorder& aBorder,
const nsStylePadding& aPadding,
nscoord aDX,
nscoord aDY);
PRBool aCanPaintNonWhite);
static void PaintRoundedBackground(nsIPresContext* aPresContext,
nsIRenderingContext& aRenderingContext,
@ -258,9 +253,8 @@ protected:
const nsRect& aBorderArea,
const nsStyleBackground& aColor,
const nsStyleBorder& aBorder,
nscoord aDX,
nscoord aDY,
PRInt16 aTheRadius[4]);
PRInt16 aTheRadius[4],
PRBool aCanPaintNonWhite);
static nscolor MakeBevelColor(PRIntn whichSide, PRUint8 style,
nscolor aBackgroundColor,

Просмотреть файл

@ -425,7 +425,7 @@ nsTableCellFrame::PaintUnderlay(nsIPresContext& aPresContext,
nsRect rect(0, 0, mRect.width, mRect.height);
nsCSSRendering::PaintBackground(&aPresContext, aRenderingContext, this,
aDirtyRect, rect, aStyleBorder, aStylePadding,
0, 0, PR_TRUE);
PR_TRUE);
// draw the border only when there is content or showing empty cells
if (!GetContentEmpty() || NS_STYLE_TABLE_EMPTY_CELLS_SHOW == aCellTableStyle.mEmptyCells) {
PRIntn skipSides = GetSkipSides();
@ -1541,7 +1541,7 @@ nsBCTableCellFrame::PaintUnderlay(nsIPresContext& aPresContext,
nsRect rect(0, 0, mRect.width, mRect.height);
nsCSSRendering::PaintBackground(&aPresContext, aRenderingContext, this,
aDirtyRect, rect, myBorder, aStylePadding,
0, 0, PR_TRUE);
PR_TRUE);
// borders are painted by nsTableFrame
}

Просмотреть файл

@ -1470,7 +1470,7 @@ nsTableFrame::Paint(nsIPresContext* aPresContext,
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *border, *padding,
0, 0, PR_TRUE);
PR_TRUE);
// paint the border here only for separate borders
if (!IsBorderCollapse()) {

Просмотреть файл

@ -1908,11 +1908,11 @@ nsMathMLChar::Paint(nsIPresContext* aPresContext,
0 == (backg->mBackgroundFlags & NS_STYLE_BG_COLOR_TRANSPARENT))
nsCSSRendering::PaintBackgroundWithSC(aPresContext, aRenderingContext, aForFrame,
aDirtyRect, rect, *backg, *border, *padding,
0, 0);
PR_TRUE);
//else
// our container frame will take care of painting its background
// nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, aForFrame,
// aDirtyRect, rect, *border, *padding, 0, 0);
// aDirtyRect, rect, *border, *padding, PR_TRUE);
#if defined(NS_DEBUG) && defined(SHOW_BOUNDING_BOX)
// for visual debug
PRIntn skipSides = 0; //aForFrame->GetSkipSides();

Просмотреть файл

@ -133,6 +133,7 @@ static const char* kPrintingPromptService = "@mozilla.org/embedcomp/printingprom
#include "nsLayoutCID.h"
#include "nsGenericHTMLElement.h"
#include "nsIPresShell.h"
#include "nsLayoutUtils.h"
#include "nsViewsCID.h"
#include "nsWidgetsCID.h"
@ -3687,25 +3688,6 @@ nsPrintEngine::DoProgressForSeparateFrames()
}
}
/** ---------------------------------------------------
* Giving a child frame it searches "up" the tree until it
* finds a "Page" frame.
*/
static nsIFrame * GetPageFrame(nsIFrame * aFrame)
{
nsIFrame * frame = aFrame;
while (frame != nsnull) {
nsCOMPtr<nsIAtom> type;
frame->GetFrameType(getter_AddRefs(type));
if (type.get() == nsLayoutAtoms::pageFrame) {
return frame;
}
frame->GetParent(&frame);
}
return nsnull;
}
/** ---------------------------------------------------
* Find by checking content's tag type
*/
@ -3900,12 +3882,12 @@ nsPrintEngine::GetPageRangeForSelection(nsIPresShell * aPresShell,
// the FindSelectionBounds step, but walking up to find
// the parent of a child frame isn't expensive and it makes
// FindSelectionBounds a little easier to understand
startPageFrame = GetPageFrame(startFrame);
startPageFrame = nsLayoutUtils::GetPageFrame(startFrame);
endPageFrame = startPageFrame;
aEndRect = aStartRect;
} else {
startPageFrame = GetPageFrame(startFrame);
endPageFrame = GetPageFrame(endFrame);
startPageFrame = nsLayoutUtils::GetPageFrame(startFrame);
endPageFrame = nsLayoutUtils::GetPageFrame(endFrame);
}
} else {
return NS_ERROR_FAILURE;

Просмотреть файл

@ -804,7 +804,7 @@ nsSVGOuterSVGFrame::Paint(nsIPresContext* aPresContext,
// nsRect rect(0, 0, mRect.width, mRect.height);
// // nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
// // aDirtyRect, rect, *border, *padding, 0, 0);
// // aDirtyRect, rect, *border, *padding, PR_TRUE);
// nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
// aDirtyRect, rect, *border, mStyleContext, 0);
// nsCSSRendering::PaintOutline(aPresContext, aRenderingContext, this,

Просмотреть файл

@ -425,7 +425,7 @@ nsTableCellFrame::PaintUnderlay(nsIPresContext& aPresContext,
nsRect rect(0, 0, mRect.width, mRect.height);
nsCSSRendering::PaintBackground(&aPresContext, aRenderingContext, this,
aDirtyRect, rect, aStyleBorder, aStylePadding,
0, 0, PR_TRUE);
PR_TRUE);
// draw the border only when there is content or showing empty cells
if (!GetContentEmpty() || NS_STYLE_TABLE_EMPTY_CELLS_SHOW == aCellTableStyle.mEmptyCells) {
PRIntn skipSides = GetSkipSides();
@ -1541,7 +1541,7 @@ nsBCTableCellFrame::PaintUnderlay(nsIPresContext& aPresContext,
nsRect rect(0, 0, mRect.width, mRect.height);
nsCSSRendering::PaintBackground(&aPresContext, aRenderingContext, this,
aDirtyRect, rect, myBorder, aStylePadding,
0, 0, PR_TRUE);
PR_TRUE);
// borders are painted by nsTableFrame
}

Просмотреть файл

@ -1470,7 +1470,7 @@ nsTableFrame::Paint(nsIPresContext* aPresContext,
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *border, *padding,
0, 0, PR_TRUE);
PR_TRUE);
// paint the border here only for separate borders
if (!IsBorderCollapse()) {

Просмотреть файл

@ -1455,7 +1455,7 @@ nsBoxFrame::Paint(nsIPresContext* aPresContext,
}
if (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer) {
PaintSelf(aPresContext, aRenderingContext, aDirtyRect);
PaintSelf(aPresContext, aRenderingContext, aDirtyRect, 0, PR_FALSE);
}
nsCOMPtr<nsIAtom> frameType;

Просмотреть файл

@ -164,7 +164,7 @@ nsGroupBoxFrame::Paint(nsIPresContext* aPresContext,
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *borderStyleData,
*paddingStyleData, 0, 0, PR_FALSE);
*paddingStyleData, PR_FALSE);
if (groupBox) {

Просмотреть файл

@ -3152,7 +3152,7 @@ nsTreeBodyFrame::PaintBackgroundLayer(nsStyleContext* aStyleContext,
nsCSSRendering::PaintBackgroundWithSC(aPresContext, aRenderingContext,
this, aDirtyRect, aRect,
*myColor, *myBorder, *myPadding,
0, 0);
PR_TRUE);
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
aDirtyRect, aRect, *myBorder, mStyleContext, 0);