This is an automated email from the git hooks/post-receive script.
pierov pushed a commit to branch geckoview-99.0.1-11.0-1 in repository tor-browser.
commit 1adf5b6c0a15b84ec84abeb109e98026ba8212c5 Author: Emilio Cobos Álvarez emilio@crisal.io AuthorDate: Mon Mar 14 23:18:22 2022 +0000
Bug 1759494 - Remove some dead code introduced for PDFium. r=dholbert a=dmeehan
IsSyncPagePrinting() only had one implementation which unconditionally returned true.
So, any code that was conditioned on !IsSyncPagePrinting() is necessarily dead/unreachable.
These are also crashing due to a null deref in mPrintTarget which might happen if print is aborted.
Differential Revision: https://phabricator.services.mozilla.com/D140988 --- gfx/src/nsDeviceContext.cpp | 16 ---------------- gfx/src/nsDeviceContext.h | 4 ---- gfx/thebes/PrintTarget.cpp | 7 ------- gfx/thebes/PrintTarget.h | 15 --------------- layout/printing/ipc/RemotePrintJobParent.cpp | 19 +------------------ layout/printing/nsPrintJob.cpp | 15 --------------- 6 files changed, 1 insertion(+), 75 deletions(-)
diff --git a/gfx/src/nsDeviceContext.cpp b/gfx/src/nsDeviceContext.cpp index a7d86912c62f0..2676320cf66cb 100644 --- a/gfx/src/nsDeviceContext.cpp +++ b/gfx/src/nsDeviceContext.cpp @@ -479,19 +479,3 @@ DesktopToLayoutDeviceScale nsDeviceContext::GetDesktopToDeviceScale() {
return DesktopToLayoutDeviceScale(1.0); } - -bool nsDeviceContext::IsSyncPagePrinting() const { - MOZ_ASSERT(mPrintTarget); - return mPrintTarget->IsSyncPagePrinting(); -} - -void nsDeviceContext::RegisterPageDoneCallback( - PrintTarget::PageDoneCallback&& aCallback) { - MOZ_ASSERT(mPrintTarget && aCallback && !IsSyncPagePrinting()); - mPrintTarget->RegisterPageDoneCallback(std::move(aCallback)); -} -void nsDeviceContext::UnregisterPageDoneCallback() { - if (mPrintTarget) { - mPrintTarget->UnregisterPageDoneCallback(); - } -} diff --git a/gfx/src/nsDeviceContext.h b/gfx/src/nsDeviceContext.h index 69df0ccb392b4..f64512a8983ee 100644 --- a/gfx/src/nsDeviceContext.h +++ b/gfx/src/nsDeviceContext.h @@ -233,10 +233,6 @@ class nsDeviceContext final {
mozilla::DesktopToLayoutDeviceScale GetDesktopToDeviceScale();
- bool IsSyncPagePrinting() const; - void RegisterPageDoneCallback(PrintTarget::PageDoneCallback&& aCallback); - void UnregisterPageDoneCallback(); - private: // Private destructor, to discourage deletion outside of Release(): ~nsDeviceContext(); diff --git a/gfx/thebes/PrintTarget.cpp b/gfx/thebes/PrintTarget.cpp index 300c2a0e646cd..dc748e9116a9c 100644 --- a/gfx/thebes/PrintTarget.cpp +++ b/gfx/thebes/PrintTarget.cpp @@ -186,11 +186,4 @@ void PrintTarget::Finish() { cairo_surface_finish(mCairoSurface); }
-void PrintTarget::RegisterPageDoneCallback(PageDoneCallback&& aCallback) { - MOZ_ASSERT(aCallback && !IsSyncPagePrinting()); - mPageDoneCallback = std::move(aCallback); -} - -void PrintTarget::UnregisterPageDoneCallback() { mPageDoneCallback = nullptr; } - } // namespace mozilla::gfx diff --git a/gfx/thebes/PrintTarget.h b/gfx/thebes/PrintTarget.h index c7b3c532e8bbc..71fda3e350841 100644 --- a/gfx/thebes/PrintTarget.h +++ b/gfx/thebes/PrintTarget.h @@ -28,8 +28,6 @@ class DrawEventRecorder; */ class PrintTarget { public: - typedef std::function<void(nsresult)> PageDoneCallback; - NS_INLINE_DECL_REFCOUNTING(PrintTarget);
/// Must be matched 1:1 by an EndPrinting/AbortPrinting call. @@ -130,17 +128,6 @@ class PrintTarget { */ virtual already_AddRefed<DrawTarget> GetReferenceDrawTarget();
- /** - * If IsSyncPagePrinting returns true, then a user can assume the content of - * a page was already printed after EndPage(). - * If IsSyncPagePrinting returns false, then a user should register a - * callback function using RegisterPageDoneCallback to receive page print - * done notifications. - */ - virtual bool IsSyncPagePrinting() const { return true; } - void RegisterPageDoneCallback(PageDoneCallback&& aCallback); - void UnregisterPageDoneCallback(); - static void AdjustPrintJobNameForIPP(const nsAString& aJobName, nsCString& aAdjustedJobName); static void AdjustPrintJobNameForIPP(const nsAString& aJobName, @@ -164,8 +151,6 @@ class PrintTarget { #ifdef DEBUG bool mHasActivePage; #endif - - PageDoneCallback mPageDoneCallback; };
} // namespace gfx diff --git a/layout/printing/ipc/RemotePrintJobParent.cpp b/layout/printing/ipc/RemotePrintJobParent.cpp index 4f97ae48abbad..57e5f6daac5f4 100644 --- a/layout/printing/ipc/RemotePrintJobParent.cpp +++ b/layout/printing/ipc/RemotePrintJobParent.cpp @@ -87,11 +87,6 @@ nsresult RemotePrintJobParent::InitializePrintDevice( return rv; }
- if (!mPrintDeviceContext->IsSyncPagePrinting()) { - mPrintDeviceContext->RegisterPageDoneCallback( - [self = RefPtr{this}](nsresult aResult) { self->PageDone(aResult); }); - } - mIsDoingPrinting = true;
return NS_OK; @@ -147,9 +142,7 @@ void RemotePrintJobParent::FinishProcessingPage(
mCurrentPageStream.Close();
- if (mPrintDeviceContext->IsSyncPagePrinting()) { - PageDone(rv); - } + PageDone(rv); }
nsresult RemotePrintJobParent::PrintPage( @@ -202,11 +195,6 @@ mozilla::ipc::IPCResult RemotePrintJobParent::RecvFinalizePrint() {
// Too late to abort the child just log. NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "EndDocument failed"); - - // Since RecvFinalizePrint is called after all page printed, there should - // be no more page-done callbacks after that, in theory. Unregistering - // page-done callback is not must have, but we still do this for safety. - mPrintDeviceContext->UnregisterPageDoneCallback(); }
mIsDoingPrinting = false; @@ -219,7 +207,6 @@ mozilla::ipc::IPCResult RemotePrintJobParent::RecvAbortPrint( const nsresult& aRv) { if (mPrintDeviceContext) { Unused << mPrintDeviceContext->AbortDocument(); - mPrintDeviceContext->UnregisterPageDoneCallback(); }
mIsDoingPrinting = false; @@ -281,10 +268,6 @@ RemotePrintJobParent::~RemotePrintJobParent() { }
void RemotePrintJobParent::ActorDestroy(ActorDestroyReason aWhy) { - if (mPrintDeviceContext) { - mPrintDeviceContext->UnregisterPageDoneCallback(); - } - mIsDoingPrinting = false;
// If progress dialog is opened, notify closing it. diff --git a/layout/printing/nsPrintJob.cpp b/layout/printing/nsPrintJob.cpp index 3afe9283dcd41..9f22423e0aecb 100644 --- a/layout/printing/nsPrintJob.cpp +++ b/layout/printing/nsPrintJob.cpp @@ -605,12 +605,6 @@ nsresult nsPrintJob::DoCommonPrint(bool aIsPrintPreview, printData->mPrintDC = new nsDeviceContext(); MOZ_TRY(printData->mPrintDC->InitForPrinting(devspec));
- if (XRE_IsParentProcess() && !printData->mPrintDC->IsSyncPagePrinting()) { - RefPtr<nsPrintJob> self(this); - printData->mPrintDC->RegisterPageDoneCallback( - [self](nsresult aResult) { self->PageDone(aResult); }); - } - MOZ_TRY(EnablePOsForPrinting());
if (!mIsCreatingPrintPreview) { @@ -2041,10 +2035,6 @@ bool nsPrintJob::PrintSheet(nsPrintObject* aPO, bool& aInRange) { return true; }
- if (XRE_IsParentProcess() && !printData->mPrintDC->IsSyncPagePrinting()) { - mPagePrintTimer->WaitForRemotePrint(); - } - // Print the sheet // if a print job was cancelled externally, an EndPage or BeginPage may // fail and the failure is passed back here. @@ -2177,11 +2167,6 @@ bool nsPrintJob::DonePrintingSheets(nsPrintObject* aPO, nsresult aResult) { } }
- if (XRE_IsParentProcess() && printData->mPrintDC && - !printData->mPrintDC->IsSyncPagePrinting()) { - printData->mPrintDC->UnregisterPageDoneCallback(); - } - if (NS_SUCCEEDED(aResult)) { FirePrintCompletionEvent(); // XXX mPrt may be cleared or replaced with new instance here.