Bug 1661873 - Generate nsRootPresShell for printing ducuments only if the document has no parent OR the parent is not going to be printed AND GetParentViewForRoot() is not null. r=smaug

Though there is no automated test for this change, I think the test cases in the
previous commit well cover the original issue (bug 468568) that downloadable
fonts are not rendered in printing.

Depends on D89095

Differential Revision: https://phabricator.services.mozilla.com/D89096
This commit is contained in:
Hiroyuki Ikezoe 2020-09-03 01:39:11 +00:00
Родитель b15a8fe457
Коммит c9ac4c645c
1 изменённых файлов: 5 добавлений и 5 удалений

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

@ -1803,11 +1803,11 @@ nsresult nsPrintJob::ReflowPrintObject(const UniquePtr<nsPrintObject>& aPO) {
nsPresContext::nsPresContextType type =
mIsCreatingPrintPreview ? nsPresContext::eContext_PrintPreview
: nsPresContext::eContext_Print;
nsView* parentView = aPO->mParent && aPO->mParent->PrintingIsEnabled()
? nullptr
: GetParentViewForRoot();
aPO->mPresContext = parentView ? new nsPresContext(aPO->mDocument, type)
: new nsRootPresContext(aPO->mDocument, type);
const bool shouldBeRoot =
(!aPO->mParent || !aPO->mParent->PrintingIsEnabled()) &&
!GetParentViewForRoot();
aPO->mPresContext = shouldBeRoot ? new nsRootPresContext(aPO->mDocument, type)
: new nsPresContext(aPO->mDocument, type);
aPO->mPresContext->SetPrintSettings(printData->mPrintSettings);
// set the presentation context to the value in the print settings