added init() method to prescontext.

creator of prescontext is responsible for initializing pres context.
devicecontext is now init()ed with a nsNativeWidget.
removed hacky X Display stuff from device context and font metrics.
removed hacky code from windows font metrics.
changed nsNativeWindow to be nsNativeWidget.
added more code for compositor back-to-front pass.
improved text performance on X.
changed nsHTMLTagContent.cpp so that it will build with MSVC 4.1.
This commit is contained in:
michaelp 1998-06-25 04:24:45 +00:00
Родитель 6d041ea3be
Коммит ec4811f612
64 изменённых файлов: 404 добавлений и 271 удалений

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

@ -37,6 +37,7 @@ class nsIViewManager;
class nsString;
class nsIWebWidget;
class nsIDOMEvent;
class nsIDeviceContext;
// IID for the nsIDocument interface
#define NS_IDOCUMENT_IID \

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

@ -210,6 +210,7 @@ nsresult nsDocument::CreateShell(nsIPresContext* aContext,
if (NS_OK != rv) {
return rv;
}
if (NS_OK != shell->Init(this, aContext, aViewManager, aStyleSet)) {
NS_RELEASE(shell);
return rv;

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

@ -66,7 +66,7 @@ nsDeviceContextUnix :: nsDeviceContextUnix()
mGreenOffset = 0;
mBlueOffset = 0;
mNativeDisplay = nsnull;
mNativeWidget = nsnull;
mDepth = 0 ;
mColormap = 0 ;
@ -84,38 +84,24 @@ nsDeviceContextUnix :: ~nsDeviceContextUnix()
NS_IF_RELEASE(mFontCache);
if (mSurface) delete mSurface;
if (mNativeDisplay)
::XCloseDisplay((Display *)mNativeDisplay);
}
NS_IMPL_QUERY_INTERFACE(nsDeviceContextUnix, kDeviceContextIID)
NS_IMPL_ADDREF(nsDeviceContextUnix)
NS_IMPL_RELEASE(nsDeviceContextUnix)
nsNativeDeviceContext gNativeDeviceContext = nsnull;
nsresult nsDeviceContextUnix :: Init(nsNativeDeviceContext aNativeDeviceContext)
nsresult nsDeviceContextUnix :: Init(nsNativeWidget aNativeWidget)
{
for (PRInt32 cnt = 0; cnt < 256; cnt++)
mGammaTable[cnt] = cnt;
// XXX We really need to have Display passed to us since it could be specified
// not from the environment, which is the one we use here.
if (aNativeDeviceContext == nsnull)
mNativeDisplay = ::XOpenDisplay(nsnull);
if (gNativeDeviceContext == nsnull) {
gNativeDeviceContext = mNativeDisplay;
}
if (mNativeDisplay == nsnull) {
mNativeDisplay = gNativeDeviceContext;
}
mNativeWidget = aNativeWidget;
mTwipsToPixels = (((float)::XDisplayWidth((Display *)mNativeDisplay, DefaultScreen((Display *)mNativeDisplay))) /
((float)::XDisplayWidthMM((Display *)mNativeDisplay,DefaultScreen((Display *)mNativeDisplay) )) * 25.4) /
mTwipsToPixels = (((float)::XDisplayWidth(XtDisplay((Widget)mNativeWidget), DefaultScreen(XtDisplay((Widget)mNativeWidget)))) /
((float)::XDisplayWidthMM(XtDisplay((Widget)mNativeWidget),DefaultScreen(XtDisplay((Widget)mNativeWidget)) )) * 25.4) /
NS_POINTS_TO_TWIPS_FLOAT(72.0f);
mPixelsToTwips = 1.0f / mTwipsToPixels;
@ -193,6 +179,98 @@ nsresult nsDeviceContextUnix :: InitRenderingContext(nsIRenderingContext *aConte
return (aContext->Init(this, aWin));
}
nsIFontCache* nsDeviceContextUnix::GetFontCache()
{
if (nsnull == mFontCache) {
if (NS_OK != CreateFontCache()) {
return nsnull;
}
}
NS_ADDREF(mFontCache);
return mFontCache;
}
nsresult nsDeviceContextUnix::CreateFontCache()
{
nsresult rv = NS_NewFontCache(&mFontCache);
if (NS_OK != rv) {
return rv;
}
mFontCache->Init(this);
return NS_OK;
}
void nsDeviceContextUnix::FlushFontCache()
{
NS_RELEASE(mFontCache);
}
nsIFontMetrics* nsDeviceContextUnix::GetMetricsFor(const nsFont& aFont)
{
if (nsnull == mFontCache) {
if (NS_OK != CreateFontCache()) {
return nsnull;
}
}
return mFontCache->GetMetricsFor(aFont);
}
void nsDeviceContextUnix :: SetZoom(float aZoom)
{
mZoom = aZoom;
}
float nsDeviceContextUnix :: GetZoom() const
{
return mZoom;
}
nsDrawingSurface nsDeviceContextUnix :: GetDrawingSurface(nsIRenderingContext &aContext)
{
return aContext.CreateDrawingSurface(nsnull);
}
float nsDeviceContextUnix :: GetGamma(void)
{
return mGammaValue;
}
void nsDeviceContextUnix :: SetGamma(float aGamma)
{
if (aGamma != mGammaValue)
{
//we don't need to-recorrect existing images for this case
//so pass in 1.0 for the current gamma regardless of what it
//really happens to be. existing images will get a one time
//re-correction when they're rendered the next time. MMP
SetGammaTable(mGammaTable, 1.0f, aGamma);
mGammaValue = aGamma;
}
}
PRUint8 * nsDeviceContextUnix :: GetGammaTable(void)
{
//XXX we really need to ref count this somehow. MMP
return mGammaTable;
}
void nsDeviceContextUnix :: SetGammaTable(PRUint8 * aTable, float aCurrentGamma, float aNewGamma)
{
double fgval = (1.0f / aCurrentGamma) * (1.0f / aNewGamma);
for (PRInt32 cnt = 0; cnt < 256; cnt++)
aTable[cnt] = (PRUint8)(pow((double)cnt * (1. / 256.), fgval) * 255.99999999);
}
nsNativeWidget nsDeviceContextUnix :: GetNativeWidget(void)
{
return mNativeWidget;
}
PRUint32 nsDeviceContextUnix :: ConvertPixel(nscolor aColor)
{
PRUint32 newcolor = 0;
@ -421,104 +499,11 @@ void nsDeviceContextUnix :: InstallColormap()
}
}
nsIFontCache* nsDeviceContextUnix::GetFontCache()
{
if (nsnull == mFontCache) {
if (NS_OK != CreateFontCache()) {
return nsnull;
}
}
NS_ADDREF(mFontCache);
return mFontCache;
}
nsresult nsDeviceContextUnix::CreateFontCache()
{
nsresult rv = NS_NewFontCache(&mFontCache);
if (NS_OK != rv) {
return rv;
}
mFontCache->Init(this);
return NS_OK;
}
void nsDeviceContextUnix::FlushFontCache()
{
NS_RELEASE(mFontCache);
}
nsIFontMetrics* nsDeviceContextUnix::GetMetricsFor(const nsFont& aFont)
{
if (nsnull == mFontCache) {
if (NS_OK != CreateFontCache()) {
return nsnull;
}
}
return mFontCache->GetMetricsFor(aFont);
}
void nsDeviceContextUnix :: SetZoom(float aZoom)
{
mZoom = aZoom;
}
float nsDeviceContextUnix :: GetZoom() const
{
return mZoom;
}
nsDrawingSurface nsDeviceContextUnix :: GetDrawingSurface(nsIRenderingContext &aContext)
{
return ( aContext.CreateDrawingSurface(nsnull));
}
nsDrawingSurface nsDeviceContextUnix :: GetDrawingSurface()
{
return (mSurface);
}
float nsDeviceContextUnix :: GetGamma(void)
{
return mGammaValue;
}
void nsDeviceContextUnix :: SetGamma(float aGamma)
{
if (aGamma != mGammaValue)
{
//we don't need to-recorrect existing images for this case
//so pass in 1.0 for the current gamma regardless of what it
//really happens to be. existing images will get a one time
//re-correction when they're rendered the next time. MMP
SetGammaTable(mGammaTable, 1.0f, aGamma);
mGammaValue = aGamma;
}
}
PRUint8 * nsDeviceContextUnix :: GetGammaTable(void)
{
//XXX we really need to ref count this somehow. MMP
return mGammaTable;
}
void nsDeviceContextUnix :: SetGammaTable(PRUint8 * aTable, float aCurrentGamma, float aNewGamma)
{
double fgval = (1.0f / aCurrentGamma) * (1.0f / aNewGamma);
for (PRInt32 cnt = 0; cnt < 256; cnt++)
aTable[cnt] = (PRUint8)(pow((double)cnt * (1. / 256.), fgval) * 255.99999999);
}
nsNativeDeviceContext nsDeviceContextUnix :: GetNativeDeviceContext()
{
return ((nsNativeDeviceContext)mNativeDisplay);
return mSurface;
}

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

@ -44,7 +44,7 @@ public:
NS_DECL_ISUPPORTS
virtual nsresult Init(nsNativeDeviceContext aNativeDeviceContext);
virtual nsresult Init(nsNativeWidget aNativeWidget);
virtual nsIRenderingContext * CreateRenderingContext(nsIView *aView);
virtual nsresult InitRenderingContext(nsIRenderingContext *aContext, nsIWidget *aWidget);
@ -70,7 +70,6 @@ public:
virtual float GetZoom() const;
virtual nsDrawingSurface GetDrawingSurface(nsIRenderingContext &aContext);
virtual nsDrawingSurface GetDrawingSurface();
//functions for handling gamma correction of output device
virtual float GetGamma(void);
@ -79,6 +78,8 @@ public:
//XXX the return from this really needs to be ref counted somehow. MMP
virtual PRUint8 * GetGammaTable(void);
virtual nsNativeWidget GetNativeWidget(void);
virtual PRUint32 ConvertPixel(nscolor aColor);
protected:
@ -107,7 +108,7 @@ public:
void InstallColormap(void);
void SetDrawingSurface(nsDrawingSurfaceUnix * aSurface) { mSurface = aSurface; }
void SetGammaTable(PRUint8 * aTable, float aCurrentGamma, float aNewGamma);
nsNativeDeviceContext GetNativeDeviceContext();
nsDrawingSurface GetDrawingSurface();
private:
PRUint32 mRedMask;
@ -120,8 +121,7 @@ private:
PRUint32 mGreenOffset;
PRUint32 mBlueOffset;
nsNativeDeviceContext mNativeDisplay;
nsNativeWidget mNativeWidget;
};
#endif /* nsDeviceContextUnix_h___ */

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

