mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-25 19:25:43 +00:00
Added SetEditorType to control whether a plain text or HTML editor is instantiated.
This commit is contained in:
parent
e4039d57d4
commit
ae6d208e80
@ -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();
|
||||
|
@ -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(); } \
|
||||
|
@ -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},
|
||||
|
Loading…
Reference in New Issue
Block a user