зеркало из https://github.com/mozilla/pjs.git
Adding files created by Ori Kravitz (orik@mercury.co.il) for exposing
interfaces for testing the layout engine.
This commit is contained in:
Родитель
45f2da8bf2
Коммит
6be5f553af
|
@ -0,0 +1,30 @@
|
|||
#//------------------------------------------------------------------------
|
||||
#//
|
||||
#// Makefile to build the MODULES\LIBTEST tree
|
||||
#//
|
||||
#//------------------------------------------------------------------------
|
||||
|
||||
#//------------------------------------------------------------------------
|
||||
#//
|
||||
#// Specify the depth of the current directory relative to the
|
||||
#// root of NS
|
||||
#//
|
||||
#//------------------------------------------------------------------------
|
||||
DEPTH=../..
|
||||
|
||||
#//------------------------------------------------------------------------
|
||||
#//
|
||||
#// Specify any "command" targets. (ie. DIRS, INSTALL_FILES, ...)
|
||||
#// (these must come before the common makefiles are included)
|
||||
#//
|
||||
#// DIRS - There are subdirectories to process
|
||||
#//
|
||||
#//------------------------------------------------------------------------
|
||||
DIRS= public src
|
||||
|
||||
#//------------------------------------------------------------------------
|
||||
#//
|
||||
#// Include the common makefile rules
|
||||
#//
|
||||
#//------------------------------------------------------------------------
|
||||
include $(DEPTH)/config/rules.mk
|
|
@ -0,0 +1,36 @@
|
|||
#//------------------------------------------------------------------------
|
||||
#//
|
||||
#// Makefile to build the MODULES/LIBTEST tree
|
||||
#//
|
||||
#//------------------------------------------------------------------------
|
||||
|
||||
#//------------------------------------------------------------------------
|
||||
#//
|
||||
#// Specify the depth of the current directory relative to the
|
||||
#// root of NS
|
||||
#//
|
||||
#//------------------------------------------------------------------------
|
||||
DEPTH=../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
#//------------------------------------------------------------------------
|
||||
#//
|
||||
#// Specify any "command" targets. (ie. DIRS, INSTALL_FILES, ...)
|
||||
#// (these must come before the common makefiles are included)
|
||||
#//
|
||||
#// DIRS - There are subdirectories to process
|
||||
#//
|
||||
#//------------------------------------------------------------------------
|
||||
DIRS= public src
|
||||
|
||||
#//------------------------------------------------------------------------
|
||||
#//
|
||||
#// Include the common makefile rules
|
||||
#//
|
||||
#//------------------------------------------------------------------------
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
#//------------------------------------------------------------------------
|
||||
#//
|
||||
#// Makefile to build the MODULES\LIBTEST tree
|
||||
#//
|
||||
#//------------------------------------------------------------------------
|
||||
|
||||
#//------------------------------------------------------------------------
|
||||
#//
|
||||
#// Specify the depth of the current directory relative to the
|
||||
#// root of NS
|
||||
#//
|
||||
#//------------------------------------------------------------------------
|
||||
DEPTH=..\..
|
||||
|
||||
#//------------------------------------------------------------------------
|
||||
#//
|
||||
#// Specify any "command" targets. (ie. DIRS, INSTALL_FILES, ...)
|
||||
#// (these must come before the common makefiles are included)
|
||||
#//
|
||||
#// DIRS - There are subdirectories to process
|
||||
#//
|
||||
#//------------------------------------------------------------------------
|
||||
DIRS= public src
|
||||
|
||||
#//------------------------------------------------------------------------
|
||||
#//
|
||||
#// Include the common makefile rules
|
||||
#//
|
||||
#//------------------------------------------------------------------------
|
||||
include <$(DEPTH)\config\rules.mak>
|
|
@ -0,0 +1,23 @@
|
|||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
#
|
||||
|
||||
#
|
||||
# This is a list of local files which get copied to the mozilla:dist directory
|
||||
#
|
||||
|
||||
nsITestEventsApi.h
|
||||
nsITestQueryApi.h
|
|
@ -0,0 +1,26 @@
|
|||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH = ../../..
|
||||
|
||||
MODULE = libtest
|
||||
|
||||
EXPORTS = \
|
||||
nsITestEventsApi.h \
|
||||
nsITestQueryApi.h
|
||||
|
||||
include $(DEPTH)/config/rules.mk
|
|
@ -0,0 +1,33 @@
|
|||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
#
|
||||
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = libtest
|
||||
|
||||
EXPORTS = \
|
||||
nsITestEventsApi.h \
|
||||
nsITestQueryApi.h
|
||||
|
||||
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
|
@ -0,0 +1,29 @@
|
|||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
IGNORE_MANIFEST=1
|
||||
|
||||
DEPTH = ..\..\..
|
||||
|
||||
MODULE = libtest
|
||||
|
||||
EXPORTS = \
|
||||
nsITestEventsApi.h \
|
||||
nsITestQueryApi.h
|
||||
|
||||
include <$(DEPTH)/config/rules.mak>
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
#ifndef nsITestEventsApi_h__
|
||||
#define nsITestEventsApi_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "layprobe.h"
|
||||
|
||||
// {10709450-24C0-11d2-9A6D-0080C8845D91}
|
||||
#define NS_ITESTEVENTSAPI_IID \
|
||||
{ 0x10709450, 0x24c0, 0x11d2, \
|
||||
{ 0x9a, 0x6d, 0x0, 0x80, 0xc8, 0x84, 0x5d, 0x91 }};
|
||||
|
||||
//
|
||||
// nsITestApi Interface declaration
|
||||
//////////////////////////////////////
|
||||
|
||||
class nsITestEventsApi: public nsISupports {
|
||||
public:
|
||||
|
||||
NS_IMETHOD RegisterNotifyCallback(
|
||||
int32* OUT_lpCallbackID,
|
||||
ID_NOTIFY_PT* lpFunc,
|
||||
int32 EventID
|
||||
)=0;
|
||||
|
||||
NS_IMETHOD RegisterElementCallback(
|
||||
int32* OUT_lpCallbackID,
|
||||
ELEMENT_NOTIFY_PT* lpFunc,
|
||||
int32 EventID
|
||||
)=0;
|
||||
|
||||
NS_IMETHOD UnregisterCallbackFunction(
|
||||
void* CalbackID
|
||||
)=0;
|
||||
};
|
||||
|
||||
#endif /* nsITestEventsApi */
|
|
@ -0,0 +1,100 @@
|
|||
#ifndef nsITestQueryApi_h__
|
||||
#define nsITestQueryApi_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "layprobe.h"
|
||||
|
||||
// {47A6D121-3C0C-11d2-9A9E-0080C8845D91}
|
||||
#define NS_ITESTQUERYAPI_IID \
|
||||
{0x47a6d121, 0x3c0c, 0x11d2, \
|
||||
{0x9a, 0x9e, 0x0, 0x80, 0xc8, 0x84, 0x5d, 0x91 }}
|
||||
|
||||
//
|
||||
// nsITestQueryApi Interface declaration
|
||||
//////////////////////////////////////
|
||||
|
||||
class nsITestQueryApi: public nsISupports {
|
||||
public:
|
||||
|
||||
NS_IMETHOD GetFrames(
|
||||
XP_List** lppList
|
||||
)=0;
|
||||
|
||||
NS_IMETHOD FrameGetStringProperty(
|
||||
MWContext* FrameID,
|
||||
char* PropertyName,
|
||||
char** lpszPropVal
|
||||
)=0;
|
||||
|
||||
NS_IMETHOD FrameGetNumProperty(
|
||||
MWContext* FrameID,
|
||||
char* PropertyName,
|
||||
int32* lpPropVal
|
||||
)=0;
|
||||
|
||||
NS_IMETHOD FrameGetElements(
|
||||
XP_List* lpList,
|
||||
MWContext* FrameID,
|
||||
int16 ElementLAPIType,
|
||||
char* ElementName
|
||||
)=0;
|
||||
|
||||
|
||||
NS_IMETHOD FrameGetElementFromPoint(
|
||||
LO_Element** OUT_lppElement,
|
||||
MWContext* FrameID,
|
||||
int xPos,
|
||||
int yPos
|
||||
)=0;
|
||||
|
||||
|
||||
NS_IMETHOD GetFirstElement (
|
||||
LO_Element** OUT_lppElement,
|
||||
MWContext* FrameID
|
||||
)=0;
|
||||
|
||||
|
||||
NS_IMETHOD GetNextElement (
|
||||
LO_Element** OUT_lppElement,
|
||||
MWContext* FrameID,
|
||||
LO_Element* ElementID
|
||||
)=0;
|
||||
|
||||
|
||||
NS_IMETHOD GetPrevElement (
|
||||
LO_Element** OUT_lppElement,
|
||||
MWContext* FrameID,
|
||||
LO_Element* ElementID
|
||||
)=0;
|
||||
|
||||
|
||||
NS_IMETHOD GetChildElement (
|
||||
LO_Element** OUT_lppElement,
|
||||
MWContext* FrameID,
|
||||
LO_Element* ElementID
|
||||
)=0;
|
||||
|
||||
NS_IMETHOD ElementGetStringProperty(
|
||||
MWContext* FrameID,
|
||||
LO_Element* ElementID,
|
||||
char* PropertyName,
|
||||
char** lpszPropVal
|
||||
)=0;
|
||||
|
||||
|
||||
NS_IMETHOD ElementGetNumProperty(
|
||||
MWContext* FrameID,
|
||||
LO_Element* ElementID,
|
||||
char* PropertyName,
|
||||
int32* lpPropVal
|
||||
)=0;
|
||||
|
||||
|
||||
NS_IMETHOD GetParnetElement (
|
||||
LO_Element** OUT_lppElement,
|
||||
MWContext* FrameID,
|
||||
LO_Element* ElementID
|
||||
)=0;
|
||||
};
|
||||
|
||||
#endif /* nsITestQueryApi_h__ */
|
|
@ -0,0 +1,6 @@
|
|||
#
|
||||
# This is a list of local files which get copied to the mozilla:dist directory
|
||||
#
|
||||
|
||||
nsTestEventsApi.h
|
||||
nsTestQueryApi.h
|
|
@ -0,0 +1,26 @@
|
|||
#//------------------------------------------------------------------------
|
||||
#//
|
||||
#// Makefile to build LIBTEST
|
||||
#//
|
||||
#//------------------------------------------------------------------------
|
||||
|
||||
DEPTH = ../../..
|
||||
|
||||
include $(DEPTH)/config/config.mk
|
||||
|
||||
MODULE = libtest
|
||||
|
||||
ifdef MOZ_LIBTEST
|
||||
LIBRARY_NAME = libtest
|
||||
|
||||
CPPSRCS = nsTestEventsApi.cpp \
|
||||
nsTestQueryApi.cpp
|
||||
|
||||
REQUIRES = xpcom libtest layout
|
||||
endif # MOZ_LIBTEST
|
||||
|
||||
EXPORTS = nsTestEventsApi.h \
|
||||
nsTestQueryApi.h
|
||||
|
||||
include $(DEPTH)/config/rules.mk
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
#//------------------------------------------------------------------------
|
||||
#//
|
||||
#// Makefile to build LIBTEST
|
||||
#//
|
||||
#//------------------------------------------------------------------------
|
||||
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
MODULE = libtestimpl
|
||||
|
||||
ifdef MOZ_LIBTEST
|
||||
LIBRARY_NAME = libtest
|
||||
|
||||
CPPSRCS = nsTestEventsApi.cpp \
|
||||
nsTestQueryApi.cpp
|
||||
|
||||
REQUIRES = xpcom libtest
|
||||
endif # MOZ_LIBTEST
|
||||
|
||||
EXPORTS = nsTestEventsApi.h \
|
||||
nsTestQueryApi.h
|
||||
|
||||
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
|
@ -0,0 +1,106 @@
|
|||
IGNORE_MANIFEST=1
|
||||
#//------------------------------------------------------------------------
|
||||
#//
|
||||
#// Makefile to build
|
||||
#//
|
||||
#//------------------------------------------------------------------------
|
||||
|
||||
|
||||
#//------------------------------------------------------------------------
|
||||
#//
|
||||
#// Specify the depth of the current directory relative to the
|
||||
#// root of NS
|
||||
#//
|
||||
#//------------------------------------------------------------------------
|
||||
DEPTH= ..\..\..
|
||||
|
||||
include <$(DEPTH)/config/config.mak>
|
||||
|
||||
!ifdef MOZ_LIBTEST
|
||||
|
||||
!ifndef MAKE_OBJ_TYPE
|
||||
MAKE_OBJ_TYPE=EXE
|
||||
!endif
|
||||
|
||||
#//------------------------------------------------------------------------
|
||||
#//
|
||||
#// Define any Public Make Variables here: (ie. PDFFILE, MAPFILE, ...)
|
||||
#//
|
||||
#//------------------------------------------------------------------------
|
||||
LIBNAME=libtest$(MOZ_BITS)
|
||||
PDBFILE=$(LIBNAME).pdb
|
||||
|
||||
#//------------------------------------------------------------------------
|
||||
#//
|
||||
#// Define the files necessary to build the target (ie. OBJS)
|
||||
#//
|
||||
#//------------------------------------------------------------------------
|
||||
|
||||
OBJS = .\$(OBJDIR)\nsTestEventsApi.obj \
|
||||
.\$(OBJDIR)\nsTestQueryApi.obj
|
||||
|
||||
#//------------------------------------------------------------------------
|
||||
#//
|
||||
#// Define any Public Targets here (ie. PROGRAM, LIBRARY, DLL, ...)
|
||||
#// (these must be defined before the common makefiles are included)
|
||||
#//
|
||||
#//------------------------------------------------------------------------
|
||||
|
||||
LIBRARY= .\$(OBJDIR)\$(LIBNAME).lib
|
||||
|
||||
#//------------------------------------------------------------------------
|
||||
#//
|
||||
#// Define any local options for the make tools
|
||||
#// (ie. LCFLAGS, LLFLAGS, LLIBS, LINCS)
|
||||
#//
|
||||
#//------------------------------------------------------------------------
|
||||
|
||||
LINCS= $(LINCS) -I_jri \
|
||||
#
|
||||
# For Win16 the following include directories are copied into
|
||||
# ns/dist/public/win16
|
||||
#
|
||||
!if "$(MOZ_BITS)" == "32"
|
||||
-I$(PUBLIC)/xpcom \
|
||||
-I$(PUBLIC)/libtest \
|
||||
!endif
|
||||
-I$(DEPTH)/lib/layout \
|
||||
$(NULL)
|
||||
|
||||
CSRCS = nsTestEventsApi.cpp \
|
||||
nsTestQueryApi.cpp
|
||||
|
||||
!endif # MOZ_LIBTEST
|
||||
|
||||
MODULE = libtestimpl
|
||||
|
||||
EXPORTS = nsTestEventsApi.h \
|
||||
nsTestQueryApi.h
|
||||
|
||||
#//------------------------------------------------------------------------
|
||||
#//
|
||||
#// Include the common makefile rules
|
||||
#//
|
||||
#//------------------------------------------------------------------------
|
||||
include <$(DEPTH)/config/rules.mak>
|
||||
|
||||
LCFLAGS=$(LCFLAGS) ^
|
||||
$(JAVA_DEFINES)
|
||||
|
||||
!if "$(MOZ_BITS)" == "32"
|
||||
PUBLIC_HEADER_DIR=$(PUBLIC)\libtestimpl
|
||||
!else
|
||||
PUBLIC_HEADER_DIR=$(PUBLIC)\win16
|
||||
!endif
|
||||
|
||||
export::
|
||||
$(MAKE_INSTALL) nsTestEventsApi.h $(PUBLIC_HEADER_DIR)
|
||||
$(MAKE_INSTALL) nsTestQueryApi.h $(PUBLIC_HEADER_DIR)
|
||||
|
||||
!ifdef MOZ_LIBTEST
|
||||
install:: $(LIBRARY)
|
||||
$(MAKE_INSTALL) $(LIBRARY) $(DIST)\lib
|
||||
|
||||
clobber::
|
||||
$(RM_R) _jri
|
||||
!endif # MOZ_LIBTEST
|
|
@ -0,0 +1,275 @@
|
|||
#include "nsITestEventsApi.h"
|
||||
#include "nsTestEventsApi.h"
|
||||
#include "layprobe.h"
|
||||
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
|
||||
static NS_DEFINE_IID(kITestEventsApiIID, NS_ITESTEVENTSAPI_IID);
|
||||
static NS_DEFINE_CID(kITestEventsApiCID, NS_TESTEVENTSAPI_CID);
|
||||
|
||||
//
|
||||
// nsTestEventsApi Class Declaration
|
||||
///////////////////////////////////////////////
|
||||
|
||||
class nsTestEventsApi: public nsITestEventsApi
|
||||
{
|
||||
private:
|
||||
nsrefcnt mRefCnt;
|
||||
|
||||
public:
|
||||
// Constructor and Destuctor
|
||||
nsTestEventsApi();
|
||||
~nsTestEventsApi();
|
||||
|
||||
// nsISupports methods
|
||||
NS_IMETHOD QueryInterface(const nsIID &aIID,
|
||||
void **aResult);
|
||||
NS_IMETHOD_(nsrefcnt) AddRef(void);
|
||||
NS_IMETHOD_(nsrefcnt) Release(void);
|
||||
|
||||
// nsITestEventsApi methods
|
||||
|
||||
NS_IMETHOD RegisterNotifyCallback(
|
||||
int32* OUT_lpCallbackID,
|
||||
ID_NOTIFY_PT* lpFunc,
|
||||
int32 EventID
|
||||
);
|
||||
|
||||
NS_IMETHOD RegisterElementCallback(
|
||||
int32* OUT_lpCallbackID,
|
||||
ELEMENT_NOTIFY_PT* lpFunc,
|
||||
int32 EventID
|
||||
);
|
||||
|
||||
NS_IMETHOD UnregisterCallbackFunction(
|
||||
void* CalbackID
|
||||
);
|
||||
};
|
||||
|
||||
//
|
||||
// nsTestEventsApi Factory Declaration
|
||||
/////////////////////////////////////////////
|
||||
|
||||
class nsTestEventsApiFactory: public nsIFactory
|
||||
{
|
||||
private:
|
||||
nsrefcnt mRefCnt;
|
||||
|
||||
public:
|
||||
nsTestEventsApiFactory();
|
||||
~nsTestEventsApiFactory();
|
||||
|
||||
// nsISupports methods
|
||||
NS_IMETHOD QueryInterface(const nsIID &aIID,
|
||||
void **aResult);
|
||||
NS_IMETHOD_(nsrefcnt) AddRef(void);
|
||||
NS_IMETHOD_(nsrefcnt) Release(void);
|
||||
|
||||
// nsIFactory methods
|
||||
NS_IMETHOD CreateInstance(nsISupports *aOuter,
|
||||
const nsIID &aIID,
|
||||
void **aResult);
|
||||
|
||||
NS_IMETHOD LockFactory(PRBool aLock);
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////
|
||||
// nsTestEventsApi Implementation //
|
||||
///////////////////////////////////////////////
|
||||
|
||||
nsTestEventsApi::nsTestEventsApi()
|
||||
{
|
||||
mRefCnt = 0;
|
||||
}
|
||||
|
||||
nsTestEventsApi::~nsTestEventsApi()
|
||||
{
|
||||
assert(mRefCnt == 0);
|
||||
}
|
||||
|
||||
NS_METHOD nsTestEventsApi::QueryInterface(const nsIID &aIID,
|
||||
void **aResult)
|
||||
{
|
||||
if (aResult == NULL)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
// Always NULL result, in case of failure
|
||||
*aResult = NULL;
|
||||
|
||||
if (aIID.Equals(kISupportsIID))
|
||||
{
|
||||
*aResult = (void *) this;
|
||||
}
|
||||
else if (aIID.Equals(kITestEventsApiIID))
|
||||
{
|
||||
*aResult = (void *) this;
|
||||
}
|
||||
|
||||
if (aResult != NULL)
|
||||
return NS_ERROR_NO_INTERFACE;
|
||||
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsrefcnt nsTestEventsApi::AddRef()
|
||||
{
|
||||
return ++mRefCnt;
|
||||
}
|
||||
|
||||
nsrefcnt nsTestEventsApi::Release()
|
||||
{
|
||||
if (--mRefCnt == 0)
|
||||
{
|
||||
delete this;
|
||||
return 0; // Don't access mRefCnt after deleting!
|
||||
}
|
||||
return mRefCnt;
|
||||
}
|
||||
|
||||
|
||||
// API Callback regisration
|
||||
/////////////////////////////////////////
|
||||
|
||||
NS_METHOD nsTestEventsApi::RegisterNotifyCallback(
|
||||
int32* OUT_lppCallbackID,
|
||||
ID_NOTIFY_PT* lpFunc,
|
||||
int32 EventID
|
||||
)
|
||||
{
|
||||
*OUT_lppCallbackID = LAPIRegisterNotifyCallback(lpFunc, EventID);
|
||||
|
||||
if (*OUT_lppCallbackID)
|
||||
return NS_OK;
|
||||
else
|
||||
return LAPIGetLastError();
|
||||
}
|
||||
|
||||
|
||||
NS_METHOD nsTestEventsApi::RegisterElementCallback(
|
||||
int32* OUT_lppCallbackID,
|
||||
ELEMENT_NOTIFY_PT* lpFunc,
|
||||
int32 EventID
|
||||
)
|
||||
{
|
||||
*OUT_lppCallbackID = LAPIRegisterElementCallback(lpFunc, EventID);
|
||||
|
||||
if (*OUT_lppCallbackID)
|
||||
return NS_OK;
|
||||
else
|
||||
return LAPIGetLastError();
|
||||
}
|
||||
|
||||
|
||||
NS_METHOD nsTestEventsApi::UnregisterCallbackFunction(
|
||||
void* CallbackID
|
||||
)
|
||||
{
|
||||
if (UnregisterCallbackFunction(CallbackID))
|
||||
return NS_OK;
|
||||
else
|
||||
return LAPI_E_GENERAL_ERROR;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////
|
||||
// nsTestEventsApiFactory Implementation //
|
||||
///////////////////////////////////////////////////
|
||||
|
||||
nsTestEventsApiFactory::nsTestEventsApiFactory()
|
||||
{
|
||||
mRefCnt = 0;
|
||||
}
|
||||
|
||||
nsTestEventsApiFactory::~nsTestEventsApiFactory()
|
||||
{
|
||||
assert(mRefCnt == 0);
|
||||
}
|
||||
|
||||
NS_METHOD nsTestEventsApiFactory::QueryInterface(const nsIID &aIID,
|
||||
void **aResult)
|
||||
{
|
||||
if (aResult == NULL)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
// Always NULL result, in case of failure
|
||||
*aResult = NULL;
|
||||
|
||||
if (aIID.Equals(kISupportsIID))
|
||||
{
|
||||
*aResult = (void *) this;
|
||||
}
|
||||
else if (aIID.Equals(kIFactoryIID))
|
||||
{
|
||||
*aResult = (void *) this;
|
||||
}
|
||||
|
||||
if (*aResult == NULL)
|
||||
return NS_ERROR_NO_INTERFACE;
|
||||
|
||||
AddRef(); // Increase reference count for caller
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsrefcnt nsTestEventsApiFactory::AddRef()
|
||||
{
|
||||
return ++mRefCnt;
|
||||
}
|
||||
|
||||
nsrefcnt nsTestEventsApiFactory::Release()
|
||||
{
|
||||
if (--mRefCnt == 0)
|
||||
{
|
||||
delete this;
|
||||
return 0; // Don't access mRefCnt after deleting!
|
||||
}
|
||||
|
||||
return mRefCnt;
|
||||
}
|
||||
|
||||
NS_METHOD nsTestEventsApiFactory::CreateInstance(nsISupports *aOuter,
|
||||
const nsIID &aIID,
|
||||
void **aResult)
|
||||
{
|
||||
if (aResult == NULL)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*aResult = NULL;
|
||||
|
||||
nsISupports *inst = new nsTestEventsApi();
|
||||
|
||||
if (inst == NULL)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
nsresult res = inst->QueryInterface(aIID, aResult);
|
||||
|
||||
if (res != NS_OK)
|
||||
delete inst; // We didn't get the right interface, so clean up
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
NS_METHOD nsTestEventsApiFactory::LockFactory(PRBool aLock)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
nsresult GetTestEventsApiFactory(nsIFactory **aResult)
|
||||
{
|
||||
if (aResult == NULL)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*aResult = NULL;
|
||||
|
||||
nsISupports *inst = new nsTestEventsApiFactory();
|
||||
|
||||
if (inst == NULL)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
nsresult res = inst->QueryInterface(kIFactoryIID, (void**)aResult);
|
||||
|
||||
if (res != NS_OK)
|
||||
delete inst; // We didn't get the right interface, so clean up
|
||||
|
||||
return res;
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
#ifndef nsTestEventsApiCID_h__
|
||||
#define nsTestEventsApiCID_h__
|
||||
|
||||
#include "nsIFactory.h"
|
||||
|
||||
// {10709451-24C0-11d2-9A6D-0080C8845D91}
|
||||
#define NS_TESTEVENTSAPI_CID \
|
||||
{ 0x10709451, 0x24c0, 0x11d2, \
|
||||
{ 0x9a, 0x6d, 0x0, 0x80, 0xc8, 0x84, 0x5d, 0x91 } }
|
||||
|
||||
extern nsresult GetTestEventsApiFactory(nsIFactory **aResult);
|
||||
|
||||
#endif /* nsTestEventsApiCID_h__ */
|
|
@ -0,0 +1,470 @@
|
|||
#include "nsITestQueryApi.h"
|
||||
#include "nsTestQueryApi.h"
|
||||
#include "layprobe.h"
|
||||
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
|
||||
static NS_DEFINE_IID(kITestQueryApiIID, NS_ITESTQUERYAPI_IID);
|
||||
static NS_DEFINE_CID(kITestQueryApiCID, NS_TESTQUERYAPI_CID);
|
||||
|
||||
//
|
||||
// nsTestQueryApi Class Declaration
|
||||
/////////////////////////////////////
|
||||
|
||||
class nsTestQueryApi: public nsITestQueryApi
|
||||
{
|
||||
private:
|
||||
nsrefcnt mRefCnt;
|
||||
|
||||
public:
|
||||
// Constructor and Destuctor
|
||||
nsTestQueryApi();
|
||||
~nsTestQueryApi();
|
||||
|
||||
// nsISupports methods
|
||||
NS_IMETHOD QueryInterface(const nsIID &aIID,
|
||||
void **aResult);
|
||||
NS_IMETHOD_(nsrefcnt) AddRef(void);
|
||||
NS_IMETHOD_(nsrefcnt) Release(void);
|
||||
|
||||
// nsITestQueryApi methods
|
||||
|
||||
|
||||
NS_IMETHOD GetFrames(
|
||||
XP_List** lppList
|
||||
);
|
||||
|
||||
NS_IMETHOD FrameGetStringProperty(
|
||||
MWContext* FrameID,
|
||||
char* PropertyName,
|
||||
char** lpszPropVal
|
||||
);
|
||||
|
||||
NS_IMETHOD FrameGetNumProperty(
|
||||
MWContext* FrameID,
|
||||
char* PropertyName,
|
||||
int32* lpPropVal
|
||||
);
|
||||
|
||||
NS_IMETHOD FrameGetElements(
|
||||
XP_List* lppList,
|
||||
MWContext* FrameID,
|
||||
int16 ElementLAPIType,
|
||||
char* ElementName
|
||||
);
|
||||
|
||||
|
||||
NS_IMETHOD FrameGetElementFromPoint(
|
||||
LO_Element** OUT_lppElement,
|
||||
MWContext* FrameID,
|
||||
int xPos,
|
||||
int yPos
|
||||
);
|
||||
|
||||
|
||||
NS_IMETHOD GetFirstElement (
|
||||
LO_Element** OUT_lppElement,
|
||||
MWContext* FrameID
|
||||
);
|
||||
|
||||
|
||||
NS_IMETHOD GetNextElement (
|
||||
LO_Element** OUT_lppElement,
|
||||
MWContext* FrameID,
|
||||
LO_Element* ElementID
|
||||
);
|
||||
|
||||
|
||||
NS_IMETHOD GetPrevElement (
|
||||
LO_Element** OUT_lppElement,
|
||||
MWContext* FrameID,
|
||||
LO_Element* ElementID
|
||||
);
|
||||
|
||||
|
||||
NS_IMETHOD GetChildElement (
|
||||
LO_Element** OUT_lppElement,
|
||||
MWContext* FrameID,
|
||||
LO_Element* ElementID
|
||||
);
|
||||
|
||||
NS_IMETHOD ElementGetStringProperty(
|
||||
MWContext* FrameID,
|
||||
LO_Element* ElementID,
|
||||
char* PropertyName,
|
||||
char** lpszPropVal
|
||||
);
|
||||
|
||||
|
||||
NS_IMETHOD ElementGetNumProperty(
|
||||
MWContext* FrameID,
|
||||
LO_Element* ElementID,
|
||||
char* PropertyName,
|
||||
int32* lpPropVal
|
||||
);
|
||||
|
||||
|
||||
NS_IMETHOD GetParnetElement (
|
||||
LO_Element** OUT_lppElement,
|
||||
MWContext* FrameID,
|
||||
LO_Element* ElementID
|
||||
);
|
||||
};
|
||||
|
||||
//
|
||||
// nsITestQueryApi Factory Declaration
|
||||
/////////////////////////////////////////
|
||||
|
||||
class nsTestQueryApiFactory: public nsIFactory
|
||||
{
|
||||
private:
|
||||
nsrefcnt mRefCnt;
|
||||
|
||||
public:
|
||||
nsTestQueryApiFactory();
|
||||
~nsTestQueryApiFactory();
|
||||
|
||||
// nsISupports methods
|
||||
NS_IMETHOD QueryInterface(const nsIID &aIID,
|
||||
void **aResult);
|
||||
NS_IMETHOD_(nsrefcnt) AddRef(void);
|
||||
NS_IMETHOD_(nsrefcnt) Release(void);
|
||||
|
||||
// nsIFactory methods
|
||||
NS_IMETHOD CreateInstance(nsISupports *aOuter,
|
||||
const nsIID &aIID,
|
||||
void **aResult);
|
||||
|
||||
NS_IMETHOD LockFactory(PRBool aLock);
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////
|
||||
// nsTestQueryApi Implementation //
|
||||
///////////////////////////////////////////////
|
||||
|
||||
nsTestQueryApi::nsTestQueryApi()
|
||||
{
|
||||
mRefCnt = 0;
|
||||
}
|
||||
|
||||
nsTestQueryApi::~nsTestQueryApi()
|
||||
{
|
||||
assert(mRefCnt == 0);
|
||||
}
|
||||
|
||||
NS_METHOD nsTestQueryApi::QueryInterface(const nsIID &aIID,
|
||||
void **aResult)
|
||||
{
|
||||
if (aResult == NULL)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
// Always NULL result, in case of failure
|
||||
*aResult = NULL;
|
||||
|
||||
if (aIID.Equals(kISupportsIID))
|
||||
{
|
||||
*aResult = (void *) this;
|
||||
}
|
||||
else if (aIID.Equals(kITestQueryApiIID))
|
||||
{
|
||||
*aResult = (void *) this;
|
||||
}
|
||||
|
||||
if (aResult != NULL)
|
||||
return NS_ERROR_NO_INTERFACE;
|
||||
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsrefcnt nsTestQueryApi::AddRef()
|
||||
{
|
||||
return ++mRefCnt;
|
||||
}
|
||||
|
||||
nsrefcnt nsTestQueryApi::Release()
|
||||
{
|
||||
if (--mRefCnt == 0)
|
||||
{
|
||||
delete this;
|
||||
return 0; // Don't access mRefCnt after deleting!
|
||||
}
|
||||
return mRefCnt;
|
||||
}
|
||||
|
||||
NS_METHOD nsTestQueryApi::GetFrames(
|
||||
XP_List** lppList
|
||||
)
|
||||
{
|
||||
if (LAPIGetFrames(lppList))
|
||||
return NS_OK;
|
||||
else
|
||||
return LAPIGetLastError();
|
||||
}
|
||||
|
||||
NS_METHOD nsTestQueryApi::FrameGetStringProperty(
|
||||
MWContext* FrameID,
|
||||
char* PropertyName,
|
||||
char** lpszPropVal
|
||||
)
|
||||
{
|
||||
if (LAPIFrameGetStringProperty(FrameID, PropertyName, lpszPropVal))
|
||||
return NS_OK;
|
||||
else
|
||||
return LAPIGetLastError();
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_METHOD nsTestQueryApi::FrameGetNumProperty(
|
||||
MWContext* FrameID,
|
||||
char* PropertyName,
|
||||
int32* lpPropVal
|
||||
)
|
||||
{
|
||||
if (LAPIFrameGetNumProperty(FrameID, PropertyName, lpPropVal))
|
||||
return NS_OK;
|
||||
else
|
||||
return LAPIGetLastError();
|
||||
}
|
||||
|
||||
|
||||
NS_METHOD nsTestQueryApi::FrameGetElements(
|
||||
XP_List* OUT_lpFList,
|
||||
MWContext* FrameID,
|
||||
int16 ElementLAPIType,
|
||||
char* ElementName
|
||||
)
|
||||
{
|
||||
if (!OUT_lpFList)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (LAPIFrameGetElements(OUT_lpFList, FrameID, ElementLAPIType, ElementName))
|
||||
return NS_OK;
|
||||
else
|
||||
return LAPIGetLastError();
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_METHOD nsTestQueryApi::FrameGetElementFromPoint(
|
||||
LO_Element** OUT_lppElement,
|
||||
MWContext* FrameID,
|
||||
int xPos,
|
||||
int yPos
|
||||
)
|
||||
{
|
||||
(*OUT_lppElement) = LAPIFrameGetElementFromPoint(FrameID, xPos, yPos);
|
||||
|
||||
if ((*OUT_lppElement))
|
||||
return NS_OK;
|
||||
else
|
||||
return LAPIGetLastError();
|
||||
}
|
||||
|
||||
|
||||
NS_METHOD nsTestQueryApi::GetFirstElement (
|
||||
LO_Element** OUT_lppElement,
|
||||
MWContext * FrameID
|
||||
)
|
||||
{
|
||||
(*OUT_lppElement) = LAPIGetFirstElement(FrameID);
|
||||
|
||||
if (*OUT_lppElement != NULL)
|
||||
return NS_OK;
|
||||
else
|
||||
return LAPIGetLastError();
|
||||
}
|
||||
|
||||
NS_METHOD nsTestQueryApi::GetNextElement (
|
||||
LO_Element** OUT_lppElement,
|
||||
MWContext* FrameID,
|
||||
LO_Element* ElementID
|
||||
)
|
||||
{
|
||||
(*OUT_lppElement) = LAPIGetNextElement(FrameID, ElementID);
|
||||
|
||||
if (*OUT_lppElement != NULL)
|
||||
return NS_OK;
|
||||
else
|
||||
return LAPIGetLastError();
|
||||
}
|
||||
|
||||
|
||||
NS_METHOD nsTestQueryApi::GetPrevElement (
|
||||
LO_Element** OUT_lppElement,
|
||||
MWContext* FrameID,
|
||||
LO_Element* ElementID
|
||||
)
|
||||
{
|
||||
(*OUT_lppElement) = LAPIGetPrevElement(FrameID, ElementID);
|
||||
|
||||
if (*OUT_lppElement != NULL)
|
||||
return NS_OK;
|
||||
else
|
||||
return LAPIGetLastError();
|
||||
}
|
||||
|
||||
|
||||
NS_METHOD nsTestQueryApi::GetChildElement (
|
||||
LO_Element** OUT_lppElement,
|
||||
MWContext* FrameID,
|
||||
LO_Element* ElementID
|
||||
)
|
||||
{
|
||||
(*OUT_lppElement) = LAPIGetChildElement(FrameID, ElementID);
|
||||
|
||||
if (*OUT_lppElement != NULL)
|
||||
return NS_OK;
|
||||
else
|
||||
return LAPIGetLastError();
|
||||
}
|
||||
|
||||
|
||||
NS_METHOD nsTestQueryApi::GetParnetElement (
|
||||
LO_Element** OUT_lppElement,
|
||||
MWContext* FrameID,
|
||||
LO_Element* ElementID
|
||||
)
|
||||
{
|
||||
(*OUT_lppElement) = LAPIGetParentElement(FrameID, ElementID);
|
||||
|
||||
if (*OUT_lppElement != NULL)
|
||||
return NS_OK;
|
||||
else
|
||||
return LAPIGetLastError();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
NS_METHOD nsTestQueryApi::ElementGetStringProperty(
|
||||
MWContext* FrameID,
|
||||
LO_Element* ElementID,
|
||||
char* PropertyName,
|
||||
char** lpszPropVal
|
||||
)
|
||||
{
|
||||
if (LAPIElementGetStringProperty(FrameID, ElementID, PropertyName, lpszPropVal))
|
||||
return NS_OK;
|
||||
else
|
||||
return LAPIGetLastError();
|
||||
}
|
||||
|
||||
|
||||
NS_METHOD nsTestQueryApi::ElementGetNumProperty(
|
||||
MWContext* FrameID,
|
||||
LO_Element* ElementID,
|
||||
char* PropertyName,
|
||||
int32* lpPropVal
|
||||
)
|
||||
{
|
||||
if (LAPIElementGetNumProperty(FrameID, ElementID, PropertyName, lpPropVal))
|
||||
return NS_OK;
|
||||
else
|
||||
return LAPIGetLastError();
|
||||
}
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////
|
||||
// nsITestQueryApi Factory Implementation //
|
||||
////////////////////////////////////////////////
|
||||
|
||||
nsTestQueryApiFactory::nsTestQueryApiFactory()
|
||||
{
|
||||
mRefCnt = 0;
|
||||
}
|
||||
|
||||
nsTestQueryApiFactory::~nsTestQueryApiFactory()
|
||||
{
|
||||
assert(mRefCnt == 0);
|
||||
}
|
||||
|
||||
NS_METHOD nsTestQueryApiFactory::QueryInterface(const nsIID &aIID,
|
||||
void **aResult)
|
||||
{
|
||||
if (aResult == NULL)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
// Always NULL result, in case of failure
|
||||
*aResult = NULL;
|
||||
|
||||
if (aIID.Equals(kISupportsIID))
|
||||
{
|
||||
*aResult = (void *) this;
|
||||
}
|
||||
else if (aIID.Equals(kIFactoryIID))
|
||||
{
|
||||
*aResult = (void *) this;
|
||||
}
|
||||
|
||||
if (*aResult == NULL)
|
||||
return NS_ERROR_NO_INTERFACE;
|
||||
|
||||
AddRef(); // Increase reference count for caller
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsrefcnt nsTestQueryApiFactory::AddRef()
|
||||
{
|
||||
return ++mRefCnt;
|
||||
}
|
||||
|
||||
nsrefcnt nsTestQueryApiFactory::Release()
|
||||
{
|
||||
if (--mRefCnt == 0)
|
||||
{
|
||||
delete this;
|
||||
return 0; // Don't access mRefCnt after deleting!
|
||||
}
|
||||
|
||||
return mRefCnt;
|
||||
}
|
||||
|
||||
NS_METHOD nsTestQueryApiFactory::CreateInstance(nsISupports *aOuter,
|
||||
const nsIID &aIID,
|
||||
void **aResult)
|
||||
{
|
||||
if (aResult == NULL)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*aResult = NULL;
|
||||
|
||||
nsISupports *inst = new nsTestQueryApi();
|
||||
|
||||
if (inst == NULL)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
nsresult res = inst->QueryInterface(aIID, aResult);
|
||||
|
||||
if (res != NS_OK)
|
||||
delete inst; // We didn't get the right interface, so clean up
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
NS_METHOD nsTestQueryApiFactory::LockFactory(PRBool aLock)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
nsresult GetTestQueryApiFactory(nsIFactory **aResult)
|
||||
{
|
||||
if (aResult == NULL)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*aResult = NULL;
|
||||
|
||||
nsISupports *inst = new nsTestQueryApiFactory();
|
||||
|
||||
if (inst == NULL)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
nsresult res = inst->QueryInterface(kIFactoryIID, (void**)aResult);
|
||||
|
||||
if (res != NS_OK)
|
||||
delete inst; // We didn't get the right interface, so clean up
|
||||
|
||||
return res;
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
#ifndef nsTestQueryApiCID_h__
|
||||
#define nsTestQueryApiCID_h__
|
||||
|
||||
#include "nsIFactory.h"
|
||||
|
||||
// {10709451-24C0-11d2-9A6D-0080C8845D91}
|
||||
#define NS_TESTQUERYAPI_CID \
|
||||
{ 0x47a6d120, 0x3c0c, 0x11d2, \
|
||||
{ 0x9a, 0x9e, 0x0, 0x80, 0xc8, 0x84, 0x5d, 0x91 } }
|
||||
|
||||
extern nsresult GetTestQueryApiFactory(nsIFactory **aResult);
|
||||
|
||||
#endif /* nsTestQueryApiCID_h__ */
|
Загрузка…
Ссылка в новой задаче