зеркало из https://github.com/mozilla/gecko-dev.git
Don't create multiple XPrint or PostScript device contexts -- the
contexts share globals and are careless... Bug 127627, patch by Roland Mainz <Roland.Mainz@informatik.med.uni-giessen.de>, r=bryner,rods, sr=jag, a=asa
This commit is contained in:
Родитель
be7e92f3cd
Коммит
64367531bf
|
@ -36,6 +36,14 @@
|
|||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/* PostScript/Xprint print modules do not support more than one object
|
||||
* instance because they use global vars which cannot be shared between
|
||||
* multiple instances...
|
||||
* bug 119491 ("Cleanup global vars in PostScript and Xprint modules) will fix
|
||||
* that...
|
||||
*/
|
||||
#define WE_DO_NOT_SUPPORT_MULTIPLE_PRINT_DEVICECONTEXTS 1
|
||||
|
||||
#include "nsDeviceContextPS.h"
|
||||
#include "nsRenderingContextPS.h"
|
||||
|
@ -43,6 +51,10 @@
|
|||
#include "nsFontMetricsPS.h"
|
||||
#include "nsPostScriptObj.h"
|
||||
|
||||
#ifdef WE_DO_NOT_SUPPORT_MULTIPLE_PRINT_DEVICECONTEXTS
|
||||
static int instance_counter = 0;
|
||||
#endif /* WE_DO_NOT_SUPPORT_MULTIPLE_PRINT_DEVICECONTEXTS */
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* See documentation in nsIDeviceContext.h
|
||||
* @update 12/21/98 dwc
|
||||
|
@ -52,6 +64,11 @@ nsDeviceContextPS :: nsDeviceContextPS()
|
|||
{
|
||||
mSpec = nsnull;
|
||||
mParentDeviceContext = nsnull;
|
||||
|
||||
#ifdef WE_DO_NOT_SUPPORT_MULTIPLE_PRINT_DEVICECONTEXTS
|
||||
instance_counter++;
|
||||
NS_ASSERTION(instance_counter < 2, "Cannot have more than one print device context.");
|
||||
#endif /* WE_DO_NOT_SUPPORT_MULTIPLE_PRINT_DEVICECONTEXTS */
|
||||
}
|
||||
|
||||
/** ---------------------------------------------------
|
||||
|
@ -63,6 +80,11 @@ nsDeviceContextPS :: ~nsDeviceContextPS()
|
|||
/* nsCOMPtr<> will dispose the objects... */
|
||||
mSpec = nsnull;
|
||||
mParentDeviceContext = nsnull;
|
||||
|
||||
#ifdef WE_DO_NOT_SUPPORT_MULTIPLE_PRINT_DEVICECONTEXTS
|
||||
instance_counter--;
|
||||
NS_ASSERTION(instance_counter >= 0, "We cannot have less than zero instances.");
|
||||
#endif /* WE_DO_NOT_SUPPORT_MULTIPLE_PRINT_DEVICECONTEXTS */
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -70,6 +92,13 @@ nsDeviceContextPS :: SetSpec(nsIDeviceContextSpec* aSpec)
|
|||
{
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
|
||||
#ifdef WE_DO_NOT_SUPPORT_MULTIPLE_PRINT_DEVICECONTEXTS
|
||||
NS_ASSERTION(instance_counter < 2, "Cannot have more than one print device context.");
|
||||
if (instance_counter > 1) {
|
||||
return NS_ERROR_GFX_PRINTER_PRINT_WHILE_PREVIEW;
|
||||
}
|
||||
#endif /* WE_DO_NOT_SUPPORT_MULTIPLE_PRINT_DEVICECONTEXTS */
|
||||
|
||||
mSpec = aSpec;
|
||||
|
||||
nsCOMPtr<nsIDeviceContextSpecPS> psSpec;
|
||||
|
@ -100,6 +129,13 @@ nsDeviceContextPS::InitDeviceContextPS(nsIDeviceContext *aCreatingDeviceContext,
|
|||
float origscale, newscale;
|
||||
float t2d, a2d;
|
||||
|
||||
#ifdef WE_DO_NOT_SUPPORT_MULTIPLE_PRINT_DEVICECONTEXTS
|
||||
NS_ASSERTION(instance_counter < 2, "Cannot have more than one print device context.");
|
||||
if (instance_counter > 1) {
|
||||
return NS_ERROR_GFX_PRINTER_PRINT_WHILE_PREVIEW;
|
||||
}
|
||||
#endif /* WE_DO_NOT_SUPPORT_MULTIPLE_PRINT_DEVICECONTEXTS */
|
||||
|
||||
mDepth = 1; // just for arguments sake
|
||||
|
||||
mTwipsToPixels = (float)72.0/(float)NSIntPointsToTwips(72);
|
||||
|
|
|
@ -38,6 +38,14 @@
|
|||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/* PostScript/Xprint print modules do not support more than one object
|
||||
* instance because they use global vars which cannot be shared between
|
||||
* multiple instances...
|
||||
* bug 119491 ("Cleanup global vars in PostScript and Xprint modules) will fix
|
||||
* that...
|
||||
*/
|
||||
#define WE_DO_NOT_SUPPORT_MULTIPLE_PRINT_DEVICECONTEXTS 1
|
||||
|
||||
#include "nsDeviceContextXP.h"
|
||||
#include "nsRenderingContextXp.h"
|
||||
#include "nsFontMetricsXlib.h"
|
||||
|
@ -50,6 +58,10 @@
|
|||
static PRLogModuleInfo *nsDeviceContextXpLM = PR_NewLogModule("nsDeviceContextXp");
|
||||
#endif /* PR_LOGGING */
|
||||
|
||||
#ifdef WE_DO_NOT_SUPPORT_MULTIPLE_PRINT_DEVICECONTEXTS
|
||||
static int instance_counter = 0;
|
||||
#endif /* WE_DO_NOT_SUPPORT_MULTIPLE_PRINT_DEVICECONTEXTS */
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* See documentation in nsIDeviceContext.h
|
||||
*/
|
||||
|
@ -59,6 +71,11 @@ nsDeviceContextXp :: nsDeviceContextXp()
|
|||
mPrintContext = nsnull;
|
||||
mSpec = nsnull;
|
||||
mParentDeviceContext = nsnull;
|
||||
|
||||
#ifdef WE_DO_NOT_SUPPORT_MULTIPLE_PRINT_DEVICECONTEXTS
|
||||
instance_counter++;
|
||||
NS_ASSERTION(instance_counter < 2, "Cannot have more than one print device context.");
|
||||
#endif /* WE_DO_NOT_SUPPORT_MULTIPLE_PRINT_DEVICECONTEXTS */
|
||||
}
|
||||
|
||||
/** ---------------------------------------------------
|
||||
|
@ -68,6 +85,11 @@ nsDeviceContextXp :: nsDeviceContextXp()
|
|||
nsDeviceContextXp :: ~nsDeviceContextXp()
|
||||
{
|
||||
DestroyXPContext();
|
||||
|
||||
#ifdef WE_DO_NOT_SUPPORT_MULTIPLE_PRINT_DEVICECONTEXTS
|
||||
instance_counter--;
|
||||
NS_ASSERTION(instance_counter >= 0, "We cannot have less than zero instances.");
|
||||
#endif /* WE_DO_NOT_SUPPORT_MULTIPLE_PRINT_DEVICECONTEXTS */
|
||||
}
|
||||
|
||||
|
||||
|
@ -75,9 +97,15 @@ NS_IMETHODIMP
|
|||
nsDeviceContextXp::SetSpec(nsIDeviceContextSpec* aSpec)
|
||||
{
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
|
||||
PR_LOG(nsDeviceContextXpLM, PR_LOG_DEBUG, ("nsDeviceContextXp::SetSpec()\n"));
|
||||
|
||||
#ifdef WE_DO_NOT_SUPPORT_MULTIPLE_PRINT_DEVICECONTEXTS
|
||||
NS_ASSERTION(instance_counter < 2, "Cannot have more than one print device context.");
|
||||
if (instance_counter > 1) {
|
||||
return NS_ERROR_GFX_PRINTER_PRINT_WHILE_PREVIEW;
|
||||
}
|
||||
#endif /* WE_DO_NOT_SUPPORT_MULTIPLE_PRINT_DEVICECONTEXTS */
|
||||
|
||||
nsCOMPtr<nsIDeviceContextSpecXp> xpSpec;
|
||||
|
||||
mSpec = aSpec;
|
||||
|
@ -114,6 +142,13 @@ nsDeviceContextXp::InitDeviceContextXP(nsIDeviceContext *aCreatingDeviceContext,
|
|||
float t2d, a2d;
|
||||
int print_resolution;
|
||||
|
||||
#ifdef WE_DO_NOT_SUPPORT_MULTIPLE_PRINT_DEVICECONTEXTS
|
||||
NS_ASSERTION(instance_counter < 2, "Cannot have more than one print device context.");
|
||||
if (instance_counter > 1) {
|
||||
return NS_ERROR_GFX_PRINTER_PRINT_WHILE_PREVIEW;
|
||||
}
|
||||
#endif /* WE_DO_NOT_SUPPORT_MULTIPLE_PRINT_DEVICECONTEXTS */
|
||||
|
||||
mPrintContext->GetPrintResolution(print_resolution);
|
||||
|
||||
mPixelsToTwips = (float)NSIntPointsToTwips(72) / (float)print_resolution;
|
||||
|
|
Загрузка…
Ссылка в новой задаче