mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-11 12:25:53 +00:00
Bug 584516. With linked view manager hierarchies we need to draw the print preview background on subdocument frames as well. r=roc
This commit is contained in:
parent
f972d43f24
commit
6ed096006a
@ -137,8 +137,8 @@ typedef struct CapturingContentInfo {
|
||||
} CapturingContentInfo;
|
||||
|
||||
#define NS_IPRESSHELL_IID \
|
||||
{ 0xb2d3df3b, 0x54ba, 0x44cf, \
|
||||
{ 0x8c, 0xfd, 0x24, 0x84, 0x3e, 0xac, 0x27, 0x96 } }
|
||||
{ 0xe31f651a, 0x8c88, 0x4f19, \
|
||||
{ 0x8a, 0xb0, 0x00, 0x1f, 0x94, 0xed, 0x5f, 0xbd } }
|
||||
|
||||
// Constants for ScrollContentIntoView() function
|
||||
#define NS_PRESSHELL_SCROLL_TOP 0
|
||||
@ -952,6 +952,16 @@ public:
|
||||
nscolor aBackstopColor = NS_RGBA(0,0,0,0),
|
||||
PRBool aForceDraw = PR_FALSE) = 0;
|
||||
|
||||
/**
|
||||
* Add a solid color item to the bottom of aList with frame aFrame and
|
||||
* bounds aBounds representing the dark grey background behind the page of a
|
||||
* print preview presentation.
|
||||
*/
|
||||
virtual nsresult AddPrintPreviewBackgroundItem(nsDisplayListBuilder& aBuilder,
|
||||
nsDisplayList& aList,
|
||||
nsIFrame* aFrame,
|
||||
const nsRect& aBounds) = 0;
|
||||
|
||||
void ObserveNativeAnonMutationsForPrint(PRBool aObserve)
|
||||
{
|
||||
mObservesMutationsForPrint = aObserve;
|
||||
|
@ -1290,14 +1290,11 @@ nsLayoutUtils::PaintFrame(nsIRenderingContext* aRenderingContext, nsIFrame* aFra
|
||||
nsIAtom* frameType = aFrame->GetType();
|
||||
// For the viewport frame in print preview/page layout we want to paint
|
||||
// the grey background behind the page, not the canvas color.
|
||||
if (frameType == nsGkAtoms::viewportFrame &&
|
||||
presContext->IsRootPaginatedDocument() &&
|
||||
(presContext->Type() == nsPresContext::eContext_PrintPreview ||
|
||||
presContext->Type() == nsPresContext::eContext_PageLayout)) {
|
||||
if (frameType == nsGkAtoms::viewportFrame &&
|
||||
nsLayoutUtils::NeedsPrintPreviewBackground(presContext)) {
|
||||
nsRect bounds = nsRect(builder.ToReferenceFrame(aFrame),
|
||||
aFrame->GetSize());
|
||||
rv = list.AppendNewToBottom(new (&builder) nsDisplaySolidColor(
|
||||
aFrame, bounds, NS_RGB(115, 115, 115)));
|
||||
rv = presShell->AddPrintPreviewBackgroundItem(builder, list, aFrame, bounds);
|
||||
} else if (frameType != nsGkAtoms::pageFrame) {
|
||||
// For printing, this function is first called on an nsPageFrame, which
|
||||
// creates a display list with a PageContent item. The PageContent item's
|
||||
|
@ -1138,6 +1138,16 @@ public:
|
||||
*/
|
||||
static nsIContent*
|
||||
GetEditableRootContentByContentEditable(nsIDocument* aDocument);
|
||||
|
||||
/**
|
||||
* Returns true if the passed in prescontext needs the dark grey background
|
||||
* that goes behind the page of a print preview presentation.
|
||||
*/
|
||||
static PRBool NeedsPrintPreviewBackground(nsPresContext* aPresContext) {
|
||||
return aPresContext->IsRootPaginatedDocument() &&
|
||||
(aPresContext->Type() == nsPresContext::eContext_PrintPreview ||
|
||||
aPresContext->Type() == nsPresContext::eContext_PageLayout);
|
||||
}
|
||||
};
|
||||
|
||||
class nsSetAttrRunnable : public nsRunnable
|
||||
|
@ -951,6 +951,11 @@ public:
|
||||
nscolor aBackstopColor,
|
||||
PRBool aForceDraw);
|
||||
|
||||
virtual nsresult AddPrintPreviewBackgroundItem(nsDisplayListBuilder& aBuilder,
|
||||
nsDisplayList& aList,
|
||||
nsIFrame* aFrame,
|
||||
const nsRect& aBounds);
|
||||
|
||||
protected:
|
||||
virtual ~PresShell();
|
||||
|
||||
@ -5732,6 +5737,16 @@ PresShell::RenderSelection(nsISelection* aSelection,
|
||||
aScreenRect);
|
||||
}
|
||||
|
||||
nsresult
|
||||
PresShell::AddPrintPreviewBackgroundItem(nsDisplayListBuilder& aBuilder,
|
||||
nsDisplayList& aList,
|
||||
nsIFrame* aFrame,
|
||||
const nsRect& aBounds)
|
||||
{
|
||||
return aList.AppendNewToBottom(
|
||||
new (&aBuilder) nsDisplaySolidColor(aFrame, aBounds, NS_RGB(115, 115, 115)));
|
||||
}
|
||||
|
||||
static PRBool
|
||||
AddCanvasBackgroundColor(const nsDisplayList& aList, nsIFrame* aCanvasFrame,
|
||||
nscolor aColor)
|
||||
|
@ -415,10 +415,12 @@ nsSubDocumentFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
||||
}
|
||||
}
|
||||
|
||||
nsPresContext* presContext = presShell->GetPresContext();
|
||||
|
||||
nsDisplayList childItems;
|
||||
|
||||
PRInt32 parentAPD = PresContext()->AppUnitsPerDevPixel();
|
||||
PRInt32 subdocAPD = presShell->GetPresContext()->AppUnitsPerDevPixel();
|
||||
PRInt32 subdocAPD = presContext->AppUnitsPerDevPixel();
|
||||
|
||||
nsRect dirty;
|
||||
if (subdocRootFrame) {
|
||||
@ -459,12 +461,22 @@ nsSubDocumentFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
||||
} else {
|
||||
bounds = subdocBoundsInParentUnits;
|
||||
}
|
||||
// Add the canvas background color to the bottom of the list. This
|
||||
// happens after we've built the list so that AddCanvasBackgroundColorItem
|
||||
// can monkey with the contents if necessary.
|
||||
rv = presShell->AddCanvasBackgroundColorItem(
|
||||
*aBuilder, childItems, subdocRootFrame ? subdocRootFrame : this,
|
||||
bounds, NS_RGBA(0,0,0,0), PR_TRUE);
|
||||
|
||||
// If we are in print preview/page layout we want to paint the grey
|
||||
// background behind the page, not the canvas color. The canvas color gets
|
||||
// painted on the page itself.
|
||||
if (nsLayoutUtils::NeedsPrintPreviewBackground(presContext)) {
|
||||
rv = presShell->AddPrintPreviewBackgroundItem(
|
||||
*aBuilder, childItems, subdocRootFrame ? subdocRootFrame : this,
|
||||
bounds);
|
||||
} else {
|
||||
// Add the canvas background color to the bottom of the list. This
|
||||
// happens after we've built the list so that AddCanvasBackgroundColorItem
|
||||
// can monkey with the contents if necessary.
|
||||
rv = presShell->AddCanvasBackgroundColorItem(
|
||||
*aBuilder, childItems, subdocRootFrame ? subdocRootFrame : this,
|
||||
bounds, NS_RGBA(0,0,0,0), PR_TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
|
Loading…
Reference in New Issue
Block a user