зеркало из https://github.com/mozilla/pjs.git
Fixed HTMLDocument and HTMLCollection interfaces
This commit is contained in:
Родитель
b60713860e
Коммит
d62e0991a5
|
@ -34,10 +34,9 @@ class nsIDOMHTMLCollection;
|
||||||
class nsIDOMHTMLCollection : public nsISupports {
|
class nsIDOMHTMLCollection : public nsISupports {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
NS_IMETHOD GetLength(PRInt32* aLength)=0;
|
NS_IMETHOD GetLength(PRUint32* aLength)=0;
|
||||||
NS_IMETHOD SetLength(PRInt32 aLength)=0;
|
|
||||||
|
|
||||||
NS_IMETHOD Item(PRInt32 aIndex, nsIDOMNode** aReturn)=0;
|
NS_IMETHOD Item(PRUint32 aIndex, nsIDOMNode** aReturn)=0;
|
||||||
|
|
||||||
NS_IMETHOD NamedItem(const nsString& aName, nsIDOMNode** aReturn)=0;
|
NS_IMETHOD NamedItem(const nsString& aName, nsIDOMNode** aReturn)=0;
|
||||||
};
|
};
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#include "nsString.h"
|
#include "nsString.h"
|
||||||
#include "nsIScriptContext.h"
|
#include "nsIScriptContext.h"
|
||||||
#include "nsIDOMDocument.h"
|
#include "nsIDOMDocument.h"
|
||||||
|
#include "jsapi.h"
|
||||||
|
|
||||||
class nsIDOMElement;
|
class nsIDOMElement;
|
||||||
class nsIDOMHTMLElement;
|
class nsIDOMHTMLElement;
|
||||||
|
@ -42,54 +43,42 @@ public:
|
||||||
NS_IMETHOD SetTitle(const nsString& aTitle)=0;
|
NS_IMETHOD SetTitle(const nsString& aTitle)=0;
|
||||||
|
|
||||||
NS_IMETHOD GetReferrer(nsString& aReferrer)=0;
|
NS_IMETHOD GetReferrer(nsString& aReferrer)=0;
|
||||||
NS_IMETHOD SetReferrer(const nsString& aReferrer)=0;
|
|
||||||
|
|
||||||
NS_IMETHOD GetFileSize(nsString& aFileSize)=0;
|
NS_IMETHOD GetFileSize(nsString& aFileSize)=0;
|
||||||
NS_IMETHOD SetFileSize(const nsString& aFileSize)=0;
|
|
||||||
|
|
||||||
NS_IMETHOD GetFileCreatedDate(nsString& aFileCreatedDate)=0;
|
NS_IMETHOD GetFileCreatedDate(nsString& aFileCreatedDate)=0;
|
||||||
NS_IMETHOD SetFileCreatedDate(const nsString& aFileCreatedDate)=0;
|
|
||||||
|
|
||||||
NS_IMETHOD GetFileModifiedDate(nsString& aFileModifiedDate)=0;
|
NS_IMETHOD GetFileModifiedDate(nsString& aFileModifiedDate)=0;
|
||||||
NS_IMETHOD SetFileModifiedDate(const nsString& aFileModifiedDate)=0;
|
|
||||||
|
|
||||||
NS_IMETHOD GetFileUpdatedDate(nsString& aFileUpdatedDate)=0;
|
NS_IMETHOD GetFileUpdatedDate(nsString& aFileUpdatedDate)=0;
|
||||||
NS_IMETHOD SetFileUpdatedDate(const nsString& aFileUpdatedDate)=0;
|
|
||||||
|
|
||||||
NS_IMETHOD GetDomain(nsString& aDomain)=0;
|
NS_IMETHOD GetDomain(nsString& aDomain)=0;
|
||||||
NS_IMETHOD SetDomain(const nsString& aDomain)=0;
|
|
||||||
|
|
||||||
NS_IMETHOD GetURL(nsString& aURL)=0;
|
NS_IMETHOD GetURL(nsString& aURL)=0;
|
||||||
NS_IMETHOD SetURL(const nsString& aURL)=0;
|
|
||||||
|
|
||||||
NS_IMETHOD GetBody(nsIDOMHTMLElement** aBody)=0;
|
NS_IMETHOD GetBody(nsIDOMHTMLElement** aBody)=0;
|
||||||
NS_IMETHOD SetBody(nsIDOMHTMLElement* aBody)=0;
|
NS_IMETHOD SetBody(nsIDOMHTMLElement* aBody)=0;
|
||||||
|
|
||||||
NS_IMETHOD GetImages(nsIDOMHTMLCollection** aImages)=0;
|
NS_IMETHOD GetImages(nsIDOMHTMLCollection** aImages)=0;
|
||||||
NS_IMETHOD SetImages(nsIDOMHTMLCollection* aImages)=0;
|
|
||||||
|
|
||||||
NS_IMETHOD GetApplets(nsIDOMHTMLCollection** aApplets)=0;
|
NS_IMETHOD GetApplets(nsIDOMHTMLCollection** aApplets)=0;
|
||||||
NS_IMETHOD SetApplets(nsIDOMHTMLCollection* aApplets)=0;
|
|
||||||
|
|
||||||
NS_IMETHOD GetLinks(nsIDOMHTMLCollection** aLinks)=0;
|
NS_IMETHOD GetLinks(nsIDOMHTMLCollection** aLinks)=0;
|
||||||
NS_IMETHOD SetLinks(nsIDOMHTMLCollection* aLinks)=0;
|
|
||||||
|
|
||||||
NS_IMETHOD GetForms(nsIDOMHTMLCollection** aForms)=0;
|
NS_IMETHOD GetForms(nsIDOMHTMLCollection** aForms)=0;
|
||||||
NS_IMETHOD SetForms(nsIDOMHTMLCollection* aForms)=0;
|
|
||||||
|
|
||||||
NS_IMETHOD GetAnchors(nsIDOMHTMLCollection** aAnchors)=0;
|
NS_IMETHOD GetAnchors(nsIDOMHTMLCollection** aAnchors)=0;
|
||||||
NS_IMETHOD SetAnchors(nsIDOMHTMLCollection* aAnchors)=0;
|
|
||||||
|
|
||||||
NS_IMETHOD GetCookie(nsString& aCookie)=0;
|
NS_IMETHOD GetCookie(nsString& aCookie)=0;
|
||||||
NS_IMETHOD SetCookie(const nsString& aCookie)=0;
|
NS_IMETHOD SetCookie(const nsString& aCookie)=0;
|
||||||
|
|
||||||
NS_IMETHOD Open()=0;
|
NS_IMETHOD Open(JSContext *cx, jsval *argv, PRUint32 argc)=0;
|
||||||
|
|
||||||
NS_IMETHOD Close()=0;
|
NS_IMETHOD Close()=0;
|
||||||
|
|
||||||
NS_IMETHOD Write(const nsString& aText)=0;
|
NS_IMETHOD Write(JSContext *cx, jsval *argv, PRUint32 argc)=0;
|
||||||
|
|
||||||
NS_IMETHOD Writeln(const nsString& aText)=0;
|
NS_IMETHOD Writeln(JSContext *cx, jsval *argv, PRUint32 argc)=0;
|
||||||
|
|
||||||
NS_IMETHOD GetElementById(const nsString& aElementId, nsIDOMElement** aReturn)=0;
|
NS_IMETHOD GetElementById(const nsString& aElementId, nsIDOMElement** aReturn)=0;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
interface HTMLCollection {
|
interface HTMLCollection {
|
||||||
attribute long length;
|
readonly attribute unsigned long length;
|
||||||
Node item(in long index);
|
Node item(in unsigned long index);
|
||||||
Node namedItem(in wstring name);
|
Node namedItem(in wstring name);
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,23 +1,23 @@
|
||||||
interface HTMLDocument : Document {
|
interface HTMLDocument : Document {
|
||||||
attribute wstring title;
|
attribute wstring title;
|
||||||
attribute wstring referrer;
|
readonly attribute wstring referrer;
|
||||||
attribute wstring fileSize;
|
readonly attribute wstring fileSize;
|
||||||
attribute wstring fileCreatedDate;
|
readonly attribute wstring fileCreatedDate;
|
||||||
attribute wstring fileModifiedDate;
|
readonly attribute wstring fileModifiedDate;
|
||||||
attribute wstring fileUpdatedDate;
|
readonly attribute wstring fileUpdatedDate;
|
||||||
attribute wstring domain;
|
readonly attribute wstring domain;
|
||||||
attribute wstring URL;
|
readonly attribute wstring URL;
|
||||||
attribute HTMLElement body;
|
attribute HTMLElement body;
|
||||||
attribute HTMLCollection images;
|
readonly attribute HTMLCollection images;
|
||||||
attribute HTMLCollection applets;
|
readonly attribute HTMLCollection applets;
|
||||||
attribute HTMLCollection links;
|
readonly attribute HTMLCollection links;
|
||||||
attribute HTMLCollection forms;
|
readonly attribute HTMLCollection forms;
|
||||||
attribute HTMLCollection anchors;
|
readonly attribute HTMLCollection anchors;
|
||||||
attribute wstring cookie;
|
attribute wstring cookie;
|
||||||
void open();
|
void open(/* ... */);
|
||||||
void close();
|
void close();
|
||||||
void write(in wstring text);
|
void write(/* ... */);
|
||||||
void writeln(in wstring text);
|
void writeln(/* ... */);
|
||||||
Element getElementById(in wstring elementId);
|
Element getElementById(in wstring elementId);
|
||||||
NodeList getElementsByName(in wstring elementName);
|
NodeList getElementsByName(in wstring elementName);
|
||||||
};
|
};
|
||||||
|
|
|
@ -264,6 +264,7 @@ GlobalWindowImpl::SetNewDocument(nsIDOMDocument *aDocument)
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_RELEASE(mDocument);
|
NS_RELEASE(mDocument);
|
||||||
|
JS_GC((JSContext *)mContext->GetNativeContext());
|
||||||
}
|
}
|
||||||
|
|
||||||
mDocument = aDocument;
|
mDocument = aDocument;
|
||||||
|
@ -275,8 +276,6 @@ GlobalWindowImpl::SetNewDocument(nsIDOMDocument *aDocument)
|
||||||
mContext->InitContext(this);
|
mContext->InitContext(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JS_GC((JSContext *)mContext->GetNativeContext());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
|
|
|
@ -18,6 +18,8 @@
|
||||||
#include "nsJSEnvironment.h"
|
#include "nsJSEnvironment.h"
|
||||||
#include "nsIScriptGlobalObject.h"
|
#include "nsIScriptGlobalObject.h"
|
||||||
#include "nsIDOMNavigator.h"
|
#include "nsIDOMNavigator.h"
|
||||||
|
#include "nsIDOMHTMLDocument.h"
|
||||||
|
#include "nsIDOMHTMLCollection.h"
|
||||||
#include "nsIScriptEventListener.h"
|
#include "nsIScriptEventListener.h"
|
||||||
|
|
||||||
// Force references to all of the symbols that we want exported from
|
// Force references to all of the symbols that we want exported from
|
||||||
|
@ -28,5 +30,7 @@ void XXXDomNeverCalled()
|
||||||
nsJSContext* jcx = new nsJSContext(0);
|
nsJSContext* jcx = new nsJSContext(0);
|
||||||
NS_NewScriptGlobalObject(0);
|
NS_NewScriptGlobalObject(0);
|
||||||
NS_NewScriptNavigator(0, 0, 0, 0);
|
NS_NewScriptNavigator(0, 0, 0, 0);
|
||||||
|
NS_NewScriptHTMLDocument(0, 0, 0, 0);
|
||||||
|
NS_NewScriptHTMLCollection(0, 0, 0, 0);
|
||||||
NS_NewScriptEventListener(0, 0, 0);
|
NS_NewScriptEventListener(0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,7 +63,7 @@ GetHTMLCollectionProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||||
switch(JSVAL_TO_INT(id)) {
|
switch(JSVAL_TO_INT(id)) {
|
||||||
case HTMLCOLLECTION_LENGTH:
|
case HTMLCOLLECTION_LENGTH:
|
||||||
{
|
{
|
||||||
PRInt32 prop;
|
PRUint32 prop;
|
||||||
if (NS_OK == a->GetLength(&prop)) {
|
if (NS_OK == a->GetLength(&prop)) {
|
||||||
*vp = INT_TO_JSVAL(prop);
|
*vp = INT_TO_JSVAL(prop);
|
||||||
}
|
}
|
||||||
|
@ -129,22 +129,7 @@ SetHTMLCollectionProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||||
|
|
||||||
if (JSVAL_IS_INT(id)) {
|
if (JSVAL_IS_INT(id)) {
|
||||||
switch(JSVAL_TO_INT(id)) {
|
switch(JSVAL_TO_INT(id)) {
|
||||||
case HTMLCOLLECTION_LENGTH:
|
case 0:
|
||||||
{
|
|
||||||
PRInt32 prop;
|
|
||||||
int32 temp;
|
|
||||||
if (JSVAL_IS_NUMBER(*vp) && JS_ValueToInt32(cx, *vp, &temp)) {
|
|
||||||
prop = (PRInt32)temp;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
JS_ReportError(cx, "Parameter must be a number");
|
|
||||||
return JS_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
a->SetLength(prop);
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
nsIJSScriptObject *object;
|
nsIJSScriptObject *object;
|
||||||
|
@ -241,7 +226,7 @@ HTMLCollectionItem(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval
|
||||||
nsIDOMHTMLCollection *nativeThis = (nsIDOMHTMLCollection*)JS_GetPrivate(cx, obj);
|
nsIDOMHTMLCollection *nativeThis = (nsIDOMHTMLCollection*)JS_GetPrivate(cx, obj);
|
||||||
JSBool rBool = JS_FALSE;
|
JSBool rBool = JS_FALSE;
|
||||||
nsIDOMNode* nativeRet;
|
nsIDOMNode* nativeRet;
|
||||||
PRInt32 b0;
|
PRUint32 b0;
|
||||||
|
|
||||||
*rval = JSVAL_NULL;
|
*rval = JSVAL_NULL;
|
||||||
|
|
||||||
|
@ -368,7 +353,7 @@ JSClass HTMLCollectionClass = {
|
||||||
//
|
//
|
||||||
static JSPropertySpec HTMLCollectionProperties[] =
|
static JSPropertySpec HTMLCollectionProperties[] =
|
||||||
{
|
{
|
||||||
{"length", HTMLCOLLECTION_LENGTH, JSPROP_ENUMERATE},
|
{"length", HTMLCOLLECTION_LENGTH, JSPROP_ENUMERATE | JSPROP_READONLY},
|
||||||
{0}
|
{0}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -419,111 +419,6 @@ SetHTMLDocumentProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case HTMLDOCUMENT_REFERRER:
|
|
||||||
{
|
|
||||||
nsAutoString prop;
|
|
||||||
JSString *jsstring;
|
|
||||||
if ((jsstring = JS_ValueToString(cx, *vp)) != nsnull) {
|
|
||||||
prop.SetString(JS_GetStringChars(jsstring));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
prop.SetString((const char *)nsnull);
|
|
||||||
}
|
|
||||||
|
|
||||||
a->SetReferrer(prop);
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case HTMLDOCUMENT_FILESIZE:
|
|
||||||
{
|
|
||||||
nsAutoString prop;
|
|
||||||
JSString *jsstring;
|
|
||||||
if ((jsstring = JS_ValueToString(cx, *vp)) != nsnull) {
|
|
||||||
prop.SetString(JS_GetStringChars(jsstring));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
prop.SetString((const char *)nsnull);
|
|
||||||
}
|
|
||||||
|
|
||||||
a->SetFileSize(prop);
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case HTMLDOCUMENT_FILECREATEDDATE:
|
|
||||||
{
|
|
||||||
nsAutoString prop;
|
|
||||||
JSString *jsstring;
|
|
||||||
if ((jsstring = JS_ValueToString(cx, *vp)) != nsnull) {
|
|
||||||
prop.SetString(JS_GetStringChars(jsstring));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
prop.SetString((const char *)nsnull);
|
|
||||||
}
|
|
||||||
|
|
||||||
a->SetFileCreatedDate(prop);
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case HTMLDOCUMENT_FILEMODIFIEDDATE:
|
|
||||||
{
|
|
||||||
nsAutoString prop;
|
|
||||||
JSString *jsstring;
|
|
||||||
if ((jsstring = JS_ValueToString(cx, *vp)) != nsnull) {
|
|
||||||
prop.SetString(JS_GetStringChars(jsstring));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
prop.SetString((const char *)nsnull);
|
|
||||||
}
|
|
||||||
|
|
||||||
a->SetFileModifiedDate(prop);
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case HTMLDOCUMENT_FILEUPDATEDDATE:
|
|
||||||
{
|
|
||||||
nsAutoString prop;
|
|
||||||
JSString *jsstring;
|
|
||||||
if ((jsstring = JS_ValueToString(cx, *vp)) != nsnull) {
|
|
||||||
prop.SetString(JS_GetStringChars(jsstring));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
prop.SetString((const char *)nsnull);
|
|
||||||
}
|
|
||||||
|
|
||||||
a->SetFileUpdatedDate(prop);
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case HTMLDOCUMENT_DOMAIN:
|
|
||||||
{
|
|
||||||
nsAutoString prop;
|
|
||||||
JSString *jsstring;
|
|
||||||
if ((jsstring = JS_ValueToString(cx, *vp)) != nsnull) {
|
|
||||||
prop.SetString(JS_GetStringChars(jsstring));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
prop.SetString((const char *)nsnull);
|
|
||||||
}
|
|
||||||
|
|
||||||
a->SetDomain(prop);
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case HTMLDOCUMENT_URL:
|
|
||||||
{
|
|
||||||
nsAutoString prop;
|
|
||||||
JSString *jsstring;
|
|
||||||
if ((jsstring = JS_ValueToString(cx, *vp)) != nsnull) {
|
|
||||||
prop.SetString(JS_GetStringChars(jsstring));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
prop.SetString((const char *)nsnull);
|
|
||||||
}
|
|
||||||
|
|
||||||
a->SetURL(prop);
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case HTMLDOCUMENT_BODY:
|
case HTMLDOCUMENT_BODY:
|
||||||
{
|
{
|
||||||
nsIDOMHTMLElement* prop;
|
nsIDOMHTMLElement* prop;
|
||||||
|
@ -547,121 +442,6 @@ SetHTMLDocumentProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||||
if (prop) NS_RELEASE(prop);
|
if (prop) NS_RELEASE(prop);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case HTMLDOCUMENT_IMAGES:
|
|
||||||
{
|
|
||||||
nsIDOMHTMLCollection* prop;
|
|
||||||
if (JSVAL_IS_NULL(*vp)) {
|
|
||||||
prop = nsnull;
|
|
||||||
}
|
|
||||||
else if (JSVAL_IS_OBJECT(*vp)) {
|
|
||||||
JSObject *jsobj = JSVAL_TO_OBJECT(*vp);
|
|
||||||
nsISupports *supports = (nsISupports *)JS_GetPrivate(cx, jsobj);
|
|
||||||
if (NS_OK != supports->QueryInterface(kIHTMLCollectionIID, (void **)&prop)) {
|
|
||||||
JS_ReportError(cx, "Parameter must be of type HTMLCollection");
|
|
||||||
return JS_FALSE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
JS_ReportError(cx, "Parameter must be an object");
|
|
||||||
return JS_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
a->SetImages(prop);
|
|
||||||
if (prop) NS_RELEASE(prop);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case HTMLDOCUMENT_APPLETS:
|
|
||||||
{
|
|
||||||
nsIDOMHTMLCollection* prop;
|
|
||||||
if (JSVAL_IS_NULL(*vp)) {
|
|
||||||
prop = nsnull;
|
|
||||||
}
|
|
||||||
else if (JSVAL_IS_OBJECT(*vp)) {
|
|
||||||
JSObject *jsobj = JSVAL_TO_OBJECT(*vp);
|
|
||||||
nsISupports *supports = (nsISupports *)JS_GetPrivate(cx, jsobj);
|
|
||||||
if (NS_OK != supports->QueryInterface(kIHTMLCollectionIID, (void **)&prop)) {
|
|
||||||
JS_ReportError(cx, "Parameter must be of type HTMLCollection");
|
|
||||||
return JS_FALSE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
JS_ReportError(cx, "Parameter must be an object");
|
|
||||||
return JS_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
a->SetApplets(prop);
|
|
||||||
if (prop) NS_RELEASE(prop);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case HTMLDOCUMENT_LINKS:
|
|
||||||
{
|
|
||||||
nsIDOMHTMLCollection* prop;
|
|
||||||
if (JSVAL_IS_NULL(*vp)) {
|
|
||||||
prop = nsnull;
|
|
||||||
}
|
|
||||||
else if (JSVAL_IS_OBJECT(*vp)) {
|
|
||||||
JSObject *jsobj = JSVAL_TO_OBJECT(*vp);
|
|
||||||
nsISupports *supports = (nsISupports *)JS_GetPrivate(cx, jsobj);
|
|
||||||
if (NS_OK != supports->QueryInterface(kIHTMLCollectionIID, (void **)&prop)) {
|
|
||||||
JS_ReportError(cx, "Parameter must be of type HTMLCollection");
|
|
||||||
return JS_FALSE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
JS_ReportError(cx, "Parameter must be an object");
|
|
||||||
return JS_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
a->SetLinks(prop);
|
|
||||||
if (prop) NS_RELEASE(prop);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case HTMLDOCUMENT_FORMS:
|
|
||||||
{
|
|
||||||
nsIDOMHTMLCollection* prop;
|
|
||||||
if (JSVAL_IS_NULL(*vp)) {
|
|
||||||
prop = nsnull;
|
|
||||||
}
|
|
||||||
else if (JSVAL_IS_OBJECT(*vp)) {
|
|
||||||
JSObject *jsobj = JSVAL_TO_OBJECT(*vp);
|
|
||||||
nsISupports *supports = (nsISupports *)JS_GetPrivate(cx, jsobj);
|
|
||||||
if (NS_OK != supports->QueryInterface(kIHTMLCollectionIID, (void **)&prop)) {
|
|
||||||
JS_ReportError(cx, "Parameter must be of type HTMLCollection");
|
|
||||||
return JS_FALSE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
JS_ReportError(cx, "Parameter must be an object");
|
|
||||||
return JS_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
a->SetForms(prop);
|
|
||||||
if (prop) NS_RELEASE(prop);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case HTMLDOCUMENT_ANCHORS:
|
|
||||||
{
|
|
||||||
nsIDOMHTMLCollection* prop;
|
|
||||||
if (JSVAL_IS_NULL(*vp)) {
|
|
||||||
prop = nsnull;
|
|
||||||
}
|
|
||||||
else if (JSVAL_IS_OBJECT(*vp)) {
|
|
||||||
JSObject *jsobj = JSVAL_TO_OBJECT(*vp);
|
|
||||||
nsISupports *supports = (nsISupports *)JS_GetPrivate(cx, jsobj);
|
|
||||||
if (NS_OK != supports->QueryInterface(kIHTMLCollectionIID, (void **)&prop)) {
|
|
||||||
JS_ReportError(cx, "Parameter must be of type HTMLCollection");
|
|
||||||
return JS_FALSE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
JS_ReportError(cx, "Parameter must be an object");
|
|
||||||
return JS_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
a->SetAnchors(prop);
|
|
||||||
if (prop) NS_RELEASE(prop);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case HTMLDOCUMENT_COOKIE:
|
case HTMLDOCUMENT_COOKIE:
|
||||||
{
|
{
|
||||||
nsAutoString prop;
|
nsAutoString prop;
|
||||||
|
@ -782,7 +562,7 @@ HTMLDocumentOpen(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *r
|
||||||
|
|
||||||
if (argc >= 0) {
|
if (argc >= 0) {
|
||||||
|
|
||||||
if (NS_OK != nativeThis->Open()) {
|
if (NS_OK != nativeThis->Open(cx, argv+0, argc-0)) {
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -838,7 +618,6 @@ HTMLDocumentWrite(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *
|
||||||
{
|
{
|
||||||
nsIDOMHTMLDocument *nativeThis = (nsIDOMHTMLDocument*)JS_GetPrivate(cx, obj);
|
nsIDOMHTMLDocument *nativeThis = (nsIDOMHTMLDocument*)JS_GetPrivate(cx, obj);
|
||||||
JSBool rBool = JS_FALSE;
|
JSBool rBool = JS_FALSE;
|
||||||
nsAutoString b0;
|
|
||||||
|
|
||||||
*rval = JSVAL_NULL;
|
*rval = JSVAL_NULL;
|
||||||
|
|
||||||
|
@ -847,24 +626,16 @@ HTMLDocumentWrite(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *
|
||||||
return JS_TRUE;
|
return JS_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argc >= 1) {
|
if (argc >= 0) {
|
||||||
|
|
||||||
JSString *jsstring0 = JS_ValueToString(cx, argv[0]);
|
if (NS_OK != nativeThis->Write(cx, argv+0, argc-0)) {
|
||||||
if (nsnull != jsstring0) {
|
|
||||||
b0.SetString(JS_GetStringChars(jsstring0));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
b0.SetString(""); // Should this really be null??
|
|
||||||
}
|
|
||||||
|
|
||||||
if (NS_OK != nativeThis->Write(b0)) {
|
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
*rval = JSVAL_VOID;
|
*rval = JSVAL_VOID;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
JS_ReportError(cx, "Function write requires 1 parameters");
|
JS_ReportError(cx, "Function write requires 0 parameters");
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -880,7 +651,6 @@ HTMLDocumentWriteln(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval
|
||||||
{
|
{
|
||||||
nsIDOMHTMLDocument *nativeThis = (nsIDOMHTMLDocument*)JS_GetPrivate(cx, obj);
|
nsIDOMHTMLDocument *nativeThis = (nsIDOMHTMLDocument*)JS_GetPrivate(cx, obj);
|
||||||
JSBool rBool = JS_FALSE;
|
JSBool rBool = JS_FALSE;
|
||||||
nsAutoString b0;
|
|
||||||
|
|
||||||
*rval = JSVAL_NULL;
|
*rval = JSVAL_NULL;
|
||||||
|
|
||||||
|
@ -889,24 +659,16 @@ HTMLDocumentWriteln(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval
|
||||||
return JS_TRUE;
|
return JS_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argc >= 1) {
|
if (argc >= 0) {
|
||||||
|
|
||||||
JSString *jsstring0 = JS_ValueToString(cx, argv[0]);
|
if (NS_OK != nativeThis->Writeln(cx, argv+0, argc-0)) {
|
||||||
if (nsnull != jsstring0) {
|
|
||||||
b0.SetString(JS_GetStringChars(jsstring0));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
b0.SetString(""); // Should this really be null??
|
|
||||||
}
|
|
||||||
|
|
||||||
if (NS_OK != nativeThis->Writeln(b0)) {
|
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
*rval = JSVAL_VOID;
|
*rval = JSVAL_VOID;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
JS_ReportError(cx, "Function writeln requires 1 parameters");
|
JS_ReportError(cx, "Function writeln requires 0 parameters");
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1054,19 +816,19 @@ JSClass HTMLDocumentClass = {
|
||||||
static JSPropertySpec HTMLDocumentProperties[] =
|
static JSPropertySpec HTMLDocumentProperties[] =
|
||||||
{
|
{
|
||||||
{"title", HTMLDOCUMENT_TITLE, JSPROP_ENUMERATE},
|
{"title", HTMLDOCUMENT_TITLE, JSPROP_ENUMERATE},
|
||||||
{"referrer", HTMLDOCUMENT_REFERRER, JSPROP_ENUMERATE},
|
{"referrer", HTMLDOCUMENT_REFERRER, JSPROP_ENUMERATE | JSPROP_READONLY},
|
||||||
{"fileSize", HTMLDOCUMENT_FILESIZE, JSPROP_ENUMERATE},
|
{"fileSize", HTMLDOCUMENT_FILESIZE, JSPROP_ENUMERATE | JSPROP_READONLY},
|
||||||
{"fileCreatedDate", HTMLDOCUMENT_FILECREATEDDATE, JSPROP_ENUMERATE},
|
{"fileCreatedDate", HTMLDOCUMENT_FILECREATEDDATE, JSPROP_ENUMERATE | JSPROP_READONLY},
|
||||||
{"fileModifiedDate", HTMLDOCUMENT_FILEMODIFIEDDATE, JSPROP_ENUMERATE},
|
{"fileModifiedDate", HTMLDOCUMENT_FILEMODIFIEDDATE, JSPROP_ENUMERATE | JSPROP_READONLY},
|
||||||
{"fileUpdatedDate", HTMLDOCUMENT_FILEUPDATEDDATE, JSPROP_ENUMERATE},
|
{"fileUpdatedDate", HTMLDOCUMENT_FILEUPDATEDDATE, JSPROP_ENUMERATE | JSPROP_READONLY},
|
||||||
{"domain", HTMLDOCUMENT_DOMAIN, JSPROP_ENUMERATE},
|
{"domain", HTMLDOCUMENT_DOMAIN, JSPROP_ENUMERATE | JSPROP_READONLY},
|
||||||
{"URL", HTMLDOCUMENT_URL, JSPROP_ENUMERATE},
|
{"URL", HTMLDOCUMENT_URL, JSPROP_ENUMERATE | JSPROP_READONLY},
|
||||||
{"body", HTMLDOCUMENT_BODY, JSPROP_ENUMERATE},
|
{"body", HTMLDOCUMENT_BODY, JSPROP_ENUMERATE},
|
||||||
{"images", HTMLDOCUMENT_IMAGES, JSPROP_ENUMERATE},
|
{"images", HTMLDOCUMENT_IMAGES, JSPROP_ENUMERATE | JSPROP_READONLY},
|
||||||
{"applets", HTMLDOCUMENT_APPLETS, JSPROP_ENUMERATE},
|
{"applets", HTMLDOCUMENT_APPLETS, JSPROP_ENUMERATE | JSPROP_READONLY},
|
||||||
{"links", HTMLDOCUMENT_LINKS, JSPROP_ENUMERATE},
|
{"links", HTMLDOCUMENT_LINKS, JSPROP_ENUMERATE | JSPROP_READONLY},
|
||||||
{"forms", HTMLDOCUMENT_FORMS, JSPROP_ENUMERATE},
|
{"forms", HTMLDOCUMENT_FORMS, JSPROP_ENUMERATE | JSPROP_READONLY},
|
||||||
{"anchors", HTMLDOCUMENT_ANCHORS, JSPROP_ENUMERATE},
|
{"anchors", HTMLDOCUMENT_ANCHORS, JSPROP_ENUMERATE | JSPROP_READONLY},
|
||||||
{"cookie", HTMLDOCUMENT_COOKIE, JSPROP_ENUMERATE},
|
{"cookie", HTMLDOCUMENT_COOKIE, JSPROP_ENUMERATE},
|
||||||
{0}
|
{0}
|
||||||
};
|
};
|
||||||
|
@ -1079,8 +841,8 @@ static JSFunctionSpec HTMLDocumentMethods[] =
|
||||||
{
|
{
|
||||||
{"open", HTMLDocumentOpen, 0},
|
{"open", HTMLDocumentOpen, 0},
|
||||||
{"close", HTMLDocumentClose, 0},
|
{"close", HTMLDocumentClose, 0},
|
||||||
{"write", HTMLDocumentWrite, 1},
|
{"write", HTMLDocumentWrite, 0},
|
||||||
{"writeln", HTMLDocumentWriteln, 1},
|
{"writeln", HTMLDocumentWriteln, 0},
|
||||||
{"getElementById", HTMLDocumentGetElementById, 1},
|
{"getElementById", HTMLDocumentGetElementById, 1},
|
||||||
{"getElementsByName", HTMLDocumentGetElementsByName, 1},
|
{"getElementsByName", HTMLDocumentGetElementsByName, 1},
|
||||||
{0}
|
{0}
|
||||||
|
|
|
@ -0,0 +1,66 @@
|
||||||
|
<html>
|
||||||
|
<body>
|
||||||
|
<p>This test does a few things:
|
||||||
|
<ul>
|
||||||
|
<li>It has a couple of:
|
||||||
|
<ul>
|
||||||
|
<li>Images: <IMG SRC="http://zabadubop/layers/tests/mzcolor.gif"> and
|
||||||
|
<IMG SRC="http://peoplestage.netscape.com/kipp/nerdly_int.gif">.
|
||||||
|
<li>Links to <a href="http://home.netscape.com">Netscape</a> and
|
||||||
|
<A HREF="http://peoplestage.netscape.com/kipp">Kippy's Home Page</A>.
|
||||||
|
<li>and Anchors to <a NAME="anchor1">here</A> and
|
||||||
|
<A name="anchor2">here</a>.
|
||||||
|
</ul>
|
||||||
|
<li>It dumps (check the JS console) the images, links and anchors using
|
||||||
|
the document.images, document.links and document.anchors arrays.
|
||||||
|
<li>Then it removes one of the images.
|
||||||
|
<li>Dumps the images array again. This is to prove that the images array
|
||||||
|
is live.
|
||||||
|
<li>Adds back the image.
|
||||||
|
<li>And the dumps the images array again. The image arrays order should
|
||||||
|
now be different.
|
||||||
|
<li>It gets a list of LIs (using getElementsByTagName()) and prints
|
||||||
|
out all their tagNames. There should be 10.
|
||||||
|
</ul>
|
||||||
|
<script>
|
||||||
|
var x;
|
||||||
|
dump("Images:\n");
|
||||||
|
for (x=0; x < document.images.length; x++) {
|
||||||
|
dump("Image#" + x + ": " + document.images[x].getDOMAttribute("SRC") + "\n");
|
||||||
|
}
|
||||||
|
dump("\nLinks:\n");
|
||||||
|
for (x=0; x < document.links.length; x++) {
|
||||||
|
dump("Link#" + x + ": " + document.links[x].getDOMAttribute("HREF") + "\n");
|
||||||
|
}
|
||||||
|
dump("\nAnchors:\n");
|
||||||
|
for (x=0; x < document.anchors.length; x++) {
|
||||||
|
dump("Anchors#" + x + ": " + document.anchors[x].getDOMAttribute("NAME") + "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
dump("\nRemoving image\n");
|
||||||
|
var img=document.images[1];
|
||||||
|
var parent=img.parentNode;
|
||||||
|
parent.removeChild(img);
|
||||||
|
dump("Images:\n");
|
||||||
|
for (x=0; x < document.images.length; x++) {
|
||||||
|
dump("Image#" + x + ": " + document.images[x].getDOMAttribute("SRC") + "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
dump("\nInserting image back into list\n");
|
||||||
|
var sib=parent.childNodes[0];
|
||||||
|
parent.insertBefore(img, sib);
|
||||||
|
dump("Images:\n");
|
||||||
|
for (x=0; x < document.images.length; x++) {
|
||||||
|
dump("Image#" + x + ": " + document.images[x].getDOMAttribute("SRC") + "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
var lis = document.getElementsByTagName("LI");
|
||||||
|
dump("Lists:\n");
|
||||||
|
for (x=0; x < lis.length; x++) {
|
||||||
|
dump(lis[x].tagName + "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
Загрузка…
Ссылка в новой задаче