зеркало из https://github.com/mozilla/gecko-dev.git
Bug 339548. Part 2: Introduce nsRootPresContext.
This commit is contained in:
Родитель
cd388d6051
Коммит
16f8bf9ac4
|
@ -816,6 +816,16 @@ DocumentViewerImpl::InitPresentationStuff(PRBool aDoInitialReflow, PRBool aReena
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
static nsPresContext*
|
||||
CreatePresContext(nsIDocument* aDocument,
|
||||
nsPresContext::nsPresContextType aType,
|
||||
nsIView* aContainerView)
|
||||
{
|
||||
if (aContainerView)
|
||||
return new nsPresContext(aDocument, aType);
|
||||
return new nsRootPresContext(aDocument, aType);
|
||||
}
|
||||
|
||||
//-----------------------------------------------
|
||||
// This method can be used to initial the "presentation"
|
||||
// The aDoCreation indicates whether it should create
|
||||
|
@ -845,10 +855,10 @@ DocumentViewerImpl::InitInternal(nsIWidget* aParentWidget,
|
|||
// Create presentation context
|
||||
if (mIsPageMode) {
|
||||
//Presentation context already created in SetPageMode which is calling this method
|
||||
} else {
|
||||
mPresContext = CreatePresContext(mDocument,
|
||||
nsPresContext::eContext_Galley, containerView);
|
||||
}
|
||||
else
|
||||
mPresContext =
|
||||
new nsPresContext(mDocument, nsPresContext::eContext_Galley);
|
||||
NS_ENSURE_TRUE(mPresContext, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
nsresult rv = mPresContext->Init(mDeviceContext);
|
||||
|
@ -1912,7 +1922,8 @@ DocumentViewerImpl::Show(void)
|
|||
|
||||
// Create presentation context
|
||||
NS_ASSERTION(!mPresContext, "Shouldn't have a prescontext if we have no shell!");
|
||||
mPresContext = new nsPresContext(mDocument, nsPresContext::eContext_Galley);
|
||||
mPresContext = CreatePresContext(mDocument,
|
||||
nsPresContext::eContext_Galley, containerView);
|
||||
NS_ENSURE_TRUE(mPresContext, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
rv = mPresContext->Init(mDeviceContext);
|
||||
|
@ -4245,8 +4256,8 @@ NS_IMETHODIMP DocumentViewerImpl::SetPageMode(PRBool aPageMode, nsIPrintSettings
|
|||
NS_ENSURE_STATE(mDocument);
|
||||
if (aPageMode)
|
||||
{
|
||||
mPresContext =
|
||||
new nsPresContext(mDocument, nsPresContext::eContext_PageLayout);
|
||||
mPresContext = CreatePresContext(mDocument,
|
||||
nsPresContext::eContext_PageLayout, FindContainerView());
|
||||
NS_ENSURE_TRUE(mPresContext, NS_ERROR_OUT_OF_MEMORY);
|
||||
mPresContext->SetPaginatedScrolling(PR_TRUE);
|
||||
mPresContext->SetPrintSettings(aPrintSettings);
|
||||
|
|
|
@ -1025,7 +1025,7 @@ nsPresContext::Observe(nsISupports* aSubject,
|
|||
}
|
||||
|
||||
// We may want to replace this with something faster, maybe caching the root prescontext
|
||||
nsPresContext*
|
||||
nsRootPresContext*
|
||||
nsPresContext::RootPresContext()
|
||||
{
|
||||
nsPresContext* pc = this;
|
||||
|
@ -1040,7 +1040,7 @@ nsPresContext::RootPresContext()
|
|||
}
|
||||
}
|
||||
}
|
||||
return pc;
|
||||
return static_cast<nsRootPresContext*>(pc);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2151,3 +2151,9 @@ nsPresContext::CheckForInterrupt(nsIFrame* aFrame)
|
|||
}
|
||||
return mHasPendingInterrupt;
|
||||
}
|
||||
|
||||
nsRootPresContext::nsRootPresContext(nsIDocument* aDocument,
|
||||
nsPresContextType aType)
|
||||
: nsPresContext(aDocument, aType)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -151,6 +151,8 @@ enum nsLayoutPhase {
|
|||
#define NS_AUTHOR_SPECIFIED_BORDER (1 << 1)
|
||||
#define NS_AUTHOR_SPECIFIED_PADDING (1 << 2)
|
||||
|
||||
class nsRootPresContext;
|
||||
|
||||
// An interface for presentation contexts. Presentation contexts are
|
||||
// objects that provide an outer context for a presentation shell.
|
||||
|
||||
|
@ -197,7 +199,7 @@ public:
|
|||
|
||||
// Find the prescontext for the root of the view manager hierarchy that contains
|
||||
// this prescontext.
|
||||
nsPresContext* RootPresContext();
|
||||
nsRootPresContext* RootPresContext();
|
||||
|
||||
nsIDocument* Document() const
|
||||
{
|
||||
|
@ -1035,7 +1037,7 @@ protected:
|
|||
|
||||
protected:
|
||||
|
||||
~nsPresContext() NS_HIDDEN;
|
||||
virtual ~nsPresContext() NS_HIDDEN;
|
||||
|
||||
// these are private, use the list in nsFont.h if you want a public list
|
||||
enum {
|
||||
|
@ -1061,6 +1063,11 @@ public:
|
|||
|
||||
};
|
||||
|
||||
class nsRootPresContext : public nsPresContext {
|
||||
public:
|
||||
nsRootPresContext(nsIDocument* aDocument, nsPresContextType aType) NS_HIDDEN;
|
||||
};
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
struct nsAutoLayoutPhase {
|
||||
|
|
|
@ -7908,7 +7908,7 @@ PresShell::VerifyIncrementalReflow()
|
|||
|
||||
// Create a presentation context to view the new frame tree
|
||||
nsCOMPtr<nsPresContext> cx =
|
||||
new nsPresContext(mDocument, mPresContext->IsPaginated() ?
|
||||
new nsRootPresContext(mDocument, mPresContext->IsPaginated() ?
|
||||
nsPresContext::eContext_PrintPreview :
|
||||
nsPresContext::eContext_Galley);
|
||||
NS_ENSURE_TRUE(cx, PR_FALSE);
|
||||
|
|
|
@ -1915,10 +1915,9 @@ nsPrintEngine::ReflowPrintObject(nsPrintObject * aPO)
|
|||
}
|
||||
|
||||
// create the PresContext
|
||||
aPO->mPresContext = new nsPresContext(aPO->mDocument,
|
||||
mIsCreatingPrintPreview ?
|
||||
nsPresContext::eContext_PrintPreview:
|
||||
nsPresContext::eContext_Print);
|
||||
aPO->mPresContext = new nsRootPresContext(aPO->mDocument,
|
||||
mIsCreatingPrintPreview ? nsPresContext::eContext_PrintPreview:
|
||||
nsPresContext::eContext_Print);
|
||||
NS_ENSURE_TRUE(aPO->mPresContext, NS_ERROR_OUT_OF_MEMORY);
|
||||
aPO->mPresContext->SetPrintSettings(mPrt->mPrintSettings);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче