Updating the DOM interface CSSStyleDeclaration to DOM Level 2.

This commit is contained in:
jst%netscape.com 2000-04-20 13:50:56 +00:00
Родитель a906eff95b
Коммит 65686de7fb
23 изменённых файлов: 512 добавлений и 43 удалений

Просмотреть файл

@ -108,6 +108,9 @@ public:
nsDOMCSSAttributeDeclaration(nsIHTMLContent *aContent);
~nsDOMCSSAttributeDeclaration();
NS_IMETHOD RemoveProperty(const nsString& aPropertyName,
nsString& aReturn);
virtual void DropReference();
virtual nsresult GetCSSDeclaration(nsICSSDeclaration **aDecl,
PRBool aAllocate);
@ -134,6 +137,47 @@ nsDOMCSSAttributeDeclaration::~nsDOMCSSAttributeDeclaration()
MOZ_COUNT_DTOR(nsDOMCSSAttributeDeclaration);
}
NS_IMETHODIMP
nsDOMCSSAttributeDeclaration::RemoveProperty(const nsString& aPropertyName,
nsString& aReturn)
{
nsCOMPtr<nsICSSDeclaration> decl;
nsresult rv = GetCSSDeclaration(getter_AddRefs(decl), PR_TRUE);
if (NS_SUCCEEDED(rv) && decl && mContent) {
nsCOMPtr<nsIDocument> doc;
mContent->GetDocument(*getter_AddRefs(doc));
if (doc)
doc->BeginUpdate();
nsCSSProperty prop = nsCSSProps::LookupProperty(aPropertyName);
nsCSSValue val;
#if 0 // Once nsICSSDeclaration has a RemoveProperty this ifdef should be removed
rv = decl->RemoveProperty(prop, val);
#else
rv = NS_ERROR_NOT_IMPLEMENTED;
#endif
if (NS_FAILED(rv))
return rv;
val.ToString(aReturn, prop);
if (doc) {
PRInt32 hint;
decl->GetStyleImpact(&hint);
doc->AttributeChanged(mContent, kNameSpaceID_None, nsHTMLAtoms::style,
hint);
doc->EndUpdate();
}
}
return rv;
}
void
nsDOMCSSAttributeDeclaration::DropReference()
{

Просмотреть файл

@ -787,6 +787,9 @@ public:
DOMCSSDeclarationImpl(nsICSSStyleRule *aRule);
~DOMCSSDeclarationImpl(void);
NS_IMETHOD RemoveProperty(const nsString& aPropertyName,
nsString& aReturn);
virtual void DropReference(void);
virtual nsresult GetCSSDeclaration(nsICSSDeclaration **aDecl,
PRBool aAllocate);
@ -813,6 +816,34 @@ DOMCSSDeclarationImpl::~DOMCSSDeclarationImpl(void)
MOZ_COUNT_DTOR(DOMCSSDeclarationImpl);
}
NS_IMETHODIMP
DOMCSSDeclarationImpl::RemoveProperty(const nsString& aPropertyName,
nsString& aReturn)
{
aReturn.Truncate();
nsCOMPtr<nsICSSDeclaration> decl;
nsresult rv = GetCSSDeclaration(getter_AddRefs(decl), PR_TRUE);
if (NS_SUCCEEDED(rv) && decl) {
nsCSSProperty prop = nsCSSProps::LookupProperty(aPropertyName);
nsCSSValue val;
#if 0 // This is not done yet, once it is this ifdef should be removed
rv = decl->RemoveProperty(prop, val);
#else
rv = NS_ERROR_NOT_IMPLEMENTED;
#endif
if (NS_FAILED(rv))
return rv;
val.ToString(aReturn, prop);
}
return rv;
}
void
DOMCSSDeclarationImpl::DropReference(void)
{
@ -906,6 +937,9 @@ DOMCSSDeclarationImpl::GetParent(nsISupports **aParent)
{
if (nsnull != mRule) {
return mRule->QueryInterface(kISupportsIID, (void **)aParent);
} else {
NS_ENSURE_ARG_POINTER(aParent);
*aParent = nsnull;
}
return NS_OK;

Просмотреть файл

@ -21,10 +21,12 @@
*/
#include "nsDOMCSSDeclaration.h"
#include "nsIDOMCSSRule.h"
#include "nsICSSParser.h"
#include "nsIStyleRule.h"
#include "nsICSSDeclaration.h"
#include "nsCSSProps.h"
#include "nsCOMPtr.h"
#include "nsIURL.h"
nsDOMCSSDeclaration::nsDOMCSSDeclaration()
@ -88,9 +90,9 @@ nsDOMCSSDeclaration::GetScriptObject(nsIScriptContext* aContext,
nsresult res = NS_OK;
if (nsnull == mScriptObject) {
nsISupports *parent = nsnull;
nsCOMPtr<nsISupports> parent;
res = GetParent(&parent);
res = GetParent(getter_AddRefs(parent));
if (NS_OK == res) {
nsISupports *supports = (nsISupports *)(nsIDOMCSS2Properties *)this;
// XXX Should be done through factory
@ -98,7 +100,6 @@ nsDOMCSSDeclaration::GetScriptObject(nsIScriptContext* aContext,
supports,
parent,
(void**)&mScriptObject);
NS_RELEASE(parent);
}
}
*aScriptObject = mScriptObject;
@ -106,28 +107,29 @@ nsDOMCSSDeclaration::GetScriptObject(nsIScriptContext* aContext,
return res;
}
NS_IMETHODIMP
NS_IMETHODIMP
nsDOMCSSDeclaration::SetScriptObject(void* aScriptObject)
{
mScriptObject = aScriptObject;
return NS_OK;
}
NS_IMETHODIMP
NS_IMETHODIMP
nsDOMCSSDeclaration::GetCssText(nsString& aCssText)
{
aCssText.Truncate();
// XXX TBI
return NS_OK;
}
NS_IMETHODIMP
NS_IMETHODIMP
nsDOMCSSDeclaration::SetCssText(const nsString& aCssText)
{
// XXX TBI
return NS_OK;
}
NS_IMETHODIMP
NS_IMETHODIMP
nsDOMCSSDeclaration::GetLength(PRUint32* aLength)
{
nsICSSDeclaration *decl;
@ -142,7 +144,36 @@ nsDOMCSSDeclaration::GetLength(PRUint32* aLength)
return result;
}
NS_IMETHODIMP
NS_IMETHODIMP
nsDOMCSSDeclaration::GetParentRule(nsIDOMCSSRule** aParentRule)
{
nsCOMPtr<nsISupports> parent;
GetParent(getter_AddRefs(parent));
if (parent) {
parent->QueryInterface(NS_GET_IID(nsIDOMCSSRule), (void **)aParentRule);
} else {
NS_ENSURE_ARG_POINTER(aParentRule);
*aParentRule = nsnull;
}
return NS_OK;
}
NS_IMETHODIMP
nsDOMCSSDeclaration::GetPropertyCSSValue(const nsString& aPropertyName,
nsIDOMCSSValue** aReturn)
{
NS_ENSURE_ARG_POINTER(aReturn);
// We don't support CSSValue yet so we'll just return null...
*aReturn = nsnull;
return NS_OK;
}
NS_IMETHODIMP
nsDOMCSSDeclaration::Item(PRUint32 aIndex, nsString& aReturn)
{
nsICSSDeclaration *decl;

Просмотреть файл

@ -38,7 +38,22 @@ public:
NS_DECL_ISUPPORTS
NS_DECL_IDOMCSSSTYLEDECLARATION
// NS_DECL_IDOMCSSSTYLEDECLARATION
NS_IMETHOD GetCssText(nsString& aCssText);
NS_IMETHOD SetCssText(const nsString& aCssText);
NS_IMETHOD GetLength(PRUint32* aLength);
NS_IMETHOD GetParentRule(nsIDOMCSSRule** aParentRule);
NS_IMETHOD GetPropertyValue(const nsString& aPropertyName,
nsString& aReturn);
NS_IMETHOD GetPropertyCSSValue(const nsString& aPropertyName,
nsIDOMCSSValue** aReturn);
NS_IMETHOD RemoveProperty(const nsString& aPropertyName,
nsString& aReturn) = 0;
NS_IMETHOD GetPropertyPriority(const nsString& aPropertyName,
nsString& aReturn);
NS_IMETHOD SetProperty(const nsString& aPropertyName,
const nsString& aValue, const nsString& aPriority);
NS_IMETHOD Item(PRUint32 aIndex, nsString& aReturn);
NS_DECL_IDOMCSS2PROPERTIES

Просмотреть файл

@ -31,3 +31,4 @@ nsIDOMCSSStyleRule.h
nsIDOMCSSStyleRuleCollection.h
nsIDOMCSSStyleSheet.h
nsIDOMCSSUnknownRule.h
nsIDOMCSSValue.h

Просмотреть файл

@ -40,6 +40,7 @@ EXPORTS = \
nsIDOMCSSStyleRuleCollection.h \
nsIDOMCSSStyleSheet.h \
nsIDOMCSSUnknownRule.h \
nsIDOMCSSValue.h \
$(NULL)
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))

Просмотреть файл

@ -34,7 +34,8 @@ EXPORTS= \
nsIDOMCSSStyleRule.h \
nsIDOMCSSStyleRuleCollection.h \
nsIDOMCSSStyleSheet.h \
nsIDOMCSSUnknownRule.h
nsIDOMCSSUnknownRule.h \
nsIDOMCSSValue.h
MODULE=dom

Просмотреть файл

@ -28,6 +28,8 @@
#include "nsString.h"
#include "nsIScriptContext.h"
class nsIDOMCSSRule;
class nsIDOMCSSValue;
#define NS_IDOMCSSSTYLEDECLARATION_IID \
{ 0xa6cf90be, 0x15b3, 0x11d2, \
@ -42,8 +44,14 @@ public:
NS_IMETHOD GetLength(PRUint32* aLength)=0;
NS_IMETHOD GetParentRule(nsIDOMCSSRule** aParentRule)=0;
NS_IMETHOD GetPropertyValue(const nsString& aPropertyName, nsString& aReturn)=0;
NS_IMETHOD GetPropertyCSSValue(const nsString& aPropertyName, nsIDOMCSSValue** aReturn)=0;
NS_IMETHOD RemoveProperty(const nsString& aPropertyName, nsString& aReturn)=0;
NS_IMETHOD GetPropertyPriority(const nsString& aPropertyName, nsString& aReturn)=0;
NS_IMETHOD SetProperty(const nsString& aPropertyName, const nsString& aValue, const nsString& aPriority)=0;
@ -56,7 +64,10 @@ public:
NS_IMETHOD GetCssText(nsString& aCssText); \
NS_IMETHOD SetCssText(const nsString& aCssText); \
NS_IMETHOD GetLength(PRUint32* aLength); \
NS_IMETHOD GetParentRule(nsIDOMCSSRule** aParentRule); \
NS_IMETHOD GetPropertyValue(const nsString& aPropertyName, nsString& aReturn); \
NS_IMETHOD GetPropertyCSSValue(const nsString& aPropertyName, nsIDOMCSSValue** aReturn); \
NS_IMETHOD RemoveProperty(const nsString& aPropertyName, nsString& aReturn); \
NS_IMETHOD GetPropertyPriority(const nsString& aPropertyName, nsString& aReturn); \
NS_IMETHOD SetProperty(const nsString& aPropertyName, const nsString& aValue, const nsString& aPriority); \
NS_IMETHOD Item(PRUint32 aIndex, nsString& aReturn); \
@ -67,7 +78,10 @@ public:
NS_IMETHOD GetCssText(nsString& aCssText) { return _to GetCssText(aCssText); } \
NS_IMETHOD SetCssText(const nsString& aCssText) { return _to SetCssText(aCssText); } \
NS_IMETHOD GetLength(PRUint32* aLength) { return _to GetLength(aLength); } \
NS_IMETHOD GetParentRule(nsIDOMCSSRule** aParentRule) { return _to GetParentRule(aParentRule); } \
NS_IMETHOD GetPropertyValue(const nsString& aPropertyName, nsString& aReturn) { return _to GetPropertyValue(aPropertyName, aReturn); } \
NS_IMETHOD GetPropertyCSSValue(const nsString& aPropertyName, nsIDOMCSSValue** aReturn) { return _to GetPropertyCSSValue(aPropertyName, aReturn); } \
NS_IMETHOD RemoveProperty(const nsString& aPropertyName, nsString& aReturn) { return _to RemoveProperty(aPropertyName, aReturn); } \
NS_IMETHOD GetPropertyPriority(const nsString& aPropertyName, nsString& aReturn) { return _to GetPropertyPriority(aPropertyName, aReturn); } \
NS_IMETHOD SetProperty(const nsString& aPropertyName, const nsString& aValue, const nsString& aPriority) { return _to SetProperty(aPropertyName, aValue, aPriority); } \
NS_IMETHOD Item(PRUint32 aIndex, nsString& aReturn) { return _to Item(aIndex, aReturn); } \

Просмотреть файл

@ -1,18 +1,22 @@
interface CSSStyleDeclaration {
interface CSSStyleDeclaration {
/* IID: { 0xa6cf90be, 0x15b3, 0x11d2, \
{ 0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32 } } */
attribute wstring cssText;
wstring getPropertyValue(in wstring propertyName);
wstring getPropertyPriority(in wstring propertyName);
void setProperty(in wstring propertyName, in wstring value, in wstring
priority);
readonly attribute unsigned long length;
wstring item(in unsigned long index); /* Returns property name */
};
attribute DOMString cssText;
// raises(DOMException) on setting
DOMString getPropertyValue(in DOMString propertyName);
CSSValue getPropertyCSSValue(in DOMString propertyName);
DOMString removeProperty(in DOMString propertyName)
raises(DOMException);
DOMString getPropertyPriority(in DOMString propertyName);
void setProperty(in DOMString propertyName,
in DOMString value,
in DOMString priority)
raises(DOMException);
readonly attribute unsigned long length;
DOMString item(in unsigned long index);
readonly attribute CSSRule parentRule;
};

Просмотреть файл

@ -40,6 +40,7 @@ IDLSRCS = \
CSSStyleRuleCollection.idl \
CSSStyleSheet.idl \
CSSUnknownRule.idl \
CSSValue.idl \
$(NULL)
include $(DEPTH)/config/rules.mk

Просмотреть файл

@ -35,7 +35,8 @@ IDLSRCS = \
CSSStyleRule.idl \
CSSStyleRuleCollection.idl \
CSSStyleSheet.idl \
CSSUnknownRule.idl
CSSUnknownRule.idl \
CSSValue.idl
XPCOM_DESTDIR=$(DEPTH)\dom\public\css
JSSTUB_DESTDIR=$(DEPTH)\dom\src\css

Просмотреть файл

@ -189,10 +189,13 @@ enum nsDOMProp {
NS_DOM_PROP_CSSRULE_SHEET,
NS_DOM_PROP_CSSRULE_TYPE,
NS_DOM_PROP_CSSSTYLEDECLARATION_CSSTEXT,
NS_DOM_PROP_CSSSTYLEDECLARATION_GETPROPERTYCSSVALUE,
NS_DOM_PROP_CSSSTYLEDECLARATION_GETPROPERTYPRIORITY,
NS_DOM_PROP_CSSSTYLEDECLARATION_GETPROPERTYVALUE,
NS_DOM_PROP_CSSSTYLEDECLARATION_ITEM,
NS_DOM_PROP_CSSSTYLEDECLARATION_ITEM,
NS_DOM_PROP_CSSSTYLEDECLARATION_LENGTH,
NS_DOM_PROP_CSSSTYLEDECLARATION_PARENTRULE,
NS_DOM_PROP_CSSSTYLEDECLARATION_REMOVEPROPERTY,
NS_DOM_PROP_CSSSTYLEDECLARATION_SETPROPERTY,
NS_DOM_PROP_CSSSTYLERULE_SELECTORTEXT,
NS_DOM_PROP_CSSSTYLERULE_STYLE,
@ -206,6 +209,8 @@ enum nsDOMProp {
NS_DOM_PROP_CSSSTYLESHEET_OWNINGNODE,
NS_DOM_PROP_CSSSTYLESHEET_PARENTSTYLESHEET,
NS_DOM_PROP_CSSSTYLESHEET_TITLE,
NS_DOM_PROP_CSSVALUE_CSSTEXT,
NS_DOM_PROP_CSSVALUE_VALUETYPE,
NS_DOM_PROP_DOCUMENT_CREATEATTRIBUTE,
NS_DOM_PROP_DOCUMENT_CREATEATTRIBUTENS,
NS_DOM_PROP_DOCUMENT_CREATECDATASECTION,

Просмотреть файл

@ -188,10 +188,13 @@
"cssrule.sheet", \
"cssrule.type", \
"cssstyledeclaration.csstext", \
"cssstyledeclaration.getpropertycssvalue", \
"cssstyledeclaration.getpropertypriority", \
"cssstyledeclaration.getpropertyvalue", \
"cssstyledeclaration.item", \
"cssstyledeclaration.length", \
"cssstyledeclaration.parentrule", \
"cssstyledeclaration.removeproperty", \
"cssstyledeclaration.setproperty", \
"cssstylerule.selectortext", \
"cssstylerule.style", \
@ -205,6 +208,8 @@
"cssstylesheet.owningnode", \
"cssstylesheet.parentstylesheet", \
"cssstylesheet.title", \
"cssvalue.csstext", \
"cssvalue.valuetype", \
"document.createattribute", \
"document.createattributens", \
"document.createcdatasection", \

Просмотреть файл

@ -43,6 +43,7 @@ CPPSRCS = \
nsJSCSSStyleRuleCollection.cpp \
nsJSCSSStyleSheet.cpp \
nsJSCSSUnknownRule.cpp \
nsJSCSSValue.cpp \
$(NULL)
# we don't want the shared lib, but we want to force the creation of a static lib.

Просмотреть файл

@ -21,6 +21,7 @@ CPPSRCS = \
nsJSCSSStyleRuleCollection.cpp \
nsJSCSSStyleSheet.cpp \
nsJSCSSUnknownRule.cpp \
nsJSCSSValue.cpp \
$(NULL)
CPP_OBJS= \
@ -35,6 +36,7 @@ CPP_OBJS= \
.\$(OBJDIR)\nsJSCSSStyleRuleCollection.obj \
.\$(OBJDIR)\nsJSCSSStyleSheet.obj \
.\$(OBJDIR)\nsJSCSSUnknownRule.obj \
.\$(OBJDIR)\nsJSCSSValue.obj \
$(NULL)

Просмотреть файл

@ -34,20 +34,25 @@
#include "nsCOMPtr.h"
#include "nsDOMPropEnums.h"
#include "nsString.h"
#include "nsIDOMCSSRule.h"
#include "nsIDOMCSSStyleDeclaration.h"
#include "nsIDOMCSSValue.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(kICSSRuleIID, NS_IDOMCSSRULE_IID);
static NS_DEFINE_IID(kICSSStyleDeclarationIID, NS_IDOMCSSSTYLEDECLARATION_IID);
static NS_DEFINE_IID(kICSSValueIID, NS_IDOMCSSVALUE_IID);
//
// CSSStyleDeclaration property ids
//
enum CSSStyleDeclaration_slots {
CSSSTYLEDECLARATION_CSSTEXT = -1,
CSSSTYLEDECLARATION_LENGTH = -2
CSSSTYLEDECLARATION_LENGTH = -2,
CSSSTYLEDECLARATION_PARENTRULE = -3
};
/***********************************************************************/
@ -94,6 +99,19 @@ GetCSSStyleDeclarationProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp
}
break;
}
case CSSSTYLEDECLARATION_PARENTRULE:
{
rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_CSSSTYLEDECLARATION_PARENTRULE, PR_FALSE);
if (NS_SUCCEEDED(rv)) {
nsIDOMCSSRule* prop;
rv = a->GetParentRule(&prop);
if (NS_SUCCEEDED(rv)) {
// get the js object
nsJSUtils::nsConvertObjectToJSVal((nsISupports *)prop, cx, obj, vp);
}
}
break;
}
default:
{
nsAutoString prop;
@ -231,6 +249,90 @@ CSSStyleDeclarationGetPropertyValue(JSContext *cx, JSObject *obj, uintN argc, js
}
//
// Native method GetPropertyCSSValue
//
PR_STATIC_CALLBACK(JSBool)
CSSStyleDeclarationGetPropertyCSSValue(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMCSSStyleDeclaration *nativeThis = (nsIDOMCSSStyleDeclaration*)nsJSUtils::nsGetNativeThis(cx, obj);
nsresult result = NS_OK;
nsIDOMCSSValue* nativeRet;
nsAutoString b0;
// If there's no private data, this must be the prototype, so ignore
if (nsnull == 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_CSSSTYLEDECLARATION_GETPROPERTYCSSVALUE, PR_FALSE);
if (NS_FAILED(result)) {
return nsJSUtils::nsReportError(cx, obj, result);
}
if (argc < 1) {
return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_TOO_FEW_PARAMETERS_ERR);
}
nsJSUtils::nsConvertJSValToString(b0, cx, argv[0]);
result = nativeThis->GetPropertyCSSValue(b0, &nativeRet);
if (NS_FAILED(result)) {
return nsJSUtils::nsReportError(cx, obj, result);
}
nsJSUtils::nsConvertObjectToJSVal(nativeRet, cx, obj, rval);
}
return JS_TRUE;
}
//
// Native method RemoveProperty
//
PR_STATIC_CALLBACK(JSBool)
CSSStyleDeclarationRemoveProperty(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMCSSStyleDeclaration *nativeThis = (nsIDOMCSSStyleDeclaration*)nsJSUtils::nsGetNativeThis(cx, obj);
nsresult result = NS_OK;
nsAutoString nativeRet;
nsAutoString b0;
// If there's no private data, this must be the prototype, so ignore
if (nsnull == 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_CSSSTYLEDECLARATION_REMOVEPROPERTY, PR_FALSE);
if (NS_FAILED(result)) {
return nsJSUtils::nsReportError(cx, obj, result);
}
if (argc < 1) {
return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_TOO_FEW_PARAMETERS_ERR);
}
nsJSUtils::nsConvertJSValToString(b0, cx, argv[0]);
result = nativeThis->RemoveProperty(b0, nativeRet);
if (NS_FAILED(result)) {
return nsJSUtils::nsReportError(cx, obj, result);
}
nsJSUtils::nsConvertStringToJSVal(nativeRet, cx, rval);
}
return JS_TRUE;
}
//
// Native method GetPropertyPriority
//
@ -389,6 +491,7 @@ static JSPropertySpec CSSStyleDeclarationProperties[] =
{
{"cssText", CSSSTYLEDECLARATION_CSSTEXT, JSPROP_ENUMERATE},
{"length", CSSSTYLEDECLARATION_LENGTH, JSPROP_ENUMERATE | JSPROP_READONLY},
{"parentRule", CSSSTYLEDECLARATION_PARENTRULE, JSPROP_ENUMERATE | JSPROP_READONLY},
{0}
};
@ -399,6 +502,8 @@ static JSPropertySpec CSSStyleDeclarationProperties[] =
static JSFunctionSpec CSSStyleDeclarationMethods[] =
{
{"getPropertyValue", CSSStyleDeclarationGetPropertyValue, 1},
{"getPropertyCSSValue", CSSStyleDeclarationGetPropertyCSSValue, 1},
{"removeProperty", CSSStyleDeclarationRemoveProperty, 1},
{"getPropertyPriority", CSSStyleDeclarationGetPropertyPriority, 1},
{"setProperty", CSSStyleDeclarationSetProperty, 3},
{"item", CSSStyleDeclarationItem, 1},

Просмотреть файл

@ -108,6 +108,9 @@ public:
nsDOMCSSAttributeDeclaration(nsIHTMLContent *aContent);
~nsDOMCSSAttributeDeclaration();
NS_IMETHOD RemoveProperty(const nsString& aPropertyName,
nsString& aReturn);
virtual void DropReference();
virtual nsresult GetCSSDeclaration(nsICSSDeclaration **aDecl,
PRBool aAllocate);
@ -134,6 +137,47 @@ nsDOMCSSAttributeDeclaration::~nsDOMCSSAttributeDeclaration()
MOZ_COUNT_DTOR(nsDOMCSSAttributeDeclaration);
}
NS_IMETHODIMP
nsDOMCSSAttributeDeclaration::RemoveProperty(const nsString& aPropertyName,
nsString& aReturn)
{
nsCOMPtr<nsICSSDeclaration> decl;
nsresult rv = GetCSSDeclaration(getter_AddRefs(decl), PR_TRUE);
if (NS_SUCCEEDED(rv) && decl && mContent) {
nsCOMPtr<nsIDocument> doc;
mContent->GetDocument(*getter_AddRefs(doc));
if (doc)
doc->BeginUpdate();
nsCSSProperty prop = nsCSSProps::LookupProperty(aPropertyName);
nsCSSValue val;
#if 0 // Once nsICSSDeclaration has a RemoveProperty this ifdef should be removed
rv = decl->RemoveProperty(prop, val);
#else
rv = NS_ERROR_NOT_IMPLEMENTED;
#endif
if (NS_FAILED(rv))
return rv;
val.ToString(aReturn, prop);
if (doc) {
PRInt32 hint;
decl->GetStyleImpact(&hint);
doc->AttributeChanged(mContent, kNameSpaceID_None, nsHTMLAtoms::style,
hint);
doc->EndUpdate();
}
}
return rv;
}
void
nsDOMCSSAttributeDeclaration::DropReference()
{

Просмотреть файл

@ -787,6 +787,9 @@ public:
DOMCSSDeclarationImpl(nsICSSStyleRule *aRule);
~DOMCSSDeclarationImpl(void);
NS_IMETHOD RemoveProperty(const nsString& aPropertyName,
nsString& aReturn);
virtual void DropReference(void);
virtual nsresult GetCSSDeclaration(nsICSSDeclaration **aDecl,
PRBool aAllocate);
@ -813,6 +816,34 @@ DOMCSSDeclarationImpl::~DOMCSSDeclarationImpl(void)
MOZ_COUNT_DTOR(DOMCSSDeclarationImpl);
}
NS_IMETHODIMP
DOMCSSDeclarationImpl::RemoveProperty(const nsString& aPropertyName,
nsString& aReturn)
{
aReturn.Truncate();
nsCOMPtr<nsICSSDeclaration> decl;
nsresult rv = GetCSSDeclaration(getter_AddRefs(decl), PR_TRUE);
if (NS_SUCCEEDED(rv) && decl) {
nsCSSProperty prop = nsCSSProps::LookupProperty(aPropertyName);
nsCSSValue val;
#if 0 // This is not done yet, once it is this ifdef should be removed
rv = decl->RemoveProperty(prop, val);
#else
rv = NS_ERROR_NOT_IMPLEMENTED;
#endif
if (NS_FAILED(rv))
return rv;
val.ToString(aReturn, prop);
}
return rv;
}
void
DOMCSSDeclarationImpl::DropReference(void)
{
@ -906,6 +937,9 @@ DOMCSSDeclarationImpl::GetParent(nsISupports **aParent)
{
if (nsnull != mRule) {
return mRule->QueryInterface(kISupportsIID, (void **)aParent);
} else {
NS_ENSURE_ARG_POINTER(aParent);
*aParent = nsnull;
}
return NS_OK;

Просмотреть файл

@ -21,10 +21,12 @@
*/
#include "nsDOMCSSDeclaration.h"
#include "nsIDOMCSSRule.h"
#include "nsICSSParser.h"
#include "nsIStyleRule.h"
#include "nsICSSDeclaration.h"
#include "nsCSSProps.h"
#include "nsCOMPtr.h"
#include "nsIURL.h"
nsDOMCSSDeclaration::nsDOMCSSDeclaration()
@ -88,9 +90,9 @@ nsDOMCSSDeclaration::GetScriptObject(nsIScriptContext* aContext,
nsresult res = NS_OK;
if (nsnull == mScriptObject) {
nsISupports *parent = nsnull;
nsCOMPtr<nsISupports> parent;
res = GetParent(&parent);
res = GetParent(getter_AddRefs(parent));
if (NS_OK == res) {
nsISupports *supports = (nsISupports *)(nsIDOMCSS2Properties *)this;
// XXX Should be done through factory
@ -98,7 +100,6 @@ nsDOMCSSDeclaration::GetScriptObject(nsIScriptContext* aContext,
supports,
parent,
(void**)&mScriptObject);
NS_RELEASE(parent);
}
}
*aScriptObject = mScriptObject;
@ -106,28 +107,29 @@ nsDOMCSSDeclaration::GetScriptObject(nsIScriptContext* aContext,
return res;
}
NS_IMETHODIMP
NS_IMETHODIMP
nsDOMCSSDeclaration::SetScriptObject(void* aScriptObject)
{
mScriptObject = aScriptObject;
return NS_OK;
}
NS_IMETHODIMP
NS_IMETHODIMP
nsDOMCSSDeclaration::GetCssText(nsString& aCssText)
{
aCssText.Truncate();
// XXX TBI
return NS_OK;
}
NS_IMETHODIMP
NS_IMETHODIMP
nsDOMCSSDeclaration::SetCssText(const nsString& aCssText)
{
// XXX TBI
return NS_OK;
}
NS_IMETHODIMP
NS_IMETHODIMP
nsDOMCSSDeclaration::GetLength(PRUint32* aLength)
{
nsICSSDeclaration *decl;
@ -142,7 +144,36 @@ nsDOMCSSDeclaration::GetLength(PRUint32* aLength)
return result;
}
NS_IMETHODIMP
NS_IMETHODIMP
nsDOMCSSDeclaration::GetParentRule(nsIDOMCSSRule** aParentRule)
{
nsCOMPtr<nsISupports> parent;
GetParent(getter_AddRefs(parent));
if (parent) {
parent->QueryInterface(NS_GET_IID(nsIDOMCSSRule), (void **)aParentRule);
} else {
NS_ENSURE_ARG_POINTER(aParentRule);
*aParentRule = nsnull;
}
return NS_OK;
}
NS_IMETHODIMP
nsDOMCSSDeclaration::GetPropertyCSSValue(const nsString& aPropertyName,
nsIDOMCSSValue** aReturn)
{
NS_ENSURE_ARG_POINTER(aReturn);
// We don't support CSSValue yet so we'll just return null...
*aReturn = nsnull;
return NS_OK;
}
NS_IMETHODIMP
nsDOMCSSDeclaration::Item(PRUint32 aIndex, nsString& aReturn)
{
nsICSSDeclaration *decl;

Просмотреть файл

@ -38,7 +38,22 @@ public:
NS_DECL_ISUPPORTS
NS_DECL_IDOMCSSSTYLEDECLARATION
// NS_DECL_IDOMCSSSTYLEDECLARATION
NS_IMETHOD GetCssText(nsString& aCssText);
NS_IMETHOD SetCssText(const nsString& aCssText);
NS_IMETHOD GetLength(PRUint32* aLength);
NS_IMETHOD GetParentRule(nsIDOMCSSRule** aParentRule);
NS_IMETHOD GetPropertyValue(const nsString& aPropertyName,
nsString& aReturn);
NS_IMETHOD GetPropertyCSSValue(const nsString& aPropertyName,
nsIDOMCSSValue** aReturn);
NS_IMETHOD RemoveProperty(const nsString& aPropertyName,
nsString& aReturn) = 0;
NS_IMETHOD GetPropertyPriority(const nsString& aPropertyName,
nsString& aReturn);
NS_IMETHOD SetProperty(const nsString& aPropertyName,
const nsString& aValue, const nsString& aPriority);
NS_IMETHOD Item(PRUint32 aIndex, nsString& aReturn);
NS_DECL_IDOMCSS2PROPERTIES

Просмотреть файл

@ -787,6 +787,9 @@ public:
DOMCSSDeclarationImpl(nsICSSStyleRule *aRule);
~DOMCSSDeclarationImpl(void);
NS_IMETHOD RemoveProperty(const nsString& aPropertyName,
nsString& aReturn);
virtual void DropReference(void);
virtual nsresult GetCSSDeclaration(nsICSSDeclaration **aDecl,
PRBool aAllocate);
@ -813,6 +816,34 @@ DOMCSSDeclarationImpl::~DOMCSSDeclarationImpl(void)
MOZ_COUNT_DTOR(DOMCSSDeclarationImpl);
}
NS_IMETHODIMP
DOMCSSDeclarationImpl::RemoveProperty(const nsString& aPropertyName,
nsString& aReturn)
{
aReturn.Truncate();
nsCOMPtr<nsICSSDeclaration> decl;
nsresult rv = GetCSSDeclaration(getter_AddRefs(decl), PR_TRUE);
if (NS_SUCCEEDED(rv) && decl) {
nsCSSProperty prop = nsCSSProps::LookupProperty(aPropertyName);
nsCSSValue val;
#if 0 // This is not done yet, once it is this ifdef should be removed
rv = decl->RemoveProperty(prop, val);
#else
rv = NS_ERROR_NOT_IMPLEMENTED;
#endif
if (NS_FAILED(rv))
return rv;
val.ToString(aReturn, prop);
}
return rv;
}
void
DOMCSSDeclarationImpl::DropReference(void)
{
@ -906,6 +937,9 @@ DOMCSSDeclarationImpl::GetParent(nsISupports **aParent)
{
if (nsnull != mRule) {
return mRule->QueryInterface(kISupportsIID, (void **)aParent);
} else {
NS_ENSURE_ARG_POINTER(aParent);
*aParent = nsnull;
}
return NS_OK;

Просмотреть файл

@ -21,10 +21,12 @@
*/
#include "nsDOMCSSDeclaration.h"
#include "nsIDOMCSSRule.h"
#include "nsICSSParser.h"
#include "nsIStyleRule.h"
#include "nsICSSDeclaration.h"
#include "nsCSSProps.h"
#include "nsCOMPtr.h"
#include "nsIURL.h"
nsDOMCSSDeclaration::nsDOMCSSDeclaration()
@ -88,9 +90,9 @@ nsDOMCSSDeclaration::GetScriptObject(nsIScriptContext* aContext,
nsresult res = NS_OK;
if (nsnull == mScriptObject) {
nsISupports *parent = nsnull;
nsCOMPtr<nsISupports> parent;
res = GetParent(&parent);
res = GetParent(getter_AddRefs(parent));
if (NS_OK == res) {
nsISupports *supports = (nsISupports *)(nsIDOMCSS2Properties *)this;
// XXX Should be done through factory
@ -98,7 +100,6 @@ nsDOMCSSDeclaration::GetScriptObject(nsIScriptContext* aContext,
supports,
parent,
(void**)&mScriptObject);
NS_RELEASE(parent);
}
}
*aScriptObject = mScriptObject;
@ -106,28 +107,29 @@ nsDOMCSSDeclaration::GetScriptObject(nsIScriptContext* aContext,
return res;
}
NS_IMETHODIMP
NS_IMETHODIMP
nsDOMCSSDeclaration::SetScriptObject(void* aScriptObject)
{
mScriptObject = aScriptObject;
return NS_OK;
}
NS_IMETHODIMP
NS_IMETHODIMP
nsDOMCSSDeclaration::GetCssText(nsString& aCssText)
{
aCssText.Truncate();
// XXX TBI
return NS_OK;
}
NS_IMETHODIMP
NS_IMETHODIMP
nsDOMCSSDeclaration::SetCssText(const nsString& aCssText)
{
// XXX TBI
return NS_OK;
}
NS_IMETHODIMP
NS_IMETHODIMP
nsDOMCSSDeclaration::GetLength(PRUint32* aLength)
{
nsICSSDeclaration *decl;
@ -142,7 +144,36 @@ nsDOMCSSDeclaration::GetLength(PRUint32* aLength)
return result;
}
NS_IMETHODIMP
NS_IMETHODIMP
nsDOMCSSDeclaration::GetParentRule(nsIDOMCSSRule** aParentRule)
{
nsCOMPtr<nsISupports> parent;
GetParent(getter_AddRefs(parent));
if (parent) {
parent->QueryInterface(NS_GET_IID(nsIDOMCSSRule), (void **)aParentRule);
} else {
NS_ENSURE_ARG_POINTER(aParentRule);
*aParentRule = nsnull;
}
return NS_OK;
}
NS_IMETHODIMP
nsDOMCSSDeclaration::GetPropertyCSSValue(const nsString& aPropertyName,
nsIDOMCSSValue** aReturn)
{
NS_ENSURE_ARG_POINTER(aReturn);
// We don't support CSSValue yet so we'll just return null...
*aReturn = nsnull;
return NS_OK;
}
NS_IMETHODIMP
nsDOMCSSDeclaration::Item(PRUint32 aIndex, nsString& aReturn)
{
nsICSSDeclaration *decl;

Просмотреть файл

@ -38,7 +38,22 @@ public:
NS_DECL_ISUPPORTS
NS_DECL_IDOMCSSSTYLEDECLARATION
// NS_DECL_IDOMCSSSTYLEDECLARATION
NS_IMETHOD GetCssText(nsString& aCssText);
NS_IMETHOD SetCssText(const nsString& aCssText);
NS_IMETHOD GetLength(PRUint32* aLength);
NS_IMETHOD GetParentRule(nsIDOMCSSRule** aParentRule);
NS_IMETHOD GetPropertyValue(const nsString& aPropertyName,
nsString& aReturn);
NS_IMETHOD GetPropertyCSSValue(const nsString& aPropertyName,
nsIDOMCSSValue** aReturn);
NS_IMETHOD RemoveProperty(const nsString& aPropertyName,
nsString& aReturn) = 0;
NS_IMETHOD GetPropertyPriority(const nsString& aPropertyName,
nsString& aReturn);
NS_IMETHOD SetProperty(const nsString& aPropertyName,
const nsString& aValue, const nsString& aPriority);
NS_IMETHOD Item(PRUint32 aIndex, nsString& aReturn);
NS_DECL_IDOMCSS2PROPERTIES