Bug 371528: Stop creating views for pages. r+sr=roc.

This commit is contained in:
sharparrow1%yahoo.com 2007-02-25 22:26:47 +00:00
Родитель 7bfe821507
Коммит 884351335b
6 изменённых файлов: 23 добавлений и 144 удалений

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

@ -4602,10 +4602,6 @@ nsCSSFrameConstructor::ConstructPageFrame(nsIPresShell* aPresShell,
// Initialize the page frame and force it to have a view. This makes printing of // Initialize the page frame and force it to have a view. This makes printing of
// the pages easier and faster. // the pages easier and faster.
aPageFrame->Init(nsnull, aParentFrame, aPrevPageFrame); aPageFrame->Init(nsnull, aParentFrame, aPrevPageFrame);
// XXXbz should we be passing in a non-null aContentParentFrame?
nsresult rv = nsHTMLContainerFrame::CreateViewForFrame(aPageFrame, nsnull, PR_TRUE);
if (NS_FAILED(rv))
return NS_ERROR_NULL_POINTER;
nsRefPtr<nsStyleContext> pageContentPseudoStyle; nsRefPtr<nsStyleContext> pageContentPseudoStyle;
pageContentPseudoStyle = styleSet->ResolvePseudoStyleFor(nsnull, pageContentPseudoStyle = styleSet->ResolvePseudoStyleFor(nsnull,
@ -4619,17 +4615,13 @@ nsCSSFrameConstructor::ConstructPageFrame(nsIPresShell* aPresShell,
// Initialize the page content frame and force it to have a view. Also make it the // Initialize the page content frame and force it to have a view. Also make it the
// containing block for fixed elements which are repeated on every page. // containing block for fixed elements which are repeated on every page.
aPageContentFrame->Init(nsnull, aPageFrame, nsnull); aPageContentFrame->Init(nsnull, aPageFrame, nsnull);
// XXXbz should we be passing in a non-null aContentParentFrame?
nsHTMLContainerFrame::CreateViewForFrame(aPageContentFrame, nsnull, PR_TRUE);
if (NS_FAILED(rv))
return NS_ERROR_NULL_POINTER;
mFixedContainingBlock = aPageContentFrame; mFixedContainingBlock = aPageContentFrame;
aPageFrame->SetInitialChildList(nsnull, aPageContentFrame); aPageFrame->SetInitialChildList(nsnull, aPageContentFrame);
// Fixed pos kids are taken care of directly in CreateContinuingFrame() // Fixed pos kids are taken care of directly in CreateContinuingFrame()
return rv; return NS_OK;
} }
/* static */ /* static */

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

@ -561,6 +561,11 @@ nsPageFrame::PaintPageContent(nsIRenderingContext& aRenderingContext,
nsRect rect = aDirtyRect; nsRect rect = aDirtyRect;
float scale = GetPresContext()->GetPageScale(); float scale = GetPresContext()->GetPageScale();
aRenderingContext.PushState(); aRenderingContext.PushState();
// Make sure we don't draw where we aren't supposed to draw, especially
// when printing selection
nsRect clipRect(nsPoint(0, 0), GetSize());
clipRect.Deflate(mPD->mReflowMargin);
aRenderingContext.SetClipRect(clipRect, nsClipCombine_kIntersect);
// aPt translates to coords relative to this, then margins translate to // aPt translates to coords relative to this, then margins translate to
// pageContentFrame's coords // pageContentFrame's coords
nsPoint framePos = aPt + pageContentFrame->GetOffsetTo(this); nsPoint framePos = aPt + pageContentFrame->GetOffsetTo(this);

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

@ -41,7 +41,6 @@
#include "nsIRenderingContext.h" #include "nsIRenderingContext.h"
#include "nsGkAtoms.h" #include "nsGkAtoms.h"
#include "nsIDeviceContext.h" #include "nsIDeviceContext.h"
#include "nsIViewManager.h"
#include "nsIPresShell.h" #include "nsIPresShell.h"
#include "nsIFontMetrics.h" #include "nsIFontMetrics.h"
#include "nsIPrintSettings.h" #include "nsIPrintSettings.h"
@ -275,8 +274,6 @@ nsSimplePageSequenceFrame::Reflow(nsPresContext* aPresContext,
const nscoord x = deadSpaceGap; const nscoord x = deadSpaceGap;
nscoord y = deadSpaceGap;// Running y-offset for each page nscoord y = deadSpaceGap;// Running y-offset for each page
nsSize reflowPageSize(0,0);
nsSize availSize(pageSize.width + shadowSize.width + extraMargin.LeftRight(), nsSize availSize(pageSize.width + shadowSize.width + extraMargin.LeftRight(),
pageSize.height + shadowSize.height + pageSize.height + shadowSize.height +
extraMargin.TopBottom()); extraMargin.TopBottom());
@ -301,8 +298,6 @@ nsSimplePageSequenceFrame::Reflow(nsPresContext* aPresContext,
// max width then center it horizontally // max width then center it horizontally
ReflowChild(kidFrame, aPresContext, kidSize, kidReflowState, x, y, 0, status); ReflowChild(kidFrame, aPresContext, kidSize, kidReflowState, x, y, 0, status);
reflowPageSize.SizeTo(kidSize.width, kidSize.height);
FinishReflowChild(kidFrame, aPresContext, nsnull, kidSize, x, y, 0); FinishReflowChild(kidFrame, aPresContext, nsnull, kidSize, x, y, 0);
y += kidSize.height; y += kidSize.height;
@ -497,35 +492,6 @@ nsSimplePageSequenceFrame::StartPrint(nsPresContext* aPresContext,
// Begin printing of the document // Begin printing of the document
nsresult rv = NS_OK; nsresult rv = NS_OK;
#if defined(DEBUG_rods) || defined(DEBUG_dcone)
{
nsIView* seqView = GetView();
nsRect rect = GetRect();
PR_PL(("Seq Frame: %p - [%5d,%5d,%5d,%5d] ", this, rect.x, rect.y, rect.width, rect.height));
PR_PL(("view: %p ", seqView));
if (seqView) {
nsRect viewRect = seqView->GetBounds();
PR_PL((" [%5d,%5d,%5d,%5d]", viewRect.x, viewRect.y, viewRect.width, viewRect.height));
}
PR_PL(("\n"));
}
{
PRInt32 pageNum = 1;
for (nsIFrame* page = mFrames.FirstChild(); page;
page = page->GetNextSibling()) {
nsIView* view = page->GetView();
NS_ASSERTION(view, "no page view");
nsRect rect = page->GetRect();
nsRect viewRect = view->GetBounds();
PR_PL((" Page: %p No: %d - [%5d,%5d,%5d,%5d] ", page, pageNum, rect.x, rect.y, rect.width, rect.height));
PR_PL((" [%5d,%5d,%5d,%5d]\n", viewRect.x, viewRect.y, viewRect.width, viewRect.height));
pageNum++;
}
}
//printf("***** Setting aPresContext %p is painting selection %d\n", aPresContext, nsIPrintSettings::kRangeSelection == mPrintRangeType);
#endif
// Determine if we are rendering only the selection // Determine if we are rendering only the selection
aPresContext->SetIsRenderingOnlySelection(nsIPrintSettings::kRangeSelection == mPrintRangeType); aPresContext->SetIsRenderingOnlySelection(nsIPrintSettings::kRangeSelection == mPrintRangeType);
@ -541,31 +507,11 @@ nsSimplePageSequenceFrame::StartPrint(nsPresContext* aPresContext,
for (nsIFrame* page = mFrames.FirstChild(); page; for (nsIFrame* page = mFrames.FirstChild(); page;
page = page->GetNextSibling()) { page = page->GetNextSibling()) {
nsIView* view = page->GetView(); if (pageNum >= mFromPageNum && pageNum <= mToPageNum) {
NS_ASSERTION(view, "no page view");
nsIViewManager* vm = view->GetViewManager();
NS_ASSERTION(vm, "no view manager");
if (pageNum < mFromPageNum || pageNum > mToPageNum) {
// Hide the pages that won't be printed to the Viewmanager
// doesn't put them in the display list. Also, makde
// sure the child views don't get asked to print
// but my guess is that there won't be any
vm->SetViewVisibility(view, nsViewVisibility_kHide);
} else {
nsRect rect = page->GetRect(); nsRect rect = page->GetRect();
rect.y = y; rect.y = y;
rect.height = height; rect.height = height;
page->SetRect(rect); page->SetRect(rect);
nsRect viewRect = view->GetBounds();
viewRect.y = y;
viewRect.height = height;
vm->MoveViewTo(view, viewRect.x, viewRect.y);
viewRect.x = 0;
viewRect.y = 0;
vm->ResizeView(view, viewRect);
y += rect.height + mMargin.top + mMargin.bottom; y += rect.height + mMargin.top + mMargin.bottom;
} }
pageNum++; pageNum++;
@ -612,8 +558,6 @@ nsSimplePageSequenceFrame::PrintNextPage()
// Begin printing of the document // Begin printing of the document
nsIDeviceContext *dc = GetPresContext()->DeviceContext(); nsIDeviceContext *dc = GetPresContext()->DeviceContext();
nsIViewManager* vm = GetPresContext()->GetViewManager();
nsresult rv = NS_OK; nsresult rv = NS_OK;
// See whether we should print this page // See whether we should print this page
@ -656,24 +600,12 @@ nsSimplePageSequenceFrame::PrintNextPage()
PRBool continuePrinting = PR_TRUE; PRBool continuePrinting = PR_TRUE;
PRInt32 width, height; PRInt32 width, height;
dc->GetDeviceSurfaceDimensions(width, height); dc->GetDeviceSurfaceDimensions(width, height);
nsRect clipRect(0, 0, width, height);
height -= mMargin.top + mMargin.bottom; height -= mMargin.top + mMargin.bottom;
width -= mMargin.left + mMargin.right; width -= mMargin.left + mMargin.right;
nscoord selectionY = height; nscoord selectionY = height;
nsIView* containerView = nsnull; nsIFrame* conFrame = mCurrentPageFrame->GetFirstChild(nsnull);
nsRect containerRect;
if (mSelectionHeight > -1) { if (mSelectionHeight > -1) {
nsIFrame* childFrame = mFrames.FirstChild(); conFrame->SetPosition(conFrame->GetPosition() + nsPoint(0, -mYSelOffset));
nsIFrame* conFrame = childFrame->GetFirstChild(nsnull);
containerView = conFrame->GetView();
NS_ASSERTION(containerView, "Container view can't be null!");
containerRect = containerView->GetBounds();
containerRect.y -= mYSelOffset;
vm->MoveViewTo(containerView, containerRect.x, containerRect.y);
nsRect r(0, 0, containerRect.width, containerRect.height);
vm->ResizeView(containerView, r, PR_FALSE);
clipRect.SetRect(mMargin.left, mMargin.right, width, height);
} }
// cast the frame to be a page frame // cast the frame to be a page frame
@ -690,26 +622,22 @@ nsSimplePageSequenceFrame::PrintNextPage()
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
} }
PR_PL(("SeqFr::Paint -> %p PageNo: %d", pf, mPageNum));
// Print the page nsCOMPtr<nsIRenderingContext> renderingContext;
nsIView* view = mCurrentPageFrame->GetView(); GetPresContext()->PresShell()->
CreateRenderingContext(mCurrentPageFrame,
NS_ASSERTION(view, "no page view"); getter_AddRefs(renderingContext));
nsRegion drawingRegion(nsRect(nsPoint(0, 0),
PR_PL(("SeqFr::Paint -> %p PageNo: %d View: %p", pf, mPageNum, view)); mCurrentPageFrame->GetSize()));
nsLayoutUtils::PaintFrame(renderingContext, mCurrentPageFrame,
vm->Display(view, 0, 0, clipRect); drawingRegion, NS_RGBA(0,0,0,0));
if (mSelectionHeight > -1 && selectionY < mSelectionHeight) { if (mSelectionHeight > -1 && selectionY < mSelectionHeight) {
selectionY += height; selectionY += height;
printedPageNum++; printedPageNum++;
pf->SetPageNumInfo(printedPageNum, mTotalPages); pf->SetPageNumInfo(printedPageNum, mTotalPages);
containerRect.y -= height; conFrame->SetPosition(conFrame->GetPosition() + nsPoint(0, -height));
containerRect.height += height;
vm->MoveViewTo(containerView, containerRect.x, containerRect.y);
nsRect r(0, 0, containerRect.width, containerRect.height);
vm->ResizeView(containerView, r, PR_FALSE);
PR_PL(("***************** End Page (PrintNextPage) *****************\n")); PR_PL(("***************** End Page (PrintNextPage) *****************\n"));
rv = dc->EndPage(); rv = dc->EndPage();

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

@ -62,10 +62,10 @@ enum nsRectVisibility {
nsRectVisibility_kZeroAreaRect nsRectVisibility_kZeroAreaRect
}; };
// 38439490-51d4-416a-a12f-20535d9d8119 // 143945d0-0a20-4bf0-a04d-ad212ab9acc2
#define NS_IVIEWMANAGER_IID \ #define NS_IVIEWMANAGER_IID \
{ 0x38439490, 0x51d4, 0x416a, \ { 0x143945d0, 0x0a20, 0x4bf0, \
{ 0xa1, 0x2f, 0x20, 0x53, 0x5d, 0x9d, 0x81, 0x19 } } { 0xa0, 0x4d, 0xad, 0x21, 0x2a, 0xb9, 0xac, 0xc2 } }
class nsIViewManager : public nsISupports class nsIViewManager : public nsISupports
{ {
@ -389,12 +389,6 @@ public:
*/ */
NS_IMETHOD GetRootScrollableView(nsIScrollableView **aScrollable) = 0; NS_IMETHOD GetRootScrollableView(nsIScrollableView **aScrollable) = 0;
/**
* Display the specified view. Used when printing.
*/
//XXXbz how is this different from UpdateView(NS_VMREFRESH_IMMEDIATE)?
NS_IMETHOD Display(nsIView *aView, nscoord aX, nscoord aY, const nsRect& aClipRect) = 0;
/** /**
* Dump the specified view into a new offscreen rendering context. * Dump the specified view into a new offscreen rendering context.
* @param aRect is the region to capture into the offscreen buffer, in the view's * @param aRect is the region to capture into the offscreen buffer, in the view's

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

@ -72,9 +72,6 @@ static NS_DEFINE_IID(kBlenderCID, NS_BLENDER_CID);
static NS_DEFINE_IID(kRegionCID, NS_REGION_CID); static NS_DEFINE_IID(kRegionCID, NS_REGION_CID);
static NS_DEFINE_IID(kRenderingContextCID, NS_RENDERING_CONTEXT_CID); static NS_DEFINE_IID(kRenderingContextCID, NS_RENDERING_CONTEXT_CID);
#define ARENA_ALLOCATE(var, pool, type) \
{void *_tmp_; PL_ARENA_ALLOCATE(_tmp_, pool, sizeof(type)); \
var = NS_REINTERPRET_CAST(type*, _tmp_); }
/** /**
XXX TODO XXX XXX TODO XXX
@ -2327,41 +2324,6 @@ NS_IMETHODIMP nsViewManager::RenderOffscreen(nsIView* aView, nsRect aRect,
aBackgroundColor, aRenderedContext); aBackgroundColor, aRenderedContext);
} }
NS_IMETHODIMP nsViewManager::Display(nsIView* aView, nscoord aX, nscoord aY, const nsRect& aClipRect)
{
nsView *view = NS_STATIC_CAST(nsView*, aView);
nsCOMPtr<nsIRenderingContext> localcx;
if (! IsRefreshEnabled() || !mObserver)
return NS_OK;
NS_ASSERTION(!IsPainting(), "recursive painting not permitted");
SetPainting(PR_TRUE);
mContext->CreateRenderingContext(*getter_AddRefs(localcx));
//couldn't get rendering context. this is ok if at startup
if (nsnull == localcx)
{
SetPainting(PR_FALSE);
return NS_ERROR_FAILURE;
}
nsRect trect = view->GetBounds();
view->ConvertFromParentCoords(&trect.x, &trect.y);
localcx->Translate(aX, aY);
localcx->SetClipRect(aClipRect, nsClipCombine_kReplace);
nsresult rv = mObserver->Paint(view, localcx, nsRegion(trect));
SetPainting(PR_FALSE);
return rv;
}
NS_IMETHODIMP nsViewManager::AddCompositeListener(nsICompositeListener* aListener) NS_IMETHODIMP nsViewManager::AddCompositeListener(nsICompositeListener* aListener)
{ {
if (nsnull == mCompositeListeners) { if (nsnull == mCompositeListeners) {

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

@ -222,8 +222,6 @@ public:
NS_IMETHOD SetRootScrollableView(nsIScrollableView *aScrollable); NS_IMETHOD SetRootScrollableView(nsIScrollableView *aScrollable);
NS_IMETHOD GetRootScrollableView(nsIScrollableView **aScrollable); NS_IMETHOD GetRootScrollableView(nsIScrollableView **aScrollable);
NS_IMETHOD Display(nsIView *aView, nscoord aX, nscoord aY, const nsRect& aClipRect);
NS_IMETHOD RenderOffscreen(nsIView* aView, nsRect aRect, PRBool aUntrusted, NS_IMETHOD RenderOffscreen(nsIView* aView, nsRect aRect, PRBool aUntrusted,
PRBool aIgnoreViewportScrolling, PRBool aIgnoreViewportScrolling,
nscolor aBackgroundColor, nscolor aBackgroundColor,