@ -31,16 +31,16 @@ nsFontMetricsUnix :: nsFontMetricsUnix()
NS_INIT_REFCNT();
mFont = nsnull;
mFontHandle = nsnull;
hackyfontnamething = nsnull;
// hackyfontnamething = nsnull;
}
nsFontMetricsUnix :: ~nsFontMetricsUnix()
{
if (nsnull != hackyfontnamething)
{
PR_Free(hackyfontnamething);
hackyfontnamething = nsnull;
}
// if (nsnull != hackyfontnamething)
// {
// PR_Free(hackyfontnamething);
// hackyfontnamething = nsnull;
// }
if (nsnull != mFont)
{
@ -60,6 +60,7 @@ nsresult nsFontMetricsUnix :: Init(const nsFont& aFont, nsIDeviceContext* aCX)
char altitalicization = 0;
XFontStruct *fonts;
PRInt32 dpi = NS_TO_INT_ROUND(aCX->GetTwipsToDevUnits() * 1440);
Display *dpy = XtDisplay((Widget)mContext->GetNativeWidget());
if (nsnull == wildstring)
return NS_ERROR_NOT_INITIALIZED;
@ -76,7 +77,7 @@ nsresult nsFontMetricsUnix :: Init(const nsFont& aFont, nsIDeviceContext* aCX)
dpi = 100;
#ifdef NOISY_FONTS
fprintf(stderr, "looking for font %s (%d)", wildstring, aFont.size / 20);
// fprintf(stderr, "looking for font %s (%d)", wildstring, aFont.size / 20);
#endif
//font properties we care about:
@ -92,8 +93,7 @@ nsresult nsFontMetricsUnix :: Init(const nsFont& aFont, nsIDeviceContext* aCX)
(aFont.style == NS_FONT_STYLE_NORMAL) ? 'r' :
((aFont.style == NS_FONT_STYLE_ITALIC) ? 'i' : 'o'), dpi, dpi);
fnames = XListFontsWithInfo((Display *)mContext->GetNativeDeviceContext(),
&wildstring[namelen + 1], 200, &numnames, &fonts);
fnames = XListFontsWithInfo(dpy, &wildstring[namelen + 1], 200, &numnames, &fonts);
if (aFont.style == NS_FONT_STYLE_ITALIC)
altitalicization = 'o';
@ -104,12 +104,11 @@ nsresult nsFontMetricsUnix :: Init(const nsFont& aFont, nsIDeviceContext* aCX)
{
PR_snprintf(&wildstring[namelen + 1], namelen + 200,
"*-%s-%s-%c-normal--*-*-%d-%d-*-*-*",
wildstring,
wildstring,
(aFont.weight <= NS_FONT_WEIGHT_NORMAL) ? "medium" : "bold",
altitalicization, dpi, dpi);
fnames = XListFontsWithInfo((Display *)mContext->GetNativeDeviceContext(),
&wildstring[namelen + 1], 200, &numnames, &fonts);
fnames = XListFontsWithInfo(dpy, &wildstring[namelen + 1], 200, &numnames, &fonts);
}
if (numnames <= 0)
@ -125,8 +124,7 @@ nsresult nsFontMetricsUnix :: Init(const nsFont& aFont, nsIDeviceContext* aCX)
(aFont.style == NS_FONT_STYLE_NORMAL) ? 'r' :
((aFont.style == NS_FONT_STYLE_ITALIC) ? 'i' : 'o'), dpi, dpi);
fnames = XListFontsWithInfo((Display *)mContext->GetNativeDeviceContext(),
&wildstring[namelen + 1], 200, &numnames, &fonts);
fnames = XListFontsWithInfo(dpy, &wildstring[namelen + 1], 200, &numnames, &fonts);
if ((numnames <= 0) && altitalicization)
{
@ -136,8 +134,7 @@ nsresult nsFontMetricsUnix :: Init(const nsFont& aFont, nsIDeviceContext* aCX)
(aFont.weight <= NS_FONT_WEIGHT_NORMAL) ? "medium" : "bold",
altitalicization, dpi, dpi);
fnames = XListFontsWithInfo((Display *)mContext->GetNativeDeviceContext(),
&wildstring[namelen + 1], 200, &numnames, &fonts);
fnames = XListFontsWithInfo(dpy, &wildstring[namelen + 1], 200, &numnames, &fonts);
}
}
@ -145,10 +142,10 @@ nsresult nsFontMetricsUnix :: Init(const nsFont& aFont, nsIDeviceContext* aCX)
{
char *nametouse = PickAppropriateSize(fnames, fonts, numnames, aFont.size);
mFontHandle = ::XLoadFont((Display *)mContext->GetNativeDeviceContext(), nametouse);
mFontHandle = ::XLoadFont(dpy, nametouse);
hackyfontnamething = (char *)PR_Malloc(nsCRT::strlen(nametouse) + 1);
strcpy(hackyfontnamething, nametouse);
// hackyfontnamething = (char *)PR_Malloc(nsCRT::strlen(nametouse) + 1);
// strcpy(hackyfontnamething, nametouse);
XFreeFontInfo(fnames, fonts, numnames);
}
@ -156,13 +153,14 @@ nsresult nsFontMetricsUnix :: Init(const nsFont& aFont, nsIDeviceContext* aCX)
{
//ack. we're in real trouble, go for fixed...
hackyfontnamething = (char *)PR_Malloc(nsCRT::strlen("fixed") + 1);
strcpy(hackyfontnamething, "fixed");
mFontHandle = ::XLoadFont((Display *)mContext->GetNativeDeviceContext(), "fixed");
// hackyfontnamething = (char *)PR_Malloc(nsCRT::strlen("fixed") + 1);
// strcpy(hackyfontnamething, "fixed");
mFontHandle = ::XLoadFont(dpy, "fixed");
}
#ifdef NOISY_FONTS
fprintf(stderr, " is: %s\n", hackyfontnamething);
// fprintf(stderr, " is: %s\n", hackyfontnamething);
#endif
RealizeFont();
@ -220,7 +218,7 @@ char * nsFontMetricsUnix::PickAppropriateSize(char **names, XFontStruct *fonts,
void nsFontMetricsUnix::RealizeFont()
{
XFontStruct * fs = ::XQueryFont((Display *)mContext->GetNativeDeviceContext(), mFontHandle);
XFontStruct * fs = ::XQueryFont(XtDisplay((Widget)mContext->GetNativeWidget()), mFontHandle);
float f = mContext->GetDevUnitsToAppUnits();
@ -270,9 +268,9 @@ nscoord nsFontMetricsUnix :: GetWidth(const char *aString)
{
PRInt32 rc = 0 ;
mFontHandle = ::XLoadFont((Display *)mContext->GetNativeDeviceContext(), hackyfontnamething);
// mFontHandle = ::XLoadFont(XtDisplay((Widget)mContext->GetNativeWidget()), hackyfontnamething);
XFontStruct * fs = ::XQueryFont((Display *)mContext->GetNativeDeviceContext(), mFontHandle);
XFontStruct * fs = ::XQueryFont(XtDisplay((Widget)mContext->GetNativeWidget()), mFontHandle);
rc = (PRInt32) ::XTextWidth(fs, aString, nsCRT::strlen(aString));
@ -297,9 +295,9 @@ nscoord nsFontMetricsUnix :: GetWidth(const PRUnichar *aString, PRUint32 aLength
thischar->byte1 = (aunichar & 0xff00) >> 8;
}
mFontHandle = ::XLoadFont((Display *)mContext->GetNativeDeviceContext(), hackyfontnamething);
// mFontHandle = ::XLoadFont(XtDisplay((Widget)mContext->GetNativeWidget()), hackyfontnamething);
XFontStruct * fs = ::XQueryFont((Display *)mContext->GetNativeDeviceContext(), mFontHandle);
XFontStruct * fs = ::XQueryFont(XtDisplay((Widget)mContext->GetNativeWidget()), mFontHandle);
width = ::XTextWidth16(fs, xstring, aLength);
@ -345,8 +343,8 @@ const nsFont& nsFontMetricsUnix :: GetFont()
nsFontHandle nsFontMetricsUnix :: GetFontHandle()
{
return ((nsFontHandle)hackyfontnamething);
// return ((nsFontHandle)mFontHandle);
// return ((nsFontHandle)hackyfontnamething);
return ((nsFontHandle)mFontHandle);
}

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

@ -503,15 +503,15 @@ void nsRenderingContextUnix :: SetFont(const nsFont& aFont)
if (mFontMetrics)
{
mCurrFontHandle = ::XLoadFont(mRenderingSurface->display, (char *)mFontMetrics->GetFontHandle());
// mCurrFontHandle = ::XLoadFont(mRenderingSurface->display, (char *)mFontMetrics->GetFontHandle());
mCurrFontHandle = (Font)mFontMetrics->GetFontHandle());
::XSetFont(mRenderingSurface->display,
mRenderingSurface->gc,
mCurrFontHandle);
mRenderingSurface->gc,
mCurrFontHandle);
::XFlushGC(mRenderingSurface->display,
mRenderingSurface->gc);
mRenderingSurface->gc);
}
}

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

