mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-01 08:42:13 +00:00
Bug 1354443 part.1-1 Make nsPrintData refcountable r=dholbert
MozReview-Commit-ID: 78azPbH9S9x
This commit is contained in:
parent
9a2799794a
commit
3fd5206e5b
@ -34,7 +34,6 @@ nsPrintData::nsPrintData(ePrintDataType aType) :
|
||||
mShrinkRatio(1.0), mOrigDCScale(1.0), mPPEventListeners(nullptr),
|
||||
mBrandName(nullptr)
|
||||
{
|
||||
MOZ_COUNT_CTOR(nsPrintData);
|
||||
nsCOMPtr<nsIStringBundle> brandBundle;
|
||||
nsCOMPtr<nsIStringBundleService> svc =
|
||||
mozilla::services::GetStringBundleService();
|
||||
@ -53,7 +52,6 @@ nsPrintData::nsPrintData(ePrintDataType aType) :
|
||||
|
||||
nsPrintData::~nsPrintData()
|
||||
{
|
||||
MOZ_COUNT_DTOR(nsPrintData);
|
||||
// remove the event listeners
|
||||
if (mPPEventListeners) {
|
||||
mPPEventListeners->RemoveListeners();
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "nsDeviceContext.h"
|
||||
#include "nsIPrintProgressParams.h"
|
||||
#include "nsIPrintSettings.h"
|
||||
#include "nsISupportsImpl.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsCOMArray.h"
|
||||
|
||||
@ -37,11 +38,11 @@ class nsIWebProgressListener;
|
||||
//------------------------------------------------------------------------
|
||||
class nsPrintData {
|
||||
public:
|
||||
|
||||
typedef enum {eIsPrinting, eIsPrintPreview } ePrintDataType;
|
||||
|
||||
explicit nsPrintData(ePrintDataType aType);
|
||||
~nsPrintData(); // non-virtual
|
||||
|
||||
NS_INLINE_DECL_REFCOUNTING(nsPrintData)
|
||||
|
||||
// Listener Helper Methods
|
||||
void OnEndPrinting();
|
||||
@ -93,6 +94,7 @@ private:
|
||||
nsPrintData() = delete;
|
||||
nsPrintData& operator=(const nsPrintData& aOther) = delete;
|
||||
|
||||
~nsPrintData(); // non-virtual
|
||||
};
|
||||
|
||||
#endif /* nsPrintData_h___ */
|
||||
|
@ -210,18 +210,18 @@ NS_IMPL_ISUPPORTS(nsPrintEngine, nsIWebProgressListener,
|
||||
//---------------------------------------------------
|
||||
//-- nsPrintEngine Class Impl
|
||||
//---------------------------------------------------
|
||||
nsPrintEngine::nsPrintEngine() :
|
||||
mIsCreatingPrintPreview(false),
|
||||
mIsDoingPrinting(false),
|
||||
mIsDoingPrintPreview(false),
|
||||
mProgressDialogIsShown(false),
|
||||
mScreenDPI(115.0f),
|
||||
mPagePrintTimer(nullptr),
|
||||
mDebugFile(nullptr),
|
||||
mLoadCounter(0),
|
||||
mDidLoadDataForPrinting(false),
|
||||
mIsDestroying(false),
|
||||
mDisallowSelectionPrint(false)
|
||||
nsPrintEngine::nsPrintEngine()
|
||||
: mIsCreatingPrintPreview(false)
|
||||
, mIsDoingPrinting(false)
|
||||
, mIsDoingPrintPreview(false)
|
||||
, mProgressDialogIsShown(false)
|
||||
, mScreenDPI(115.0f)
|
||||
, mPagePrintTimer(nullptr)
|
||||
, mDebugFile(nullptr)
|
||||
, mLoadCounter(0)
|
||||
, mDidLoadDataForPrinting(false)
|
||||
, mIsDestroying(false)
|
||||
, mDisallowSelectionPrint(false)
|
||||
{
|
||||
}
|
||||
|
||||
@ -431,10 +431,8 @@ nsPrintEngine::DoCommonPrint(bool aIsPrintPreview,
|
||||
mProgressDialogIsShown = false;
|
||||
}
|
||||
|
||||
mPrt = mozilla::MakeUnique<nsPrintData>(aIsPrintPreview
|
||||
? nsPrintData::eIsPrintPreview
|
||||
: nsPrintData::eIsPrinting);
|
||||
NS_ENSURE_TRUE(mPrt, NS_ERROR_OUT_OF_MEMORY);
|
||||
mPrt = new nsPrintData(aIsPrintPreview ? nsPrintData::eIsPrintPreview :
|
||||
nsPrintData::eIsPrinting);
|
||||
|
||||
// if they don't pass in a PrintSettings, then get the Global PS
|
||||
mPrt->mPrintSettings = aPrintSettings;
|
||||
|
@ -265,13 +265,19 @@ protected:
|
||||
nsWeakPtr mContainer;
|
||||
float mScreenDPI;
|
||||
|
||||
mozilla::UniquePtr<nsPrintData> mPrt;
|
||||
// We are the primary owner of our nsPrintData member vars. These vars
|
||||
// are refcounted so that functions (e.g. nsPrintData methods) can create
|
||||
// temporary owning references when they need to fire a callback that
|
||||
// could conceivably destroy this nsPrintEngine owner object and all its
|
||||
// member-data.
|
||||
RefPtr<nsPrintData> mPrt;
|
||||
|
||||
nsPagePrintTimer* mPagePrintTimer;
|
||||
WeakFrame mPageSeqFrame;
|
||||
|
||||
// Print Preview
|
||||
mozilla::UniquePtr<nsPrintData> mPrtPreview;
|
||||
mozilla::UniquePtr<nsPrintData> mOldPrtPreview;
|
||||
RefPtr<nsPrintData> mPrtPreview;
|
||||
RefPtr<nsPrintData> mOldPrtPreview;
|
||||
|
||||
nsCOMPtr<nsIDocument> mDocument;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user