Hooking up document.getOverrideStyle() in the DOM JS glue code, no implementation yet.

This commit is contained in:
jst%netscape.com 2000-05-06 18:05:10 +00:00
parent c53454967d
commit 36cc288ddd
4 changed files with 72 additions and 1 deletions

View File

@ -42,7 +42,7 @@ interface Document : Node {
};
interface DocumentStyle {
/* IID: { 0x3d9f4973, 0xdd2e, 0x48f5, \
/* IID: { 0x3d9f4973, 0xdd2e, 0x48f5, \
{ 0xb5, 0xf7, 0x26, 0x34, 0xe0, 0x9e, 0xad, 0xd9 } } */
readonly attribute StyleSheetList styleSheets;
@ -55,6 +55,15 @@ interface DocumentView {
readonly attribute AbstractView defaultView;
};
// Introduced in DOM Level 2:
interface DocumentCSS : DocumentStyle {
/* IID: { 0x39f76c23, 0x45b2, 0x428a, \
{ 0x92, 0x40, 0xa9, 0x81, 0xe5, 0xab, 0xf1, 0x48 } } */
CSSStyleDeclaration getOverrideStyle(in Element elt,
in DOMString pseudoElt);
};
interface NSDocument {
/* IID: { 0xa6cf90cd, 0x15b3, 0x11d2, \
{ 0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32} } */

View File

@ -226,6 +226,7 @@ enum nsDOMProp {
NS_DOM_PROP_DOCUMENT_GETELEMENTSBYTAGNAMENS,
NS_DOM_PROP_DOCUMENT_IMPLEMENTATION,
NS_DOM_PROP_DOCUMENT_IMPORTNODE,
NS_DOM_PROP_DOCUMENTCSS_GETOVERRIDESTYLE,
NS_DOM_PROP_DOCUMENTSTYLE_STYLESHEETS,
NS_DOM_PROP_DOCUMENTTYPE_ENTITIES,
NS_DOM_PROP_DOCUMENTTYPE_INTERNALSUBSET,

View File

@ -225,6 +225,7 @@
"document.getelementsbytagnamens", \
"document.implementation", \
"document.importnode", \
"documentcss.getoverridestyle", \
"documentstyle.stylesheets", \
"documenttype.entities", \
"documenttype.internalsubset", \

View File

@ -34,8 +34,10 @@
#include "nsCOMPtr.h"
#include "nsDOMPropEnums.h"
#include "nsString.h"
#include "nsIDOMDocumentCSS.h"
#include "nsIDOMElement.h"
#include "nsIDOMDocumentView.h"
#include "nsIDOMCSSStyleDeclaration.h"
#include "nsIDOMAttr.h"
#include "nsIDOMDocument.h"
#include "nsIDOMProcessingInstruction.h"
@ -58,8 +60,10 @@
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(kIDocumentCSSIID, NS_IDOMDOCUMENTCSS_IID);
static NS_DEFINE_IID(kIElementIID, NS_IDOMELEMENT_IID);
static NS_DEFINE_IID(kIDocumentViewIID, NS_IDOMDOCUMENTVIEW_IID);
static NS_DEFINE_IID(kICSSStyleDeclarationIID, NS_IDOMCSSSTYLEDECLARATION_IID);
static NS_DEFINE_IID(kIAttrIID, NS_IDOMATTR_IID);
static NS_DEFINE_IID(kIDocumentIID, NS_IDOMDOCUMENT_IID);
static NS_DEFINE_IID(kIProcessingInstructionIID, NS_IDOMPROCESSINGINSTRUCTION_IID);
@ -926,6 +930,61 @@ DocumentGetElementById(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, js
}
//
// Native method GetOverrideStyle
//
PR_STATIC_CALLBACK(JSBool)
DocumentCSSGetOverrideStyle(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMDocument *privateThis = (nsIDOMDocument*)nsJSUtils::nsGetNativeThis(cx, obj);
nsCOMPtr<nsIDOMDocumentCSS> nativeThis;
nsresult result = NS_OK;
if (NS_OK != privateThis->QueryInterface(kIDocumentCSSIID, getter_AddRefs(nativeThis))) {
return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_WRONG_TYPE_ERR);
}
nsIDOMCSSStyleDeclaration* nativeRet;
nsCOMPtr<nsIDOMElement> b0;
nsAutoString b1;
// If there's no private data, this must be the prototype, so ignore
if (!nativeThis) {
return JS_TRUE;
}
{
*rval = JSVAL_NULL;
nsIScriptSecurityManager *secMan = nsJSUtils::nsGetSecurityManager(cx, obj);
if (!secMan)
return PR_FALSE;
result = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_DOCUMENTCSS_GETOVERRIDESTYLE, PR_FALSE);
if (NS_FAILED(result)) {
return nsJSUtils::nsReportError(cx, obj, result);
}
if (argc < 2) {
return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_TOO_FEW_PARAMETERS_ERR);
}
if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)(void**)getter_AddRefs(b0),
kIElementIID,
NS_ConvertASCIItoUCS2("Element"),
cx,
argv[0])) {
return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_NOT_OBJECT_ERR);
}
nsJSUtils::nsConvertJSValToString(b1, cx, argv[1]);
result = nativeThis->GetOverrideStyle(b0, b1, &nativeRet);
if (NS_FAILED(result)) {
return nsJSUtils::nsReportError(cx, obj, result);
}
nsJSUtils::nsConvertObjectToJSVal(nativeRet, cx, obj, rval);
}
return JS_TRUE;
}
//
// Native method CreateElementWithNameSpace
//
@ -1120,6 +1179,7 @@ static JSFunctionSpec DocumentMethods[] =
{"createAttributeNS", DocumentCreateAttributeNS, 2},
{"getElementsByTagNameNS", DocumentGetElementsByTagNameNS, 2},
{"getElementById", DocumentGetElementById, 1},
{"getOverrideStyle", DocumentCSSGetOverrideStyle, 2},
{"createElementWithNameSpace", NSDocumentCreateElementWithNameSpace, 2},
{"createRange", NSDocumentCreateRange, 0},
{"load", NSDocumentLoad, 2},