зеркало из https://github.com/mozilla/gecko-dev.git
Bug 651017, part 4: deCOM nsIDeviceContext; include-minimization on nsDeviceContext.h itself; merge GetPrintDC() into Windows/OS/2 specific code; merge Shutdown() with ClearCachedSystemFonts(). Most references outside gfx not fixed up.
--HG-- rename : gfx/src/nsThebesDeviceContext.cpp => gfx/src/nsDeviceContext.cpp rename : gfx/src/nsThebesDeviceContext.h => gfx/src/nsDeviceContext.h extra : rebase_source : 9fb366d99d18c9335ba297d21f673178dae62a64
This commit is contained in:
Родитель
67295a5d8d
Коммит
0d75035ecd
|
@ -40,7 +40,7 @@
|
|||
#include "gfxContext.h"
|
||||
#include "gfxPlatform.h"
|
||||
#include "gfxUtils.h"
|
||||
#include "nsIDeviceContext.h"
|
||||
#include "nsDeviceContext.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
|
@ -189,7 +189,7 @@ MovePixels(gfxASurface* aBuffer,
|
|||
// seaming are likely. Assume that the precision of these
|
||||
// computations is 1 app unit, and toss in a fudge factor of 2.0.
|
||||
static const gfxFloat kPrecision =
|
||||
1.0 / gfxFloat(nsIDeviceContext::AppUnitsPerCSSPixel());
|
||||
1.0 / gfxFloat(nsDeviceContext::AppUnitsPerCSSPixel());
|
||||
// FIXME/bug 637852: we've decided to live with transient glitches
|
||||
// during fast-panning for the time being.
|
||||
NS_WARN_IF_FALSE(
|
||||
|
|
|
@ -84,7 +84,7 @@ EXPORTS = \
|
|||
nsTransform2D.h \
|
||||
nsRenderingContext.h \
|
||||
nsFontMetrics.h \
|
||||
nsIDeviceContext.h \
|
||||
nsDeviceContext.h \
|
||||
nsGfxCIID.h \
|
||||
nsIRegion.h \
|
||||
nsITheme.h \
|
||||
|
@ -104,7 +104,7 @@ CPPSRCS = \
|
|||
nsTransform2D.cpp \
|
||||
nsScriptableRegion.cpp \
|
||||
gfxCrashReporterUtils.cpp \
|
||||
nsThebesDeviceContext.cpp \
|
||||
nsDeviceContext.cpp \
|
||||
nsThebesRegion.cpp \
|
||||
nsThebesGfxFactory.cpp \
|
||||
nsRenderingContext.cpp \
|
||||
|
|
|
@ -37,26 +37,19 @@
|
|||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsFont.h"
|
||||
#include "nsGfxCIID.h"
|
||||
#include "nsILanguageAtomService.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
#include "nsDeviceContext.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsFontMetrics.h"
|
||||
#include "nsRenderingContext.h"
|
||||
#include "nsIView.h"
|
||||
#include "nsIWidget.h"
|
||||
|
||||
#include "mozilla/Services.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsILanguageAtomService.h"
|
||||
#include "nsIObserver.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsCRT.h"
|
||||
#include "mozilla/Services.h"
|
||||
|
||||
#include "nsThebesDeviceContext.h"
|
||||
#include "nsRenderingContext.h"
|
||||
#include "gfxUserFontSet.h"
|
||||
#include "gfxPlatform.h"
|
||||
|
||||
#include "nsIWidget.h"
|
||||
#include "nsIView.h"
|
||||
#include "nsILookAndFeel.h"
|
||||
#include "nsIPrefService.h"
|
||||
|
||||
#include "gfxImageSurface.h"
|
||||
|
||||
|
@ -70,17 +63,14 @@ static nsSystemFontsGTK2 *gSystemFonts = nsnull;
|
|||
#include "gfxWindowsSurface.h"
|
||||
#include "gfxPDFSurface.h"
|
||||
static nsSystemFontsWin *gSystemFonts = nsnull;
|
||||
#ifndef WINCE
|
||||
#include <usp10.h>
|
||||
#endif
|
||||
#elif defined(XP_OS2)
|
||||
#include "nsSystemFontsOS2.h"
|
||||
#include "gfxOS2Surface.h"
|
||||
#include "gfxPDFSurface.h"
|
||||
static nsSystemFontsOS2 *gSystemFonts = nsnull;
|
||||
#elif XP_MACOSX
|
||||
#include "nsSystemFontsMac.h"
|
||||
#include "gfxQuartzSurface.h"
|
||||
#include "gfxImageSurface.h"
|
||||
static nsSystemFontsMac *gSystemFonts = nsnull;
|
||||
#elif defined(MOZ_WIDGET_QT)
|
||||
#include "nsSystemFontsQt.h"
|
||||
|
@ -105,7 +95,7 @@ public:
|
|||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIOBSERVER
|
||||
|
||||
void Init(nsIDeviceContext* aContext);
|
||||
void Init(nsDeviceContext* aContext);
|
||||
void Destroy();
|
||||
|
||||
nsresult GetMetricsFor(const nsFont& aFont, nsIAtom* aLanguage,
|
||||
|
@ -117,7 +107,7 @@ public:
|
|||
void Flush();
|
||||
|
||||
protected:
|
||||
nsIDeviceContext* mContext; // owner
|
||||
nsDeviceContext* mContext; // owner
|
||||
nsTArray<nsFontMetrics*> mFontMetrics;
|
||||
};
|
||||
|
||||
|
@ -127,7 +117,7 @@ NS_IMPL_ISUPPORTS1(nsFontCache, nsIObserver)
|
|||
// safe to call AddObserver from a constructor or RemoveObserver
|
||||
// from a destructor. That should be fixed.
|
||||
void
|
||||
nsFontCache::Init(nsIDeviceContext* aContext)
|
||||
nsFontCache::Init(nsDeviceContext* aContext)
|
||||
{
|
||||
mContext = aContext;
|
||||
// register as a memory-pressure observer to free font resources
|
||||
|
@ -266,28 +256,19 @@ nsFontCache::Flush()
|
|||
mFontMetrics.Clear();
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsThebesDeviceContext, nsIDeviceContext)
|
||||
|
||||
nsThebesDeviceContext::nsThebesDeviceContext()
|
||||
nsDeviceContext::nsDeviceContext()
|
||||
: mWidth(0), mHeight(0), mDepth(0),
|
||||
mAppUnitsPerDevPixel(-1), mAppUnitsPerDevNotScaledPixel(-1),
|
||||
mAppUnitsPerPhysicalInch(-1),
|
||||
mPixelScale(1.0f), mPrintingScale(1.0f),
|
||||
mFontCache(nsnull)
|
||||
{
|
||||
mAppUnitsPerDevPixel = nscoord(-1);
|
||||
mAppUnitsPerPhysicalInch = nscoord(-1);
|
||||
mAppUnitsPerDevNotScaledPixel = nscoord(-1);
|
||||
mPixelScale = 1.0f;
|
||||
|
||||
mFontCache = nsnull;
|
||||
mWidget = nsnull;
|
||||
|
||||
mDepth = 0;
|
||||
mWidth = 0;
|
||||
mHeight = 0;
|
||||
mPrintingScale = 1.0f;
|
||||
}
|
||||
|
||||
// Note: we use a bare pointer for mFontCache so that nsFontCache
|
||||
// can be an incomplete type in nsThebesDeviceContext.h.
|
||||
// can be an incomplete type in nsDeviceContext.h.
|
||||
// Therefore we have to do all the refcounting by hand.
|
||||
nsThebesDeviceContext::~nsThebesDeviceContext()
|
||||
nsDeviceContext::~nsDeviceContext()
|
||||
{
|
||||
if (mFontCache) {
|
||||
mFontCache->Destroy();
|
||||
|
@ -295,16 +276,17 @@ nsThebesDeviceContext::~nsThebesDeviceContext()
|
|||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsThebesDeviceContext::CreateFontCache()
|
||||
void
|
||||
nsDeviceContext::CreateFontCache()
|
||||
{
|
||||
mFontCache = new nsFontCache();
|
||||
NS_ADDREF(mFontCache);
|
||||
mFontCache->Init(this);
|
||||
GetLocaleLanguage();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsThebesDeviceContext::FontMetricsDeleted(const nsFontMetrics* aFontMetrics)
|
||||
nsresult
|
||||
nsDeviceContext::FontMetricsDeleted(const nsFontMetrics* aFontMetrics)
|
||||
{
|
||||
if (mFontCache) {
|
||||
mFontCache->FontMetricsDeleted(aFontMetrics);
|
||||
|
@ -313,7 +295,7 @@ NS_IMETHODIMP nsThebesDeviceContext::FontMetricsDeleted(const nsFontMetrics* aFo
|
|||
}
|
||||
|
||||
void
|
||||
nsThebesDeviceContext::GetLocaleLanguage(void)
|
||||
nsDeviceContext::GetLocaleLanguage(void)
|
||||
{
|
||||
if (!mLocaleLanguage) {
|
||||
nsCOMPtr<nsILanguageAtomService> langService;
|
||||
|
@ -327,8 +309,11 @@ nsThebesDeviceContext::GetLocaleLanguage(void)
|
|||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsThebesDeviceContext::GetMetricsFor(const nsFont& aFont,
|
||||
nsIAtom* aLanguage, gfxUserFontSet* aUserFontSet, nsFontMetrics*& aMetrics)
|
||||
nsresult
|
||||
nsDeviceContext::GetMetricsFor(const nsFont& aFont,
|
||||
nsIAtom* aLanguage,
|
||||
gfxUserFontSet* aUserFontSet,
|
||||
nsFontMetrics*& aMetrics)
|
||||
{
|
||||
if (!mFontCache)
|
||||
CreateFontCache();
|
||||
|
@ -342,9 +327,10 @@ NS_IMETHODIMP nsThebesDeviceContext::GetMetricsFor(const nsFont& aFont,
|
|||
return mFontCache->GetMetricsFor(aFont, aLanguage, aUserFontSet, aMetrics);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsThebesDeviceContext::GetMetricsFor(const nsFont& aFont,
|
||||
gfxUserFontSet* aUserFontSet,
|
||||
nsFontMetrics*& aMetrics)
|
||||
nsresult
|
||||
nsDeviceContext::GetMetricsFor(const nsFont& aFont,
|
||||
gfxUserFontSet* aUserFontSet,
|
||||
nsFontMetrics*& aMetrics)
|
||||
{
|
||||
if (!mFontCache)
|
||||
CreateFontCache();
|
||||
|
@ -366,9 +352,9 @@ FontEnumCallback(const nsString& aFamily, PRBool aGeneric, void *aData)
|
|||
return PR_FALSE; // stop
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsThebesDeviceContext::FirstExistingFont(const nsFont& aFont,
|
||||
nsString& aFaceName)
|
||||
nsresult
|
||||
nsDeviceContext::FirstExistingFont(const nsFont& aFont,
|
||||
nsString& aFaceName)
|
||||
{
|
||||
FontEnumData data(aFaceName);
|
||||
if (aFont.EnumerateFamilies(FontEnumCallback, &data)) {
|
||||
|
@ -377,38 +363,32 @@ nsThebesDeviceContext::FirstExistingFont(const nsFont& aFont,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsThebesDeviceContext::GetLocalFontName(const nsString& aFaceName,
|
||||
nsString& aLocalName,
|
||||
PRBool& aAliased)
|
||||
nsresult
|
||||
nsDeviceContext::GetLocalFontName(const nsString& aFaceName,
|
||||
nsString& aLocalName,
|
||||
PRBool& aAliased)
|
||||
{
|
||||
aLocalName = aFaceName;
|
||||
aAliased = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsThebesDeviceContext::FlushFontCache(void)
|
||||
nsresult
|
||||
nsDeviceContext::FlushFontCache(void)
|
||||
{
|
||||
if (mFontCache)
|
||||
mFontCache->Flush();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* static */ void
|
||||
nsThebesDeviceContext::Shutdown()
|
||||
{
|
||||
delete gSystemFonts;
|
||||
gSystemFonts = nsnull;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsThebesDeviceContext::IsPrinterSurface()
|
||||
nsDeviceContext::IsPrinterSurface()
|
||||
{
|
||||
return(mPrintingSurface != NULL);
|
||||
return(mPrintingSurface != NULL);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsThebesDeviceContext::SetDPI()
|
||||
void
|
||||
nsDeviceContext::SetDPI()
|
||||
{
|
||||
float dpi = -1.0f;
|
||||
|
||||
|
@ -416,34 +396,37 @@ nsThebesDeviceContext::SetDPI()
|
|||
// Use a printing DC to determine the other dpi values
|
||||
if (mPrintingSurface) {
|
||||
switch (mPrintingSurface->GetType()) {
|
||||
case gfxASurface::SurfaceTypePDF:
|
||||
case gfxASurface::SurfaceTypePS:
|
||||
case gfxASurface::SurfaceTypeQuartz:
|
||||
dpi = 72.0f;
|
||||
break;
|
||||
case gfxASurface::SurfaceTypePDF:
|
||||
case gfxASurface::SurfaceTypePS:
|
||||
case gfxASurface::SurfaceTypeQuartz:
|
||||
dpi = 72.0f;
|
||||
break;
|
||||
#ifdef XP_WIN
|
||||
case gfxASurface::SurfaceTypeWin32:
|
||||
case gfxASurface::SurfaceTypeWin32Printing: {
|
||||
PRInt32 OSVal = GetDeviceCaps(GetPrintHDC(), LOGPIXELSY);
|
||||
dpi = 144.0f;
|
||||
mPrintingScale = float(OSVal) / dpi;
|
||||
break;
|
||||
}
|
||||
case gfxASurface::SurfaceTypeWin32:
|
||||
case gfxASurface::SurfaceTypeWin32Printing: {
|
||||
HDC dc = reinterpret_cast<gfxWindowsSurface*>(mPrintingSurface.get())->GetDC();
|
||||
PRInt32 OSVal = GetDeviceCaps(dc, LOGPIXELSY);
|
||||
dpi = 144.0f;
|
||||
mPrintingScale = float(OSVal) / dpi;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
#ifdef XP_OS2
|
||||
case gfxASurface::SurfaceTypeOS2:
|
||||
LONG lDPI;
|
||||
if (DevQueryCaps(GetPrintHDC(), CAPS_VERTICAL_FONT_RES, 1, &lDPI))
|
||||
dpi = lDPI;
|
||||
break;
|
||||
case gfxASurface::SurfaceTypeOS2: {
|
||||
LONG lDPI;
|
||||
HDC dc = GpiQueryDevice(reinterpret_cast<gfxOS2Surface*>(mPrintingSurface.get())->GetPS());
|
||||
if (DevQueryCaps(dc, CAPS_VERTICAL_FONT_RES, 1, &lDPI))
|
||||
dpi = lDPI;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
default:
|
||||
NS_NOTREACHED("Unexpected printing surface type");
|
||||
break;
|
||||
default:
|
||||
NS_NOTREACHED("Unexpected printing surface type");
|
||||
break;
|
||||
}
|
||||
|
||||
mAppUnitsPerDevNotScaledPixel =
|
||||
NS_lround((AppUnitsPerCSSPixel() * 96) / dpi);
|
||||
NS_lround((AppUnitsPerCSSPixel() * 96) / dpi);
|
||||
} else {
|
||||
nsCOMPtr<nsIPrefBranch> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID);
|
||||
|
||||
|
@ -500,12 +483,10 @@ nsThebesDeviceContext::SetDPI()
|
|||
|
||||
mAppUnitsPerPhysicalInch = NS_lround(dpi * mAppUnitsPerDevNotScaledPixel);
|
||||
UpdateScaledAppUnits();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsThebesDeviceContext::Init(nsIWidget *aWidget)
|
||||
nsresult
|
||||
nsDeviceContext::Init(nsIWidget *aWidget)
|
||||
{
|
||||
if (mScreenManager && mWidget == aWidget)
|
||||
return NS_OK;
|
||||
|
@ -521,9 +502,9 @@ nsThebesDeviceContext::Init(nsIWidget *aWidget)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsThebesDeviceContext::CreateRenderingContext(nsIView *aView,
|
||||
nsRenderingContext *&aContext)
|
||||
nsresult
|
||||
nsDeviceContext::CreateRenderingContext(nsIView *aView,
|
||||
nsRenderingContext *&aContext)
|
||||
{
|
||||
// This is currently only called by the caret code
|
||||
NS_ENSURE_ARG_POINTER(aView);
|
||||
|
@ -535,9 +516,9 @@ nsThebesDeviceContext::CreateRenderingContext(nsIView *aView,
|
|||
return CreateRenderingContext(widget, aContext);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsThebesDeviceContext::CreateRenderingContext(nsIWidget *aWidget,
|
||||
nsRenderingContext *&aContext)
|
||||
nsresult
|
||||
nsDeviceContext::CreateRenderingContext(nsIWidget *aWidget,
|
||||
nsRenderingContext *&aContext)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
|
@ -558,8 +539,8 @@ nsThebesDeviceContext::CreateRenderingContext(nsIWidget *aWidget,
|
|||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsThebesDeviceContext::CreateRenderingContext(nsRenderingContext *&aContext)
|
||||
nsresult
|
||||
nsDeviceContext::CreateRenderingContext(nsRenderingContext *&aContext)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
|
@ -580,8 +561,8 @@ nsThebesDeviceContext::CreateRenderingContext(nsRenderingContext *&aContext)
|
|||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsThebesDeviceContext::CreateRenderingContextInstance(nsRenderingContext *&aContext)
|
||||
nsresult
|
||||
nsDeviceContext::CreateRenderingContextInstance(nsRenderingContext *&aContext)
|
||||
{
|
||||
nsRefPtr<nsRenderingContext> renderingContext = new nsRenderingContext();
|
||||
if (!renderingContext)
|
||||
|
@ -593,19 +574,17 @@ nsThebesDeviceContext::CreateRenderingContextInstance(nsRenderingContext *&aCont
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsThebesDeviceContext::ClearCachedSystemFonts()
|
||||
/* static */ void
|
||||
nsDeviceContext::ClearCachedSystemFonts()
|
||||
{
|
||||
//clear our cache of stored system fonts
|
||||
if (gSystemFonts) {
|
||||
delete gSystemFonts;
|
||||
gSystemFonts = nsnull;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsThebesDeviceContext::GetSystemFont(nsSystemFontID aID, nsFont *aFont) const
|
||||
nsresult
|
||||
nsDeviceContext::GetSystemFont(nsSystemFontID aID, nsFont *aFont) const
|
||||
{
|
||||
if (!gSystemFonts) {
|
||||
#ifdef MOZ_ENABLE_GTK2
|
||||
|
@ -644,14 +623,14 @@ nsThebesDeviceContext::GetSystemFont(nsSystemFontID aID, nsFont *aFont) const
|
|||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsThebesDeviceContext::CheckFontExistence(const nsString& aFaceName)
|
||||
nsresult
|
||||
nsDeviceContext::CheckFontExistence(const nsString& aFaceName)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsThebesDeviceContext::GetDepth(PRUint32& aDepth)
|
||||
nsresult
|
||||
nsDeviceContext::GetDepth(PRUint32& aDepth)
|
||||
{
|
||||
if (mDepth == 0) {
|
||||
nsCOMPtr<nsIScreen> primaryScreen;
|
||||
|
@ -663,8 +642,8 @@ nsThebesDeviceContext::GetDepth(PRUint32& aDepth)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsThebesDeviceContext::GetDeviceSurfaceDimensions(nscoord &aWidth, nscoord &aHeight)
|
||||
nsresult
|
||||
nsDeviceContext::GetDeviceSurfaceDimensions(nscoord &aWidth, nscoord &aHeight)
|
||||
{
|
||||
if (mPrintingSurface) {
|
||||
// we have a printer device
|
||||
|
@ -680,8 +659,8 @@ nsThebesDeviceContext::GetDeviceSurfaceDimensions(nscoord &aWidth, nscoord &aHei
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsThebesDeviceContext::GetRect(nsRect &aRect)
|
||||
nsresult
|
||||
nsDeviceContext::GetRect(nsRect &aRect)
|
||||
{
|
||||
if (mPrintingSurface) {
|
||||
// we have a printer device
|
||||
|
@ -695,8 +674,8 @@ nsThebesDeviceContext::GetRect(nsRect &aRect)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsThebesDeviceContext::GetClientRect(nsRect &aRect)
|
||||
nsresult
|
||||
nsDeviceContext::GetClientRect(nsRect &aRect)
|
||||
{
|
||||
if (mPrintingSurface) {
|
||||
// we have a printer device
|
||||
|
@ -711,8 +690,8 @@ nsThebesDeviceContext::GetClientRect(nsRect &aRect)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsThebesDeviceContext::PrepareNativeWidget(nsIWidget* aWidget, void** aOut)
|
||||
nsresult
|
||||
nsDeviceContext::PrepareNativeWidget(nsIWidget* aWidget, void** aOut)
|
||||
{
|
||||
*aOut = nsnull;
|
||||
return NS_OK;
|
||||
|
@ -722,8 +701,8 @@ nsThebesDeviceContext::PrepareNativeWidget(nsIWidget* aWidget, void** aOut)
|
|||
/*
|
||||
* below methods are for printing
|
||||
*/
|
||||
NS_IMETHODIMP
|
||||
nsThebesDeviceContext::InitForPrinting(nsIDeviceContextSpec *aDevice)
|
||||
nsresult
|
||||
nsDeviceContext::InitForPrinting(nsIDeviceContextSpec *aDevice)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aDevice);
|
||||
|
||||
|
@ -741,19 +720,19 @@ nsThebesDeviceContext::InitForPrinting(nsIDeviceContextSpec *aDevice)
|
|||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsThebesDeviceContext::PrepareDocument(PRUnichar * aTitle,
|
||||
PRUnichar* aPrintToFileName)
|
||||
nsresult
|
||||
nsDeviceContext::PrepareDocument(PRUnichar * aTitle,
|
||||
PRUnichar* aPrintToFileName)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsThebesDeviceContext::BeginDocument(PRUnichar* aTitle,
|
||||
PRUnichar* aPrintToFileName,
|
||||
PRInt32 aStartPage,
|
||||
PRInt32 aEndPage)
|
||||
nsresult
|
||||
nsDeviceContext::BeginDocument(PRUnichar* aTitle,
|
||||
PRUnichar* aPrintToFileName,
|
||||
PRInt32 aStartPage,
|
||||
PRInt32 aEndPage)
|
||||
{
|
||||
static const PRUnichar kEmpty[] = { '\0' };
|
||||
nsresult rv;
|
||||
|
@ -768,8 +747,8 @@ nsThebesDeviceContext::BeginDocument(PRUnichar* aTitle,
|
|||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsThebesDeviceContext::EndDocument(void)
|
||||
nsresult
|
||||
nsDeviceContext::EndDocument(void)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
|
@ -786,8 +765,8 @@ nsThebesDeviceContext::EndDocument(void)
|
|||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsThebesDeviceContext::AbortDocument(void)
|
||||
nsresult
|
||||
nsDeviceContext::AbortDocument(void)
|
||||
{
|
||||
nsresult rv = mPrintingSurface->AbortPrinting();
|
||||
|
||||
|
@ -798,8 +777,8 @@ nsThebesDeviceContext::AbortDocument(void)
|
|||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsThebesDeviceContext::BeginPage(void)
|
||||
nsresult
|
||||
nsDeviceContext::BeginPage(void)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
|
@ -808,7 +787,7 @@ nsThebesDeviceContext::BeginPage(void)
|
|||
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
/* We need to get a new surface for each page on the Mac */
|
||||
/* We need to get a new surface for each page on the Mac */
|
||||
#ifdef XP_MACOSX
|
||||
mDeviceContextSpec->GetSurfaceForPrinter(getter_AddRefs(mPrintingSurface));
|
||||
#endif
|
||||
|
@ -817,8 +796,8 @@ nsThebesDeviceContext::BeginPage(void)
|
|||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsThebesDeviceContext::EndPage(void)
|
||||
nsresult
|
||||
nsDeviceContext::EndPage(void)
|
||||
{
|
||||
nsresult rv = mPrintingSurface->EndPage();
|
||||
|
||||
|
@ -838,7 +817,7 @@ nsThebesDeviceContext::EndPage(void)
|
|||
/** End printing methods **/
|
||||
|
||||
void
|
||||
nsThebesDeviceContext::ComputeClientRectUsingScreen(nsRect* outRect)
|
||||
nsDeviceContext::ComputeClientRectUsingScreen(nsRect* outRect)
|
||||
{
|
||||
// we always need to recompute the clientRect
|
||||
// because the window may have moved onto a different screen. In the single
|
||||
|
@ -859,7 +838,7 @@ nsThebesDeviceContext::ComputeClientRectUsingScreen(nsRect* outRect)
|
|||
}
|
||||
|
||||
void
|
||||
nsThebesDeviceContext::ComputeFullAreaUsingScreen(nsRect* outRect)
|
||||
nsDeviceContext::ComputeFullAreaUsingScreen(nsRect* outRect)
|
||||
{
|
||||
// if we have more than one screen, we always need to recompute the clientRect
|
||||
// because the window may have moved onto a different screen. In the single
|
||||
|
@ -888,7 +867,7 @@ nsThebesDeviceContext::ComputeFullAreaUsingScreen(nsRect* outRect)
|
|||
// Determines which screen intersects the largest area of the given surface.
|
||||
//
|
||||
void
|
||||
nsThebesDeviceContext::FindScreen(nsIScreen** outScreen)
|
||||
nsDeviceContext::FindScreen(nsIScreen** outScreen)
|
||||
{
|
||||
if (mWidget && mWidget->GetNativeData(NS_NATIVE_WINDOW))
|
||||
mScreenManager->ScreenForNativeWidget(mWidget->GetNativeData(NS_NATIVE_WINDOW),
|
||||
|
@ -898,7 +877,7 @@ nsThebesDeviceContext::FindScreen(nsIScreen** outScreen)
|
|||
}
|
||||
|
||||
void
|
||||
nsThebesDeviceContext::CalcPrintingSize()
|
||||
nsDeviceContext::CalcPrintingSize()
|
||||
{
|
||||
if (!mPrintingSurface)
|
||||
return;
|
||||
|
@ -936,39 +915,39 @@ nsThebesDeviceContext::CalcPrintingSize()
|
|||
#ifdef XP_WIN
|
||||
case gfxASurface::SurfaceTypeWin32:
|
||||
case gfxASurface::SurfaceTypeWin32Printing:
|
||||
{
|
||||
inPoints = PR_FALSE;
|
||||
HDC dc = GetPrintHDC();
|
||||
if (!dc)
|
||||
dc = GetDC((HWND)mWidget->GetNativeData(NS_NATIVE_WIDGET));
|
||||
size.width = NSFloatPixelsToAppUnits(::GetDeviceCaps(dc, HORZRES)/mPrintingScale, AppUnitsPerDevPixel());
|
||||
size.height = NSFloatPixelsToAppUnits(::GetDeviceCaps(dc, VERTRES)/mPrintingScale, AppUnitsPerDevPixel());
|
||||
mDepth = (PRUint32)::GetDeviceCaps(dc, BITSPIXEL);
|
||||
if (dc != (HDC)GetPrintHDC())
|
||||
ReleaseDC((HWND)mWidget->GetNativeData(NS_NATIVE_WIDGET), dc);
|
||||
break;
|
||||
}
|
||||
{
|
||||
inPoints = PR_FALSE;
|
||||
HDC dc = reinterpret_cast<gfxWindowsSurface*>(mPrintingSurface.get())->GetDC();
|
||||
if (!dc)
|
||||
dc = GetDC((HWND)mWidget->GetNativeData(NS_NATIVE_WIDGET));
|
||||
size.width = NSFloatPixelsToAppUnits(::GetDeviceCaps(dc, HORZRES)/mPrintingScale, AppUnitsPerDevPixel());
|
||||
size.height = NSFloatPixelsToAppUnits(::GetDeviceCaps(dc, VERTRES)/mPrintingScale, AppUnitsPerDevPixel());
|
||||
mDepth = (PRUint32)::GetDeviceCaps(dc, BITSPIXEL);
|
||||
if (dc != reinterpret_cast<gfxWindowsSurface*>(mPrintingSurface.get())->GetDC())
|
||||
ReleaseDC((HWND)mWidget->GetNativeData(NS_NATIVE_WIDGET), dc);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef XP_OS2
|
||||
case gfxASurface::SurfaceTypeOS2:
|
||||
{
|
||||
inPoints = PR_FALSE;
|
||||
// we already set the size in the surface constructor we set for
|
||||
// printing, so just get those values here
|
||||
size = reinterpret_cast<gfxOS2Surface*>(mPrintingSurface.get())->GetSize();
|
||||
// as they are in pixels we need to scale them to app units
|
||||
size.width = NSFloatPixelsToAppUnits(size.width, AppUnitsPerDevPixel());
|
||||
size.height = NSFloatPixelsToAppUnits(size.height, AppUnitsPerDevPixel());
|
||||
// still need to get the depth from the device context
|
||||
HDC dc = GetPrintHDC();
|
||||
LONG value;
|
||||
if (DevQueryCaps(dc, CAPS_COLOR_BITCOUNT, 1, &value))
|
||||
mDepth = value;
|
||||
else
|
||||
mDepth = 8; // default to 8bpp, should be enough for printers
|
||||
break;
|
||||
}
|
||||
{
|
||||
inPoints = PR_FALSE;
|
||||
// we already set the size in the surface constructor we set for
|
||||
// printing, so just get those values here
|
||||
size = reinterpret_cast<gfxOS2Surface*>(mPrintingSurface.get())->GetSize();
|
||||
// as they are in pixels we need to scale them to app units
|
||||
size.width = NSFloatPixelsToAppUnits(size.width, AppUnitsPerDevPixel());
|
||||
size.height = NSFloatPixelsToAppUnits(size.height, AppUnitsPerDevPixel());
|
||||
// still need to get the depth from the device context
|
||||
HDC dc = GpiQueryDevice(reinterpret_cast<gfxOS2Surface*>(mPrintingSurface.get())->GetPS());
|
||||
LONG value;
|
||||
if (DevQueryCaps(dc, CAPS_COLOR_BITCOUNT, 1, &value))
|
||||
mDepth = value;
|
||||
else
|
||||
mDepth = 8; // default to 8bpp, should be enough for printers
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
default:
|
||||
NS_ERROR("trying to print to unknown surface type");
|
||||
|
@ -985,18 +964,18 @@ nsThebesDeviceContext::CalcPrintingSize()
|
|||
}
|
||||
}
|
||||
|
||||
PRBool nsThebesDeviceContext::CheckDPIChange() {
|
||||
PRBool nsDeviceContext::CheckDPIChange() {
|
||||
PRInt32 oldDevPixels = mAppUnitsPerDevNotScaledPixel;
|
||||
PRInt32 oldInches = mAppUnitsPerPhysicalInch;
|
||||
|
||||
SetDPI();
|
||||
|
||||
return oldDevPixels != mAppUnitsPerDevNotScaledPixel ||
|
||||
oldInches != mAppUnitsPerPhysicalInch;
|
||||
oldInches != mAppUnitsPerPhysicalInch;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsThebesDeviceContext::SetPixelScale(float aScale)
|
||||
nsDeviceContext::SetPixelScale(float aScale)
|
||||
{
|
||||
if (aScale <= 0) {
|
||||
NS_NOTREACHED("Invalid pixel scale value");
|
||||
|
@ -1009,35 +988,8 @@ nsThebesDeviceContext::SetPixelScale(float aScale)
|
|||
}
|
||||
|
||||
void
|
||||
nsThebesDeviceContext::UpdateScaledAppUnits()
|
||||
nsDeviceContext::UpdateScaledAppUnits()
|
||||
{
|
||||
mAppUnitsPerDevPixel =
|
||||
PR_MAX(1, NSToIntRound(float(mAppUnitsPerDevNotScaledPixel) / mPixelScale));
|
||||
}
|
||||
|
||||
#if defined(XP_WIN) || defined(XP_OS2)
|
||||
HDC
|
||||
nsThebesDeviceContext::GetPrintHDC()
|
||||
{
|
||||
if (mPrintingSurface) {
|
||||
switch (mPrintingSurface->GetType()) {
|
||||
#ifdef XP_WIN
|
||||
case gfxASurface::SurfaceTypeWin32:
|
||||
case gfxASurface::SurfaceTypeWin32Printing:
|
||||
return reinterpret_cast<gfxWindowsSurface*>(mPrintingSurface.get())->GetDC();
|
||||
#endif
|
||||
|
||||
#ifdef XP_OS2
|
||||
case gfxASurface::SurfaceTypeOS2:
|
||||
return GpiQueryDevice(reinterpret_cast<gfxOS2Surface*>(mPrintingSurface.get())->GetPS());
|
||||
#endif
|
||||
|
||||
default:
|
||||
NS_ERROR("invalid surface type in GetPrintHDC");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return nsnull;
|
||||
}
|
||||
#endif
|
|
@ -0,0 +1,409 @@
|
|||
/* -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is thebes gfx
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* mozilla.org.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2005
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Vladimir Vukicevic <vladimir@pobox.com>
|
||||
* Stuart Parmenter <pavlov@pavlov.net>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef _NS_DEVICECONTEXT_H_
|
||||
#define _NS_DEVICECONTEXT_H_
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "nsIDeviceContextSpec.h"
|
||||
#include "nsIScreenManager.h"
|
||||
#include "nsIWidget.h"
|
||||
#include "nsCoord.h"
|
||||
#include "gfxContext.h"
|
||||
|
||||
class nsIView;
|
||||
class nsFontCache;
|
||||
class gfxUserFontSet;
|
||||
|
||||
typedef enum {
|
||||
eSystemFont_Caption, // css2
|
||||
eSystemFont_Icon,
|
||||
eSystemFont_Menu,
|
||||
eSystemFont_MessageBox,
|
||||
eSystemFont_SmallCaption,
|
||||
eSystemFont_StatusBar,
|
||||
|
||||
eSystemFont_Window, // css3
|
||||
eSystemFont_Document,
|
||||
eSystemFont_Workspace,
|
||||
eSystemFont_Desktop,
|
||||
eSystemFont_Info,
|
||||
eSystemFont_Dialog,
|
||||
eSystemFont_Button,
|
||||
eSystemFont_PullDownMenu,
|
||||
eSystemFont_List,
|
||||
eSystemFont_Field,
|
||||
|
||||
eSystemFont_Tooltips, // moz
|
||||
eSystemFont_Widget
|
||||
} nsSystemFontID;
|
||||
|
||||
class nsDeviceContext
|
||||
{
|
||||
public:
|
||||
nsDeviceContext();
|
||||
~nsDeviceContext();
|
||||
|
||||
NS_INLINE_DECL_REFCOUNTING(nsDeviceContext)
|
||||
|
||||
/**
|
||||
* Initialize the device context from a widget
|
||||
* @param aWidget a widget to initialize the device context from
|
||||
* @return error status
|
||||
*/
|
||||
nsresult Init(nsIWidget *aWidget);
|
||||
|
||||
/**
|
||||
* Initialize the device context from a device context spec
|
||||
* @param aDevSpec the specification of the printing device
|
||||
* @return error status
|
||||
*/
|
||||
nsresult InitForPrinting(nsIDeviceContextSpec *aDevSpec);
|
||||
|
||||
/**
|
||||
* Create a rendering context and initialize it from an nsIView
|
||||
* @param aView view to initialize context from
|
||||
* @param aContext out parameter for new rendering context
|
||||
* @return error status
|
||||
*/
|
||||
nsresult CreateRenderingContext(nsIView *aView,
|
||||
nsRenderingContext *&aContext);
|
||||
|
||||
/**
|
||||
* Create a rendering context and initialize it from an nsIWidget
|
||||
* @param aWidget widget to initialize context from
|
||||
* @param aContext out parameter for new rendering context
|
||||
* @return error status
|
||||
*/
|
||||
nsresult CreateRenderingContext(nsIWidget *aWidget,
|
||||
nsRenderingContext *&aContext);
|
||||
|
||||
/**
|
||||
* Create a rendering context and initialize it.
|
||||
* @param aContext out parameter for new rendering context
|
||||
* @return error status
|
||||
*/
|
||||
nsresult CreateRenderingContext(nsRenderingContext *&aContext);
|
||||
|
||||
/**
|
||||
* Create an uninitalised rendering context.
|
||||
* @param aContext out parameter for new rendering context
|
||||
* @return error status
|
||||
*/
|
||||
nsresult CreateRenderingContextInstance(nsRenderingContext *&aContext);
|
||||
|
||||
/**
|
||||
* We are in the process of creating the native widget for
|
||||
* aWidget. Do any device-specific processing required to
|
||||
* initialize the native widget for this device. A pointer to some
|
||||
* platform-specific data is returned in aOut.
|
||||
*/
|
||||
nsresult PrepareNativeWidget(nsIWidget *aWidget, void **aOut);
|
||||
|
||||
/**
|
||||
* Gets the number of app units in one CSS pixel; this number is global,
|
||||
* not unique to each device context.
|
||||
*/
|
||||
static PRInt32 AppUnitsPerCSSPixel() { return 60; }
|
||||
|
||||
/**
|
||||
* Convert app units to CSS pixels. This is a global scale factor.
|
||||
*/
|
||||
static gfxFloat AppUnitsToGfxCSSPixels(nscoord aAppUnits)
|
||||
{ return gfxFloat(aAppUnits) / AppUnitsPerCSSPixel(); }
|
||||
|
||||
/**
|
||||
* Gets the number of app units in one device pixel; this number
|
||||
* is usually a factor of AppUnitsPerCSSPixel(), although that is
|
||||
* not guaranteed.
|
||||
*/
|
||||
PRInt32 AppUnitsPerDevPixel() const { return mAppUnitsPerDevPixel; }
|
||||
|
||||
/**
|
||||
* Convert device pixels which is used for gfx/thebes to nearest
|
||||
* (rounded) app units
|
||||
*/
|
||||
nscoord GfxUnitsToAppUnits(gfxFloat aGfxUnits) const
|
||||
{ return nscoord(NS_round(aGfxUnits * AppUnitsPerDevPixel())); }
|
||||
|
||||
/**
|
||||
* Convert app units to device pixels which is used for gfx/thebes.
|
||||
*/
|
||||
gfxFloat AppUnitsToGfxUnits(nscoord aAppUnits) const
|
||||
{ return gfxFloat(aAppUnits) / AppUnitsPerDevPixel(); }
|
||||
|
||||
/**
|
||||
* Gets the number of app units in one physical inch; this is the
|
||||
* device's DPI times AppUnitsPerDevPixel().
|
||||
*/
|
||||
PRInt32 AppUnitsPerPhysicalInch() const
|
||||
{ return mAppUnitsPerPhysicalInch; }
|
||||
|
||||
/**
|
||||
* Gets the number of app units in one CSS inch; this is
|
||||
* 96 times AppUnitsPerCSSPixel.
|
||||
*/
|
||||
static PRInt32 AppUnitsPerCSSInch() { return 96 * AppUnitsPerCSSPixel(); }
|
||||
|
||||
/**
|
||||
* Get the unscaled ratio of app units to dev pixels; useful if something
|
||||
* needs to be converted from to unscaled pixels
|
||||
*/
|
||||
PRInt32 UnscaledAppUnitsPerDevPixel() const
|
||||
{ return mAppUnitsPerDevNotScaledPixel; }
|
||||
|
||||
/**
|
||||
* Fill in an nsFont based on the ID of a system font. This function
|
||||
* may or may not fill in the size, so the size should be set to a
|
||||
* reasonable default before calling.
|
||||
*
|
||||
* @param aID The system font ID.
|
||||
* @param aInfo The font structure to be filled in.
|
||||
* @return error status
|
||||
*/
|
||||
nsresult GetSystemFont(nsSystemFontID aID, nsFont *aFont) const;
|
||||
|
||||
/**
|
||||
* Clear cached system fonts (refresh from theme when requested).
|
||||
*/
|
||||
static void ClearCachedSystemFonts();
|
||||
|
||||
/**
|
||||
* Get the nsFontMetrics that describe the properties of
|
||||
* an nsFont.
|
||||
* @param aFont font description to obtain metrics for
|
||||
* @param aLanguage the language of the document
|
||||
* @param aMetrics out parameter for font metrics
|
||||
* @param aUserFontSet user font set
|
||||
* @return error status
|
||||
*/
|
||||
nsresult GetMetricsFor(const nsFont& aFont, nsIAtom* aLanguage,
|
||||
gfxUserFontSet* aUserFontSet,
|
||||
nsFontMetrics*& aMetrics);
|
||||
|
||||
/**
|
||||
* Get the nsFontMetrics that describe the properties of
|
||||
* an nsFont.
|
||||
* @param aFont font description to obtain metrics for
|
||||
* @param aMetrics out parameter for font metrics
|
||||
* @param aUserFontSet user font set
|
||||
* @return error status
|
||||
*/
|
||||
nsresult GetMetricsFor(const nsFont& aFont,
|
||||
gfxUserFontSet* aUserFontSet,
|
||||
nsFontMetrics*& aMetrics);
|
||||
|
||||
/**
|
||||
* Notification when a font metrics instance created for this device is
|
||||
* about to be deleted
|
||||
*/
|
||||
nsresult FontMetricsDeleted(const nsFontMetrics* aFontMetrics);
|
||||
|
||||
/**
|
||||
* Attempt to free up resources by flushing out any fonts no longer
|
||||
* referenced by anything other than the font cache itself.
|
||||
* @return error status
|
||||
*/
|
||||
nsresult FlushFontCache();
|
||||
|
||||
/**
|
||||
* Check to see if a particular named font exists.
|
||||
* @param aFontName character string of font face name
|
||||
* @return NS_OK if font is available, else font is unavailable
|
||||
*/
|
||||
nsresult CheckFontExistence(const nsString& aFaceName);
|
||||
nsresult FirstExistingFont(const nsFont& aFont, nsString& aFaceName);
|
||||
nsresult GetLocalFontName(const nsString& aFaceName, nsString& aLocalName,
|
||||
PRBool& aAliased);
|
||||
|
||||
|
||||
/**
|
||||
* Return the bit depth of the device.
|
||||
*/
|
||||
nsresult GetDepth(PRUint32& aDepth);
|
||||
|
||||
/**
|
||||
* Get the size of the displayable area of the output device
|
||||
* in app units.
|
||||
* @param aWidth out parameter for width
|
||||
* @param aHeight out parameter for height
|
||||
* @return error status
|
||||
*/
|
||||
nsresult GetDeviceSurfaceDimensions(nscoord& aWidth, nscoord& aHeight);
|
||||
|
||||
/**
|
||||
* Get the size of the content area of the output device in app
|
||||
* units. This corresponds on a screen device, for instance, to
|
||||
* the entire screen.
|
||||
* @param aRect out parameter for full rect. Position (x,y) will
|
||||
* be (0,0) or relative to the primary monitor if
|
||||
* this is not the primary.
|
||||
* @return error status
|
||||
*/
|
||||
nsresult GetRect(nsRect& aRect);
|
||||
|
||||
/**
|
||||
* Get the size of the content area of the output device in app
|
||||
* units. This corresponds on a screen device, for instance, to
|
||||
* the area reported by GetDeviceSurfaceDimensions, minus the
|
||||
* taskbar (Windows) or menubar (Macintosh).
|
||||
* @param aRect out parameter for client rect. Position (x,y) will
|
||||
* be (0,0) adjusted for any upper/left non-client
|
||||
* space if present or relative to the primary
|
||||
* monitor if this is not the primary.
|
||||
* @return error status
|
||||
*/
|
||||
nsresult GetClientRect(nsRect& aRect);
|
||||
|
||||
/**
|
||||
* Do anything that needs to be done to prepare for printing.
|
||||
* @param aTitle - title of Document
|
||||
* @param aPrintToFileName - name of file to print to, if NULL
|
||||
* then don't print to file
|
||||
*
|
||||
* @return error status
|
||||
*/
|
||||
nsresult PrepareDocument(PRUnichar *aTitle,
|
||||
PRUnichar *aPrintToFileName);
|
||||
|
||||
/**
|
||||
* Inform the output device that output of a document is beginning
|
||||
* Used for print related device contexts. Must be matched 1:1 with
|
||||
* EndDocument() or AbortDocument().
|
||||
*
|
||||
* @param aTitle - title of Document
|
||||
* @param aPrintToFileName - name of file to print to, if NULL
|
||||
* then don't print to file
|
||||
* @param aStartPage - starting page number (must be greater than zero)
|
||||
* @param aEndPage - ending page number (must be less than or
|
||||
* equal to number of pages)
|
||||
*
|
||||
* @return error status
|
||||
*/
|
||||
nsresult BeginDocument(PRUnichar *aTitle,
|
||||
PRUnichar *aPrintToFileName,
|
||||
PRInt32 aStartPage,
|
||||
PRInt32 aEndPage);
|
||||
|
||||
/**
|
||||
* Inform the output device that output of a document is ending.
|
||||
* Used for print related device contexts. Must be matched 1:1 with
|
||||
* BeginDocument()
|
||||
* @return error status
|
||||
*/
|
||||
nsresult EndDocument();
|
||||
|
||||
/**
|
||||
* Inform the output device that output of a document is being aborted.
|
||||
* Must be matched 1:1 with BeginDocument()
|
||||
* @return error status
|
||||
*/
|
||||
nsresult AbortDocument();
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* @return error status
|
||||
*/
|
||||
nsresult BeginPage();
|
||||
|
||||
/**
|
||||
* Inform the output device that output of a page is ending
|
||||
* Used for print related device contexts. Must be matched 1:1 with
|
||||
* BeginPage() and within a BeginDocument()/EndDocument() pair.
|
||||
* @return error status
|
||||
*/
|
||||
nsresult EndPage();
|
||||
|
||||
/**
|
||||
* Check to see if the DPI has changed
|
||||
* @return whether there was actually a change in the DPI (whether
|
||||
* AppUnitsPerDevPixel() or AppUnitsPerPhysicalInch()
|
||||
* changed)
|
||||
*/
|
||||
PRBool CheckDPIChange();
|
||||
|
||||
/**
|
||||
* Set the pixel scaling factor: all lengths are multiplied by this factor
|
||||
* when we convert them to device pixels. Returns whether the ratio of
|
||||
* app units to dev pixels changed because of the scale factor.
|
||||
*/
|
||||
PRBool SetPixelScale(float aScale);
|
||||
|
||||
/**
|
||||
* Get the pixel scaling factor; defaults to 1.0, but can be changed with
|
||||
* SetPixelScale.
|
||||
*/
|
||||
float GetPixelScale() const { return mPixelScale; }
|
||||
|
||||
/**
|
||||
* True if this device context was created for printing.
|
||||
*/
|
||||
PRBool IsPrinterSurface();
|
||||
|
||||
protected:
|
||||
void CreateFontCache();
|
||||
void GetLocaleLanguage();
|
||||
void SetDPI();
|
||||
void ComputeClientRectUsingScreen(nsRect *outRect);
|
||||
void ComputeFullAreaUsingScreen(nsRect *outRect);
|
||||
void FindScreen(nsIScreen **outScreen);
|
||||
void CalcPrintingSize();
|
||||
void UpdateScaledAppUnits();
|
||||
|
||||
nscoord mWidth;
|
||||
nscoord mHeight;
|
||||
PRUint32 mDepth;
|
||||
PRInt32 mAppUnitsPerDevPixel;
|
||||
PRInt32 mAppUnitsPerDevNotScaledPixel;
|
||||
PRInt32 mAppUnitsPerPhysicalInch;
|
||||
float mPixelScale;
|
||||
float mPrintingScale;
|
||||
|
||||
nsFontCache* mFontCache;
|
||||
nsCOMPtr<nsIAtom> mLocaleLanguage;
|
||||
nsCOMPtr<nsIWidget> mWidget;
|
||||
nsCOMPtr<nsIScreenManager> mScreenManager;
|
||||
nsCOMPtr<nsIDeviceContextSpec> mDeviceContextSpec;
|
||||
nsRefPtr<gfxASurface> mPrintingSurface;
|
||||
};
|
||||
|
||||
#endif /* _NS_DEVICECONTEXT_H_ */
|
|
@ -39,7 +39,7 @@
|
|||
#include "nsFontMetrics.h"
|
||||
#include "nsBoundingMetrics.h"
|
||||
#include "nsRenderingContext.h"
|
||||
#include "nsThebesDeviceContext.h"
|
||||
#include "nsDeviceContext.h"
|
||||
#include "gfxTextRunCache.h"
|
||||
|
||||
namespace {
|
||||
|
@ -105,14 +105,14 @@ nsFontMetrics::~nsFontMetrics()
|
|||
|
||||
nsresult
|
||||
nsFontMetrics::Init(const nsFont& aFont, nsIAtom* aLanguage,
|
||||
nsIDeviceContext *aContext,
|
||||
nsDeviceContext *aContext,
|
||||
gfxUserFontSet *aUserFontSet)
|
||||
{
|
||||
NS_ABORT_IF_FALSE(mP2A == -1, "already initialized");
|
||||
|
||||
mFont = aFont;
|
||||
mLanguage = aLanguage;
|
||||
mDeviceContext = (nsThebesDeviceContext*)aContext;
|
||||
mDeviceContext = aContext;
|
||||
mP2A = mDeviceContext->AppUnitsPerDevPixel();
|
||||
|
||||
gfxFontStyle style(aFont.style,
|
||||
|
|
|
@ -45,9 +45,8 @@
|
|||
#include "gfxFont.h"
|
||||
|
||||
class nsIAtom;
|
||||
class nsIDeviceContext;
|
||||
class nsDeviceContext;
|
||||
class nsRenderingContext;
|
||||
class nsThebesDeviceContext;
|
||||
struct nsBoundingMetrics;
|
||||
|
||||
/**
|
||||
|
@ -80,10 +79,10 @@ public:
|
|||
* Initialize the font metrics. Call this after creating the font metrics.
|
||||
* Font metrics you get from the font cache do NOT need to be initialized
|
||||
*
|
||||
* @see nsIDeviceContext#GetMetricsFor()
|
||||
* @see nsDeviceContext#GetMetricsFor()
|
||||
*/
|
||||
nsresult Init(const nsFont& aFont, nsIAtom* aLanguage,
|
||||
nsIDeviceContext *aContext,
|
||||
nsDeviceContext *aContext,
|
||||
gfxUserFontSet *aUserFontSet = nsnull);
|
||||
|
||||
/**
|
||||
|
@ -238,7 +237,7 @@ protected:
|
|||
nsFont mFont;
|
||||
nsRefPtr<gfxFontGroup> mFontGroup;
|
||||
nsCOMPtr<nsIAtom> mLanguage;
|
||||
nsThebesDeviceContext *mDeviceContext;
|
||||
nsDeviceContext *mDeviceContext;
|
||||
PRInt32 mP2A;
|
||||
PRPackedBool mTextRunRTL;
|
||||
};
|
||||
|
|
|
@ -38,10 +38,6 @@
|
|||
#ifndef nsGfxCIID_h__
|
||||
#define nsGfxCIID_h__
|
||||
|
||||
#define NS_DEVICE_CONTEXT_CID \
|
||||
{ 0x6049b262, 0xc1e6, 0x11d1, \
|
||||
{ 0xa8, 0x27, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9 } }
|
||||
|
||||
#define NS_FONT_ENUMERATOR_CID \
|
||||
{ 0xa6cf9115, 0x15b3, 0x11d2, \
|
||||
{ 0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32 } }
|
||||
|
|
|
@ -1,386 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Roland Mainz <roland.mainz@informatik.med.uni-giessen.de>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsIDeviceContext_h___
|
||||
#define nsIDeviceContext_h___
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsCoord.h"
|
||||
#include "gfxTypes.h"
|
||||
#include "nsStringFwd.h"
|
||||
|
||||
class nsIView;
|
||||
class nsFontMetrics;
|
||||
class nsIWidget;
|
||||
class nsIDeviceContextSpec;
|
||||
class nsIAtom;
|
||||
class nsRect;
|
||||
class gfxUserFontSet;
|
||||
class nsRenderingContext;
|
||||
struct nsFont;
|
||||
|
||||
#define NS_IDEVICE_CONTEXT_IID \
|
||||
{ 0x30a9d22f, 0x8e51, 0x40af, \
|
||||
{ 0xa1, 0xf5, 0x48, 0xe3, 0x00, 0xaa, 0xa9, 0x27 } }
|
||||
|
||||
typedef enum {
|
||||
eSystemFont_Caption, // css2
|
||||
eSystemFont_Icon,
|
||||
eSystemFont_Menu,
|
||||
eSystemFont_MessageBox,
|
||||
eSystemFont_SmallCaption,
|
||||
eSystemFont_StatusBar,
|
||||
|
||||
eSystemFont_Window, // css3
|
||||
eSystemFont_Document,
|
||||
eSystemFont_Workspace,
|
||||
eSystemFont_Desktop,
|
||||
eSystemFont_Info,
|
||||
eSystemFont_Dialog,
|
||||
eSystemFont_Button,
|
||||
eSystemFont_PullDownMenu,
|
||||
eSystemFont_List,
|
||||
eSystemFont_Field,
|
||||
|
||||
eSystemFont_Tooltips, // moz
|
||||
eSystemFont_Widget
|
||||
} nsSystemFontID;
|
||||
|
||||
class nsIDeviceContext : public nsISupports
|
||||
{
|
||||
public:
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IDEVICE_CONTEXT_IID)
|
||||
|
||||
/**
|
||||
* Initialize the device context from a widget
|
||||
* @param aWidget a widget to initialize the device context from
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD Init(nsIWidget* aWidget) = 0;
|
||||
|
||||
/**
|
||||
* Initialize the device context from a device context spec
|
||||
* @param aDevSpec the specification of the printng device (platform-specific)
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD InitForPrinting(nsIDeviceContextSpec* aDevSpec) = 0;
|
||||
|
||||
/**
|
||||
* Create a rendering context and initialize it from an nsIView
|
||||
* @param aView view to initialize context from
|
||||
* @param aContext out parameter for new rendering context
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD CreateRenderingContext(nsIView *aView, nsRenderingContext *&aContext) = 0;
|
||||
|
||||
/**
|
||||
* Create a rendering context and initialize it from an nsIWidget
|
||||
* @param aWidget widget to initialize context from
|
||||
* @param aContext out parameter for new rendering context
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD CreateRenderingContext(nsIWidget *aWidget, nsRenderingContext *&aContext) = 0;
|
||||
|
||||
/**
|
||||
* Create a rendering context and initialize it.
|
||||
* @param aContext out parameter for new rendering context
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD CreateRenderingContext(nsRenderingContext *&aContext) = 0;
|
||||
|
||||
/**
|
||||
* Create an uninitalised rendering context.
|
||||
* @param aContext out parameter for new rendering context
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD CreateRenderingContextInstance(nsRenderingContext *&aContext) = 0;
|
||||
|
||||
/**
|
||||
* We are in the process of creating the native widget for aWidget.
|
||||
* Do any device-specific processing required to initialize the
|
||||
* native widget for this device. A pointer to some platform-specific data is
|
||||
* returned in aOut.
|
||||
*
|
||||
* GTK2 calls this to get the required visual for the window.
|
||||
*/
|
||||
NS_IMETHOD PrepareNativeWidget(nsIWidget* aWidget, void** aOut) = 0;
|
||||
|
||||
/**
|
||||
* Gets the number of app units in one CSS pixel; this number is global,
|
||||
* not unique to each device context.
|
||||
*/
|
||||
static PRInt32 AppUnitsPerCSSPixel() { return 60; }
|
||||
|
||||
/**
|
||||
* Convert app units to CSS pixels which is used in gfx/thebes.
|
||||
*/
|
||||
static gfxFloat AppUnitsToGfxCSSPixels(nscoord aAppUnits)
|
||||
{ return gfxFloat(aAppUnits) / AppUnitsPerCSSPixel(); }
|
||||
|
||||
/**
|
||||
* Gets the number of app units in one device pixel; this number is usually
|
||||
* a factor of AppUnitsPerCSSPixel(), although that is not guaranteed.
|
||||
*/
|
||||
PRInt32 AppUnitsPerDevPixel() const { return mAppUnitsPerDevPixel; }
|
||||
|
||||
/**
|
||||
* Convert device pixels which is used for gfx/thebes to nearest (rounded)
|
||||
* app units
|
||||
*/
|
||||
nscoord GfxUnitsToAppUnits(gfxFloat aGfxUnits) const
|
||||
{ return nscoord(NS_round(aGfxUnits * AppUnitsPerDevPixel())); }
|
||||
|
||||
/**
|
||||
* Convert app units to device pixels which is used for gfx/thebes.
|
||||
*/
|
||||
gfxFloat AppUnitsToGfxUnits(nscoord aAppUnits) const
|
||||
{ return gfxFloat(aAppUnits) / AppUnitsPerDevPixel(); }
|
||||
|
||||
/**
|
||||
* Gets the number of app units in one physical inch; this is the
|
||||
* device's DPI times AppUnitsPerDevPixel().
|
||||
*/
|
||||
PRInt32 AppUnitsPerPhysicalInch() const { return mAppUnitsPerPhysicalInch; }
|
||||
|
||||
/**
|
||||
* Gets the number of app units in one CSS inch; this is the
|
||||
* 96 times AppUnitsPerCSSPixel.
|
||||
*/
|
||||
static PRInt32 AppUnitsPerCSSInch() { return 96 * AppUnitsPerCSSPixel(); }
|
||||
|
||||
/**
|
||||
* Fill in an nsFont based on the ID of a system font. This function
|
||||
* may or may not fill in the size, so the size should be set to a
|
||||
* reasonable default before calling.
|
||||
*
|
||||
* @param aID The system font ID.
|
||||
* @param aInfo The font structure to be filled in.
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD GetSystemFont(nsSystemFontID aID, nsFont *aFont) const = 0;
|
||||
|
||||
/**
|
||||
* Get the nsFontMetrics that describe the properties of
|
||||
* an nsFont.
|
||||
* @param aFont font description to obtain metrics for
|
||||
* @param aLanguage the language of the document
|
||||
* @param aMetrics out parameter for font metrics
|
||||
* @param aUserFontSet user font set
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD GetMetricsFor(const nsFont& aFont, nsIAtom* aLanguage,
|
||||
gfxUserFontSet* aUserFontSet,
|
||||
nsFontMetrics*& aMetrics) = 0;
|
||||
|
||||
/**
|
||||
* Get the nsFontMetrics that describe the properties of
|
||||
* an nsFont.
|
||||
* @param aFont font description to obtain metrics for
|
||||
* @param aMetrics out parameter for font metrics
|
||||
* @param aUserFontSet user font set
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD GetMetricsFor(const nsFont& aFont, gfxUserFontSet* aUserFontSet,
|
||||
nsFontMetrics*& aMetrics) = 0;
|
||||
|
||||
/**
|
||||
* Check to see if a particular named font exists.
|
||||
* @param aFontName character string of font face name
|
||||
* @return NS_OK if font is available, else font is unavailable
|
||||
*/
|
||||
NS_IMETHOD CheckFontExistence(const nsString& aFaceName) = 0;
|
||||
NS_IMETHOD FirstExistingFont(const nsFont& aFont, nsString& aFaceName) = 0;
|
||||
|
||||
NS_IMETHOD GetLocalFontName(const nsString& aFaceName, nsString& aLocalName,
|
||||
PRBool& aAliased) = 0;
|
||||
|
||||
/**
|
||||
* Notification when a font metrics instance created for this device is
|
||||
* about to be deleted
|
||||
*/
|
||||
NS_IMETHOD FontMetricsDeleted(const nsFontMetrics* aFontMetrics) = 0;
|
||||
|
||||
/**
|
||||
* Attempt to free up resoruces by flushing out any fonts no longer
|
||||
* referenced by anything other than the font cache itself.
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD FlushFontCache(void) = 0;
|
||||
|
||||
/**
|
||||
* Return the bit depth of the device.
|
||||
*/
|
||||
NS_IMETHOD GetDepth(PRUint32& aDepth) = 0;
|
||||
|
||||
/**
|
||||
* Get the size of the displayable area of the output device
|
||||
* in app units.
|
||||
* @param aWidth out parameter for width
|
||||
* @param aHeight out parameter for height
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD GetDeviceSurfaceDimensions(nscoord &aWidth, nscoord &aHeight) = 0;
|
||||
|
||||
/**
|
||||
* Get the size of the content area of the output device in app units.
|
||||
* This corresponds on a screen device, for instance, to the entire screen.
|
||||
* @param aRect out parameter for full rect. Position (x,y) will be (0,0) or
|
||||
* relative to the primary monitor if this is not the primary.
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD GetRect ( nsRect &aRect ) = 0;
|
||||
|
||||
/**
|
||||
* Get the size of the content area of the output device in app units.
|
||||
* This corresponds on a screen device, for instance, to the area reported
|
||||
* by GetDeviceSurfaceDimensions, minus the taskbar (Windows) or menubar
|
||||
* (Macintosh).
|
||||
* @param aRect out parameter for client rect. Position (x,y) will be (0,0)
|
||||
* adjusted for any upper/left non-client space if present or
|
||||
* relative to the primary monitor if this is not the primary.
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD GetClientRect(nsRect &aRect) = 0;
|
||||
|
||||
/**
|
||||
* This is enables the DeviceContext to anything it needs to do for Printing
|
||||
* before Reflow and BeginDocument is where work can be done after reflow.
|
||||
* @param aTitle - itle of Document
|
||||
* @param aPrintToFileName - name of file to print to, if NULL then don't print to file
|
||||
*
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD PrepareDocument(PRUnichar * aTitle,
|
||||
PRUnichar* aPrintToFileName) = 0;
|
||||
|
||||
//XXX need to work out re-entrancy issues for these APIs... MMP
|
||||
/**
|
||||
* Inform the output device that output of a document is beginning
|
||||
* Used for print related device contexts. Must be matched 1:1 with
|
||||
* EndDocument().
|
||||
* XXX needs to take parameters so that feedback can be given to the
|
||||
* app regarding pagination progress and aborting print operations?
|
||||
*
|
||||
* @param aTitle - itle of Document
|
||||
* @param aPrintToFileName - name of file to print to, if NULL then don't print to file
|
||||
* @param aStartPage - starting page number (must be greater than zero)
|
||||
* @param aEndPage - ending page number (must be less than or equal to number of pages)
|
||||
*
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD BeginDocument(PRUnichar* aTitle,
|
||||
PRUnichar* aPrintToFileName,
|
||||
PRInt32 aStartPage,
|
||||
PRInt32 aEndPage) = 0;
|
||||
|
||||
/**
|
||||
* Inform the output device that output of a document is ending.
|
||||
* Used for print related device contexts. Must be matched 1:1 with
|
||||
* BeginDocument()
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD EndDocument(void) = 0;
|
||||
|
||||
/**
|
||||
* Inform the output device that output of a document is being aborted.
|
||||
* Must be matched 1:1 with BeginDocument()
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD AbortDocument(void) = 0;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD BeginPage(void) = 0;
|
||||
|
||||
/**
|
||||
* Inform the output device that output of a page is ending
|
||||
* Used for print related device contexts. Must be matched 1:1 with
|
||||
* BeginPage() and within a BeginDocument()/EndDocument() pair.
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD EndPage(void) = 0;
|
||||
|
||||
/**
|
||||
* Clear cached system fonts (refresh from theme when
|
||||
* requested). This method is effectively static,
|
||||
* and can be called on a new DeviceContext instance
|
||||
* without any initialization. Only really used by
|
||||
* Gtk native theme stuff.
|
||||
*/
|
||||
NS_IMETHOD ClearCachedSystemFonts() = 0;
|
||||
|
||||
/**
|
||||
* Check to see if the DPI has changed
|
||||
* @return whether there was actually a change in the DPI
|
||||
* (whether AppUnitsPerDevPixel() or AppUnitsPerPhysicalInch() changed)
|
||||
*/
|
||||
virtual PRBool CheckDPIChange() = 0;
|
||||
|
||||
/**
|
||||
* Set the pixel scaling factor: all lengths are multiplied by this factor
|
||||
* when we convert them to device pixels. Returns whether the ratio of
|
||||
* app units to dev pixels changed because of the scale factor.
|
||||
*/
|
||||
virtual PRBool SetPixelScale(float aScale) = 0;
|
||||
|
||||
/**
|
||||
* Get the pixel scaling factor; defaults to 1.0, but can be changed with
|
||||
* SetPixelScale.
|
||||
*/
|
||||
float GetPixelScale() const { return mPixelScale; }
|
||||
|
||||
/**
|
||||
* Get the unscaled ratio of app units to dev pixels; useful if something
|
||||
* needs to be converted from to unscaled pixels
|
||||
*/
|
||||
PRInt32 UnscaledAppUnitsPerDevPixel() const { return mAppUnitsPerDevNotScaledPixel; }
|
||||
|
||||
protected:
|
||||
PRInt32 mAppUnitsPerDevPixel;
|
||||
PRInt32 mAppUnitsPerPhysicalInch;
|
||||
PRInt32 mAppUnitsPerDevNotScaledPixel;
|
||||
float mPixelScale;
|
||||
};
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(nsIDeviceContext, NS_IDEVICE_CONTEXT_IID)
|
||||
|
||||
#endif /* nsIDeviceContext_h___ */
|
|
@ -52,7 +52,7 @@ struct nsFont;
|
|||
struct nsIntMargin;
|
||||
class nsPresContext;
|
||||
class nsRenderingContext;
|
||||
class nsIDeviceContext;
|
||||
class nsDeviceContext;
|
||||
class nsIFrame;
|
||||
class nsIContent;
|
||||
class nsIAtom;
|
||||
|
@ -111,7 +111,7 @@ public:
|
|||
/**
|
||||
* Get the computed CSS border for the widget, in pixels.
|
||||
*/
|
||||
NS_IMETHOD GetWidgetBorder(nsIDeviceContext* aContext,
|
||||
NS_IMETHOD GetWidgetBorder(nsDeviceContext* aContext,
|
||||
nsIFrame* aFrame,
|
||||
PRUint8 aWidgetType,
|
||||
nsIntMargin* aResult)=0;
|
||||
|
@ -125,7 +125,7 @@ public:
|
|||
* so that we don't let specified padding that has no effect change
|
||||
* the computed padding and potentially the size.
|
||||
*/
|
||||
virtual PRBool GetWidgetPadding(nsIDeviceContext* aContext,
|
||||
virtual PRBool GetWidgetPadding(nsDeviceContext* aContext,
|
||||
nsIFrame* aFrame,
|
||||
PRUint8 aWidgetType,
|
||||
nsIntMargin* aResult) = 0;
|
||||
|
@ -138,7 +138,7 @@ public:
|
|||
* fill in aResult with the desired overflow area, in appunits, relative
|
||||
* to the frame origin, and return PR_TRUE.
|
||||
*/
|
||||
virtual PRBool GetWidgetOverflow(nsIDeviceContext* aContext,
|
||||
virtual PRBool GetWidgetOverflow(nsDeviceContext* aContext,
|
||||
nsIFrame* aFrame,
|
||||
PRUint8 aWidgetType,
|
||||
/*INOUT*/ nsRect* aOverflowRect)
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
|
||||
#include "nsRect.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIDeviceContext.h"
|
||||
#include "nsDeviceContext.h"
|
||||
#include "prlog.h"
|
||||
#include <limits.h>
|
||||
|
||||
|
@ -85,16 +85,16 @@ FILE* operator<<(FILE* out, const nsRect& rect)
|
|||
// Output the coordinates in fractional pixels so they're easier to read
|
||||
tmp.AppendLiteral("{");
|
||||
tmp.AppendFloat(NSAppUnitsToFloatPixels(rect.x,
|
||||
nsIDeviceContext::AppUnitsPerCSSPixel()));
|
||||
nsDeviceContext::AppUnitsPerCSSPixel()));
|
||||
tmp.AppendLiteral(", ");
|
||||
tmp.AppendFloat(NSAppUnitsToFloatPixels(rect.y,
|
||||
nsIDeviceContext::AppUnitsPerCSSPixel()));
|
||||
nsDeviceContext::AppUnitsPerCSSPixel()));
|
||||
tmp.AppendLiteral(", ");
|
||||
tmp.AppendFloat(NSAppUnitsToFloatPixels(rect.width,
|
||||
nsIDeviceContext::AppUnitsPerCSSPixel()));
|
||||
nsDeviceContext::AppUnitsPerCSSPixel()));
|
||||
tmp.AppendLiteral(", ");
|
||||
tmp.AppendFloat(NSAppUnitsToFloatPixels(rect.height,
|
||||
nsIDeviceContext::AppUnitsPerCSSPixel()));
|
||||
nsDeviceContext::AppUnitsPerCSSPixel()));
|
||||
tmp.AppendLiteral("}");
|
||||
fputs(NS_LossyConvertUTF16toASCII(tmp).get(), out);
|
||||
return out;
|
||||
|
|
|
@ -85,14 +85,14 @@ static PRInt32 FindSafeLength(const char *aString, PRUint32 aLength,
|
|||
//// nsRenderingContext
|
||||
|
||||
void
|
||||
nsRenderingContext::Init(nsIDeviceContext* aContext,
|
||||
nsRenderingContext::Init(nsDeviceContext* aContext,
|
||||
gfxASurface *aThebesSurface)
|
||||
{
|
||||
Init(aContext, new gfxContext(aThebesSurface));
|
||||
}
|
||||
|
||||
void
|
||||
nsRenderingContext::Init(nsIDeviceContext* aContext,
|
||||
nsRenderingContext::Init(nsDeviceContext* aContext,
|
||||
gfxContext *aThebesContext)
|
||||
{
|
||||
mDeviceContext = aContext;
|
||||
|
|
|
@ -40,8 +40,7 @@
|
|||
#define NSRENDERINGCONTEXT__H__
|
||||
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIDeviceContext.h"
|
||||
#include "nsDeviceContext.h"
|
||||
#include "nsFontMetrics.h"
|
||||
#include "nsColor.h"
|
||||
#include "nsCoord.h"
|
||||
|
@ -65,12 +64,12 @@ public:
|
|||
|
||||
NS_INLINE_DECL_REFCOUNTING(nsRenderingContext)
|
||||
|
||||
void Init(nsIDeviceContext* aContext, gfxASurface* aThebesSurface);
|
||||
void Init(nsIDeviceContext* aContext, gfxContext* aThebesContext);
|
||||
void Init(nsDeviceContext* aContext, gfxASurface* aThebesSurface);
|
||||
void Init(nsDeviceContext* aContext, gfxContext* aThebesContext);
|
||||
|
||||
// These accessors will never return null.
|
||||
gfxContext *ThebesContext() { return mThebes; }
|
||||
nsIDeviceContext *DeviceContext() { return mDeviceContext; }
|
||||
nsDeviceContext *DeviceContext() { return mDeviceContext; }
|
||||
PRInt32 AppUnitsPerDevPixel() { return mP2A; }
|
||||
|
||||
// Graphics state
|
||||
|
@ -148,7 +147,7 @@ protected:
|
|||
PRInt32 GetMaxChunkLength();
|
||||
|
||||
nsRefPtr<gfxContext> mThebes;
|
||||
nsCOMPtr<nsIDeviceContext> mDeviceContext;
|
||||
nsRefPtr<nsDeviceContext> mDeviceContext;
|
||||
nsRefPtr<nsFontMetrics> mFontMetrics;
|
||||
|
||||
double mP2A; // cached app units per device pixel value
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
#define _NS_SYSTEMFONTSANDROID_H_
|
||||
|
||||
#include "gfxFont.h"
|
||||
#include "nsIDeviceContext.h"
|
||||
#include "nsDeviceContext.h"
|
||||
|
||||
class nsSystemFontsAndroid
|
||||
{
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
#define _NS_SYSTEMFONTSGTK2_H_
|
||||
|
||||
#include "gfxFont.h"
|
||||
#include "nsIDeviceContext.h"
|
||||
#include "nsDeviceContext.h"
|
||||
|
||||
typedef struct _GtkWidget GtkWidget;
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
#define _NS_SYSTEMFONTSMAC_H_
|
||||
|
||||
#include "gfxFont.h"
|
||||
#include "nsIDeviceContext.h"
|
||||
#include "nsDeviceContext.h"
|
||||
|
||||
class nsSystemFontsMac
|
||||
{
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
#define _NS_SYSTEMFONTSOS2_H_
|
||||
|
||||
#include "gfxFont.h"
|
||||
#include "nsIDeviceContext.h"
|
||||
#include "nsDeviceContext.h"
|
||||
|
||||
class nsSystemFontsOS2
|
||||
{
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
#define _NS_SYSTEMFONTSQT_H_
|
||||
|
||||
#include "gfxFont.h"
|
||||
#include "nsIDeviceContext.h"
|
||||
#include "nsDeviceContext.h"
|
||||
|
||||
class nsSystemFontsQt
|
||||
{
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
#define _NS_SYSTEMFONTSWIN_H_
|
||||
|
||||
#include "gfxFont.h"
|
||||
#include "nsIDeviceContext.h"
|
||||
#include "nsDeviceContext.h"
|
||||
#include <windows.h> // need HDC and LOGFONTW
|
||||
|
||||
class nsSystemFontsWin
|
||||
|
|
|
@ -1,155 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is thebes gfx
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* mozilla.org.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2005
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Vladimir Vukicevic <vladimir@pobox.com>
|
||||
* Stuart Parmenter <pavlov@pavlov.net>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef _NS_THEBESDEVICECONTEXT_H_
|
||||
#define _NS_THEBESDEVICECONTEXT_H_
|
||||
|
||||
#include "nsIScreenManager.h"
|
||||
#include "nsIDeviceContext.h"
|
||||
#include "nsIDeviceContextSpec.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "gfxContext.h"
|
||||
|
||||
#ifdef XP_WIN
|
||||
#include "gfxWindowsSurface.h"
|
||||
#elif defined(XP_OS2)
|
||||
#include "gfxOS2Surface.h"
|
||||
#endif
|
||||
|
||||
class nsFontCache;
|
||||
|
||||
class nsThebesDeviceContext : public nsIDeviceContext
|
||||
{
|
||||
public:
|
||||
nsThebesDeviceContext();
|
||||
virtual ~nsThebesDeviceContext();
|
||||
|
||||
static void Shutdown();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD Init(nsIWidget *aWidget);
|
||||
NS_IMETHOD InitForPrinting(nsIDeviceContextSpec *aDevSpec);
|
||||
NS_IMETHOD CreateRenderingContext(nsIView *aView, nsRenderingContext *&aContext);
|
||||
NS_IMETHOD CreateRenderingContext(nsIWidget *aWidget, nsRenderingContext *&aContext);
|
||||
NS_IMETHOD CreateRenderingContext(nsRenderingContext *&aContext);
|
||||
NS_IMETHOD CreateRenderingContextInstance(nsRenderingContext *&aContext);
|
||||
|
||||
NS_IMETHOD GetMetricsFor(const nsFont& aFont, nsIAtom* aLanguage,
|
||||
gfxUserFontSet* aUserFontSet,
|
||||
nsFontMetrics*& aMetrics);
|
||||
NS_IMETHOD GetMetricsFor(const nsFont& aFont,
|
||||
gfxUserFontSet* aUserFontSet,
|
||||
nsFontMetrics*& aMetrics);
|
||||
|
||||
NS_IMETHOD FirstExistingFont(const nsFont& aFont, nsString& aFaceName);
|
||||
|
||||
NS_IMETHOD GetLocalFontName(const nsString& aFaceName, nsString& aLocalName,
|
||||
PRBool& aAliased);
|
||||
|
||||
NS_IMETHOD CreateFontCache();
|
||||
NS_IMETHOD FontMetricsDeleted(const nsFontMetrics* aFontMetrics);
|
||||
NS_IMETHOD FlushFontCache(void);
|
||||
|
||||
NS_IMETHOD PrepareNativeWidget(nsIWidget *aWidget, void **aOut);
|
||||
|
||||
NS_IMETHOD GetSystemFont(nsSystemFontID aID, nsFont *aFont) const;
|
||||
NS_IMETHOD ClearCachedSystemFonts();
|
||||
|
||||
NS_IMETHOD CheckFontExistence(const nsString& aFaceName);
|
||||
|
||||
NS_IMETHOD GetDepth(PRUint32& aDepth);
|
||||
|
||||
NS_IMETHOD GetDeviceSurfaceDimensions(nscoord& aWidth, nscoord& aHeight);
|
||||
NS_IMETHOD GetRect(nsRect& aRect);
|
||||
NS_IMETHOD GetClientRect(nsRect& aRect);
|
||||
|
||||
/* printing goop */
|
||||
NS_IMETHOD PrepareDocument(PRUnichar *aTitle,
|
||||
PRUnichar *aPrintToFileName);
|
||||
|
||||
NS_IMETHOD BeginDocument(PRUnichar *aTitle,
|
||||
PRUnichar *aPrintToFileName,
|
||||
PRInt32 aStartPage,
|
||||
PRInt32 aEndPage);
|
||||
|
||||
NS_IMETHOD EndDocument(void);
|
||||
NS_IMETHOD AbortDocument(void);
|
||||
NS_IMETHOD BeginPage(void);
|
||||
NS_IMETHOD EndPage(void);
|
||||
/* end printing goop */
|
||||
|
||||
virtual PRBool CheckDPIChange();
|
||||
|
||||
virtual PRBool SetPixelScale(float aScale);
|
||||
|
||||
PRBool IsPrinterSurface(void);
|
||||
|
||||
#if defined(XP_WIN) || defined(XP_OS2)
|
||||
HDC GetPrintHDC();
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void GetLocaleLanguage(void);
|
||||
nsresult SetDPI();
|
||||
void ComputeClientRectUsingScreen(nsRect *outRect);
|
||||
void ComputeFullAreaUsingScreen(nsRect *outRect);
|
||||
void FindScreen(nsIScreen **outScreen);
|
||||
void CalcPrintingSize();
|
||||
void UpdateScaledAppUnits();
|
||||
|
||||
PRUint32 mDepth;
|
||||
nsFontCache* mFontCache;
|
||||
nsCOMPtr<nsIAtom> mLocaleLanguage; // XXX temp fix for performance bug
|
||||
nsCOMPtr<nsIWidget> mWidget;
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsIScreenManager> mScreenManager;
|
||||
|
||||
nscoord mWidth;
|
||||
nscoord mHeight;
|
||||
|
||||
nsRefPtr<gfxASurface> mPrintingSurface;
|
||||
float mPrintingScale;
|
||||
nsCOMPtr<nsIDeviceContextSpec> mDeviceContextSpec;
|
||||
};
|
||||
|
||||
#endif /* _NS_CAIRODEVICECONTEXT_H_ */
|
||||
|
|
@ -40,11 +40,11 @@
|
|||
#include "nsCOMPtr.h"
|
||||
#include "nsGfxCIID.h"
|
||||
|
||||
#include "nsThebesFontEnumerator.h"
|
||||
#include "nsThebesRegion.h"
|
||||
#include "nsScriptableRegion.h"
|
||||
|
||||
#include "nsThebesDeviceContext.h"
|
||||
#include "nsThebesRegion.h"
|
||||
#include "nsThebesFontEnumerator.h"
|
||||
#include "nsDeviceContext.h"
|
||||
#include "gfxPlatform.h"
|
||||
|
||||
// This service doesn't do anything; its only purpose is to force the
|
||||
|
@ -62,10 +62,8 @@ class GfxInitialization : public nsISupports {
|
|||
NS_IMPL_ISUPPORTS0(GfxInitialization)
|
||||
}
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsThebesDeviceContext)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsThebesRegion)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsThebesFontEnumerator)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(GfxInitialization)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsThebesRegion)
|
||||
|
||||
static nsresult
|
||||
nsScriptableRegionConstructor(nsISupports *aOuter, REFNSIID aIID, void **aResult)
|
||||
|
@ -108,15 +106,15 @@ nsScriptableRegionConstructor(nsISupports *aOuter, REFNSIID aIID, void **aResult
|
|||
return rv;
|
||||
}
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(GfxInitialization)
|
||||
|
||||
NS_DEFINE_NAMED_CID(NS_FONT_ENUMERATOR_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_DEVICE_CONTEXT_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_REGION_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_SCRIPTABLE_REGION_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_GFX_INITIALIZATION_CID);
|
||||
|
||||
static const mozilla::Module::CIDEntry kThebesCIDs[] = {
|
||||
{ &kNS_FONT_ENUMERATOR_CID, false, NULL, nsThebesFontEnumeratorConstructor },
|
||||
{ &kNS_DEVICE_CONTEXT_CID, false, NULL, nsThebesDeviceContextConstructor },
|
||||
{ &kNS_REGION_CID, false, NULL, nsThebesRegionConstructor },
|
||||
{ &kNS_SCRIPTABLE_REGION_CID, false, NULL, nsScriptableRegionConstructor },
|
||||
{ &kNS_GFX_INITIALIZATION_CID, false, NULL, GfxInitializationConstructor },
|
||||
|
@ -125,7 +123,6 @@ static const mozilla::Module::CIDEntry kThebesCIDs[] = {
|
|||
|
||||
static const mozilla::Module::ContractIDEntry kThebesContracts[] = {
|
||||
{ "@mozilla.org/gfx/fontenumerator;1", &kNS_FONT_ENUMERATOR_CID },
|
||||
{ "@mozilla.org/gfx/devicecontext;1", &kNS_DEVICE_CONTEXT_CID },
|
||||
{ "@mozilla.org/gfx/region/nsThebes;1", &kNS_REGION_CID },
|
||||
{ "@mozilla.org/gfx/region;1", &kNS_SCRIPTABLE_REGION_CID },
|
||||
{ "@mozilla.org/gfx/init;1", &kNS_GFX_INITIALIZATION_CID },
|
||||
|
@ -146,7 +143,7 @@ nsThebesGfxModuleCtor()
|
|||
static void
|
||||
nsThebesGfxModuleDtor()
|
||||
{
|
||||
nsThebesDeviceContext::Shutdown();
|
||||
nsDeviceContext::ClearCachedSystemFonts();
|
||||
gfxPlatform::Shutdown();
|
||||
}
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ typedef double gfxFloat;
|
|||
* gfx errors
|
||||
*/
|
||||
|
||||
/* nsIDeviceContext.h defines a set of printer errors */
|
||||
/* nsIDeviceContextSpec.h defines a set of printer errors */
|
||||
#define NS_ERROR_GFX_GENERAL_BASE (50)
|
||||
|
||||
/* Font cmap is strangely structured - avoid this font! */
|
||||
|
|
|
@ -517,7 +517,6 @@ protected:
|
|||
//------------------------------------------------------------------
|
||||
// Class IDs
|
||||
static NS_DEFINE_CID(kViewManagerCID, NS_VIEW_MANAGER_CID);
|
||||
static NS_DEFINE_CID(kDeviceContextCID, NS_DEVICE_CONTEXT_CID);
|
||||
|
||||
//------------------------------------------------------------------
|
||||
nsresult
|
||||
|
@ -926,23 +925,6 @@ DocumentViewerImpl::InitInternal(nsIWidget* aParentWidget,
|
|||
// be measuring/scaling with the print device context, not the
|
||||
// screen device context, but this is good enough to allow
|
||||
// printing reftests to work.
|
||||
#if 0
|
||||
nsCOMPtr<nsIDeviceContextSpec> devspec =
|
||||
do_CreateInstance("@mozilla.org/gfx/devicecontextspec;1", &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
// mWindow has been initialized by preceding call to MakeWindow
|
||||
rv = devspec->Init(mWindow, mPresContext->GetPrintSettings(), PR_FALSE);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsCOMPtr<nsIDeviceContext> devctx =
|
||||
do_CreateInstance("@mozilla.org/gfx/devicecontext;1", &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = devctx->InitForPrinting(devspec);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
// XXX I'm breaking this code; I'm not sure I really want to mess with
|
||||
// the document viewer at the moment to get the right device context
|
||||
// (this won't break anyone, since page layout mode was never really
|
||||
// usable)
|
||||
#endif
|
||||
double pageWidth = 0, pageHeight = 0;
|
||||
mPresContext->GetPrintSettings()->GetEffectivePageSize(&pageWidth,
|
||||
&pageHeight);
|
||||
|
@ -2446,13 +2428,10 @@ DocumentViewerImpl::CreateDeviceContext(nsIView* aContainerView)
|
|||
|
||||
// Create a device context even if we already have one, since our widget
|
||||
// might have changed.
|
||||
mDeviceContext = do_CreateInstance(kDeviceContextCID);
|
||||
NS_ENSURE_TRUE(mDeviceContext, NS_ERROR_FAILURE);
|
||||
nsIWidget* widget = nsnull;
|
||||
if (aContainerView) {
|
||||
widget = aContainerView->GetNearestWidget(nsnull);
|
||||
}
|
||||
// The device context needs a widget to be able to determine the screen it is on.
|
||||
if (!widget) {
|
||||
widget = mParentWidget;
|
||||
}
|
||||
|
@ -2460,6 +2439,7 @@ DocumentViewerImpl::CreateDeviceContext(nsIView* aContainerView)
|
|||
widget = widget->GetTopLevelWidget();
|
||||
}
|
||||
|
||||
mDeviceContext = new nsDeviceContext();
|
||||
mDeviceContext->Init(widget);
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -348,7 +348,7 @@ TraverseImageLoader(const void * aKey, nsRefPtr<nsImageLoader>& aData,
|
|||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsPresContext)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mDocument);
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_RAWPTR(mDeviceContext); // worth bothering?
|
||||
// NS_IMPL_CYCLE_COLLECTION_TRAVERSE_RAWPTR(mDeviceContext); // not xpcom
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_RAWPTR(mEventManager);
|
||||
// NS_IMPL_CYCLE_COLLECTION_TRAVERSE_RAWPTR(mLookAndFeel); // a service
|
||||
// NS_IMPL_CYCLE_COLLECTION_TRAVERSE_RAWPTR(mLanguage); // an atom
|
||||
|
|
|
@ -655,11 +655,10 @@ nsPrintEngine::DoCommonPrint(PRBool aIsPrintPreview,
|
|||
rv = devspec->Init(nsnull, mPrt->mPrintSettings, aIsPrintPreview);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
mPrt->mPrintDC = do_CreateInstance("@mozilla.org/gfx/devicecontext;1", &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
mPrt->mPrintDC = new nsDeviceContext();
|
||||
rv = mPrt->mPrintDC->InitForPrinting(devspec);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
|
||||
if (aIsPrintPreview) {
|
||||
mPrt->mPrintSettings->SetPrintFrameType(nsIPrintSettings::kFramesAsIs);
|
||||
|
||||
|
|
|
@ -1245,11 +1245,7 @@ nsNativeThemeGTK::WidgetStateChanged(nsIFrame* aFrame, PRUint8 aWidgetType,
|
|||
NS_IMETHODIMP
|
||||
nsNativeThemeGTK::ThemeChanged()
|
||||
{
|
||||
// this totally sucks. this method is really supposed to be
|
||||
// static, which is why we can call it without any initialization.
|
||||
static NS_DEFINE_CID(kDeviceContextCID, NS_DEVICE_CONTEXT_CID);
|
||||
nsCOMPtr<nsIDeviceContext> dctx = do_CreateInstance(kDeviceContextCID);
|
||||
dctx->ClearCachedSystemFonts();
|
||||
nsDeviceContext::ClearCachedSystemFonts();
|
||||
|
||||
memset(mDisabledWidgetTypes, 0, sizeof(mDisabledWidgetTypes));
|
||||
return NS_OK;
|
||||
|
|
|
@ -158,9 +158,6 @@ using mozilla::layers::LayerManagerOGL;
|
|||
// out to the bounding-box if there are more
|
||||
#define MAX_RECTS_IN_REGION 100
|
||||
|
||||
/* For PrepareNativeWidget */
|
||||
static NS_DEFINE_IID(kDeviceContextCID, NS_DEVICE_CONTEXT_CID);
|
||||
|
||||
/* utility functions */
|
||||
static PRBool check_for_rollup(GdkWindow *aWindow,
|
||||
gdouble aMouseX, gdouble aMouseY,
|
||||
|
|
|
@ -156,9 +156,6 @@ nsRefPtr<nsShmImage> gShmImage;
|
|||
static int gBufferPixmapUsageCount = 0;
|
||||
static gfxIntSize gBufferMaxSize(0, 0);
|
||||
|
||||
/* For PrepareNativeWidget */
|
||||
static NS_DEFINE_IID(kDeviceContextCID, NS_DEVICE_CONTEXT_CID);
|
||||
|
||||
// initialization static functions
|
||||
static nsresult initialize_prefs (void);
|
||||
|
||||
|
|
|
@ -210,14 +210,9 @@ void nsBaseWidget::BaseCreate(nsIWidget *aParent,
|
|||
NS_ADDREF(mContext);
|
||||
}
|
||||
else {
|
||||
nsresult res;
|
||||
|
||||
static NS_DEFINE_CID(kDeviceContextCID, NS_DEVICE_CONTEXT_CID);
|
||||
|
||||
res = CallCreateInstance(kDeviceContextCID, &mContext);
|
||||
|
||||
if (NS_SUCCEEDED(res))
|
||||
mContext->Init(nsnull);
|
||||
mContext = new nsDeviceContext();
|
||||
NS_ADDREF(mContext);
|
||||
mContext->Init(nsnull);
|
||||
}
|
||||
|
||||
if (nsnull != aInitData) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче