Moved creation of first page frame to frame construction code, and changed

it so the page frame has a view. This makes printing faster and easier
This commit is contained in:
troy%netscape.com 1998-12-04 21:04:56 +00:00
Родитель b166cf8cdf
Коммит 62857a1141
11 изменённых файлов: 80 добавлений и 73 удалений

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

@ -1378,19 +1378,30 @@ HTMLStyleSheetImpl::ConstructRootFrame(nsIPresContext* aPresContext,
// Create a simple page sequence frame
rv = NS_NewSimplePageSequenceFrame(pageSequenceFrame);
if (NS_SUCCEEDED(rv)) {
nsIFrame* pageFrame;
nsIFrame* childList;
// Initialize the frame and force it to have a view
pageSequenceFrame->Init(*aPresContext, aContent, scrollFrame, pseudoStyle);
NS_RELEASE(pseudoStyle);
nsHTMLContainerFrame::CreateViewForFrame(*aPresContext, pageSequenceFrame,
pseudoStyle, PR_TRUE);
// Create the first page
NS_NewPageFrame(pageFrame);
// Initialize it and force it to have a view
// XXX Use a PAGE style context...
pageFrame->Init(*aPresContext, aContent, pageSequenceFrame, pseudoStyle);
nsHTMLContainerFrame::CreateViewForFrame(*aPresContext, pageFrame,
pseudoStyle, PR_TRUE);
NS_RELEASE(pseudoStyle);
// Process the child content, and set the page sequence frame's initial
// child list
rv = ProcessChildren(aPresContext, pageSequenceFrame, aContent, childList);
// Process the child content, and set the page and page sequence frame's
// initial child lists
rv = ProcessChildren(aPresContext, pageFrame, aContent, childList);
if (NS_SUCCEEDED(rv)) {
pageSequenceFrame->SetInitialChildList(*aPresContext, nsnull, childList);
pageFrame->SetInitialChildList(*aPresContext, nsnull, childList);
pageSequenceFrame->SetInitialChildList(*aPresContext, nsnull, pageFrame);
// Set the scroll frame's initial child list
scrollFrame->SetInitialChildList(*aPresContext, nsnull, pageSequenceFrame);

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

@ -267,6 +267,7 @@ extern nsresult NS_NewTextFrame(nsIFrame*& aResult);
extern nsresult NS_NewWBRFrame(nsIFrame*& aResult);
extern nsresult NS_NewScrollFrame(nsIFrame*& aResult);
extern nsresult NS_NewSimplePageSequenceFrame(nsIFrame*& aResult);
extern nsresult NS_NewPageFrame(nsIFrame*& aResult);
// forms
extern nsresult NS_NewFormFrame(nsIFrame*& aResult);

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

@ -155,3 +155,16 @@ nsPageFrame::GetFrameName(nsString& aResult) const
return MakeFrameName("Page", aResult);
}
//----------------------------------------------------------------------
nsresult
NS_NewPageFrame(nsIFrame*& aResult)
{
nsPageFrame* it = new nsPageFrame;
if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY;
}
aResult = it;
return NS_OK;
}

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

@ -24,31 +24,6 @@
#include "nsIStyleContext.h"
#include "nsHTMLAtoms.h"
NS_IMETHODIMP
nsSimplePageSequenceFrame::SetInitialChildList(nsIPresContext& aPresContext,
nsIAtom* aListName,
nsIFrame* aChildList)
{
// Create a page frame and initialize it
mFirstChild = new nsPageFrame;
// XXX This is all wrong...
nsIStyleContext* pseudoStyleContext =
aPresContext.ResolvePseudoStyleContextFor(mContent, nsHTMLAtoms::columnPseudo, mStyleContext);
mFirstChild->Init(aPresContext, mContent, this, pseudoStyleContext);
NS_RELEASE(pseudoStyleContext);
// Set the geometric and content parent for each of the child frames to be the
// page frame
for (nsIFrame* frame = aChildList; nsnull != frame; frame->GetNextSibling(frame)) {
frame->SetGeometricParent(mFirstChild);
frame->SetContentParent(mFirstChild);
}
// Queue up the frames for the page frame
return mFirstChild->SetInitialChildList(aPresContext, nsnull, aChildList);
}
// XXX Hack
#define PAGE_SPACING_TWIPS 100
@ -159,6 +134,8 @@ nsSimplePageSequenceFrame::Reflow(nsIPresContext& aPresContext,
nsIFrame* continuingPage;
nsresult rv = kidFrame->CreateContinuingFrame(aPresContext, this,
kidSC, continuingPage);
nsHTMLContainerFrame::CreateViewForFrame(aPresContext, continuingPage,
kidSC, PR_TRUE);
NS_RELEASE(kidSC);
reflowReason = eReflowReason_Initial;

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

@ -23,10 +23,6 @@
// Simple page sequence frame class. Used when we're in paginated mode
class nsSimplePageSequenceFrame : public nsContainerFrame {
public:
NS_IMETHOD SetInitialChildList(nsIPresContext& aPresContext,
nsIAtom* aListName,
nsIFrame* aChildList);
NS_IMETHOD Reflow(nsIPresContext& aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aMaxSize,

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

@ -267,6 +267,7 @@ extern nsresult NS_NewTextFrame(nsIFrame*& aResult);
extern nsresult NS_NewWBRFrame(nsIFrame*& aResult);
extern nsresult NS_NewScrollFrame(nsIFrame*& aResult);
extern nsresult NS_NewSimplePageSequenceFrame(nsIFrame*& aResult);
extern nsresult NS_NewPageFrame(nsIFrame*& aResult);
// forms
extern nsresult NS_NewFormFrame(nsIFrame*& aResult);

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

@ -155,3 +155,16 @@ nsPageFrame::GetFrameName(nsString& aResult) const
return MakeFrameName("Page", aResult);
}
//----------------------------------------------------------------------
nsresult
NS_NewPageFrame(nsIFrame*& aResult)
{
nsPageFrame* it = new nsPageFrame;
if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY;
}
aResult = it;
return NS_OK;
}

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

@ -24,31 +24,6 @@
#include "nsIStyleContext.h"
#include "nsHTMLAtoms.h"
NS_IMETHODIMP
nsSimplePageSequenceFrame::SetInitialChildList(nsIPresContext& aPresContext,
nsIAtom* aListName,
nsIFrame* aChildList)
{
// Create a page frame and initialize it
mFirstChild = new nsPageFrame;
// XXX This is all wrong...
nsIStyleContext* pseudoStyleContext =
aPresContext.ResolvePseudoStyleContextFor(mContent, nsHTMLAtoms::columnPseudo, mStyleContext);
mFirstChild->Init(aPresContext, mContent, this, pseudoStyleContext);
NS_RELEASE(pseudoStyleContext);
// Set the geometric and content parent for each of the child frames to be the
// page frame
for (nsIFrame* frame = aChildList; nsnull != frame; frame->GetNextSibling(frame)) {
frame->SetGeometricParent(mFirstChild);
frame->SetContentParent(mFirstChild);
}
// Queue up the frames for the page frame
return mFirstChild->SetInitialChildList(aPresContext, nsnull, aChildList);
}
// XXX Hack
#define PAGE_SPACING_TWIPS 100
@ -159,6 +134,8 @@ nsSimplePageSequenceFrame::Reflow(nsIPresContext& aPresContext,
nsIFrame* continuingPage;
nsresult rv = kidFrame->CreateContinuingFrame(aPresContext, this,
kidSC, continuingPage);
nsHTMLContainerFrame::CreateViewForFrame(aPresContext, continuingPage,
kidSC, PR_TRUE);
NS_RELEASE(kidSC);
reflowReason = eReflowReason_Initial;

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

@ -23,10 +23,6 @@
// Simple page sequence frame class. Used when we're in paginated mode
class nsSimplePageSequenceFrame : public nsContainerFrame {
public:
NS_IMETHOD SetInitialChildList(nsIPresContext& aPresContext,
nsIAtom* aListName,
nsIFrame* aChildList);
NS_IMETHOD Reflow(nsIPresContext& aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aMaxSize,

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

@ -1378,19 +1378,30 @@ HTMLStyleSheetImpl::ConstructRootFrame(nsIPresContext* aPresContext,
// Create a simple page sequence frame
rv = NS_NewSimplePageSequenceFrame(pageSequenceFrame);
if (NS_SUCCEEDED(rv)) {
nsIFrame* pageFrame;
nsIFrame* childList;
// Initialize the frame and force it to have a view
pageSequenceFrame->Init(*aPresContext, aContent, scrollFrame, pseudoStyle);
NS_RELEASE(pseudoStyle);
nsHTMLContainerFrame::CreateViewForFrame(*aPresContext, pageSequenceFrame,
pseudoStyle, PR_TRUE);
// Create the first page
NS_NewPageFrame(pageFrame);
// Initialize it and force it to have a view
// XXX Use a PAGE style context...
pageFrame->Init(*aPresContext, aContent, pageSequenceFrame, pseudoStyle);
nsHTMLContainerFrame::CreateViewForFrame(*aPresContext, pageFrame,
pseudoStyle, PR_TRUE);
NS_RELEASE(pseudoStyle);
// Process the child content, and set the page sequence frame's initial
// child list
rv = ProcessChildren(aPresContext, pageSequenceFrame, aContent, childList);
// Process the child content, and set the page and page sequence frame's
// initial child lists
rv = ProcessChildren(aPresContext, pageFrame, aContent, childList);
if (NS_SUCCEEDED(rv)) {
pageSequenceFrame->SetInitialChildList(*aPresContext, nsnull, childList);
pageFrame->SetInitialChildList(*aPresContext, nsnull, childList);
pageSequenceFrame->SetInitialChildList(*aPresContext, nsnull, pageFrame);
// Set the scroll frame's initial child list
scrollFrame->SetInitialChildList(*aPresContext, nsnull, pageSequenceFrame);

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

@ -1378,19 +1378,30 @@ HTMLStyleSheetImpl::ConstructRootFrame(nsIPresContext* aPresContext,
// Create a simple page sequence frame
rv = NS_NewSimplePageSequenceFrame(pageSequenceFrame);
if (NS_SUCCEEDED(rv)) {
nsIFrame* pageFrame;
nsIFrame* childList;
// Initialize the frame and force it to have a view
pageSequenceFrame->Init(*aPresContext, aContent, scrollFrame, pseudoStyle);
NS_RELEASE(pseudoStyle);
nsHTMLContainerFrame::CreateViewForFrame(*aPresContext, pageSequenceFrame,
pseudoStyle, PR_TRUE);
// Create the first page
NS_NewPageFrame(pageFrame);
// Initialize it and force it to have a view
// XXX Use a PAGE style context...
pageFrame->Init(*aPresContext, aContent, pageSequenceFrame, pseudoStyle);
nsHTMLContainerFrame::CreateViewForFrame(*aPresContext, pageFrame,
pseudoStyle, PR_TRUE);
NS_RELEASE(pseudoStyle);
// Process the child content, and set the page sequence frame's initial
// child list
rv = ProcessChildren(aPresContext, pageSequenceFrame, aContent, childList);
// Process the child content, and set the page and page sequence frame's
// initial child lists
rv = ProcessChildren(aPresContext, pageFrame, aContent, childList);
if (NS_SUCCEEDED(rv)) {
pageSequenceFrame->SetInitialChildList(*aPresContext, nsnull, childList);
pageFrame->SetInitialChildList(*aPresContext, nsnull, childList);
pageSequenceFrame->SetInitialChildList(*aPresContext, nsnull, pageFrame);
// Set the scroll frame's initial child list
scrollFrame->SetInitialChildList(*aPresContext, nsnull, pageSequenceFrame);