Bug 535794 - Shorter printPageDelay, r=roc

This commit is contained in:
Olli Pettay 2009-12-19 12:32:53 +02:00
Родитель c623ba3b78
Коммит 96f3c9cd42
5 изменённых файлов: 16 добавлений и 4 удалений

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

@ -45,6 +45,7 @@ NS_IMPL_ISUPPORTS1(nsPagePrintTimer, nsITimerCallback)
nsPagePrintTimer::nsPagePrintTimer() : nsPagePrintTimer::nsPagePrintTimer() :
mPrintEngine(nsnull), mPrintEngine(nsnull),
mDelay(0), mDelay(0),
mFiringCount(0),
mPrintObj(nsnull) mPrintObj(nsnull)
{ {
} }
@ -69,7 +70,16 @@ nsPagePrintTimer::StartTimer(PRBool aUseDelay)
if (NS_FAILED(result)) { if (NS_FAILED(result)) {
NS_WARNING("unable to start the timer"); NS_WARNING("unable to start the timer");
} else { } else {
mTimer->InitWithCallback(this, aUseDelay?mDelay:0, nsITimer::TYPE_ONE_SHOT); PRUint32 delay = 0;
if (aUseDelay) {
if (mFiringCount < 10) {
// Longer delay for the few first pages.
delay = mDelay + ((10 - mFiringCount) * 100);
} else {
delay = mDelay;
}
}
mTimer->InitWithCallback(this, delay, nsITimer::TYPE_ONE_SHOT);
} }
return result; return result;
} }
@ -100,6 +110,7 @@ nsPagePrintTimer::Notify(nsITimer *timer)
// returns true.) // returns true.)
Stop(); Stop();
if (initNewTimer) { if (initNewTimer) {
++mFiringCount;
nsresult result = StartTimer(inRange); nsresult result = StartTimer(inRange);
if (NS_FAILED(result)) { if (NS_FAILED(result)) {
donePrinting = PR_TRUE; // had a failure.. we are finished.. donePrinting = PR_TRUE; // had a failure.. we are finished..

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

@ -75,6 +75,7 @@ private:
nsCOMPtr<nsIDocumentViewerPrint> mDocViewerPrint; nsCOMPtr<nsIDocumentViewerPrint> mDocViewerPrint;
nsCOMPtr<nsITimer> mTimer; nsCOMPtr<nsITimer> mTimer;
PRUint32 mDelay; PRUint32 mDelay;
PRUint32 mFiringCount;
nsPrintObject * mPrintObj; nsPrintObject * mPrintObj;
}; };

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

@ -3313,7 +3313,7 @@ nsPrintEngine::StartPagePrintTimer(nsPrintObject* aPO)
// Get the delay time in between the printing of each page // Get the delay time in between the printing of each page
// this gives the user more time to press cancel // this gives the user more time to press cancel
PRInt32 printPageDelay = 500; PRInt32 printPageDelay = 50;
mPrt->mPrintSettings->GetPrintPageDelay(&printPageDelay); mPrt->mPrintSettings->GetPrintPageDelay(&printPageDelay);
mPagePrintTimer->Init(this, mDocViewerPrint, printPageDelay); mPagePrintTimer->Init(this, mDocViewerPrint, printPageDelay);

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

@ -105,7 +105,7 @@ static const char kPrintCommand[] = "print_command";
static const char kPrinterName[] = "print_printer"; static const char kPrinterName[] = "print_printer";
static const char kPrintToFile[] = "print_to_file"; static const char kPrintToFile[] = "print_to_file";
static const char kPrintToFileName[] = "print_to_filename"; static const char kPrintToFileName[] = "print_to_filename";
static const char kPrintPageDelay[] = "print_pagedelay"; static const char kPrintPageDelay[] = "print_page_delay";
static const char kPrintBGColors[] = "print_bgcolor"; static const char kPrintBGColors[] = "print_bgcolor";
static const char kPrintBGImages[] = "print_bgimages"; static const char kPrintBGImages[] = "print_bgimages";
static const char kPrintShrinkToFit[] = "print_shrink_to_fit"; static const char kPrintShrinkToFit[] = "print_shrink_to_fit";

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

@ -63,7 +63,7 @@ nsPrintSettings::nsPrintSettings() :
mPrintPreview(PR_FALSE), mPrintPreview(PR_FALSE),
mShrinkToFit(PR_TRUE), mShrinkToFit(PR_TRUE),
mShowPrintProgress(PR_TRUE), mShowPrintProgress(PR_TRUE),
mPrintPageDelay(500), mPrintPageDelay(50),
mPaperData(0), mPaperData(0),
mPaperSizeType(kPaperSizeDefined), mPaperSizeType(kPaperSizeDefined),
mPaperWidth(8.5), mPaperWidth(8.5),