зеркало из https://github.com/mozilla/gecko-dev.git
Add SelectAll() to the EditorAppCore
This commit is contained in:
Родитель
452e7019bf
Коммит
ca597944da
|
@ -16,6 +16,8 @@ interface EditorAppCore : BaseAppCore
|
|||
void copy();
|
||||
void paste();
|
||||
|
||||
void selectAll();
|
||||
|
||||
void insertText(in wstring textToInsert);
|
||||
|
||||
void exit();
|
||||
|
|
|
@ -51,6 +51,8 @@ public:
|
|||
|
||||
NS_IMETHOD Paste()=0;
|
||||
|
||||
NS_IMETHOD SelectAll()=0;
|
||||
|
||||
NS_IMETHOD InsertText(const nsString& aTextToInsert)=0;
|
||||
|
||||
NS_IMETHOD Exit()=0;
|
||||
|
@ -72,6 +74,7 @@ public:
|
|||
NS_IMETHOD Cut(); \
|
||||
NS_IMETHOD Copy(); \
|
||||
NS_IMETHOD Paste(); \
|
||||
NS_IMETHOD SelectAll(); \
|
||||
NS_IMETHOD InsertText(const nsString& aTextToInsert); \
|
||||
NS_IMETHOD Exit(); \
|
||||
NS_IMETHOD SetToolbarWindow(nsIDOMWindow* aWin); \
|
||||
|
@ -89,6 +92,7 @@ public:
|
|||
NS_IMETHOD Cut() { return _to##Cut(); } \
|
||||
NS_IMETHOD Copy() { return _to##Copy(); } \
|
||||
NS_IMETHOD Paste() { return _to##Paste(); } \
|
||||
NS_IMETHOD SelectAll() { return _to##SelectAll(); } \
|
||||
NS_IMETHOD InsertText(const nsString& aTextToInsert) { return _to##InsertText(aTextToInsert); } \
|
||||
NS_IMETHOD Exit() { return _to##Exit(); } \
|
||||
NS_IMETHOD SetToolbarWindow(nsIDOMWindow* aWin) { return _to##SetToolbarWindow(aWin); } \
|
||||
|
|
|
@ -458,6 +458,16 @@ nsEditorAppCore::Paste()
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEditorAppCore::SelectAll()
|
||||
{
|
||||
if (mEditor) {
|
||||
mEditor->SelectAll();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEditorAppCore::InsertText(const nsString& textToInsert)
|
||||
{
|
||||
|
|
|
@ -75,6 +75,7 @@ class nsEditorAppCore : public nsBaseAppCore,
|
|||
NS_IMETHOD Cut();
|
||||
NS_IMETHOD Copy();
|
||||
NS_IMETHOD Paste();
|
||||
NS_IMETHOD SelectAll();
|
||||
|
||||
NS_IMETHOD InsertText(const nsString& textToInsert);
|
||||
|
||||
|
|
|
@ -362,6 +362,39 @@ EditorAppCorePaste(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval
|
|||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method SelectAll
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
EditorAppCoreSelectAll(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMEditorAppCore *nativeThis = (nsIDOMEditorAppCore*)JS_GetPrivate(cx, obj);
|
||||
JSBool rBool = JS_FALSE;
|
||||
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == nativeThis) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
if (argc >= 0) {
|
||||
|
||||
if (NS_OK != nativeThis->SelectAll()) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
*rval = JSVAL_VOID;
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function selectAll requires 0 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method InsertText
|
||||
//
|
||||
|
@ -597,6 +630,7 @@ static JSFunctionSpec EditorAppCoreMethods[] =
|
|||
{"cut", EditorAppCoreCut, 0},
|
||||
{"copy", EditorAppCoreCopy, 0},
|
||||
{"paste", EditorAppCorePaste, 0},
|
||||
{"selectAll", EditorAppCoreSelectAll, 0},
|
||||
{"insertText", EditorAppCoreInsertText, 1},
|
||||
{"exit", EditorAppCoreExit, 0},
|
||||
{"setToolbarWindow", EditorAppCoreSetToolbarWindow, 1},
|
||||
|
|
Загрузка…
Ссылка в новой задаче