@ -23,6 +23,7 @@
#include "nsIRenderingContext.h"
#include "nsCoord.h"
#include "nsRect.h"
#include "nsIWidget.h"
class nsIView;
class nsIRenderingContext;
@ -41,7 +42,7 @@ typedef void * nsNativeDeviceContext;
class nsIDeviceContext : public nsISupports
{
public:
virtual nsresult Init(nsNativeDeviceContext aNativeDeviceContext) = 0;
virtual nsresult Init(nsNativeWidget aWidget) = 0;
virtual nsIRenderingContext * CreateRenderingContext(nsIView *aView) = 0;
virtual nsresult InitRenderingContext(nsIRenderingContext *aContext, nsIWidget *aWindow) = 0;
@ -91,7 +92,7 @@ public:
//XXX the return from this really needs to be ref counted somehow. MMP
virtual PRUint8 * GetGammaTable(void) = 0;
virtual nsNativeDeviceContext GetNativeDeviceContext(void) = 0;
virtual nsNativeWidget GetNativeWidget(void) = 0;
};
#endif /* nsIDeviceContext_h___ */

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

@ -43,7 +43,7 @@ class nsIFontMetrics : public nsISupports
public:
//initializer
virtual nsresult Init(const nsFont& aFont, nsIDeviceContext* aContext) = 0;
virtual nsresult Init(const nsFont& aFont, nsIDeviceContext *aContext) = 0;
//get the width of an 8 bit char
virtual nscoord GetWidth(char aC) = 0;

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

@ -68,11 +68,13 @@ NS_IMPL_QUERY_INTERFACE(nsDeviceContextWin, kDeviceContextIID)
NS_IMPL_ADDREF(nsDeviceContextWin)
NS_IMPL_RELEASE(nsDeviceContextWin)
nsresult nsDeviceContextWin :: Init(nsNativeDeviceContext aNativeDeviceContext)
nsresult nsDeviceContextWin :: Init(nsNativeWidget aWidget)
{
for (PRInt32 cnt = 0; cnt < 256; cnt++)
mGammaTable[cnt] = cnt;
mWidget = aWidget;
return NS_OK;
}
@ -197,9 +199,9 @@ nsDrawingSurface nsDeviceContextWin :: GetDrawingSurface(nsIRenderingContext &aC
return mSurface;
}
nsNativeDeviceContext nsDeviceContextWin :: GetNativeDeviceContext()
nsNativeWidget nsDeviceContextWin :: GetNativeWidget(void)
{
return ((nsNativeDeviceContext)nsnull);
return mWidget;
}
float nsDeviceContextWin :: GetGamma(void)

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

@ -65,7 +65,7 @@ public:
virtual void SetGamma(float aGamma);
virtual PRUint8 * GetGammaTable(void);
virtual nsNativeDeviceContext GetNativeDeviceContext(void) ;
virtual nsNativeWidget GetNativeWidget(void);
protected:
~nsDeviceContextWin();
@ -81,6 +81,7 @@ protected:
HDC mSurface;
float mGammaValue;
PRUint8 *mGammaTable;
nsNativeWidget mWidget;
};
#endif /* nsDeviceContextWin_h___ */

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

