Backed out changeset 9fce1abd1c50 (bug 1833244) for causing build bustages on nsDeviceContextAndroid.h. CLOSED TREE

This commit is contained in:
Iulian Moraru 2023-05-31 16:31:53 +03:00
Родитель d4e8510ca6
Коммит 3cfea4753c
25 изменённых файлов: 40 добавлений и 112 удалений

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

@ -327,14 +327,14 @@ nsresult nsDeviceContext::AbortDocument() {
return rv;
}
nsresult nsDeviceContext::BeginPage(const IntSize& aSizeInPoints) {
nsresult nsDeviceContext::BeginPage() {
MOZ_DIAGNOSTIC_ASSERT(!mIsCurrentlyPrintingDoc || mPrintTarget,
"What nulled out our print target while printing?");
if (mDeviceContextSpec) {
MOZ_TRY(mDeviceContextSpec->BeginPage(aSizeInPoints));
MOZ_TRY(mDeviceContextSpec->BeginPage());
}
if (mPrintTarget) {
MOZ_TRY(mPrintTarget->BeginPage(aSizeInPoints));
MOZ_TRY(mPrintTarget->BeginPage());
}
return NS_OK;
}

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

@ -20,7 +20,6 @@
#include "nscore.h" // for char16_t, nsAString
#include "mozilla/AppUnits.h" // for AppUnits
#include "nsFontMetrics.h" // for nsFontMetrics::Params
#include "mozilla/gfx/Point.h" // for IntSize
#include "mozilla/gfx/PrintTarget.h" // for PrintTarget::PageDoneCallback
#include "mozilla/gfx/PrintPromise.h"
@ -49,8 +48,7 @@ class Screen;
class nsDeviceContext final {
public:
using IntSize = mozilla::gfx::IntSize;
using PrintTarget = mozilla::gfx::PrintTarget;
typedef mozilla::gfx::PrintTarget PrintTarget;
nsDeviceContext();
@ -225,17 +223,9 @@ class nsDeviceContext final {
* Inform the output device that output of a page is beginning
* Used for print related device contexts. Must be matched 1:1 with
* EndPage() and within a BeginDocument()/EndDocument() pair.
*
* @param aSizeInPoints - The physical dimensions of the page in points.
* Currently only supported (used) by print-to-PDF
* print targets, and then only to switch the
* orientation for a specific page (arbitrary page
* sizes are not supported by the Core Graphics print-
* to-PDF APIs, for example).
*
* @return error status
*/
nsresult BeginPage(const IntSize& aSizeInPoints);
nsresult BeginPage();
/**
* Inform the output device that output of a page is ending

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

@ -43,11 +43,7 @@ class PrintTarget {
#endif
return NS_OK;
}
/**
* Note: not all print devices implement mixed page sizing. Most PrintTarget
* subclasses will ignore `aSizeInPoints`.
*/
virtual nsresult BeginPage(const IntSize& aSizeInPoints) {
virtual nsresult BeginPage() {
#ifdef DEBUG
MOZ_ASSERT(!mHasActivePage, "Missing EndPage() call");
mHasActivePage = true;

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

@ -28,7 +28,7 @@ class PrintTargetCG final : public PrintTarget {
int32_t aEndPage) final;
nsresult EndPrinting() final;
nsresult AbortPrinting() final;
nsresult BeginPage(const IntSize& aSizeInPoints) final;
nsresult BeginPage() final;
nsresult EndPage() final;
already_AddRefed<DrawTarget> GetReferenceDrawTarget() final;

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

@ -210,7 +210,7 @@ nsresult PrintTargetCG::AbortPrinting() {
return EndPrinting();
}
nsresult PrintTargetCG::BeginPage(const IntSize& aSizeInPoints) {
nsresult PrintTargetCG::BeginPage() {
NS_OBJC_BEGIN_TRY_BLOCK_RETURN;
CGContextRef context;
@ -249,7 +249,7 @@ nsresult PrintTargetCG::BeginPage(const IntSize& aSizeInPoints) {
mCairoSurface = surface;
return PrintTarget::BeginPage(aSizeInPoints);
return PrintTarget::BeginPage();
NS_OBJC_END_TRY_BLOCK_RETURN(NS_ERROR_FAILURE);
}

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

@ -54,11 +54,10 @@ nsresult PrintTargetSkPDF::BeginPrinting(const nsAString& aTitle,
return mPDFDoc ? NS_OK : NS_ERROR_FAILURE;
}
nsresult PrintTargetSkPDF::BeginPage(const IntSize& aSizeInPoints) {
nsresult PrintTargetSkPDF::BeginPage() {
mPageCanvas = mPDFDoc->beginPage(mSize.width, mSize.height);
return !mPageCanvas ? NS_ERROR_FAILURE
: PrintTarget::BeginPage(aSizeInPoints);
return !mPageCanvas ? NS_ERROR_FAILURE : PrintTarget::BeginPage();
}
nsresult PrintTargetSkPDF::EndPage() {

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

@ -33,7 +33,7 @@ class PrintTargetSkPDF final : public PrintTarget {
nsresult EndPrinting() override;
void Finish() override;
nsresult BeginPage(const IntSize& aSizeInPoints) override;
nsresult BeginPage() override;
nsresult EndPage() override;
already_AddRefed<DrawTarget> MakeDrawTarget(

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

@ -79,7 +79,7 @@ nsresult PrintTargetThebes::AbortPrinting() {
return mGfxSurface->AbortPrinting();
}
nsresult PrintTargetThebes::BeginPage(const IntSize& aSizeInPoints) {
nsresult PrintTargetThebes::BeginPage() {
#ifdef DEBUG
mHasActivePage = true;
#endif

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

@ -33,7 +33,7 @@ class PrintTargetThebes final : public PrintTarget {
int32_t aEndPage) override;
nsresult EndPrinting() override;
nsresult AbortPrinting() override;
nsresult BeginPage(const IntSize& aSizeInPoints) override;
nsresult BeginPage() override;
nsresult EndPage() override;
void Finish() override;

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

@ -103,8 +103,8 @@ nsresult PrintTargetWindows::AbortPrinting() {
return (result <= 0) ? NS_ERROR_FAILURE : NS_OK;
}
nsresult PrintTargetWindows::BeginPage(const IntSize& aSizeInPoints) {
PrintTarget::BeginPage(aSizeInPoints);
nsresult PrintTargetWindows::BeginPage() {
PrintTarget::BeginPage();
int result = ::StartPage(mDC);
return (result <= 0) ? NS_ERROR_FAILURE : NS_OK;
}

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

@ -26,7 +26,7 @@ class PrintTargetWindows final : public PrintTarget {
int32_t aEndPage) override;
nsresult EndPrinting() override;
nsresult AbortPrinting() override;
nsresult BeginPage(const IntSize& aSizeInPoints) override;
nsresult BeginPage() override;
nsresult EndPage() override;
private:

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

@ -298,16 +298,6 @@ void PrintedSheetFrame::ComputePagesPerSheetGridMetrics(
mGridCellHeight = availSpaceOnSheet.height / nscoord(numRows);
}
gfx::IntSize PrintedSheetFrame::GetPrintTargetSizeInPoints(
const int32_t aAppUnitsPerPhysicalInch) const {
const auto size = GetSize();
MOZ_ASSERT(size.width > 0 && size.height > 0);
const float pointsPerAppUnit =
POINTS_PER_INCH_FLOAT / float(aAppUnitsPerPhysicalInch);
return IntSize::Ceil(float(size.width) * pointsPerAppUnit,
float(size.height) * pointsPerAppUnit);
}
#ifdef DEBUG_FRAME_DUMP
nsresult PrintedSheetFrame::GetFrameName(nsAString& aResult) const {
return MakeFrameName(u"PrintedSheet"_ns, aResult);

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

@ -9,7 +9,6 @@
#ifndef LAYOUT_GENERIC_PRINTEDSHEETFRAME_H_
#define LAYOUT_GENERIC_PRINTEDSHEETFRAME_H_
#include "mozilla/gfx/Point.h"
#include "nsContainerFrame.h"
#include "nsHTMLParts.h"
@ -19,8 +18,6 @@ namespace mozilla {
class PrintedSheetFrame final : public nsContainerFrame {
public:
using IntSize = mozilla::gfx::IntSize;
NS_DECL_QUERYFRAME
NS_DECL_FRAMEARENA_HELPERS(PrintedSheetFrame)
@ -74,21 +71,6 @@ class PrintedSheetFrame final : public nsContainerFrame {
nsSize PrecomputeSheetSize(const nsPresContext* aPresContext);
nsSize GetPrecomputedSheetSize() const { return mPrecomputedSize; }
/**
* This method returns the dimensions of the physical page that the target
* [pseudo-]printer should create. This may be different from our own
* dimensions in the case where CSS `page-orientation` causes us to be
* rotated, but we only support that if the PrintTarget backend supports
* different page sizes/orientations. That's only the case for our Save-to-PDF
* backends (possibly other save-to-file outputs in future).
*
* The dimensions returned are expected to be passed to
* nsDeviceContext::BeginPage, which will pass them on to
* PrintTarget::BeginPage to use as the physical dimensions of the page.
*/
IntSize GetPrintTargetSizeInPoints(
const int32_t aAppUnitsPerPhysicalInch) const;
private:
// Private construtor & destructor, to avoid accidental (non-FrameArena)
// instantiation/deletion:

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

@ -584,9 +584,7 @@ nsresult nsPageSequenceFrame::PrePrintNextSheet(nsITimerCallback* aCallback,
nsDeviceContext* dc = PresContext()->DeviceContext();
PR_PL(("\n"));
PR_PL(("***************** BeginPage *****************\n"));
const IntSize sizeInPoints = currentSheet->GetPrintTargetSizeInPoints(
dc->AppUnitsPerPhysicalInch());
rv = dc->BeginPage(sizeInPoints);
rv = dc->BeginPage();
NS_ENSURE_SUCCESS(rv, rv);
mCalledBeginPage = true;
@ -677,10 +675,7 @@ nsresult nsPageSequenceFrame::PrintNextSheet() {
// page otherwise.
PR_PL(("\n"));
PR_PL(("***************** BeginPage *****************\n"));
const IntSize sizeInPoints =
currentSheetFrame->GetPrintTargetSizeInPoints(
dc->AppUnitsPerPhysicalInch());
rv = dc->BeginPage(sizeInPoints);
rv = dc->BeginPage();
NS_ENSURE_SUCCESS(rv, rv);
}
}

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

@ -25,7 +25,7 @@ parent:
// Translate the page recording writen into |fd| and play back the events to
// the real print device.
async ProcessPage(int32_t aWidthInPoints, int32_t aHeightInPoints, uint64_t[] aDeps);
async ProcessPage(uint64_t[] deps);
// This informs the real print device that we've finished, so it can trigger
// the actual print.

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

@ -56,14 +56,12 @@ void RemotePrintJobChild::SetNextPageFD(
mNextPageFD = PR_ImportFile(PROsfd(handle.release()));
}
void RemotePrintJobChild::ProcessPage(const IntSize& aSizeInPoints,
nsTArray<uint64_t>&& aDeps) {
void RemotePrintJobChild::ProcessPage(nsTArray<uint64_t>&& aDeps) {
MOZ_ASSERT(mPagePrintTimer);
mPagePrintTimer->WaitForRemotePrint();
if (!mDestroyed) {
Unused << SendProcessPage(aSizeInPoints.width, aSizeInPoints.height,
std::move(aDeps));
Unused << SendProcessPage(std::move(aDeps));
}
}

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

@ -10,7 +10,6 @@
#include "mozilla/layout/PRemotePrintJobChild.h"
#include "mozilla/RefPtr.h"
#include "mozilla/gfx/Point.h"
#include "nsIWebProgressListener.h"
class nsPagePrintTimer;
@ -22,8 +21,6 @@ namespace layout {
class RemotePrintJobChild final : public PRemotePrintJobChild,
public nsIWebProgressListener {
public:
using IntSize = mozilla::gfx::IntSize;
NS_DECL_ISUPPORTS
NS_DECL_NSIWEBPROGRESSLISTENER
@ -37,7 +34,7 @@ class RemotePrintJobChild final : public PRemotePrintJobChild,
mozilla::ipc::IPCResult RecvPrintInitializationResult(
const nsresult& aRv, const FileDescriptor& aFd) final;
void ProcessPage(const IntSize& aSizeInPoints, nsTArray<uint64_t>&& aDeps);
void ProcessPage(nsTArray<uint64_t>&& aDeps);
mozilla::ipc::IPCResult RecvPageProcessed(const FileDescriptor& aFd) final;

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

@ -106,7 +106,6 @@ nsresult RemotePrintJobParent::PrepareNextPageFD(FileDescriptor* aFd) {
}
mozilla::ipc::IPCResult RemotePrintJobParent::RecvProcessPage(
const int32_t& aWidthInPoints, const int32_t& aHeightInPoints,
nsTArray<uint64_t>&& aDeps) {
if (!mCurrentPageStream.IsOpen()) {
Unused << SendAbortPrint(NS_ERROR_FAILURE);
@ -114,10 +113,8 @@ mozilla::ipc::IPCResult RemotePrintJobParent::RecvProcessPage(
}
mCurrentPageStream.Seek(0, PR_SEEK_SET);
gfx::IntSize pageSizeInPoints(aWidthInPoints, aHeightInPoints);
if (aDeps.IsEmpty()) {
FinishProcessingPage(pageSizeInPoints);
FinishProcessingPage();
return IPC_OK();
}
@ -129,21 +126,20 @@ mozilla::ipc::IPCResult RemotePrintJobParent::RecvProcessPage(
gfx::CrossProcessPaint::Start(std::move(deps))
->Then(
GetCurrentSerialEventTarget(), __func__,
[self = RefPtr{this}, pageSizeInPoints](
[self = RefPtr{this}](
gfx::CrossProcessPaint::ResolvedFragmentMap&& aFragments) {
self->FinishProcessingPage(pageSizeInPoints, &aFragments);
self->FinishProcessingPage(&aFragments);
},
[self = RefPtr{this}, pageSizeInPoints](const nsresult& aRv) {
self->FinishProcessingPage(pageSizeInPoints);
[self = RefPtr{this}](const nsresult& aRv) {
self->FinishProcessingPage();
});
return IPC_OK();
}
void RemotePrintJobParent::FinishProcessingPage(
const gfx::IntSize& aSizeInPoints,
gfx::CrossProcessPaint::ResolvedFragmentMap* aFragments) {
nsresult rv = PrintPage(aSizeInPoints, mCurrentPageStream, aFragments);
nsresult rv = PrintPage(mCurrentPageStream, aFragments);
mCurrentPageStream.Close();
@ -151,11 +147,11 @@ void RemotePrintJobParent::FinishProcessingPage(
}
nsresult RemotePrintJobParent::PrintPage(
const gfx::IntSize& aSizeInPoints, PRFileDescStream& aRecording,
PRFileDescStream& aRecording,
gfx::CrossProcessPaint::ResolvedFragmentMap* aFragments) {
MOZ_ASSERT(mPrintDeviceContext);
nsresult rv = mPrintDeviceContext->BeginPage(aSizeInPoints);
nsresult rv = mPrintDeviceContext->BeginPage();
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}

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

@ -14,7 +14,6 @@
#include "nsCOMPtr.h"
#include "mozilla/RefPtr.h"
#include "mozilla/UniquePtr.h"
#include "mozilla/gfx/Point.h"
#include "mozilla/gfx/RecordedEvent.h"
#include "mozilla/gfx/CrossProcessPaint.h"
@ -39,9 +38,7 @@ class RemotePrintJobParent final : public PRemotePrintJobParent {
const int32_t& aStartPage,
const int32_t& aEndPage) final;
mozilla::ipc::IPCResult RecvProcessPage(const int32_t& aWidthInPoints,
const int32_t& aHeightInPoints,
nsTArray<uint64_t>&& aDeps) final;
mozilla::ipc::IPCResult RecvProcessPage(nsTArray<uint64_t>&& aDeps) final;
mozilla::ipc::IPCResult RecvFinalizePrint() final;
@ -75,10 +72,9 @@ class RemotePrintJobParent final : public PRemotePrintJobParent {
nsresult PrepareNextPageFD(FileDescriptor* aFd);
nsresult PrintPage(
const gfx::IntSize& aSizeInPoints, PRFileDescStream& aRecording,
PRFileDescStream& aRecording,
gfx::CrossProcessPaint::ResolvedFragmentMap* aFragments = nullptr);
void FinishProcessingPage(
const gfx::IntSize& aSizeInPoints,
gfx::CrossProcessPaint::ResolvedFragmentMap* aFragments = nullptr);
/**

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

@ -28,7 +28,7 @@ class nsDeviceContextSpecX : public nsIDeviceContextSpec {
const nsAString& aPrintToFileName,
int32_t aStartPage, int32_t aEndPage) override;
RefPtr<mozilla::gfx::PrintEndDocumentPromise> EndDocument() override;
NS_IMETHOD BeginPage(const IntSize& aSizeInPoints) override { return NS_OK; };
NS_IMETHOD BeginPage() override { return NS_OK; };
NS_IMETHOD EndPage() override { return NS_OK; };
void GetPaperRect(double* aTop, double* aLeft, double* aBottom,

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

@ -39,7 +39,7 @@ class nsDeviceContextSpecGTK : public nsIDeviceContextSpec {
const nsAString& aPrintToFileName,
int32_t aStartPage, int32_t aEndPage) override;
RefPtr<mozilla::gfx::PrintEndDocumentPromise> EndDocument() override;
NS_IMETHOD BeginPage(const IntSize& aSizeInPoints) override { return NS_OK; }
NS_IMETHOD BeginPage() override { return NS_OK; }
NS_IMETHOD EndPage() override { return NS_OK; }
protected:

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

@ -130,14 +130,13 @@ nsDeviceContextSpecProxy::EndDocument() {
}
NS_IMETHODIMP
nsDeviceContextSpecProxy::BeginPage(const IntSize& aSizeInPoints) {
nsDeviceContextSpecProxy::BeginPage() {
if (!mRemotePrintJob || mRemotePrintJob->IsDestroyed()) {
mRemotePrintJob = nullptr;
return NS_ERROR_NOT_AVAILABLE;
}
mRecorder->OpenFD(mRemotePrintJob->GetNextPageFD());
mCurrentPageSizeInPoints = aSizeInPoints;
return NS_OK;
}
@ -151,8 +150,7 @@ nsDeviceContextSpecProxy::EndPage() {
// Send the page recording to the parent.
mRecorder->Close();
mRemotePrintJob->ProcessPage(mCurrentPageSizeInPoints,
std::move(mRecorder->TakeDependentSurfaces()));
mRemotePrintJob->ProcessPage(std::move(mRecorder->TakeDependentSurfaces()));
return NS_OK;
}

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

@ -24,7 +24,6 @@ class RemotePrintJobChild;
class nsDeviceContextSpecProxy final : public nsIDeviceContextSpec {
public:
using IntSize = mozilla::gfx::IntSize;
using RemotePrintJobChild = mozilla::layout::RemotePrintJobChild;
explicit nsDeviceContextSpecProxy(RemotePrintJobChild* aRemotePrintJob);
@ -44,7 +43,7 @@ class nsDeviceContextSpecProxy final : public nsIDeviceContextSpec {
RefPtr<mozilla::gfx::PrintEndDocumentPromise> EndDocument() final;
NS_IMETHOD BeginPage(const IntSize& aSizeInPoints) final;
NS_IMETHOD BeginPage() final;
NS_IMETHOD EndPage() final;
@ -53,7 +52,6 @@ class nsDeviceContextSpecProxy final : public nsIDeviceContextSpec {
RefPtr<RemotePrintJobChild> mRemotePrintJob;
RefPtr<mozilla::layout::DrawEventRecorderPRFileDesc> mRecorder;
IntSize mCurrentPageSizeInPoints;
};
#endif // nsDeviceContextSpecProxy_h

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

@ -9,7 +9,6 @@
#include "gfxPoint.h"
#include "nsISupports.h"
#include "mozilla/StaticPrefs_print.h"
#include "mozilla/gfx/Point.h"
#include "mozilla/gfx/PrintPromise.h"
#include "mozilla/MoveOnlyFunction.h"
@ -33,7 +32,6 @@ class PrintTarget;
class nsIDeviceContextSpec : public nsISupports {
public:
typedef mozilla::gfx::PrintTarget PrintTarget;
using IntSize = mozilla::gfx::IntSize;
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IDEVICE_CONTEXT_SPEC_IID)
@ -81,12 +79,7 @@ class nsIDeviceContextSpec : public nsISupports {
int32_t aStartPage, int32_t aEndPage) = 0;
virtual RefPtr<mozilla::gfx::PrintEndDocumentPromise> EndDocument() = 0;
/**
* Note: not all print devices implement mixed page sizing. Internally,
* aSizeInPoints gets handed off to a PrintTarget, and most PrintTarget
* subclasses will ignore `aSizeInPoints`.
*/
NS_IMETHOD BeginPage(const IntSize& aSizeInPoints) = 0;
NS_IMETHOD BeginPage() = 0;
NS_IMETHOD EndPage() = 0;
protected:

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

@ -31,7 +31,7 @@ class nsDeviceContextSpecWin : public nsIDeviceContextSpec {
return NS_OK;
}
RefPtr<mozilla::gfx::PrintEndDocumentPromise> EndDocument() override;
NS_IMETHOD BeginPage(const IntSize& aSizeInPoints) override { return NS_OK; }
NS_IMETHOD BeginPage() override { return NS_OK; }
NS_IMETHOD EndPage() override { return NS_OK; }
NS_IMETHOD Init(nsIPrintSettings* aPS, bool aIsPrintPreview) override;