diff --git a/gfx/src/xlib/nsDeviceContextXlib.cpp b/gfx/src/xlib/nsDeviceContextXlib.cpp index 300385eef35..5f5ac31ecac 100644 --- a/gfx/src/xlib/nsDeviceContextXlib.cpp +++ b/gfx/src/xlib/nsDeviceContextXlib.cpp @@ -16,81 +16,111 @@ * Reserved. */ +#include "nsRenderingContextXlib.h" +#include "nsDrawingSurfaceXlib.h" #include "nsDeviceContextXlib.h" nsDeviceContextXlib::nsDeviceContextXlib() : DeviceContextImpl() { + printf("nsDeviceContextXlib::nsDeviceContextXlib()\n"); NS_INIT_REFCNT(); } NS_IMETHODIMP nsDeviceContextXlib::Init(nsNativeWidget aNativeWidget) { + printf("nsDeviceContextXlib::Init()\n"); return NS_OK; } NS_IMETHODIMP nsDeviceContextXlib::CreateRenderingContext(nsIRenderingContext *&aContext) { + printf("nsDeviceContextXlib::CreateRenderingContext()\n"); + + nsIRenderingContext *context = nsnull; + nsIDrawingSurface *surface = nsnull; + // XXX umm...this isn't done. + context = new nsRenderingContextXlib(); + + if (nsnull != context) { + NS_ADDREF(context); + surface = new nsDrawingSurfaceXlib(); + } + + aContext = context; + return NS_OK; } NS_IMETHODIMP nsDeviceContextXlib::SupportsNativeWidgets(PRBool &aSupportsWidgets) { + printf("nsDeviceContextXlib::SupportsNativeWidgets()\n"); return NS_OK; } NS_IMETHODIMP nsDeviceContextXlib::GetScrollBarDimensions(float &aWidth, float &aHeight) const { + printf("nsDeviceContextXlib::GetScrollBarDimensions()\n"); return NS_OK; } NS_IMETHODIMP nsDeviceContextXlib::GetSystemAttribute(nsSystemAttrID anID, SystemAttrStruct * aInfo) const { + printf("nsDeviceContextXlib::GetSystemAttribute()\n"); return NS_OK; } NS_IMETHODIMP nsDeviceContextXlib::GetDrawingSurface(nsIRenderingContext &aContext, nsDrawingSurface &aSurface) { + printf("nsDeviceContextXlib::GetDrawingSurface()\n"); return NS_OK; } NS_IMETHODIMP nsDeviceContextXlib::ConvertPixel(nscolor aColor, PRUint32 & aPixel) { + printf("nsDeviceContextXlib::ConvertPixel()\n"); return NS_OK; } NS_IMETHODIMP nsDeviceContextXlib::CheckFontExistence(const nsString& aFontName) { + printf("nsDeviceContextXlib::CheckFontExistence()\n"); return NS_OK; } NS_IMETHODIMP nsDeviceContextXlib::GetDeviceSurfaceDimensions(PRInt32 &aWidth, PRInt32 &aHeight) { + printf("nsDeviceContextXlib::GetDeviceSurfaceDimensions()\n"); return NS_OK; } NS_IMETHODIMP nsDeviceContextXlib::GetDeviceContextFor(nsIDeviceContextSpec *aDevice, nsIDeviceContext *&aContext) { + printf("nsDeviceContextXlib::GetDeviceContextFor()\n"); return NS_OK; } NS_IMETHODIMP nsDeviceContextXlib::BeginDocument(void) { + printf("nsDeviceContextXlib::BeginDocument()\n"); return NS_OK; } NS_IMETHODIMP nsDeviceContextXlib::EndDocument(void) { + printf("nsDeviceContextXlib::EndDocument()\n"); return NS_OK; } NS_IMETHODIMP nsDeviceContextXlib::BeginPage(void) { + printf("nsDeviceContextXlib::BeginPage()\n"); return NS_OK; } NS_IMETHODIMP nsDeviceContextXlib::EndPage(void) { + printf("nsDeviceContextXlib::EndPage()\n"); return NS_OK; } diff --git a/gfx/src/xlib/nsDrawingSurfaceXlib.cpp b/gfx/src/xlib/nsDrawingSurfaceXlib.cpp index 28e91684e72..eb8d4fcc34f 100644 --- a/gfx/src/xlib/nsDrawingSurfaceXlib.cpp +++ b/gfx/src/xlib/nsDrawingSurfaceXlib.cpp @@ -79,6 +79,7 @@ nsDrawingSurfaceXlib::nsDrawingSurfaceXlib() nsDrawingSurfaceXlib::~nsDrawingSurfaceXlib() { + printf("nsDrawingSurfaceXlib::~nsDrawingSurfaceXlib()\n"); if (mPixmap) { XFreePixmap(gDisplay, mPixmap); } @@ -98,6 +99,7 @@ nsDrawingSurfaceXlib::Lock(PRInt32 aX, PRInt32 aY, void **aBits, PRInt32 *aStride, PRInt32 *aWidthBytes, PRUint32 aFlags) { + printf("nsDrawingSurfaceXlib::Lock()\n"); if (mLocked) { NS_ASSERTION(0, "nested lock attempt"); @@ -128,6 +130,7 @@ nsDrawingSurfaceXlib::Lock(PRInt32 aX, PRInt32 aY, NS_IMETHODIMP nsDrawingSurfaceXlib::Unlock(void) { + printf("nsDrawingSurfaceXlib::UnLock()\n"); if (!mLocked) { NS_ASSERTION(0, "attempting to unlock an DS that isn't locked"); return NS_ERROR_FAILURE; diff --git a/gfx/src/xlib/nsFontMetricsXlib.cpp b/gfx/src/xlib/nsFontMetricsXlib.cpp index bef4428a527..2c960771e85 100644 --- a/gfx/src/xlib/nsFontMetricsXlib.cpp +++ b/gfx/src/xlib/nsFontMetricsXlib.cpp @@ -22,81 +22,97 @@ static NS_DEFINE_IID(kIFontMetricsIID, NS_IFONT_METRICS_IID); nsFontMetricsXlib::nsFontMetricsXlib() { + printf("nsFontMetricsXlib::nsFontMetricsXlib()\n"); NS_INIT_REFCNT(); } nsFontMetricsXlib::~nsFontMetricsXlib() { + printf("nsFontMetricsXlib::~nsFontMetricsXlib()\n"); } NS_IMPL_ISUPPORTS(nsFontMetricsXlib, kIFontMetricsIID) NS_IMETHODIMP nsFontMetricsXlib::Init(const nsFont& aFont, nsIDeviceContext* aContext) { + printf("nsFontMetricsXlib::Init()\n"); return NS_OK; } NS_IMETHODIMP nsFontMetricsXlib::Destroy() { + printf("nsFontMetricsXlib::Destroy()\n"); return NS_OK; } NS_IMETHODIMP nsFontMetricsXlib::GetXHeight(nscoord& aResult) { + printf("nsFontMetricsXlib::GetXHeight()\n"); return NS_OK; } NS_IMETHODIMP nsFontMetricsXlib::GetSuperscriptOffset(nscoord& aResult) { + printf("nsFontMetricsXlib::GetSuperscriptOffset()\n"); return NS_OK; } NS_IMETHODIMP nsFontMetricsXlib::GetSubscriptOffset(nscoord& aResult) { + printf("nsFontMetricsXlib::GetSubscriptOffset()\n"); return NS_OK; } NS_IMETHODIMP nsFontMetricsXlib::GetStrikeout(nscoord& aOffset, nscoord& aSize) { + printf("nsFontMetricsXlib::GetStrikeout()\n"); return NS_OK; } NS_IMETHODIMP nsFontMetricsXlib::GetUnderline(nscoord& aOffset, nscoord& aSize) { + printf("nsFontMetricsXlib::GetUnderline()\n"); return NS_OK; } NS_IMETHODIMP nsFontMetricsXlib::GetHeight(nscoord &aHeight) { + printf("nsFontMetricsXlib::GetHeight()\n"); return NS_OK; } NS_IMETHODIMP nsFontMetricsXlib::GetLeading(nscoord &aLeading) { + printf("nsFontMetricsXlib::GetLeading()\n"); return NS_OK; } NS_IMETHODIMP nsFontMetricsXlib::GetMaxAscent(nscoord &aAscent) { + printf("nsFontMetricsXlib::GetMaxAscent()\n"); return NS_OK; } NS_IMETHODIMP nsFontMetricsXlib::GetMaxDescent(nscoord &aDescent) { + printf("nsFontMetricsXlib::GetMaxDescent()\n"); return NS_OK; } NS_IMETHODIMP nsFontMetricsXlib::GetMaxAdvance(nscoord &aAdvance) { + printf("nsFontMetricsXlib::GetMaxAdvance()\n"); return NS_OK; } NS_IMETHODIMP nsFontMetricsXlib::GetFont(const nsFont *&aFont) { + printf("nsFontMetricsXlib::GetFont()\n"); return NS_OK; } NS_IMETHODIMP nsFontMetricsXlib::GetFontHandle(nsFontHandle &aHandle) { + printf("nsFontMetricsXlib::GetFontHandle()\n"); return NS_OK; } diff --git a/gfx/src/xlib/nsRenderingContextXlib.cpp b/gfx/src/xlib/nsRenderingContextXlib.cpp index b84b57e59f6..4af52d4b7be 100644 --- a/gfx/src/xlib/nsRenderingContextXlib.cpp +++ b/gfx/src/xlib/nsRenderingContextXlib.cpp @@ -27,6 +27,18 @@ nsRenderingContextXlib::nsRenderingContextXlib() { printf("nsRenderingContextXlib::nsRenderingContextXlib()\n"); NS_INIT_REFCNT(); + mRenderingSurface = nsnull; + mTMatrix = nsnull; + mFontMetrics = nsnull; + mContext = nsnull; + mScriptObject = nsnull; +} + +nsRenderingContextXlib::~nsRenderingContextXlib() +{ + printf("nsRenderingContextXlib::~nsRenderingContextXlib()\n"); + NS_IF_RELEASE(mContext); + NS_IF_RELEASE(mFontMetrics); } nsresult @@ -76,14 +88,34 @@ NS_IMETHODIMP nsRenderingContextXlib::Init(nsIDeviceContext* aContext, nsIWidget *aWindow) { printf("nsRenderingContextXlib::Init()\n"); - return NS_OK; + mContext = aContext; + NS_IF_ADDREF(mContext); + + mRenderingSurface = (nsDrawingSurfaceXlib *)new nsDrawingSurfaceXlib(); + + return CommonInit(); } NS_IMETHODIMP nsRenderingContextXlib::Init(nsIDeviceContext* aContext, nsDrawingSurface aSurface) { printf("nsRenderingContxtXbli::Init()\n"); - return NS_OK; + + mContext = aContext; + NS_IF_ADDREF(mContext); + + mRenderingSurface = (nsDrawingSurfaceXlib *)aSurface; + + if (nsnull != mRenderingSurface) { + NS_ADDREF(mRenderingSurface); + } + + return CommonInit(); +} + +nsresult nsRenderingContextXlib::CommonInit(void) +{ + // put common stuff in here. } NS_IMETHODIMP diff --git a/gfx/src/xlib/nsRenderingContextXlib.h b/gfx/src/xlib/nsRenderingContextXlib.h index 4e01507b567..8bb19db6cb8 100644 --- a/gfx/src/xlib/nsRenderingContextXlib.h +++ b/gfx/src/xlib/nsRenderingContextXlib.h @@ -43,6 +43,7 @@ class nsRenderingContextXlib : public nsIRenderingContext, { public: nsRenderingContextXlib(); + ~nsRenderingContextXlib(); NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW @@ -155,10 +156,15 @@ class nsRenderingContextXlib : public nsIRenderingContext, // XXX uncomment this... NS_DECL_IDOMRENDERINGCONTEXT -private: - nsDrawingSurfaceXlib *mRenderingSurface; + // this is a common init function for both of the init functions. + nsresult CommonInit(void); - nsTransform2D *mTMatrix; +private: + nsDrawingSurfaceXlib *mRenderingSurface; + nsTransform2D *mTMatrix; + nsIFontMetrics *mFontMetrics; + nsIDeviceContext *mContext; + void *mScriptObject; }; #endif