Printing
2016 Q4 Farmer
Show Print Dialog
Show Print Dialog
Content process
Chrome process
nsDocumentViewer::Print
nsPrintEngine::Print
nsPrintEngine::CommonPrint
nsPrintEngine::DoCommonPrint
nsPrintingProxy::ShowPrintDialog
{
SendShowPrintDialog()
}
PrintingParent::RecvShowPrintDialog
PrintingParent::ShowPrintDialog
nsPrintingPromptService::ShowPrintDialog
NativeShowPrintDialog
ShowNativePrintDialog
::PrintDlgW
embedding/components/printingui/win/nsPrintingPromptService.cpp
embedding/components/printingui/win/nsPrintDialogUtil.cpp
Show Print Dialog
Content process
Chrome process
nsPrintEngine::DoCommonPrint
{
...
nsCOMPtr<nsIPrintingPromptService> printPromptService(do_GetService(kPrintingPromptService));� if (printPromptService) {� rv = printPromptService->ShowPrintDialog(domWin, wbp,mPrt->mPrintSettings);
}
...
}
nsPrintingProxy::ShowPrintDialog
{
SendShowPrintDialog()
}
PrintingParent::RecvShowPrintDialog
PrintingParent::ShowPrintDialog
{
...
nsCOMPtr<nsIPrintingPromptService> pps(do_GetService("@mozilla.org/embedcomp/printingprompt-service;1"));� rv = pps->ShowPrintDialog(parentWin, wbp, settings);
...
}
nsPrintingPromptService::ShowPrintDialog
static const char kPrintingPromptService[] = "@mozilla.org/embedcomp/printingprompt-service;1";
Show Print Dialog
embedding/components/printingui/mac/nsPrintingPromptService.h
// {E042570C-62DE-4bb6-A6E0-798E3C07B4DF}�#define NS_PRINTINGPROMPTSERVICE_CID \� {0xe042570c, 0x62de, 0x4bb6, { 0xa6, 0xe0, 0x79, 0x8e, 0x3c, 0x7, 0xb4, 0xdf}}
#define NS_PRINTINGPROMPTSERVICE_CONTRACTID \� "@mozilla.org/embedcomp/printingprompt-service;1"
embedding/components/printingui/unixshared/nsPrintingPromptService.h
// {E042570C-62DE-4bb6-A6E0-798E3C07B4DF}�#define NS_PRINTINGPROMPTSERVICE_CID \� {0xe042570c, 0x62de, 0x4bb6, { 0xa6, 0xe0, 0x79, 0x8e, 0x3c, 0x7, 0xb4, 0xdf}}
#define NS_PRINTINGPROMPTSERVICE_CONTRACTID \� "@mozilla.org/embedcomp/printingprompt-service;1"
embedding/components/printingui/win/nsPrintingPromptService.h
// {E042570C-62DE-4bb6-A6E0-798E3C07B4DF}�#define NS_PRINTINGPROMPTSERVICE_CID \� {0xe042570c, 0x62de, 0x4bb6, { 0xa6, 0xe0, 0x79, 0x8e, 0x3c, 0x7, 0xb4, 0xdf}}
#define NS_PRINTINGPROMPTSERVICE_CONTRACTID \� "@mozilla.org/embedcomp/printingprompt-service;1"
static const mozilla::Module::ContractIDEntry kEmbeddingContracts[] = {�#ifdef NS_PRINTING� { NS_PRINTINGPROMPTSERVICE_CONTRACTID, &kNS_PRINTINGPROMPTSERVICE_CID },�#endif�};
Show Print Dialog
static const mozilla::Module::CIDEntry kEmbeddingCIDs[] = {�#ifdef MOZ_XUL� { &kNS_DIALOGPARAMBLOCK_CID, false, nullptr, nsDialogParamBlockConstructor },�#ifdef NS_PRINTING��#ifdef PROXY_PRINTING� { &kNS_PRINTINGPROMPTSERVICE_CID, false, nullptr, nsPrintingPromptServiceConstructor,� mozilla::Module::MAIN_PROCESS_ONLY },� { &kNS_PRINTINGPROMPTSERVICE_CID, false, nullptr, nsPrintingProxyConstructor,� mozilla::Module::CONTENT_PROCESS_ONLY },�#else� { &kNS_PRINTINGPROMPTSERVICE_CID, false, nullptr, nsPrintingPromptServiceConstructor },�#endif�#endif�#endif� ...� { nullptr }�};
Printing
Printing - InitPrintDocConstruction
nsPrintEngine::DoCommonPrint�{
…
if (aIsPrintPreview) {� bool notifyOnInit = false;� ShowPrintProgress(false, notifyOnInit);�
if (!notifyOnInit) {� InstallPrintPreviewListener();� rv = InitPrintDocConstruction(false);� } else {� rv = NS_OK;� }� } else {� bool doNotify;� ShowPrintProgress(true, doNotify);� if (!doNotify) { //Normally, doesn’t go here, but call InitPrintDocConstruction by Observe()� // Print listener setup...� mPrt->OnStartPrinting();�� rv = InitPrintDocConstruction(false);� }� }
...
}
Printing
Content process
Chrome process
nsPrintEngine::ShowPrintProgress
nsPrintEngine::Observe
nsPrintProgress::DoneIniting
JS
nsPrintEngine::InitPrintDocConstruction
nsPrintEngine::DocumentReadyForPrinting
nsPrintEngine::SetupToPrintContent
nsPrintEngine::PrintDocContent
nsPrintEngine::DoPrint
nsPrintEngine::StartPagePrintTimer
m_observer
assign
Printing - start a runnable thread
Content process
nsPagePrintTimer::Notify
Runnable thread
nsPrintEngine::PrintPage
nsSimplePageSequenceFrame::PrintNextPage
nsLayoutUtils::PaintFrame
new
Remote Print Job
Content process
Chrome process
nsSimplePageSequenceFrame::PrintNextPage
nsDeviceContext::EndPage
nsDeviceContextSpecProxy::EndPage
RemotePrintJobChild::ProcessPage
Next Page
RemotePrintJobParent::RecvProcessPage
RemotePrintJobParent::PrintPage
{
nsDeviceContext::BeginPage()
TranslateRecording(recording);
nsDeviceContext::EndPage()
}
Print Preview
Print Preview
Content process
nsPrintEngine::DoCommonPrint
nsPrintEngine::InitPrintDocConstruction
nsPrintEngine::DocumentReadyForPrinting
nsPrintEngine::SetupToPrintContent
nsSimplePageSequenceFrame::StartPrint
PresShell::Paint
nsLayoutUtils::PaintFrame
Initialize Print
Content process
Chrome process
nsPrintEngine::DoCommonPrint
{
nsCOMPtr<nsIDeviceContextSpec> devspec;� devspec = new nsDeviceContextSpecProxy();� rv = devspec->Init(nullptr, mPrt->mPrintSettings, aIsPrintPreview);
mPrt->mPrintDC = new nsDeviceContext();� rv = mPrt->mPrintDC->InitForPrinting(devspec);
}
nsPrintEngine::SetupToPrintContent
{
mPrt->mPrintDC->BeginDocument(docTitleStr, fileNameStr, startPage, endPage);
}
RemotePrintJobParent::RecvInitializePrint
RemotePrintJobParent::InitializePrintDevice
{
nsresult rv;� nsCOMPtr<nsIDeviceContextSpec> deviceContextSpec =�do_CreateInstance("@mozilla.org/gfx/devicecontextspec;1", &rv);� rv = deviceContextSpec->Init(nullptr, mPrintSettings, false);� mPrintDeviceContext = new nsDeviceContext();� rv = mPrintDeviceContext->InitForPrinting(deviceContextSpec);� rv = mPrintDeviceContext->BeginDocument(aDocumentTitle, aPrintToFile,aStartPage, aEndPage);
}
nsDeviceContext::BeginDocument
{
nsresult rv = mPrintTarget->BeginPrinting(aTitle, aPrintToFileName);� rv = mDeviceContextSpec->BeginDocument(aTitle, aPrintToFileName, aStartPage, aEndPage);
}
nsDeviceContext::BeginDocument
{
nsresult rv = mPrintTarget->BeginPrinting(aTitle, aPrintToFileName);� mDeviceContextSpec->BeginDocument(aTitle, aPrintToFileName, aStartPage, aEndPage);
}
nsDeviceContextSpecProxy::BeginDocument
nsDeviceContextSpecWin::BeginDocument