зеркало из https://github.com/mozilla/pjs.git
Adding new files for window.history, window.screen
This commit is contained in:
Родитель
82a7382711
Коммит
3c4cec6483
|
@ -0,0 +1,185 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsHistory.h"
|
||||
#include "nsIDOMWindow.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIWebShell.h"
|
||||
|
||||
static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID);
|
||||
static NS_DEFINE_IID(kIDOMHistoryIID, NS_IDOMHISTORY_IID);
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
|
||||
//
|
||||
// History class implementation
|
||||
//
|
||||
HistoryImpl::HistoryImpl()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mWebShell = nsnull;
|
||||
mScriptObject = nsnull;
|
||||
}
|
||||
|
||||
HistoryImpl::~HistoryImpl()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(HistoryImpl)
|
||||
NS_IMPL_RELEASE(HistoryImpl)
|
||||
|
||||
nsresult
|
||||
HistoryImpl::QueryInterface(const nsIID& aIID,
|
||||
void** aInstancePtrResult)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aInstancePtrResult, "null pointer");
|
||||
if (nsnull == aInstancePtrResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
if (aIID.Equals(kIScriptObjectOwnerIID)) {
|
||||
*aInstancePtrResult = (void*) ((nsIScriptObjectOwner*)this);
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kIDOMHistoryIID)) {
|
||||
*aInstancePtrResult = (void*) ((nsIDOMHistory*)this);
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kISupportsIID)) {
|
||||
*aInstancePtrResult = (void*)(nsISupports*)(nsIScriptObjectOwner*)this;
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HistoryImpl::SetScriptObject(void *aScriptObject)
|
||||
{
|
||||
mScriptObject = aScriptObject;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HistoryImpl::GetScriptObject(nsIScriptContext *aContext, void** aScriptObject)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aScriptObject, "null arg");
|
||||
nsresult res = NS_OK;
|
||||
if (nsnull == mScriptObject) {
|
||||
nsIScriptGlobalObject *global = aContext->GetGlobalObject();
|
||||
res = NS_NewScriptHistory(aContext, (nsIDOMHistory*)this, (nsIDOMWindow*)global, &mScriptObject);
|
||||
NS_IF_RELEASE(global);
|
||||
}
|
||||
|
||||
*aScriptObject = mScriptObject;
|
||||
return res;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(void)
|
||||
HistoryImpl::SetWebShell(nsIWebShell *aWebShell)
|
||||
{
|
||||
//mWebShell isn't refcnt'd here. GlobalWindow calls SetWebShell(nsnull)
|
||||
//when it's told that the WebShell is going to be deleted.
|
||||
mWebShell = aWebShell;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HistoryImpl::GetLength(PRInt32* aLength)
|
||||
{
|
||||
if (nsnull != mWebShell) {
|
||||
mWebShell->GetHistoryLength(*aLength);
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HistoryImpl::GetCurrent(nsString& aCurrent)
|
||||
{
|
||||
PRInt32 curIndex;
|
||||
PRUnichar* curURL = nsnull;
|
||||
|
||||
if (nsnull != mWebShell && NS_OK == mWebShell->GetHistoryIndex(curIndex)) {
|
||||
mWebShell->GetURL(curIndex, &curURL);
|
||||
}
|
||||
aCurrent.SetString(curURL);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HistoryImpl::GetPrevious(nsString& aPrevious)
|
||||
{
|
||||
PRInt32 curIndex;
|
||||
PRUnichar* prevURL = nsnull;
|
||||
|
||||
if (nsnull != mWebShell && NS_OK == mWebShell->GetHistoryIndex(curIndex)) {
|
||||
mWebShell->GetURL(curIndex-1, &prevURL);
|
||||
}
|
||||
aPrevious.SetString(prevURL);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HistoryImpl::GetNext(nsString& aNext)
|
||||
{
|
||||
PRInt32 curIndex;
|
||||
PRUnichar* nextURL = nsnull;
|
||||
|
||||
if (nsnull != mWebShell && NS_OK == mWebShell->GetHistoryIndex(curIndex)) {
|
||||
mWebShell->GetURL(curIndex+1, &nextURL);
|
||||
}
|
||||
aNext.SetString(nextURL);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HistoryImpl::Back()
|
||||
{
|
||||
if (nsnull != mWebShell && NS_OK == mWebShell->CanBack()) {
|
||||
mWebShell->Back();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HistoryImpl::Forward()
|
||||
{
|
||||
if (nsnull != mWebShell && NS_OK == mWebShell->CanForward()) {
|
||||
mWebShell->Forward();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HistoryImpl::Go(PRInt32 aIndex)
|
||||
{
|
||||
if (nsnull != mWebShell) {
|
||||
mWebShell->GoTo(aIndex);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
#ifndef nsHistory_h___
|
||||
#define nsHistory_h___
|
||||
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
#include "nsIDOMHistory.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nscore.h"
|
||||
#include "nsIScriptContext.h"
|
||||
|
||||
class nsIWebShell;
|
||||
|
||||
// Script "History" object
|
||||
class HistoryImpl : public nsIScriptObjectOwner, public nsIDOMHistory {
|
||||
public:
|
||||
HistoryImpl();
|
||||
~HistoryImpl();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD GetScriptObject(nsIScriptContext *aContext, void** aScriptObject);
|
||||
NS_IMETHOD SetScriptObject(void *aScriptObject);
|
||||
|
||||
NS_IMETHOD_(void) SetWebShell(nsIWebShell *aWebShell);
|
||||
|
||||
NS_IMETHOD GetLength(PRInt32* aLength);
|
||||
NS_IMETHOD GetCurrent(nsString& aCurrent);
|
||||
NS_IMETHOD GetPrevious(nsString& aPrevious);
|
||||
NS_IMETHOD GetNext(nsString& aNext);
|
||||
NS_IMETHOD Back();
|
||||
NS_IMETHOD Forward();
|
||||
NS_IMETHOD Go(PRInt32 aIndex);
|
||||
|
||||
protected:
|
||||
nsIWebShell* mWebShell;
|
||||
void *mScriptObject;
|
||||
};
|
||||
|
||||
#endif /* nsHistory_h___ */
|
|
@ -0,0 +1,432 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
/* AUTO-GENERATED. DO NOT EDIT!!! */
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "nsJSUtils.h"
|
||||
#include "nscore.h"
|
||||
#include "nsIScriptContext.h"
|
||||
#include "nsIJSScriptObject.h"
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIPtr.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIDOMHistory.h"
|
||||
|
||||
|
||||
static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID);
|
||||
static NS_DEFINE_IID(kIJSScriptObjectIID, NS_IJSSCRIPTOBJECT_IID);
|
||||
static NS_DEFINE_IID(kIScriptGlobalObjectIID, NS_ISCRIPTGLOBALOBJECT_IID);
|
||||
static NS_DEFINE_IID(kIHistoryIID, NS_IDOMHISTORY_IID);
|
||||
|
||||
NS_DEF_PTR(nsIDOMHistory);
|
||||
|
||||
//
|
||||
// History property ids
|
||||
//
|
||||
enum History_slots {
|
||||
HISTORY_LENGTH = -1,
|
||||
HISTORY_CURRENT = -2,
|
||||
HISTORY_PREVIOUS = -3,
|
||||
HISTORY_NEXT = -4
|
||||
};
|
||||
|
||||
/***********************************************************************/
|
||||
//
|
||||
// History Properties Getter
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
GetHistoryProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
{
|
||||
nsIDOMHistory *a = (nsIDOMHistory*)JS_GetPrivate(cx, obj);
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == a) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
if (JSVAL_IS_INT(id)) {
|
||||
switch(JSVAL_TO_INT(id)) {
|
||||
case HISTORY_LENGTH:
|
||||
{
|
||||
PRInt32 prop;
|
||||
if (NS_OK == a->GetLength(&prop)) {
|
||||
*vp = INT_TO_JSVAL(prop);
|
||||
}
|
||||
else {
|
||||
return JS_FALSE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case HISTORY_CURRENT:
|
||||
{
|
||||
nsAutoString prop;
|
||||
if (NS_OK == a->GetCurrent(prop)) {
|
||||
nsJSUtils::nsConvertStringToJSVal(prop, cx, vp);
|
||||
}
|
||||
else {
|
||||
return JS_FALSE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case HISTORY_PREVIOUS:
|
||||
{
|
||||
nsAutoString prop;
|
||||
if (NS_OK == a->GetPrevious(prop)) {
|
||||
nsJSUtils::nsConvertStringToJSVal(prop, cx, vp);
|
||||
}
|
||||
else {
|
||||
return JS_FALSE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case HISTORY_NEXT:
|
||||
{
|
||||
nsAutoString prop;
|
||||
if (NS_OK == a->GetNext(prop)) {
|
||||
nsJSUtils::nsConvertStringToJSVal(prop, cx, vp);
|
||||
}
|
||||
else {
|
||||
return JS_FALSE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, id, vp);
|
||||
}
|
||||
}
|
||||
else {
|
||||
return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, id, vp);
|
||||
}
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
/***********************************************************************/
|
||||
//
|
||||
// History Properties Setter
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
SetHistoryProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
{
|
||||
nsIDOMHistory *a = (nsIDOMHistory*)JS_GetPrivate(cx, obj);
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == a) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
if (JSVAL_IS_INT(id)) {
|
||||
switch(JSVAL_TO_INT(id)) {
|
||||
case 0:
|
||||
default:
|
||||
return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, id, vp);
|
||||
}
|
||||
}
|
||||
else {
|
||||
return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, id, vp);
|
||||
}
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// History finalizer
|
||||
//
|
||||
PR_STATIC_CALLBACK(void)
|
||||
FinalizeHistory(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
nsJSUtils::nsGenericFinalize(cx, obj);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// History enumerate
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
EnumerateHistory(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
return nsJSUtils::nsGenericEnumerate(cx, obj);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// History resolve
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
ResolveHistory(JSContext *cx, JSObject *obj, jsval id)
|
||||
{
|
||||
return nsJSUtils::nsGenericResolve(cx, obj, id);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method Back
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
HistoryBack(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMHistory *nativeThis = (nsIDOMHistory*)JS_GetPrivate(cx, obj);
|
||||
JSBool rBool = JS_FALSE;
|
||||
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == nativeThis) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
if (argc >= 0) {
|
||||
|
||||
if (NS_OK != nativeThis->Back()) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
*rval = JSVAL_VOID;
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function back requires 0 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method Forward
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
HistoryForward(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMHistory *nativeThis = (nsIDOMHistory*)JS_GetPrivate(cx, obj);
|
||||
JSBool rBool = JS_FALSE;
|
||||
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == nativeThis) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
if (argc >= 0) {
|
||||
|
||||
if (NS_OK != nativeThis->Forward()) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
*rval = JSVAL_VOID;
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function forward requires 0 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method Go
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
HistoryGo(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMHistory *nativeThis = (nsIDOMHistory*)JS_GetPrivate(cx, obj);
|
||||
JSBool rBool = JS_FALSE;
|
||||
PRInt32 b0;
|
||||
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == nativeThis) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
if (argc >= 1) {
|
||||
|
||||
if (!JS_ValueToInt32(cx, argv[0], (int32 *)&b0)) {
|
||||
JS_ReportError(cx, "Parameter must be a number");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (NS_OK != nativeThis->Go(b0)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
*rval = JSVAL_VOID;
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function go requires 1 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************/
|
||||
//
|
||||
// class for History
|
||||
//
|
||||
JSClass HistoryClass = {
|
||||
"History",
|
||||
JSCLASS_HAS_PRIVATE,
|
||||
JS_PropertyStub,
|
||||
JS_PropertyStub,
|
||||
GetHistoryProperty,
|
||||
SetHistoryProperty,
|
||||
EnumerateHistory,
|
||||
ResolveHistory,
|
||||
JS_ConvertStub,
|
||||
FinalizeHistory
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// History class properties
|
||||
//
|
||||
static JSPropertySpec HistoryProperties[] =
|
||||
{
|
||||
{"length", HISTORY_LENGTH, JSPROP_ENUMERATE | JSPROP_READONLY},
|
||||
{"current", HISTORY_CURRENT, JSPROP_ENUMERATE | JSPROP_READONLY},
|
||||
{"previous", HISTORY_PREVIOUS, JSPROP_ENUMERATE | JSPROP_READONLY},
|
||||
{"next", HISTORY_NEXT, JSPROP_ENUMERATE | JSPROP_READONLY},
|
||||
{0}
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// History class methods
|
||||
//
|
||||
static JSFunctionSpec HistoryMethods[] =
|
||||
{
|
||||
{"back", HistoryBack, 0},
|
||||
{"forward", HistoryForward, 0},
|
||||
{"go", HistoryGo, 1},
|
||||
{0}
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// History constructor
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
History(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// History class initialization
|
||||
//
|
||||
nsresult NS_InitHistoryClass(nsIScriptContext *aContext, void **aPrototype)
|
||||
{
|
||||
JSContext *jscontext = (JSContext *)aContext->GetNativeContext();
|
||||
JSObject *proto = nsnull;
|
||||
JSObject *constructor = nsnull;
|
||||
JSObject *parent_proto = nsnull;
|
||||
JSObject *global = JS_GetGlobalObject(jscontext);
|
||||
jsval vp;
|
||||
|
||||
if ((PR_TRUE != JS_LookupProperty(jscontext, global, "History", &vp)) ||
|
||||
!JSVAL_IS_OBJECT(vp) ||
|
||||
((constructor = JSVAL_TO_OBJECT(vp)) == nsnull) ||
|
||||
(PR_TRUE != JS_LookupProperty(jscontext, JSVAL_TO_OBJECT(vp), "prototype", &vp)) ||
|
||||
!JSVAL_IS_OBJECT(vp)) {
|
||||
|
||||
proto = JS_InitClass(jscontext, // context
|
||||
global, // global object
|
||||
parent_proto, // parent proto
|
||||
&HistoryClass, // JSClass
|
||||
History, // JSNative ctor
|
||||
0, // ctor args
|
||||
HistoryProperties, // proto props
|
||||
HistoryMethods, // proto funcs
|
||||
nsnull, // ctor props (static)
|
||||
nsnull); // ctor funcs (static)
|
||||
if (nsnull == proto) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
}
|
||||
else if ((nsnull != constructor) && JSVAL_IS_OBJECT(vp)) {
|
||||
proto = JSVAL_TO_OBJECT(vp);
|
||||
}
|
||||
else {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (aPrototype) {
|
||||
*aPrototype = proto;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Method for creating a new History JavaScript object
|
||||
//
|
||||
extern "C" NS_DOM nsresult NS_NewScriptHistory(nsIScriptContext *aContext, nsISupports *aSupports, nsISupports *aParent, void **aReturn)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aContext && nsnull != aSupports && nsnull != aReturn, "null argument to NS_NewScriptHistory");
|
||||
JSObject *proto;
|
||||
JSObject *parent;
|
||||
nsIScriptObjectOwner *owner;
|
||||
JSContext *jscontext = (JSContext *)aContext->GetNativeContext();
|
||||
nsresult result = NS_OK;
|
||||
nsIDOMHistory *aHistory;
|
||||
|
||||
if (nsnull == aParent) {
|
||||
parent = nsnull;
|
||||
}
|
||||
else if (NS_OK == aParent->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) {
|
||||
if (NS_OK != owner->GetScriptObject(aContext, (void **)&parent)) {
|
||||
NS_RELEASE(owner);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
NS_RELEASE(owner);
|
||||
}
|
||||
else {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (NS_OK != NS_InitHistoryClass(aContext, (void **)&proto)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
result = aSupports->QueryInterface(kIHistoryIID, (void **)&aHistory);
|
||||
if (NS_OK != result) {
|
||||
return result;
|
||||
}
|
||||
|
||||
// create a js object for this class
|
||||
*aReturn = JS_NewObject(jscontext, &HistoryClass, proto, parent);
|
||||
if (nsnull != *aReturn) {
|
||||
// connect the native object to the js object
|
||||
JS_SetPrivate(jscontext, (JSObject *)*aReturn, aHistory);
|
||||
}
|
||||
else {
|
||||
NS_RELEASE(aHistory);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
|
@ -0,0 +1,376 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
/* AUTO-GENERATED. DO NOT EDIT!!! */
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "nsJSUtils.h"
|
||||
#include "nscore.h"
|
||||
#include "nsIScriptContext.h"
|
||||
#include "nsIJSScriptObject.h"
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIPtr.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIDOMScreen.h"
|
||||
|
||||
|
||||
static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID);
|
||||
static NS_DEFINE_IID(kIJSScriptObjectIID, NS_IJSSCRIPTOBJECT_IID);
|
||||
static NS_DEFINE_IID(kIScriptGlobalObjectIID, NS_ISCRIPTGLOBALOBJECT_IID);
|
||||
static NS_DEFINE_IID(kIScreenIID, NS_IDOMSCREEN_IID);
|
||||
|
||||
NS_DEF_PTR(nsIDOMScreen);
|
||||
|
||||
//
|
||||
// Screen property ids
|
||||
//
|
||||
enum Screen_slots {
|
||||
SCREEN_WIDTH = -1,
|
||||
SCREEN_HEIGHT = -2,
|
||||
SCREEN_PIXELDEPTH = -3,
|
||||
SCREEN_COLORDEPTH = -4,
|
||||
SCREEN_AVAILWIDTH = -5,
|
||||
SCREEN_AVAILHEIGHT = -6,
|
||||
SCREEN_AVAILLEFT = -7,
|
||||
SCREEN_AVAILTOP = -8
|
||||
};
|
||||
|
||||
/***********************************************************************/
|
||||
//
|
||||
// Screen Properties Getter
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
GetScreenProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
{
|
||||
nsIDOMScreen *a = (nsIDOMScreen*)JS_GetPrivate(cx, obj);
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == a) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
if (JSVAL_IS_INT(id)) {
|
||||
switch(JSVAL_TO_INT(id)) {
|
||||
case SCREEN_WIDTH:
|
||||
{
|
||||
PRInt32 prop;
|
||||
if (NS_OK == a->GetWidth(&prop)) {
|
||||
*vp = INT_TO_JSVAL(prop);
|
||||
}
|
||||
else {
|
||||
return JS_FALSE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SCREEN_HEIGHT:
|
||||
{
|
||||
PRInt32 prop;
|
||||
if (NS_OK == a->GetHeight(&prop)) {
|
||||
*vp = INT_TO_JSVAL(prop);
|
||||
}
|
||||
else {
|
||||
return JS_FALSE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SCREEN_PIXELDEPTH:
|
||||
{
|
||||
PRInt32 prop;
|
||||
if (NS_OK == a->GetPixelDepth(&prop)) {
|
||||
*vp = INT_TO_JSVAL(prop);
|
||||
}
|
||||
else {
|
||||
return JS_FALSE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SCREEN_COLORDEPTH:
|
||||
{
|
||||
PRInt32 prop;
|
||||
if (NS_OK == a->GetColorDepth(&prop)) {
|
||||
*vp = INT_TO_JSVAL(prop);
|
||||
}
|
||||
else {
|
||||
return JS_FALSE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SCREEN_AVAILWIDTH:
|
||||
{
|
||||
PRInt32 prop;
|
||||
if (NS_OK == a->GetAvailWidth(&prop)) {
|
||||
*vp = INT_TO_JSVAL(prop);
|
||||
}
|
||||
else {
|
||||
return JS_FALSE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SCREEN_AVAILHEIGHT:
|
||||
{
|
||||
PRInt32 prop;
|
||||
if (NS_OK == a->GetAvailHeight(&prop)) {
|
||||
*vp = INT_TO_JSVAL(prop);
|
||||
}
|
||||
else {
|
||||
return JS_FALSE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SCREEN_AVAILLEFT:
|
||||
{
|
||||
PRInt32 prop;
|
||||
if (NS_OK == a->GetAvailLeft(&prop)) {
|
||||
*vp = INT_TO_JSVAL(prop);
|
||||
}
|
||||
else {
|
||||
return JS_FALSE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SCREEN_AVAILTOP:
|
||||
{
|
||||
PRInt32 prop;
|
||||
if (NS_OK == a->GetAvailTop(&prop)) {
|
||||
*vp = INT_TO_JSVAL(prop);
|
||||
}
|
||||
else {
|
||||
return JS_FALSE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, id, vp);
|
||||
}
|
||||
}
|
||||
else {
|
||||
return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, id, vp);
|
||||
}
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
/***********************************************************************/
|
||||
//
|
||||
// Screen Properties Setter
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
SetScreenProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
{
|
||||
nsIDOMScreen *a = (nsIDOMScreen*)JS_GetPrivate(cx, obj);
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == a) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
if (JSVAL_IS_INT(id)) {
|
||||
switch(JSVAL_TO_INT(id)) {
|
||||
case 0:
|
||||
default:
|
||||
return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, id, vp);
|
||||
}
|
||||
}
|
||||
else {
|
||||
return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, id, vp);
|
||||
}
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Screen finalizer
|
||||
//
|
||||
PR_STATIC_CALLBACK(void)
|
||||
FinalizeScreen(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
nsJSUtils::nsGenericFinalize(cx, obj);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Screen enumerate
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
EnumerateScreen(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
return nsJSUtils::nsGenericEnumerate(cx, obj);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Screen resolve
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
ResolveScreen(JSContext *cx, JSObject *obj, jsval id)
|
||||
{
|
||||
return nsJSUtils::nsGenericResolve(cx, obj, id);
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************/
|
||||
//
|
||||
// class for Screen
|
||||
//
|
||||
JSClass ScreenClass = {
|
||||
"Screen",
|
||||
JSCLASS_HAS_PRIVATE,
|
||||
JS_PropertyStub,
|
||||
JS_PropertyStub,
|
||||
GetScreenProperty,
|
||||
SetScreenProperty,
|
||||
EnumerateScreen,
|
||||
ResolveScreen,
|
||||
JS_ConvertStub,
|
||||
FinalizeScreen
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// Screen class properties
|
||||
//
|
||||
static JSPropertySpec ScreenProperties[] =
|
||||
{
|
||||
{"width", SCREEN_WIDTH, JSPROP_ENUMERATE | JSPROP_READONLY},
|
||||
{"height", SCREEN_HEIGHT, JSPROP_ENUMERATE | JSPROP_READONLY},
|
||||
{"pixelDepth", SCREEN_PIXELDEPTH, JSPROP_ENUMERATE | JSPROP_READONLY},
|
||||
{"colorDepth", SCREEN_COLORDEPTH, JSPROP_ENUMERATE | JSPROP_READONLY},
|
||||
{"availWidth", SCREEN_AVAILWIDTH, JSPROP_ENUMERATE | JSPROP_READONLY},
|
||||
{"availHeight", SCREEN_AVAILHEIGHT, JSPROP_ENUMERATE | JSPROP_READONLY},
|
||||
{"availLeft", SCREEN_AVAILLEFT, JSPROP_ENUMERATE | JSPROP_READONLY},
|
||||
{"availTop", SCREEN_AVAILTOP, JSPROP_ENUMERATE | JSPROP_READONLY},
|
||||
{0}
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// Screen class methods
|
||||
//
|
||||
static JSFunctionSpec ScreenMethods[] =
|
||||
{
|
||||
{0}
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// Screen constructor
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
Screen(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Screen class initialization
|
||||
//
|
||||
nsresult NS_InitScreenClass(nsIScriptContext *aContext, void **aPrototype)
|
||||
{
|
||||
JSContext *jscontext = (JSContext *)aContext->GetNativeContext();
|
||||
JSObject *proto = nsnull;
|
||||
JSObject *constructor = nsnull;
|
||||
JSObject *parent_proto = nsnull;
|
||||
JSObject *global = JS_GetGlobalObject(jscontext);
|
||||
jsval vp;
|
||||
|
||||
if ((PR_TRUE != JS_LookupProperty(jscontext, global, "Screen", &vp)) ||
|
||||
!JSVAL_IS_OBJECT(vp) ||
|
||||
((constructor = JSVAL_TO_OBJECT(vp)) == nsnull) ||
|
||||
(PR_TRUE != JS_LookupProperty(jscontext, JSVAL_TO_OBJECT(vp), "prototype", &vp)) ||
|
||||
!JSVAL_IS_OBJECT(vp)) {
|
||||
|
||||
proto = JS_InitClass(jscontext, // context
|
||||
global, // global object
|
||||
parent_proto, // parent proto
|
||||
&ScreenClass, // JSClass
|
||||
Screen, // JSNative ctor
|
||||
0, // ctor args
|
||||
ScreenProperties, // proto props
|
||||
ScreenMethods, // proto funcs
|
||||
nsnull, // ctor props (static)
|
||||
nsnull); // ctor funcs (static)
|
||||
if (nsnull == proto) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
}
|
||||
else if ((nsnull != constructor) && JSVAL_IS_OBJECT(vp)) {
|
||||
proto = JSVAL_TO_OBJECT(vp);
|
||||
}
|
||||
else {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (aPrototype) {
|
||||
*aPrototype = proto;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Method for creating a new Screen JavaScript object
|
||||
//
|
||||
extern "C" NS_DOM nsresult NS_NewScriptScreen(nsIScriptContext *aContext, nsISupports *aSupports, nsISupports *aParent, void **aReturn)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aContext && nsnull != aSupports && nsnull != aReturn, "null argument to NS_NewScriptScreen");
|
||||
JSObject *proto;
|
||||
JSObject *parent;
|
||||
nsIScriptObjectOwner *owner;
|
||||
JSContext *jscontext = (JSContext *)aContext->GetNativeContext();
|
||||
nsresult result = NS_OK;
|
||||
nsIDOMScreen *aScreen;
|
||||
|
||||
if (nsnull == aParent) {
|
||||
parent = nsnull;
|
||||
}
|
||||
else if (NS_OK == aParent->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) {
|
||||
if (NS_OK != owner->GetScriptObject(aContext, (void **)&parent)) {
|
||||
NS_RELEASE(owner);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
NS_RELEASE(owner);
|
||||
}
|
||||
else {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (NS_OK != NS_InitScreenClass(aContext, (void **)&proto)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
result = aSupports->QueryInterface(kIScreenIID, (void **)&aScreen);
|
||||
if (NS_OK != result) {
|
||||
return result;
|
||||
}
|
||||
|
||||
// create a js object for this class
|
||||
*aReturn = JS_NewObject(jscontext, &ScreenClass, proto, parent);
|
||||
if (nsnull != *aReturn) {
|
||||
// connect the native object to the js object
|
||||
JS_SetPrivate(jscontext, (JSObject *)*aReturn, aScreen);
|
||||
}
|
||||
else {
|
||||
NS_RELEASE(aScreen);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
|
@ -0,0 +1,156 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsScreen.h"
|
||||
#include "nsIDOMWindow.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
|
||||
static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID);
|
||||
static NS_DEFINE_IID(kIDOMScreenIID, NS_IDOMSCREEN_IID);
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
|
||||
//
|
||||
// Screen class implementation
|
||||
//
|
||||
ScreenImpl::ScreenImpl()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mScriptObject = nsnull;
|
||||
}
|
||||
|
||||
ScreenImpl::~ScreenImpl()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(ScreenImpl)
|
||||
NS_IMPL_RELEASE(ScreenImpl)
|
||||
|
||||
nsresult
|
||||
ScreenImpl::QueryInterface(const nsIID& aIID,
|
||||
void** aInstancePtrResult)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aInstancePtrResult, "null pointer");
|
||||
if (nsnull == aInstancePtrResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
if (aIID.Equals(kIScriptObjectOwnerIID)) {
|
||||
*aInstancePtrResult = (void*) ((nsIScriptObjectOwner*)this);
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kIDOMScreenIID)) {
|
||||
*aInstancePtrResult = (void*) ((nsIDOMScreen*)this);
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kISupportsIID)) {
|
||||
*aInstancePtrResult = (void*)(nsISupports*)(nsIScriptObjectOwner*)this;
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ScreenImpl::SetScriptObject(void *aScriptObject)
|
||||
{
|
||||
mScriptObject = aScriptObject;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ScreenImpl::GetScriptObject(nsIScriptContext *aContext, void** aScriptObject)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aScriptObject, "null arg");
|
||||
nsresult res = NS_OK;
|
||||
if (nsnull == mScriptObject) {
|
||||
nsIScriptGlobalObject *global = aContext->GetGlobalObject();
|
||||
res = NS_NewScriptScreen(aContext, (nsIDOMScreen*)this, (nsIDOMWindow*)global, &mScriptObject);
|
||||
NS_IF_RELEASE(global);
|
||||
}
|
||||
|
||||
*aScriptObject = mScriptObject;
|
||||
return res;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ScreenImpl::GetWidth(PRInt32* aWidth)
|
||||
{
|
||||
//XXX not implmented
|
||||
*aWidth = -1;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ScreenImpl::GetHeight(PRInt32* aHeight)
|
||||
{
|
||||
//XXX not implmented
|
||||
*aHeight = -1;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ScreenImpl::GetPixelDepth(PRInt32* aPixelDepth)
|
||||
{
|
||||
//XXX not implmented
|
||||
*aPixelDepth = -1;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ScreenImpl::GetColorDepth(PRInt32* aColorDepth)
|
||||
{
|
||||
//XXX not implmented
|
||||
*aColorDepth = -1;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ScreenImpl::GetAvailWidth(PRInt32* aAvailWidth)
|
||||
{
|
||||
//XXX not implmented
|
||||
*aAvailWidth = -1;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ScreenImpl::GetAvailHeight(PRInt32* aAvailHeight)
|
||||
{
|
||||
//XXX not implmented
|
||||
*aAvailHeight = -1;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ScreenImpl::GetAvailLeft(PRInt32* aAvailLeft)
|
||||
{
|
||||
//XXX not implmented
|
||||
*aAvailLeft = -1;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ScreenImpl::GetAvailTop(PRInt32* aAvailTop)
|
||||
{
|
||||
//XXX not implmented
|
||||
*aAvailTop = -1;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
#ifndef nsScreen_h___
|
||||
#define nsScreen_h___
|
||||
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
#include "nsIDOMScreen.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nscore.h"
|
||||
#include "nsIScriptContext.h"
|
||||
|
||||
// Script "screen" object
|
||||
class ScreenImpl : public nsIScriptObjectOwner, public nsIDOMScreen {
|
||||
public:
|
||||
ScreenImpl();
|
||||
~ScreenImpl();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD GetScriptObject(nsIScriptContext *aContext, void** aScriptObject);
|
||||
NS_IMETHOD SetScriptObject(void *aScriptObject);
|
||||
|
||||
NS_IMETHOD GetWidth(PRInt32* aWidth);
|
||||
NS_IMETHOD GetHeight(PRInt32* aHeight);
|
||||
NS_IMETHOD GetPixelDepth(PRInt32* aPixelDepth);
|
||||
NS_IMETHOD GetColorDepth(PRInt32* aColorDepth);
|
||||
NS_IMETHOD GetAvailWidth(PRInt32* aAvailWidth);
|
||||
NS_IMETHOD GetAvailHeight(PRInt32* aAvailHeight);
|
||||
NS_IMETHOD GetAvailLeft(PRInt32* aAvailLeft);
|
||||
NS_IMETHOD GetAvailTop(PRInt32* aAvailTop);
|
||||
|
||||
protected:
|
||||
void *mScriptObject;
|
||||
};
|
||||
|
||||
#endif /* nsScreen_h___ */
|
Загрузка…
Ссылка в новой задаче