Support variable sized paging again, but only if an nspr log variable is defined

This commit is contained in:
kipp%netscape.com 1998-12-05 15:58:09 +00:00
Родитель 2ce7b88094
Коммит 926fbeff9d
1 изменённых файлов: 45 добавлений и 3 удалений

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

@ -22,6 +22,7 @@
#include "nsIWidget.h"
#include "nsGfxCIID.h"
#include "nsLayoutAtoms.h"
#include "prlog.h"
static NS_DEFINE_IID(kIPresContextIID, NS_IPRESCONTEXT_IID);
@ -34,8 +35,28 @@ public:
virtual PRBool IsPaginated();
virtual nscoord GetPageWidth();
virtual nscoord GetPageHeight();
#ifdef NS_DEBUG
static PRBool UseFakePageSize();
#endif
};
#ifdef NS_DEBUG
PRBool
PrintPreviewContext::UseFakePageSize()
{
static PRLogModuleInfo* pageSizeLM;
static PRBool useFakePageSize = PR_FALSE;
if (nsnull == pageSizeLM) {
pageSizeLM = PR_NewLogModule("pagesize");
if (nsnull != pageSizeLM) {
useFakePageSize = 0 != pageSizeLM->level;
}
}
return useFakePageSize;
}
#endif
PrintPreviewContext::PrintPreviewContext()
{
}
@ -52,19 +73,40 @@ PrintPreviewContext::GetMedium(nsIAtom*& aMedium)
return NS_OK;
}
PRBool PrintPreviewContext::IsPaginated()
PRBool
PrintPreviewContext::IsPaginated()
{
return PR_TRUE;
}
nscoord PrintPreviewContext::GetPageWidth()
nscoord
PrintPreviewContext::GetPageWidth()
{
#ifdef NS_DEBUG
if (UseFakePageSize()) {
// For testing purposes make the page width smaller than the visible
// area
float sbWidth, sbHeight;
mDeviceContext->GetScrollBarDimensions(sbWidth, sbHeight);
nscoord sbar = NSToCoordRound(sbWidth);
return mVisibleArea.width - sbar - 2*100;
}
#endif
// XXX assumes a 1/2 margin around all sides
return (nscoord) NS_INCHES_TO_TWIPS(7.5);
}
nscoord PrintPreviewContext::GetPageHeight()
nscoord
PrintPreviewContext::GetPageHeight()
{
#ifdef NS_DEBUG
if (UseFakePageSize()) {
// For testing purposes make the page height 60% of the visible area
return mVisibleArea.height * 60 / 100;
}
#endif
// XXX assumes a 1/2 margin around all sides
return (nscoord) NS_INCHES_TO_TWIPS(10);
}