@ -32,6 +32,12 @@ nsFontMetricsWin :: ~nsFontMetricsWin()
delete mFont;
mFont = nsnull;
}
if (NULL != mFontHandle)
{
::DeleteObject(mFontHandle);
mFontHandle = NULL;
}
}
NS_IMPL_ISUPPORTS(nsFontMetricsWin, kIFontMetricsIID)
@ -39,12 +45,11 @@ NS_IMPL_ISUPPORTS(nsFontMetricsWin, kIFontMetricsIID)
// Note: The presentation context has a reference to this font
// metrics, therefore avoid circular references by not AddRef'ing the
// presentation context.
nsresult nsFontMetricsWin :: Init(const nsFont& aFont, nsIDeviceContext* aCX)
nsresult nsFontMetricsWin :: Init(const nsFont& aFont, nsIDeviceContext *aContext)
{
mFont = new nsFont(aFont);
mContext = aCX;
RealizeFont();
RealizeFont(aContext);
return NS_OK;
}
@ -88,7 +93,7 @@ const char* nsFontMetricsWin::MapFamilyToFont(const nsString& aLogicalFontName)
return "Arial";/* XXX for now */
}
void nsFontMetricsWin::RealizeFont()
void nsFontMetricsWin::RealizeFont(nsIDeviceContext *aContext)
{
// Fill in logFont structure; stolen from awt
LOGFONT logFont;
@ -110,7 +115,7 @@ void nsFontMetricsWin::RealizeFont()
? FW_BOLD : FW_NORMAL;
logFont.lfItalic = (mFont->style & NS_FONT_STYLE_ITALIC)
? TRUE : FALSE;
float t2p = mContext->GetAppUnitsToDevUnits();
float t2p = aContext->GetAppUnitsToDevUnits();
logFont.lfHeight = (LONG)(-mFont->size * t2p);
strncpy(logFont.lfFaceName,
MapFamilyToFont(mFont->name),
@ -121,12 +126,12 @@ void nsFontMetricsWin::RealizeFont()
//fprintf(stderr, "fFontHandle=%x\n", fFontHandle);
// Find font metrics and character widths
HWND win = ::GetDesktopWindow();
HWND win = (HWND)aContext->GetNativeWidget();
HDC dc = ::GetDC(win);
::SelectObject(dc, (HGDIOBJ) mFontHandle);
HFONT oldfont = ::SelectObject(dc, (HGDIOBJ) mFontHandle);
// Get font metrics
float p2t = mContext->GetDevUnitsToAppUnits();
float p2t = aContext->GetDevUnitsToAppUnits();
TEXTMETRIC metrics;
::GetTextMetrics(dc, &metrics);
mHeight = nscoord(metrics.tmHeight * p2t);

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

@ -42,7 +42,7 @@ public:
NS_DECL_ISUPPORTS
virtual nsresult Init(const nsFont& aFont, nsIDeviceContext* aContext);
virtual nsresult Init(const nsFont& aFont, nsIDeviceContext *aContext);
virtual nscoord GetWidth(char aC);
virtual nscoord GetWidth(PRUnichar aC);
virtual nscoord GetWidth(const nsString& aString);
@ -58,11 +58,10 @@ public:
virtual nsFontHandle GetFontHandle();
protected:
void RealizeFont();
void RealizeFont(nsIDeviceContext *aContext);
static const char* MapFamilyToFont(const nsString& aLogicalFontName);
nsFont *mFont;
nsIDeviceContext *mContext;
nscoord mCharWidths[256];
nscoord mHeight;
nscoord mAscent;

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

@ -1020,7 +1020,7 @@ static HWND CreateTopLevel(const char* clazz, const char* title,int aWidth, int
if (NS_OK == rv)
{
gWindow->Create((nsNativeWindow)window, rect, MyHandleEvent, NULL);
gWindow->Create((nsNativeWidget)window, rect, MyHandleEvent, NULL);
}
// something for input

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

@ -46,8 +46,6 @@ EXPORTS = \
nsToken.h \
$(NULL)
# nsIParserDebug.h \
MODULE = raptor
REQUIRES = xpcom netlib raptor

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

@ -29,6 +29,7 @@ class nsIPresContext;
class nsIStyleSet;
class nsIViewManager;
class nsIReflowCommand;
class nsIDeviceContext;
#define NS_IPRESSHELL_IID \
{ 0x76e79c60, 0x944e, 0x11d1, \

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

@ -44,6 +44,10 @@ nsPresContext::nsPresContext()
mLinkHandler = nsnull;
mContainer = nsnull;
mEventManager = nsnull;
#ifdef DEBUG
mInitialized = PR_FALSE;
#endif
}
nsPresContext::~nsPresContext()
@ -72,6 +76,7 @@ nsPresContext::~nsPresContext()
NS_IF_RELEASE(mLinkHandler);
NS_IF_RELEASE(mContainer);
NS_IF_RELEASE(mEventManager);
NS_IF_RELEASE(mDeviceContext);
}
nsrefcnt
@ -93,6 +98,21 @@ nsPresContext::Release(void)
NS_IMPL_QUERY_INTERFACE(nsPresContext, kIPresContextIID);
nsresult
nsPresContext::Init(nsIDeviceContext* aDeviceContext)
{
NS_ASSERTION(!(mInitialized == PR_TRUE), "attempt to reinit pres context");
mDeviceContext = aDeviceContext;
NS_IF_ADDREF(mDeviceContext);
#ifdef DEBUG
mInitialized = PR_TRUE;
#endif
return NS_OK;
}
// Note: We don't hold a reference on the shell; it has a reference to
// us
void

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

@ -46,6 +46,11 @@ class nsIEventStateManager;
// objects that provide an outer context for a presentation shell.
class nsIPresContext : public nsISupports {
public:
/**
* Initialize the presentation context from a particular device.
*/
virtual nsresult Init(nsIDeviceContext* aDeviceContext) = 0;
/**
* Set the presentation shell that this context is bound to.
* A presentation context may only be bound to a single shell.

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

@ -37,6 +37,7 @@ class nsIViewManager;
class nsString;
class nsIWebWidget;
class nsIDOMEvent;
class nsIDeviceContext;
// IID for the nsIDocument interface
#define NS_IDOCUMENT_IID \

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

@ -46,6 +46,11 @@ class nsIEventStateManager;
// objects that provide an outer context for a presentation shell.
class nsIPresContext : public nsISupports {
public:
/**
* Initialize the presentation context from a particular device.
*/
virtual nsresult Init(nsIDeviceContext* aDeviceContext) = 0;
/**
* Set the presentation shell that this context is bound to.
* A presentation context may only be bound to a single shell.

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

@ -29,6 +29,7 @@ class nsIPresContext;
class nsIStyleSet;
class nsIViewManager;
class nsIReflowCommand;
class nsIDeviceContext;
#define NS_IPRESSHELL_IID \
{ 0x76e79c60, 0x944e, 0x11d1, \

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

@ -46,6 +46,11 @@ class nsIEventStateManager;
// objects that provide an outer context for a presentation shell.
class nsIPresContext : public nsISupports {
public:
/**
* Initialize the presentation context from a particular device.
*/
virtual nsresult Init(nsIDeviceContext* aDeviceContext) = 0;
/**
* Set the presentation shell that this context is bound to.
* A presentation context may only be bound to a single shell.

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

@ -210,6 +210,7 @@ nsresult nsDocument::CreateShell(nsIPresContext* aContext,
if (NS_OK != rv) {
return rv;
}
if (NS_OK != shell->Init(this, aContext, aViewManager, aStyleSet)) {
NS_RELEASE(shell);
return rv;

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

@ -32,26 +32,11 @@ public:
GalleyContext::GalleyContext()
{
nsresult res;
static NS_DEFINE_IID(kDeviceContextCID, NS_DEVICE_CONTEXT_CID);
static NS_DEFINE_IID(kDeviceContextIID, NS_IDEVICE_CONTEXT_IID);
res = NSRepository::CreateInstance(kDeviceContextCID, nsnull,
kDeviceContextIID,
(void **)&mDeviceContext);
if (NS_OK == res) {
mDeviceContext->Init(nsnull);
mDeviceContext->SetDevUnitsToAppUnits(mDeviceContext->GetDevUnitsToTwips());
mDeviceContext->SetAppUnitsToDevUnits(mDeviceContext->GetTwipsToDevUnits());
mDeviceContext->SetGamma(1.7f);
}
}
GalleyContext::~GalleyContext()
{
mDeviceContext->FlushFontCache();
NS_IF_RELEASE(mDeviceContext);
}
PRBool GalleyContext::IsPaginated()

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

@ -44,6 +44,10 @@ nsPresContext::nsPresContext()
mLinkHandler = nsnull;
mContainer = nsnull;
mEventManager = nsnull;
#ifdef DEBUG
mInitialized = PR_FALSE;
#endif
}
nsPresContext::~nsPresContext()
@ -72,6 +76,7 @@ nsPresContext::~nsPresContext()
NS_IF_RELEASE(mLinkHandler);
NS_IF_RELEASE(mContainer);
NS_IF_RELEASE(mEventManager);
NS_IF_RELEASE(mDeviceContext);
}
nsrefcnt
@ -93,6 +98,21 @@ nsPresContext::Release(void)
NS_IMPL_QUERY_INTERFACE(nsPresContext, kIPresContextIID);
nsresult
nsPresContext::Init(nsIDeviceContext* aDeviceContext)
{
NS_ASSERTION(!(mInitialized == PR_TRUE), "attempt to reinit pres context");
mDeviceContext = aDeviceContext;
NS_IF_ADDREF(mDeviceContext);
#ifdef DEBUG
mInitialized = PR_TRUE;
#endif
return NS_OK;
}
// Note: We don't hold a reference on the shell; it has a reference to
// us
void

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

@ -31,6 +31,7 @@ public:
NS_DECL_ISUPPORTS
// nsIPresContext methods
virtual nsresult Init(nsIDeviceContext* aDeviceContext);
virtual void SetShell(nsIPresShell* aShell);
virtual nsIPresShell* GetShell();
virtual nsIStyleContext* ResolveStyleContextFor(nsIContent* aContent,
@ -74,6 +75,10 @@ protected:
nsFont mDefaultFont;
nsVoidArray mImageLoaders;
nsIEventStateManager* mEventManager;
#ifdef DEBUG
PRBool mInitialized;
#endif
};
#endif /* nsPresContext_h___ */

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

@ -36,27 +36,10 @@ public:
PrintPreviewContext::PrintPreviewContext()
{
nsresult res;
static NS_DEFINE_IID(kDeviceContextCID, NS_DEVICE_CONTEXT_CID);
static NS_DEFINE_IID(kDeviceContextIID, NS_IDEVICE_CONTEXT_IID);
res = NSRepository::CreateInstance(kDeviceContextCID, nsnull, kDeviceContextIID, (void **)&mDeviceContext);
if (NS_OK == res)
{
mDeviceContext->Init(nsnull);
mDeviceContext->SetDevUnitsToAppUnits(mDeviceContext->GetDevUnitsToTwips());
mDeviceContext->SetAppUnitsToDevUnits(mDeviceContext->GetTwipsToDevUnits());
NS_ADDREF(mDeviceContext);
}
}
PrintPreviewContext::~PrintPreviewContext()
{
NS_IF_RELEASE(mDeviceContext);
}
PRBool PrintPreviewContext::IsPaginated()

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

@ -577,8 +577,8 @@ nsresult nsHTMLTagContent::HandleDOMEvent(nsIPresContext& aPresContext,
case NS_MOUSE_LEFT_BUTTON_UP:
if (mTag == nsHTMLAtoms::a) {
nsAutoString base, href, target;
GetAttribute("href", href);
GetAttribute("target", target);
GetAttribute(nsString("href"), href);
GetAttribute(nsString("target"), target);
TriggerLink(aPresContext, base, href, target, PR_TRUE);
aEventStatus = nsEventStatus_eConsumeNoDefault;
}
@ -591,8 +591,8 @@ nsresult nsHTMLTagContent::HandleDOMEvent(nsIPresContext& aPresContext,
case NS_MOUSE_MOVE:
if (mTag == nsHTMLAtoms::a) {
nsAutoString base, href, target;
GetAttribute("href", href);
GetAttribute("target", target);
GetAttribute(nsString("href"), href);
GetAttribute(nsString("target"), target);
TriggerLink(aPresContext, base, href, target, PR_FALSE);
aEventStatus = nsEventStatus_eConsumeNoDefault;
}

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

@ -317,7 +317,7 @@ void nsHTMLIFrameFrame::CreateWebWidget(nsSize aSize, nsString& aURL)
NS_RELEASE(view);
nsRect webBounds(0, 0, NS_TO_INT_ROUND(aSize.width * t2p),
NS_TO_INT_ROUND(aSize.height * t2p));
mWebWidget->Init(widget->GetNativeData(NS_NATIVE_WINDOW), webBounds,
mWebWidget->Init(widget->GetNativeData(NS_NATIVE_WIDGET), webBounds,
content->GetScrolling());
NS_RELEASE(widget);

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

@ -1580,9 +1580,23 @@ int main(int argc, char** argv)
// Create test document and presentation context
MyDocument *myDoc = new MyDocument();
nsIPresContext* presContext;
nsIDeviceContext *dx;
static NS_DEFINE_IID(kDeviceContextCID, NS_DEVICE_CONTEXT_CID);
static NS_DEFINE_IID(kDeviceContextIID, NS_IDEVICE_CONTEXT_IID);
nsresult rv = NSRepository::CreateInstance(kDeviceContextCID, nsnull, kDeviceContextIID, (void **)&dx);
if (NS_OK == rv) {
dx->Init(nsull);
dx->SetDevUnitsToAppUnits(dx->GetDevUnitsToTwips());
dx->SetAppUnitsToDevUnits(dx->GetTwipsToDevUnits());
}
NS_NewGalleyContext(&presContext);
presContext->Init(dx);
// Test basic reflowing of unmapped children
if (!TestReflowUnmapped(presContext)) {
return -1;

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

@ -420,6 +420,19 @@ GeometryTest::GeometryTest(BasicTest *aDoc)
#endif
nsIDeviceContext *dx;
static NS_DEFINE_IID(kDeviceContextCID, NS_DEVICE_CONTEXT_CID);
static NS_DEFINE_IID(kDeviceContextIID, NS_IDEVICE_CONTEXT_IID);
nsresult rv = NSRepository::CreateInstance(kDeviceContextCID, nsnull, kDeviceContextIID, (void **)&dx);
if (NS_OK == rv) {
dx->Init(nsnull);
dx->SetDevUnitsToAppUnits(dx->GetDevUnitsToTwips());
dx->SetAppUnitsToDevUnits(dx->GetTwipsToDevUnits());
}
nsIPresContext * pc = nsnull;
nsresult status = NS_NewGalleyContext(&pc);
if ((NS_FAILED(status)) || nsnull==pc)
@ -428,6 +441,8 @@ GeometryTest::GeometryTest(BasicTest *aDoc)
NS_ASSERTION(PR_FALSE, "bad galley pc");
}
pc->Init(dx);
// create a view manager
nsIViewManager * vm = nsnull;
@ -501,6 +516,7 @@ GeometryTest::GeometryTest(BasicTest *aDoc)
fprintf(out, "bad paginated pc");
NS_ASSERTION(PR_FALSE, "");
}
pc->Init(dx);
aDoc->CreateCorrectContent(rows, cols);
CreateGeometry(aDoc, pc);
VerifyGeometry(aDoc, pc);

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

@ -46,8 +46,6 @@ EXPORTS = \
nsToken.h \
$(NULL)
# nsIParserDebug.h \
MODULE = raptor
REQUIRES = xpcom netlib raptor

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

@ -91,7 +91,7 @@ public:
nsIView *aParent,
const nsIID *aWindowIID = nsnull,
nsWidgetInitData *aWidgetInitData = nsnull,
nsNativeWindow aNative = nsnull,
nsNativeWidget aNative = nsnull,
PRInt32 aZIndex = 0,
const nsViewClip *aClip = nsnull,
float aOpacity = 1.0f,

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

@ -330,7 +330,7 @@ nsresult nsScrollingView :: Init(nsIViewManager* aManager,
nsIView *aParent,
const nsIID *aWindowIID,
nsWidgetInitData *aWidgetInitData,
nsNativeWindow aNative,
nsNativeWidget aNative,
PRInt32 aZIndex,
const nsViewClip *aClip,
float aOpacity,

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

@ -40,7 +40,7 @@ public:
nsIView *aParent,
const nsIID *aWindowIID = nsnull,
nsWidgetInitData *aWidgetInitData = nsnull,
nsNativeWindow aNative = nsnull,
nsNativeWidget aNative = nsnull,
PRInt32 aZIndex = 0,
const nsViewClip *aClip = nsnull,
float aOpacity = 1.0f,

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

@ -272,7 +272,7 @@ nsresult nsView :: Init(nsIViewManager* aManager,
nsIView *aParent,
const nsCID *aWindowCIID,
nsWidgetInitData *aWidgetInitData,
nsNativeWindow aNative,
nsNativeWidget aNative,
PRInt32 aZIndex,
const nsViewClip *aClip,
float aOpacity,
@ -408,10 +408,6 @@ PRBool nsView :: Paint(nsIRenderingContext& rc, const nsRect& rect,
nsRect kidRect;
kid->GetBounds(kidRect);
nsRect damageArea;
// nsRect damageArea = rect;
// damageArea.x -= mBounds.x;
// damageArea.y -= mBounds.y;
// PRBool overlap = damageArea.IntersectRect(damageArea, kidRect);
PRBool overlap = damageArea.IntersectRect(rect, kidRect);
if (overlap == PR_TRUE)
@ -435,17 +431,58 @@ PRBool nsView :: Paint(nsIRenderingContext& rc, const nsRect& rect,
{
rc.PushState();
#if 0
if (HasTransparency() || (opacity < 1.0f))
{
nsRect crect;
PRBool goodclip = rc.GetClipRect(crect);
//overview of algorithm:
//1. clip is set to intersection of this view and whatever is
// left of the damage region in the rc.
//2. walk tree from this point down through the view list,
// rendering and clipping out opaque views encountered until
// there is nothing left in the clip area or the bottommost
// view is reached.
//3. walk back up through view list restoring clips and painting
// or blending any non-opaque views encountered until we reach the
// view that started the whole process
//walk down rendering only views within this clip
rc.SetClipRect(crect, nsClipCombine_kReplace);
nsIView *child = GetNextSibling(), *prevchild = this;
while (nsnull != child)
{
nsRect kidRect;
child->GetBounds(kidRect);
nsRect damageArea;
PRBool overlap = damageArea.IntersectRect(rect, kidRect);
//as we tell each kid to paint, we need to mark the kid as one that was hit
//in the front to back rendering so that when we do the back to front pass,
//we can re-add the child's rect back into the clip.
if (overlap == PR_TRUE)
{
// Translate damage area into kid's coordinate system
nsRect kidDamageArea(damageArea.x - kidRect.x, damageArea.y - kidRect.y,
damageArea.width, damageArea.height);
clipres = child->Paint(rc, kidDamageArea, aPaintFlags);
}
prevchild = child;
child = child->GetNextSibling();
if (nsnull == child)
child = child->GetParent();
if (clipres == PR_TRUE)
break;
}
if ((nsnull != prevchild) && (this != prevchild))
{
//walk backwards, rendering views
}
}
#endif
if (nsnull != mFrame)
{

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

@ -46,7 +46,7 @@ public:
nsIView *aParent,
const nsCID *aWindowIID = nsnull,
nsWidgetInitData *aWidgetInitData = nsnull,
nsNativeWindow aNative = nsnull,
nsNativeWidget aNative = nsnull,
PRInt32 aZIndex = 0,
const nsViewClip *aClip = nsnull,
float aOpacity = 1.0f,

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

@ -32,7 +32,7 @@ class nsString;
class nsIDocumentWidget : public nsISupports {
public:
// Create a native window for this web widget; may be called once
virtual nsresult Init(nsNativeWindow aNativeParent,
virtual nsresult Init(nsNativeWidget aNativeParent,
const nsRect& aBounds,
nsScrollPreference aScrolling = nsScrollPreference_kAuto) = 0;

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

@ -44,7 +44,7 @@ class nsIWebWidget : public nsIDocumentWidget {
public:
// Create a native window for this web widget; may be called once
virtual nsresult Init(nsNativeWindow aNativeParent,
virtual nsresult Init(nsNativeWidget aNativeParent,
const nsRect& aBounds,
nsScrollPreference aScrolling = nsScrollPreference_kAuto) = 0;
@ -52,7 +52,7 @@ public:
// Use the given presentation context and document for the widget
// (this widget becomes a second view on the document using the
// context for presentation).
virtual nsresult Init(nsNativeWindow aNativeParent,
virtual nsresult Init(nsNativeWidget aNativeParent,
const nsRect& aBounds,
nsIDocument* aDocument,
nsIPresContext* aPresContext,

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

@ -46,6 +46,8 @@
#include "nscore.h"
#include "nsIFactory.h"
#include "nsISupports.h"
#include "nsIDeviceContext.h"
#include "nsGfxCIID.h"
#define UA_CSS_URL "resource:/res/ua.css"
@ -66,10 +68,10 @@ public:
NS_DECL_ISUPPORTS
virtual nsresult Init(nsNativeWindow aParent,
virtual nsresult Init(nsNativeWidget aParent,
const nsRect& aBounds,
nsScrollPreference aScrolling = nsScrollPreference_kAuto);
virtual nsresult Init(nsNativeWindow aParent,
virtual nsresult Init(nsNativeWidget aParent,
const nsRect& aBounds,
nsIDocument* aDocument,
nsIPresContext* aPresContext,
@ -119,7 +121,7 @@ public:
private:
nsresult ProvideDefaultHandlers();
void ForceRefresh();
nsresult MakeWindow(nsNativeWindow aParent, const nsRect& aBounds,
nsresult MakeWindow(nsNativeWidget aParent, const nsRect& aBounds,
nsScrollPreference aScrolling);
nsresult InitUAStyleSheet(void);
nsresult CreateStyleSet(nsIDocument* aDocument, nsIStyleSet** aStyleSet);
@ -139,6 +141,7 @@ private:
nsVoidArray mChildren;
//static nsIWebWidget* gRootWebWidget;
nsString* mName;
nsIDeviceContext *mDeviceContext;
friend class WebWidgetImpl;
};
@ -203,6 +206,7 @@ printf("del %d ", this);
NS_IF_RELEASE(mScriptContext);
NS_IF_RELEASE(mScriptGlobal);
NS_IF_RELEASE(mDeviceContext);
}
void Check(WebWidgetImpl* ww)
@ -327,7 +331,7 @@ nsIWebWidget* WebWidgetImpl::GetTarget(const nsString& aName)
}
nsresult WebWidgetImpl::MakeWindow(nsNativeWindow aNativeParent,
nsresult WebWidgetImpl::MakeWindow(nsNativeWidget aNativeParent,
const nsRect& aBounds,
nsScrollPreference aScrolling)
{
@ -390,15 +394,34 @@ nsresult WebWidgetImpl::MakeWindow(nsNativeWindow aNativeParent,
return rv;
}
nsresult WebWidgetImpl::Init(nsNativeWindow aNativeParent,
nsresult WebWidgetImpl::Init(nsNativeWidget aNativeParent,
const nsRect& aBounds,
nsScrollPreference aScrolling)
{
// Create presentation context
nsresult rv = NS_NewGalleyContext(&mPresContext);
static NS_DEFINE_IID(kDeviceContextCID, NS_DEVICE_CONTEXT_CID);
static NS_DEFINE_IID(kDeviceContextIID, NS_IDEVICE_CONTEXT_IID);
nsresult rv = NSRepository::CreateInstance(kDeviceContextCID, nsnull, kDeviceContextIID, (void **)&mDeviceContext);
if (NS_OK == rv) {
mDeviceContext->Init(aNativeParent);
mDeviceContext->SetDevUnitsToAppUnits(mDeviceContext->GetDevUnitsToTwips());
mDeviceContext->SetAppUnitsToDevUnits(mDeviceContext->GetTwipsToDevUnits());
mDeviceContext->SetGamma(1.7f);
NS_ADDREF(mDeviceContext);
}
rv = NS_NewGalleyContext(&mPresContext);
if (NS_OK != rv) {
return rv;
}
mPresContext->Init(mDeviceContext);
return MakeWindow(aNativeParent, aBounds, aScrolling);
}
@ -443,7 +466,7 @@ nsresult WebWidgetImpl::InitUAStyleSheet(void)
return rv;
}
nsresult WebWidgetImpl::Init(nsNativeWindow aNativeParent,
nsresult WebWidgetImpl::Init(nsNativeWidget aNativeParent,
const nsRect& aBounds,
nsIDocument* aDocument,
nsIPresContext* aPresContext,

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

@ -340,7 +340,7 @@ static HWND CreateTopLevel(const char* clazz, const char* title,
nsresult rv = NSRepository::CreateInstance(kCChildWindowIID, NULL, kIWidgetIID, (void**)&gWindow);
if (NS_OK == rv) {
gWindow->Create((nsNativeWindow)window, rect, MyHandleEvent, NULL);
gWindow->Create((nsNativeWidget)window, rect, MyHandleEvent, NULL);
}
::ShowWindow(window, SW_SHOW);

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

@ -59,6 +59,8 @@
#include "nsIPresShell.h"
#include "nsISizeOfHandler.h"
#include "nsIViewManager.h"
#include "nsGfxCIID.h"
#include "nsIDeviceContext.h"
static NS_DEFINE_IID(kCFileWidgetCID, NS_FILEWIDGET_CID);
static NS_DEFINE_IID(kIFileWidgetIID, NS_IFILEWIDGET_IID);
@ -866,12 +868,31 @@ nsresult nsViewer::ShowPrintPreview(nsIWebWidget* web, PRIntn aColumns)
nsIDocument* doc = web->GetDocument();
if (nsnull != doc) {
nsIPresContext* cx;
nsresult rv = NS_NewPrintPreviewContext(&cx);
nsIDeviceContext* dx;
WindowData* wd = CreateTopLevel("Print Preview", 500, 300);
static NS_DEFINE_IID(kDeviceContextCID, NS_DEVICE_CONTEXT_CID);
static NS_DEFINE_IID(kDeviceContextIID, NS_IDEVICE_CONTEXT_IID);
nsresult rv = NSRepository::CreateInstance(kDeviceContextCID, nsnull, kDeviceContextIID, (void **)&dx);
if (NS_OK == rv) {
dx->Init(wd->windowWidget->GetNativeData(NS_NATIVE_WIDGET));
dx->SetDevUnitsToAppUnits(dx->GetDevUnitsToTwips());
dx->SetAppUnitsToDevUnits(dx->GetTwipsToDevUnits());
dx->SetGamma(1.7f);
NS_ADDREF(dx);
}
rv = NS_NewPrintPreviewContext(&cx);
if (NS_OK != rv) {
return rv;
}
WindowData* wd = CreateTopLevel("Print Preview", 500, 300);
cx->Init(dx);
nsRect bounds;
wd->windowWidget->GetBounds(bounds);
@ -882,6 +903,7 @@ nsresult nsViewer::ShowPrintPreview(nsIWebWidget* web, PRIntn aColumns)
wd->ww->Show();
wd->observer = NewObserver(wd->ww);
NS_RELEASE(dx);
NS_RELEASE(cx);
NS_RELEASE(doc);
}

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

@ -66,7 +66,7 @@ typedef nsEventStatus (*PR_CALLBACK EVENT_CALLBACK)(nsGUIEvent *event);
// Hide the native window systems real window type so as to avoid
// including native window system types and api's. This is necessary
// to ensure cross-platform code.
typedef void* nsNativeWindow;
typedef void* nsNativeWidget;
/**
* Border styles
@ -158,7 +158,7 @@ class nsIWidget : public nsISupports {
* @param aRect the widget dimension
* @param aHandleEventFunction the event handler callback function
*/
virtual void Create(nsNativeWindow aParent,
virtual void Create(nsNativeWidget aParent,
const nsRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,

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

@ -77,7 +77,7 @@ void nsButton::Create(nsIWidget *aParent,
}
void nsButton::Create(nsNativeWindow aParent,
void nsButton::Create(nsNativeWidget aParent,
const nsRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,

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

@ -42,7 +42,7 @@ public:
nsIDeviceContext *aContext = nsnull,
nsIToolkit *aToolkit = nsnull,
nsWidgetInitData *aInitData = nsnull);
void Create(nsNativeWindow aParent,
void Create(nsNativeWidget aParent,
const nsRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext = nsnull,

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

@ -124,7 +124,7 @@ void nsCheckButton::Create(nsIWidget *aParent,
// nsCheckButton Creator
//
//-------------------------------------------------------------------------
void nsCheckButton::Create(nsNativeWindow aParent,
void nsCheckButton::Create(nsNativeWidget aParent,
const nsRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,

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

@ -43,7 +43,7 @@ public:
nsIDeviceContext *aContext = nsnull,
nsIToolkit *aToolkit = nsnull,
nsWidgetInitData *aInitData = nsnull);
void Create(nsNativeWindow aParent,
void Create(nsNativeWidget aParent,
const nsRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext = nsnull,

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

@ -363,7 +363,7 @@ void nsComboBox::Create(nsIWidget *aParent,
// nsComboBox Creator
//
//-------------------------------------------------------------------------
void nsComboBox::Create(nsNativeWindow aParent,
void nsComboBox::Create(nsNativeWidget aParent,
const nsRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,

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

@ -43,7 +43,7 @@ public:
nsIToolkit *aToolkit = nsnull,
nsWidgetInitData *aInitData = nsnull);
void Create(nsNativeWindow aParent,
void Create(nsNativeWidget aParent,
const nsRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext = nsnull,

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

@ -89,7 +89,7 @@ void nsFileWidget:: Create(nsIWidget *aParent,
//XtManageChild(mWidget);
}
void nsFileWidget::Create(nsNativeWindow aParent,
void nsFileWidget::Create(nsNativeWidget aParent,
const nsRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,

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

@ -42,7 +42,7 @@ class nsFileWidget : public nsWindow
nsIToolkit *aToolkit = nsnull,
nsWidgetInitData *aInitData = nsnull);
void Create(nsNativeWindow aParent,
void Create(nsNativeWidget aParent,
const nsRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext = nsnull,

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

@ -289,7 +289,7 @@ void nsListBox::Create(nsIWidget *aParent,
// nsListBox Creator
//
//-------------------------------------------------------------------------
void nsListBox::Create(nsNativeWindow aParent,
void nsListBox::Create(nsNativeWidget aParent,
const nsRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,

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

@ -43,7 +43,7 @@ public:
nsIToolkit *aToolkit = nsnull,
nsWidgetInitData *aInitData = nsnull);
void Create(nsNativeWindow aParent,
void Create(nsNativeWidget aParent,
const nsRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext = nsnull,

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

@ -144,7 +144,7 @@ void nsRadioButton::Create(nsIWidget *aParent,
// nsRadioButton Creator
//
//-------------------------------------------------------------------------
void nsRadioButton::Create(nsNativeWindow aParent,
void nsRadioButton::Create(nsNativeWidget aParent,
const nsRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,

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

@ -44,7 +44,7 @@ public:
nsIToolkit *aToolkit = nsnull,
nsWidgetInitData *aInitData = nsnull);
void Create(nsNativeWindow aParent,
void Create(nsNativeWidget aParent,
const nsRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext = nsnull,

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

@ -112,7 +112,7 @@ void nsScrollbar::Create(nsIWidget *aParent,
// Create
//
//-------------------------------------------------------------------------
void nsScrollbar::Create(nsNativeWindow aParent,
void nsScrollbar::Create(nsNativeWidget aParent,
const nsRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,

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

@ -43,7 +43,7 @@ public:
nsIToolkit *aToolkit = nsnull,
nsWidgetInitData *aInitData = nsnull);
void Create(nsNativeWindow aParent,
void Create(nsNativeWidget aParent,
const nsRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext = nsnull,

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

@ -93,7 +93,7 @@ void nsTextAreaWidget::Create(nsIWidget *aParent,
}
//-------------------------------------------------------------------------
void nsTextAreaWidget::Create(nsNativeWindow aParent,
void nsTextAreaWidget::Create(nsNativeWidget aParent,
const nsRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,

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

@ -44,7 +44,7 @@ public:
nsIToolkit *aToolkit = nsnull,
nsWidgetInitData *aInitData = nsnull);
void Create(nsNativeWindow aParent,
void Create(nsNativeWidget aParent,
const nsRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext = nsnull,

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

@ -99,7 +99,7 @@ void nsTextWidget::Create(nsIWidget *aParent,
}
//-------------------------------------------------------------------------
void nsTextWidget::Create(nsNativeWindow aParent,
void nsTextWidget::Create(nsNativeWidget aParent,
const nsRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,

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

@ -45,7 +45,7 @@ public:
nsIToolkit *aToolkit = nsnull,
nsWidgetInitData *aInitData = nsnull);
void Create(nsNativeWindow aParent,
void Create(nsNativeWidget aParent,
const nsRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext = nsnull,

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

@ -224,7 +224,7 @@ nsWindow::~nsWindow()
// aNativeParent is equal to aWidgetParent->GetNativeData(NS_NATIVE_WIDGET)
//-------------------------------------------------------------------------
void nsWindow::CreateWindow(nsNativeWindow aNativeParent,
void nsWindow::CreateWindow(nsNativeWidget aNativeParent,
nsIWidget *aWidgetParent,
const nsRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
@ -463,7 +463,7 @@ void nsWindow::Create(nsIWidget *aParent,
nsIToolkit *aToolkit,
nsWidgetInitData *aInitData)
{
CreateWindow((nsNativeWindow)((aParent) ? aParent->GetNativeData(NS_NATIVE_WIDGET) : 0), aParent, aRect, aHandleEventFunction, aContext, aToolkit, aInitData);
CreateWindow((nsNativeWidget)((aParent) ? aParent->GetNativeData(NS_NATIVE_WIDGET) : 0), aParent, aRect, aHandleEventFunction, aContext, aToolkit, aInitData);
}
//-------------------------------------------------------------------------
@ -471,7 +471,7 @@ void nsWindow::Create(nsIWidget *aParent,
// create with a native parent
//
//-------------------------------------------------------------------------
void nsWindow::Create(nsNativeWindow aParent,
void nsWindow::Create(nsNativeWidget aParent,
const nsRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,

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

@ -60,7 +60,7 @@ public:
nsIDeviceContext *aContext,
nsIToolkit *aToolkit = nsnull,
nsWidgetInitData *aInitData = nsnull);
virtual void Create(nsNativeWindow aParent,
virtual void Create(nsNativeWidget aParent,
const nsRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,
@ -137,7 +137,7 @@ public:
char gInstanceClassName[256];
protected:
void InitCallbacks(char * aName = nsnull);
void CreateWindow(nsNativeWindow aNativeParent, nsIWidget *aWidgetParent,
void CreateWindow(nsNativeWidget aNativeParent, nsIWidget *aWidgetParent,
const nsRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,
@ -219,7 +219,7 @@ public: \
nsIDeviceContext *aContext, \
nsIToolkit *aToolkit = nsnull, \
nsWidgetInitData *aInitData = nsnull); \
virtual void Create(nsNativeWindow aParent, \
virtual void Create(nsNativeWidget aParent, \
const nsRect &aRect, \
EVENT_CALLBACK aHandleEventFunction, \
nsIDeviceContext *aContext, \
@ -306,7 +306,7 @@ public: \
{ \
GET_OUTER()->Create(aParent, aRect, aHandleEventFunction, aContext, aToolkit, aInitData); \
} \
void _classname::_aggname::Create(nsNativeWindow aParent, \
void _classname::_aggname::Create(nsNativeWidget aParent, \
const nsRect &aRect, \
EVENT_CALLBACK aHandleEventFunction, \
nsIDeviceContext *aContext, \

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

@ -516,7 +516,7 @@ void nsWindow::Create(nsIWidget *aParent,
// create with a native parent
//
//-------------------------------------------------------------------------
void nsWindow::Create(nsNativeWindow aParent,
void nsWindow::Create(nsNativeWidget aParent,
const nsRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,
@ -1238,7 +1238,7 @@ BOOL nsWindow::CallMethod(MethodInfo *info)
case nsWindow::CREATE_NATIVE:
NS_ASSERTION(info->nArgs == 6, "Wrong number of arguments to CallMethod");
Create((nsNativeWindow)(info->args[0]),
Create((nsNativeWidget)(info->args[0]),
(nsRect&)*(nsRect*)(info->args[1]),
(EVENT_CALLBACK)(info->args[2]),
(nsIDeviceContext*)(info->args[3]),

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

@ -61,7 +61,7 @@ public:
nsIDeviceContext *aContext,
nsIToolkit *aToolkit = nsnull,
nsWidgetInitData *aInitData = nsnull);
virtual void Create(nsNativeWindow aParent,
virtual void Create(nsNativeWidget aParent,
const nsRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,
@ -258,7 +258,7 @@ protected:
} \
#define BASE_WINDOWS_METHODS \
void Create(nsNativeWindow aParent, \
void Create(nsNativeWidget aParent, \
const nsRect &aRect, \
EVENT_CALLBACK aHandleEventFunction, \
nsIDeviceContext *aContext, \