зеркало из https://github.com/mozilla/gecko-dev.git
Bug 371528: Stop creating views for pages. r+sr=roc.
This commit is contained in:
Родитель
7bfe821507
Коммит
884351335b
|
@ -4602,10 +4602,6 @@ nsCSSFrameConstructor::ConstructPageFrame(nsIPresShell* aPresShell,
|
|||
// Initialize the page frame and force it to have a view. This makes printing of
|
||||
// the pages easier and faster.
|
||||
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;
|
||||
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
|
||||
// containing block for fixed elements which are repeated on every page.
|
||||
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;
|
||||
|
||||
aPageFrame->SetInitialChildList(nsnull, aPageContentFrame);
|
||||
|
||||
// Fixed pos kids are taken care of directly in CreateContinuingFrame()
|
||||
|
||||
return rv;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* static */
|
||||
|
|
|
@ -561,6 +561,11 @@ nsPageFrame::PaintPageContent(nsIRenderingContext& aRenderingContext,
|
|||
nsRect rect = aDirtyRect;
|
||||
float scale = GetPresContext()->GetPageScale();
|
||||
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
|
||||
// pageContentFrame's coords
|
||||
nsPoint framePos = aPt + pageContentFrame->GetOffsetTo(this);
|
||||
|
|
|
@ -41,7 +41,6 @@
|
|||
#include "nsIRenderingContext.h"
|
||||
#include "nsGkAtoms.h"
|
||||
#include "nsIDeviceContext.h"
|
||||
#include "nsIViewManager.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsIFontMetrics.h"
|
||||
#include "nsIPrintSettings.h"
|
||||
|
@ -275,8 +274,6 @@ nsSimplePageSequenceFrame::Reflow(nsPresContext* aPresContext,
|
|||
const nscoord x = deadSpaceGap;
|
||||
nscoord y = deadSpaceGap;// Running y-offset for each page
|
||||
|
||||
nsSize reflowPageSize(0,0);
|
||||
|
||||
nsSize availSize(pageSize.width + shadowSize.width + extraMargin.LeftRight(),
|
||||
pageSize.height + shadowSize.height +
|
||||
extraMargin.TopBottom());
|
||||
|
@ -301,8 +298,6 @@ nsSimplePageSequenceFrame::Reflow(nsPresContext* aPresContext,
|
|||
// max width then center it horizontally
|
||||
ReflowChild(kidFrame, aPresContext, kidSize, kidReflowState, x, y, 0, status);
|
||||
|
||||
reflowPageSize.SizeTo(kidSize.width, kidSize.height);
|
||||
|
||||
FinishReflowChild(kidFrame, aPresContext, nsnull, kidSize, x, y, 0);
|
||||
y += kidSize.height;
|
||||
|
||||
|
@ -497,35 +492,6 @@ nsSimplePageSequenceFrame::StartPrint(nsPresContext* aPresContext,
|
|||
// Begin printing of the document
|
||||
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
|
||||
aPresContext->SetIsRenderingOnlySelection(nsIPrintSettings::kRangeSelection == mPrintRangeType);
|
||||
|
||||
|
@ -541,31 +507,11 @@ nsSimplePageSequenceFrame::StartPrint(nsPresContext* aPresContext,
|
|||
|
||||
for (nsIFrame* page = mFrames.FirstChild(); page;
|
||||
page = page->GetNextSibling()) {
|
||||
nsIView* view = page->GetView();
|
||||
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 {
|
||||
if (pageNum >= mFromPageNum && pageNum <= mToPageNum) {
|
||||
nsRect rect = page->GetRect();
|
||||
rect.y = y;
|
||||
rect.height = height;
|
||||
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;
|
||||
}
|
||||
pageNum++;
|
||||
|
@ -612,8 +558,6 @@ nsSimplePageSequenceFrame::PrintNextPage()
|
|||
// Begin printing of the document
|
||||
nsIDeviceContext *dc = GetPresContext()->DeviceContext();
|
||||
|
||||
nsIViewManager* vm = GetPresContext()->GetViewManager();
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
// See whether we should print this page
|
||||
|
@ -656,24 +600,12 @@ nsSimplePageSequenceFrame::PrintNextPage()
|
|||
PRBool continuePrinting = PR_TRUE;
|
||||
PRInt32 width, height;
|
||||
dc->GetDeviceSurfaceDimensions(width, height);
|
||||
nsRect clipRect(0, 0, width, height);
|
||||
height -= mMargin.top + mMargin.bottom;
|
||||
width -= mMargin.left + mMargin.right;
|
||||
nscoord selectionY = height;
|
||||
nsIView* containerView = nsnull;
|
||||
nsRect containerRect;
|
||||
nsIFrame* conFrame = mCurrentPageFrame->GetFirstChild(nsnull);
|
||||
if (mSelectionHeight > -1) {
|
||||
nsIFrame* childFrame = mFrames.FirstChild();
|
||||
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);
|
||||
conFrame->SetPosition(conFrame->GetPosition() + nsPoint(0, -mYSelOffset));
|
||||
}
|
||||
|
||||
// cast the frame to be a page frame
|
||||
|
@ -690,26 +622,22 @@ nsSimplePageSequenceFrame::PrintNextPage()
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
PR_PL(("SeqFr::Paint -> %p PageNo: %d", pf, mPageNum));
|
||||
|
||||
// Print the page
|
||||
nsIView* view = mCurrentPageFrame->GetView();
|
||||
|
||||
NS_ASSERTION(view, "no page view");
|
||||
|
||||
PR_PL(("SeqFr::Paint -> %p PageNo: %d View: %p", pf, mPageNum, view));
|
||||
|
||||
vm->Display(view, 0, 0, clipRect);
|
||||
nsCOMPtr<nsIRenderingContext> renderingContext;
|
||||
GetPresContext()->PresShell()->
|
||||
CreateRenderingContext(mCurrentPageFrame,
|
||||
getter_AddRefs(renderingContext));
|
||||
nsRegion drawingRegion(nsRect(nsPoint(0, 0),
|
||||
mCurrentPageFrame->GetSize()));
|
||||
nsLayoutUtils::PaintFrame(renderingContext, mCurrentPageFrame,
|
||||
drawingRegion, NS_RGBA(0,0,0,0));
|
||||
|
||||
if (mSelectionHeight > -1 && selectionY < mSelectionHeight) {
|
||||
selectionY += height;
|
||||
|
||||
printedPageNum++;
|
||||
pf->SetPageNumInfo(printedPageNum, mTotalPages);
|
||||
containerRect.y -= 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);
|
||||
conFrame->SetPosition(conFrame->GetPosition() + nsPoint(0, -height));
|
||||
|
||||
PR_PL(("***************** End Page (PrintNextPage) *****************\n"));
|
||||
rv = dc->EndPage();
|
||||
|
|
|
@ -62,10 +62,10 @@ enum nsRectVisibility {
|
|||
nsRectVisibility_kZeroAreaRect
|
||||
};
|
||||
|
||||
// 38439490-51d4-416a-a12f-20535d9d8119
|
||||
// 143945d0-0a20-4bf0-a04d-ad212ab9acc2
|
||||
#define NS_IVIEWMANAGER_IID \
|
||||
{ 0x38439490, 0x51d4, 0x416a, \
|
||||
{ 0xa1, 0x2f, 0x20, 0x53, 0x5d, 0x9d, 0x81, 0x19 } }
|
||||
{ 0x143945d0, 0x0a20, 0x4bf0, \
|
||||
{ 0xa0, 0x4d, 0xad, 0x21, 0x2a, 0xb9, 0xac, 0xc2 } }
|
||||
|
||||
class nsIViewManager : public nsISupports
|
||||
{
|
||||
|
@ -389,12 +389,6 @@ public:
|
|||
*/
|
||||
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.
|
||||
* @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(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
|
||||
|
||||
|
@ -2327,41 +2324,6 @@ NS_IMETHODIMP nsViewManager::RenderOffscreen(nsIView* aView, nsRect aRect,
|
|||
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)
|
||||
{
|
||||
if (nsnull == mCompositeListeners) {
|
||||
|
|
|
@ -222,8 +222,6 @@ public:
|
|||
NS_IMETHOD SetRootScrollableView(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,
|
||||
PRBool aIgnoreViewportScrolling,
|
||||
nscolor aBackgroundColor,
|
||||
|
|
Загрузка…
Ссылка в новой задаче