diff --git a/xpfe/AppCores/idl/EditorAppCore.idl b/xpfe/AppCores/idl/EditorAppCore.idl index cabb8443fe3b..6dd2fca455ea 100755 --- a/xpfe/AppCores/idl/EditorAppCore.idl +++ b/xpfe/AppCores/idl/EditorAppCore.idl @@ -8,6 +8,7 @@ interface EditorAppCore : BaseAppCore void EditorAppCore(); + void setEditorType(in wstring editorType); void setAttribute(in wstring attr, in wstring value); void undo(); void redo(); diff --git a/xpfe/AppCores/public/nsIDOMEditorAppCore.h b/xpfe/AppCores/public/nsIDOMEditorAppCore.h index c90721dcee22..14f94c875d6a 100755 --- a/xpfe/AppCores/public/nsIDOMEditorAppCore.h +++ b/xpfe/AppCores/public/nsIDOMEditorAppCore.h @@ -39,6 +39,8 @@ public: NS_IMETHOD GetContentsAsHTML(nsString& aContentsAsHTML)=0; + NS_IMETHOD SetEditorType(const nsString& aEditorType)=0; + NS_IMETHOD SetAttribute(const nsString& aAttr, const nsString& aValue)=0; NS_IMETHOD Undo()=0; @@ -74,6 +76,7 @@ public: #define NS_DECL_IDOMEDITORAPPCORE \ NS_IMETHOD GetContentsAsText(nsString& aContentsAsText); \ NS_IMETHOD GetContentsAsHTML(nsString& aContentsAsHTML); \ + NS_IMETHOD SetEditorType(const nsString& aEditorType); \ NS_IMETHOD SetAttribute(const nsString& aAttr, const nsString& aValue); \ NS_IMETHOD Undo(); \ NS_IMETHOD Redo(); \ @@ -95,6 +98,7 @@ public: #define NS_FORWARD_IDOMEDITORAPPCORE(_to) \ NS_IMETHOD GetContentsAsText(nsString& aContentsAsText) { return _to##GetContentsAsText(aContentsAsText); } \ NS_IMETHOD GetContentsAsHTML(nsString& aContentsAsHTML) { return _to##GetContentsAsHTML(aContentsAsHTML); } \ + NS_IMETHOD SetEditorType(const nsString& aEditorType) { return _to##SetEditorType(aEditorType); } \ NS_IMETHOD SetAttribute(const nsString& aAttr, const nsString& aValue) { return _to##SetAttribute(aAttr, aValue); } \ NS_IMETHOD Undo() { return _to##Undo(); } \ NS_IMETHOD Redo() { return _to##Redo(); } \ diff --git a/xpfe/AppCores/src/nsJSEditorAppCore.cpp b/xpfe/AppCores/src/nsJSEditorAppCore.cpp index fbfb407da9ba..b85fae7b9bea 100755 --- a/xpfe/AppCores/src/nsJSEditorAppCore.cpp +++ b/xpfe/AppCores/src/nsJSEditorAppCore.cpp @@ -158,6 +158,42 @@ ResolveEditorAppCore(JSContext *cx, JSObject *obj, jsval id) } +// +// Native method SetEditorType +// +PR_STATIC_CALLBACK(JSBool) +EditorAppCoreSetEditorType(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) +{ + nsIDOMEditorAppCore *nativeThis = (nsIDOMEditorAppCore*)JS_GetPrivate(cx, obj); + JSBool rBool = JS_FALSE; + nsAutoString 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) { + + nsJSUtils::nsConvertJSValToString(b0, cx, argv[0]); + + if (NS_OK != nativeThis->SetEditorType(b0)) { + return JS_FALSE; + } + + *rval = JSVAL_VOID; + } + else { + JS_ReportError(cx, "Function setEditorType requires 1 parameters"); + return JS_FALSE; + } + + return JS_TRUE; +} + + // // Native method SetAttribute // @@ -723,6 +759,7 @@ static JSPropertySpec EditorAppCoreProperties[] = // static JSFunctionSpec EditorAppCoreMethods[] = { + {"setEditorType", EditorAppCoreSetEditorType, 1}, {"setAttribute", EditorAppCoreSetAttribute, 2}, {"undo", EditorAppCoreUndo, 0}, {"redo", EditorAppCoreRedo, 0},