зеркало из https://github.com/mozilla/gecko-dev.git
Lame support for nsIDOMRenderingContext API
This commit is contained in:
Родитель
a6a7325583
Коммит
068caa63c9
|
@ -19,6 +19,8 @@
|
|||
#include "nsDOMEvent.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIEventStateManager.h"
|
||||
#include "nsIRenderingContext.h"
|
||||
#include "nsIDOMRenderingContext.h"
|
||||
|
||||
static NS_DEFINE_IID(kIDOMNodeIID, NS_IDOMNODE_IID);
|
||||
static NS_DEFINE_IID(kIDOMEventIID, NS_IDOMEVENT_IID);
|
||||
|
@ -343,6 +345,24 @@ const char* nsDOMEvent::GetEventName(PRUint32 aEventType)
|
|||
return nsnull;
|
||||
}
|
||||
|
||||
static NS_DEFINE_IID(kIDOMRenderingContextIID, NS_IDOMRENDERINGCONTEXT_IID);
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMEvent::GetRc(nsIDOMRenderingContext** aRc)
|
||||
{
|
||||
*aRc = nsnull;
|
||||
if (NS_PAINT_EVENT == mEvent->eventStructType) {
|
||||
nsPaintEvent* pe = (nsPaintEvent*) mEvent;
|
||||
if (nsnull != pe->renderingContext) {
|
||||
nsIDOMRenderingContext* domrc;
|
||||
if (NS_OK == pe->renderingContext->QueryInterface(kIDOMRenderingContextIID, (void**) &domrc)) {
|
||||
*aRc = domrc;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult NS_NewDOMEvent(nsIDOMEvent** aInstancePtrResult, nsIPresContext& aPresContext, nsEvent *aEvent)
|
||||
{
|
||||
nsDOMEvent* it = new nsDOMEvent(&aPresContext, aEvent);
|
||||
|
|
|
@ -29,6 +29,8 @@
|
|||
#include "nsGUIEvent.h"
|
||||
class nsIContent;
|
||||
|
||||
class nsIDOMRenderingContext;
|
||||
|
||||
class nsDOMEvent : public nsIDOMEvent, public nsIDOMNSEvent, public nsIPrivateDOMEvent {
|
||||
|
||||
#define DOM_EVENT_INIT 0x0001
|
||||
|
@ -114,6 +116,8 @@ public:
|
|||
NS_IMETHOD GetLayerY(PRInt32* aLayerY);
|
||||
NS_IMETHOD SetLayerY(PRInt32 aLayerY);
|
||||
|
||||
NS_IMETHOD GetRc(nsIDOMRenderingContext** aRc);
|
||||
|
||||
// nsIPrivateDOMEvent interface
|
||||
NS_IMETHOD DuplicatePrivateData();
|
||||
|
||||
|
|
|
@ -17,6 +17,6 @@
|
|||
|
||||
DEPTH=..
|
||||
|
||||
DIRS= src tests
|
||||
DIRS= public src tests
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
|
|
@ -45,11 +45,16 @@ CPP_OBJS=.\$(OBJDIR)\nsColor.obj .\$(OBJDIR)\nsColorNames.obj \
|
|||
.\$(OBJDIR)\nsImageRequest.obj .\$(OBJDIR)\nsImageSystemServices.obj \
|
||||
.\$(OBJDIR)\nsImageURL.obj .\$(OBJDIR)\nsRect.obj \
|
||||
.\$(OBJDIR)\nsTransform2D.obj \
|
||||
.\$(OBJDIR)\nsDeviceContext.obj .\$(OBJDIR)\nsImageNetContextSync.obj
|
||||
.\$(OBJDIR)\nsDeviceContext.obj \
|
||||
.\$(OBJDIR)\nsImageNetContextSync.obj \
|
||||
.\$(OBJDIR)\nsJSRenderingContext.obj
|
||||
|
||||
LINCS=-I$(PUBLIC)\util -I$(PUBLIC)\img \
|
||||
-I$(PUBLIC)\xpcom -I$(PUBLIC)\raptor \
|
||||
-I$(PUBLIC)\netlib
|
||||
-I$(PUBLIC)\netlib \
|
||||
-I$(PUBLIC)\dom \
|
||||
-I$(PUBLIC)\js \
|
||||
$(NULL)
|
||||
|
||||
LCFLAGS = \
|
||||
$(LCFLAGS) \
|
||||
|
|
|
@ -47,6 +47,8 @@ OBJS = \
|
|||
LINCS= \
|
||||
-I$(PUBLIC)\raptor \
|
||||
-I$(PUBLIC)\xpcom \
|
||||
-I$(PUBLIC)\dom \
|
||||
-I$(PUBLIC)\js \
|
||||
!if defined(NGLAYOUT_DDRAW)
|
||||
!if "$(MOZ_VCVER)" == "50"
|
||||
-I$(NGLAYOUT_DDRAW)\include \
|
||||
|
@ -65,6 +67,7 @@ LLIBS= \
|
|||
$(DIST)\lib\xpcom32.lib \
|
||||
$(DIST)\lib\raptorbase.lib \
|
||||
$(DIST)\lib\img32$(VERSION_NUMBER).lib \
|
||||
$(DIST)\lib\js32$(VERSION_NUMBER).lib \
|
||||
$(DIST)\lib\util.lib \
|
||||
$(DIST)\lib\libplc21.lib \
|
||||
$(DIST)\lib\netlib.lib \
|
||||
|
|
|
@ -135,7 +135,7 @@ nsresult nsGfxFactoryWin::CreateInstance(nsISupports *aOuter,
|
|||
else if (mClassID.Equals(kCRenderingContext)) {
|
||||
nsRenderingContextWin* rc;
|
||||
NS_NEWXPCOM(rc, nsRenderingContextWin);
|
||||
inst = (nsISupports *)rc;
|
||||
inst = (nsISupports *)((nsIRenderingContext*)rc);
|
||||
}
|
||||
else if (mClassID.Equals(kCImage)) {
|
||||
nsImageWin* image;
|
||||
|
|
|
@ -25,11 +25,17 @@
|
|||
#include <math.h>
|
||||
#include "libimg.h"
|
||||
#include "nsDeviceContextWin.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "prprf.h"
|
||||
|
||||
#ifdef NGLAYOUT_DDRAW
|
||||
#include "ddraw.h"
|
||||
#endif
|
||||
|
||||
static NS_DEFINE_IID(kIDOMRenderingContextIID, NS_IDOMRENDERINGCONTEXT_IID);
|
||||
static NS_DEFINE_IID(kIRenderingContextIID, NS_IRENDERING_CONTEXT_IID);
|
||||
static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID);
|
||||
|
||||
#define FLAG_CLIP_VALID 0x0001
|
||||
#define FLAG_CLIP_CHANGED 0x0002
|
||||
#define FLAG_LOCAL_CLIP_VALID 0x0004
|
||||
|
@ -446,7 +452,41 @@ nsRenderingContextWin :: ~nsRenderingContextWin()
|
|||
|
||||
}
|
||||
|
||||
NS_IMPL_QUERY_INTERFACE(nsRenderingContextWin, kRenderingContextIID)
|
||||
nsresult
|
||||
nsRenderingContextWin::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
{
|
||||
if (nsnull == aInstancePtr) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
if (aIID.Equals(kIRenderingContextIID)) {
|
||||
nsIRenderingContext* tmp = this;
|
||||
*aInstancePtr = (void*) tmp;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kIScriptObjectOwnerIID)) {
|
||||
nsIScriptObjectOwner* tmp = this;
|
||||
*aInstancePtr = (void*) tmp;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kIDOMRenderingContextIID)) {
|
||||
nsIDOMRenderingContext* tmp = this;
|
||||
*aInstancePtr = (void*) tmp;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
if (aIID.Equals(kISupportsIID)) {
|
||||
nsIRenderingContext* tmp = this;
|
||||
nsISupports* tmp2 = tmp;
|
||||
*aInstancePtr = (void*) tmp2;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(nsRenderingContextWin)
|
||||
NS_IMPL_RELEASE(nsRenderingContextWin)
|
||||
|
||||
|
@ -1691,3 +1731,62 @@ nsresult nsRenderingContextWin :: CreateDDraw()
|
|||
}
|
||||
|
||||
#endif
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsRenderingContextWin::GetScriptObject(nsIScriptContext* aContext,
|
||||
void** aScriptObject)
|
||||
{
|
||||
nsresult res = NS_OK;
|
||||
nsIScriptGlobalObject *global = aContext->GetGlobalObject();
|
||||
|
||||
if (nsnull == mScriptObject) {
|
||||
res = NS_NewScriptRenderingContext(aContext,
|
||||
(nsISupports *)(nsIRenderingContext*)this,
|
||||
global, (void**)&mScriptObject);
|
||||
}
|
||||
*aScriptObject = mScriptObject;
|
||||
NS_RELEASE(global);
|
||||
return res;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsRenderingContextWin::SetScriptObject(void* aScriptObject)
|
||||
{
|
||||
mScriptObject = aScriptObject;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsRenderingContextWin::GetColor(nsString& aColor)
|
||||
{
|
||||
char cbuf[40];
|
||||
PR_snprintf(cbuf, sizeof(cbuf), "#%02x%02x%02x",
|
||||
NS_GET_R(mCurrentColor),
|
||||
NS_GET_G(mCurrentColor),
|
||||
NS_GET_B(mCurrentColor));
|
||||
aColor = cbuf;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsRenderingContextWin::SetColor(const nsString& aColor)
|
||||
{
|
||||
nscolor rgb;
|
||||
char cbuf[40];
|
||||
aColor.ToCString(cbuf, sizeof(cbuf));
|
||||
if (NS_ColorNameToRGB(cbuf, &rgb)) {
|
||||
SetColor(rgb);
|
||||
}
|
||||
else if (NS_HexToRGB(cbuf, &rgb)) {
|
||||
SetColor(rgb);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsRenderingContextWin::DrawLine2(PRInt32 aX0, PRInt32 aY0,
|
||||
PRInt32 aX1, PRInt32 aY1)
|
||||
{
|
||||
DrawLine(aX0, aY0, aX1, aY1);
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -33,6 +33,8 @@
|
|||
#include "nsImageWin.h"
|
||||
#include "nsIDeviceContext.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
#include "nsIDOMRenderingContext.h"
|
||||
|
||||
class GraphicsState;
|
||||
class nsDrawingSurfaceWin;
|
||||
|
@ -41,7 +43,9 @@ class nsDrawingSurfaceWin;
|
|||
#include "ddraw.h"
|
||||
#endif
|
||||
|
||||
class nsRenderingContextWin : public nsIRenderingContext
|
||||
class nsRenderingContextWin : public nsIRenderingContext,
|
||||
nsIDOMRenderingContext,
|
||||
nsIScriptObjectOwner
|
||||
{
|
||||
public:
|
||||
nsRenderingContextWin();
|
||||
|
@ -143,6 +147,13 @@ public:
|
|||
|
||||
NS_IMETHOD CopyOffScreenBits(nsRect &aBounds);
|
||||
|
||||
// nsIScriptObjectOwner
|
||||
NS_IMETHOD GetScriptObject(nsIScriptContext *aContext, void** aScriptObject);
|
||||
NS_IMETHOD SetScriptObject(void* aScriptObject);
|
||||
|
||||
// nsIDOMRenderingContext
|
||||
NS_DECL_IDOMRENDERINGCONTEXT
|
||||
|
||||
private:
|
||||
nsresult CommonInit(void);
|
||||
nsresult SetupDC(HDC aOldDC, HDC aNewDC);
|
||||
|
@ -201,6 +212,8 @@ protected:
|
|||
static nsresult mDDrawResult;
|
||||
#endif
|
||||
|
||||
void* mScriptObject;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
#include "nsDOMEvent.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIEventStateManager.h"
|
||||
#include "nsIRenderingContext.h"
|
||||
#include "nsIDOMRenderingContext.h"
|
||||
|
||||
static NS_DEFINE_IID(kIDOMNodeIID, NS_IDOMNODE_IID);
|
||||
static NS_DEFINE_IID(kIDOMEventIID, NS_IDOMEVENT_IID);
|
||||
|
@ -343,6 +345,24 @@ const char* nsDOMEvent::GetEventName(PRUint32 aEventType)
|
|||
return nsnull;
|
||||
}
|
||||
|
||||
static NS_DEFINE_IID(kIDOMRenderingContextIID, NS_IDOMRENDERINGCONTEXT_IID);
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMEvent::GetRc(nsIDOMRenderingContext** aRc)
|
||||
{
|
||||
*aRc = nsnull;
|
||||
if (NS_PAINT_EVENT == mEvent->eventStructType) {
|
||||
nsPaintEvent* pe = (nsPaintEvent*) mEvent;
|
||||
if (nsnull != pe->renderingContext) {
|
||||
nsIDOMRenderingContext* domrc;
|
||||
if (NS_OK == pe->renderingContext->QueryInterface(kIDOMRenderingContextIID, (void**) &domrc)) {
|
||||
*aRc = domrc;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult NS_NewDOMEvent(nsIDOMEvent** aInstancePtrResult, nsIPresContext& aPresContext, nsEvent *aEvent)
|
||||
{
|
||||
nsDOMEvent* it = new nsDOMEvent(&aPresContext, aEvent);
|
||||
|
|
|
@ -29,6 +29,8 @@
|
|||
#include "nsGUIEvent.h"
|
||||
class nsIContent;
|
||||
|
||||
class nsIDOMRenderingContext;
|
||||
|
||||
class nsDOMEvent : public nsIDOMEvent, public nsIDOMNSEvent, public nsIPrivateDOMEvent {
|
||||
|
||||
#define DOM_EVENT_INIT 0x0001
|
||||
|
@ -114,6 +116,8 @@ public:
|
|||
NS_IMETHOD GetLayerY(PRInt32* aLayerY);
|
||||
NS_IMETHOD SetLayerY(PRInt32 aLayerY);
|
||||
|
||||
NS_IMETHOD GetRc(nsIDOMRenderingContext** aRc);
|
||||
|
||||
// nsIPrivateDOMEvent interface
|
||||
NS_IMETHOD DuplicatePrivateData();
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче