[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor-browser] 63/76: Bug 1759494 - Remove some dead code introduced for PDFium. r=dholbert a=RyanVM
This is an automated email from the git hooks/post-receive script.
richard pushed a commit to branch tor-browser-91.8.0esr-11.0-1
in repository tor-browser.
commit 48bcc68a7c173591461f4b55453340341fba5f32
Author: Emilio Cobos Álvarez <emilio@xxxxxxxxx>
AuthorDate: Mon Mar 14 23:18:22 2022 +0000
Bug 1759494 - Remove some dead code introduced for PDFium. r=dholbert a=RyanVM
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 0d9e741d46f08..168af3ee125cf 100644
--- a/gfx/src/nsDeviceContext.cpp
+++ b/gfx/src/nsDeviceContext.cpp
@@ -705,19 +705,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 e538537b6b013..745b778d74580 100644
--- a/gfx/src/nsDeviceContext.h
+++ b/gfx/src/nsDeviceContext.h
@@ -263,10 +263,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 b5908ae920cf9..4dd540a643516 100644
--- a/gfx/thebes/PrintTarget.cpp
+++ b/gfx/thebes/PrintTarget.cpp
@@ -188,11 +188,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 b8a736fe29be6..115075ccd3536 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(
@@ -200,11 +193,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;
@@ -217,7 +205,6 @@ mozilla::ipc::IPCResult RemotePrintJobParent::RecvAbortPrint(
const nsresult& aRv) {
if (mPrintDeviceContext) {
Unused << mPrintDeviceContext->AbortDocument();
- mPrintDeviceContext->UnregisterPageDoneCallback();
}
mIsDoingPrinting = false;
@@ -278,10 +265,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 ecbf3d9f6d846..606b90520dde1 100644
--- a/layout/printing/nsPrintJob.cpp
+++ b/layout/printing/nsPrintJob.cpp
@@ -778,12 +778,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); });
- }
-
if (!StaticPrefs::print_tab_modal_enabled() && mIsCreatingPrintPreview) {
// In legacy print-preview mode, override any UI that wants to PrintPreview
// any selection or page range. The legacy print-preview intends to view
@@ -2350,10 +2344,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.
@@ -2486,11 +2476,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.
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits