зеркало из https://github.com/mozilla/pjs.git
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:
Родитель
6ea30bd937
Коммит
55f632387d
|
@ -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);
|
||||
|
||||
// Process the child content, and set the page sequence frame's initial
|
||||
// child list
|
||||
rv = ProcessChildren(aPresContext, pageSequenceFrame, aContent, childList);
|
||||
// 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 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);
|
||||
|
||||
// Process the child content, and set the page sequence frame's initial
|
||||
// child list
|
||||
rv = ProcessChildren(aPresContext, pageSequenceFrame, aContent, childList);
|
||||
// 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 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);
|
||||
|
||||
// Process the child content, and set the page sequence frame's initial
|
||||
// child list
|
||||
rv = ProcessChildren(aPresContext, pageSequenceFrame, aContent, childList);
|
||||
// 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 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);
|
||||
|
|
Загрузка…
Ссылка в новой задаче