зеркало из https://github.com/mozilla/gecko-dev.git
adding ShowDialog()
This commit is contained in:
Родитель
427bd2b535
Коммит
e2fab61bae
|
@ -4,5 +4,6 @@ interface ToolkitCore : BaseAppCore
|
|||
{0x81, 0xb2, 0x00, 0x60, 0x08, 0x3a, 0x0b, 0xcf}} *\
|
||||
|
||||
void ToolkitCore();
|
||||
void ShowDialog(in wstring url, in Window parent);
|
||||
void ShowWindow(in wstring url, in Window parent);
|
||||
};
|
||||
|
|
|
@ -35,20 +35,24 @@ class nsIDOMToolkitCore : public nsIDOMBaseAppCore {
|
|||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IDOMTOOLKITCORE_IID; return iid; }
|
||||
|
||||
NS_IMETHOD ShowDialog(const nsString& aUrl, nsIDOMWindow* aParent)=0;
|
||||
|
||||
NS_IMETHOD ShowWindow(const nsString& aUrl, nsIDOMWindow* aParent)=0;
|
||||
};
|
||||
|
||||
|
||||
#define NS_DECL_IDOMTOOLKITCORE \
|
||||
NS_IMETHOD ShowDialog(const nsString& aUrl, nsIDOMWindow* aParent); \
|
||||
NS_IMETHOD ShowWindow(const nsString& aUrl, nsIDOMWindow* aParent); \
|
||||
|
||||
|
||||
|
||||
#define NS_FORWARD_IDOMTOOLKITCORE(_to) \
|
||||
NS_IMETHOD ShowDialog(const nsString& aUrl, nsIDOMWindow* aParent) { return _to##ShowDialog(aUrl, aParent); } \
|
||||
NS_IMETHOD ShowWindow(const nsString& aUrl, nsIDOMWindow* aParent) { return _to##ShowWindow(aUrl, aParent); } \
|
||||
|
||||
|
||||
extern nsresult NS_InitToolkitCoreClass(nsIScriptContext *aContext, void **aPrototype);
|
||||
extern "C" NS_DOM nsresult NS_InitToolkitCoreClass(nsIScriptContext *aContext, void **aPrototype);
|
||||
|
||||
extern "C" NS_DOM nsresult NS_NewScriptToolkitCore(nsIScriptContext *aContext, nsISupports *aSupports, nsISupports *aParent, void **aReturn);
|
||||
|
||||
|
|
|
@ -130,6 +130,51 @@ ResolveToolkitCore(JSContext *cx, JSObject *obj, jsval id)
|
|||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method ShowDialog
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
ToolkitCoreShowDialog(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMToolkitCore *nativeThis = (nsIDOMToolkitCore*)JS_GetPrivate(cx, obj);
|
||||
JSBool rBool = JS_FALSE;
|
||||
nsAutoString b0;
|
||||
nsIDOMWindowPtr b1;
|
||||
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == nativeThis) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
if (argc >= 2) {
|
||||
|
||||
nsJSUtils::nsConvertJSValToString(b0, cx, argv[0]);
|
||||
|
||||
if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b1,
|
||||
kIWindowIID,
|
||||
"Window",
|
||||
cx,
|
||||
argv[1])) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (NS_OK != nativeThis->ShowDialog(b0, b1)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
*rval = JSVAL_VOID;
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function ShowDialog requires 2 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method ShowWindow
|
||||
//
|
||||
|
@ -207,6 +252,7 @@ static JSPropertySpec ToolkitCoreProperties[] =
|
|||
//
|
||||
static JSFunctionSpec ToolkitCoreMethods[] =
|
||||
{
|
||||
{"ShowDialog", ToolkitCoreShowDialog, 2},
|
||||
{"ShowWindow", ToolkitCoreShowWindow, 2},
|
||||
{0}
|
||||
};
|
||||
|
@ -264,7 +310,7 @@ ToolkitCore(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
|||
//
|
||||
// ToolkitCore class initialization
|
||||
//
|
||||
nsresult NS_InitToolkitCoreClass(nsIScriptContext *aContext, void **aPrototype)
|
||||
extern "C" NS_DOM nsresult NS_InitToolkitCoreClass(nsIScriptContext *aContext, void **aPrototype)
|
||||
{
|
||||
JSContext *jscontext = (JSContext *)aContext->GetNativeContext();
|
||||
JSObject *proto = nsnull;
|
||||
|
|
|
@ -127,6 +127,44 @@ nsToolkitCore::Init(const nsString& aId) {
|
|||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsToolkitCore::ShowDialog(const nsString& aUrl, nsIDOMWindow* aParent) {
|
||||
|
||||
nsresult rv;
|
||||
nsString controllerCID;
|
||||
nsIAppShellService *appShell;
|
||||
nsIWidget *window;
|
||||
|
||||
window = nsnull;
|
||||
|
||||
nsCOMPtr<nsIURL> urlObj;
|
||||
rv = NS_NewURL(getter_AddRefs(urlObj), aUrl);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
rv = nsServiceManager::GetService(kAppShellServiceCID, kIAppShellServiceIID,
|
||||
(nsISupports**) &appShell);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
// hardwired temporary hack. See nsAppRunner.cpp at main()
|
||||
controllerCID = "43147b80-8a39-11d2-9938-0080c7cb1081";
|
||||
|
||||
nsCOMPtr<nsIWebShellWindow> webWindow = DOMWindowToWebShellWindow(aParent);
|
||||
nsCOMPtr<nsIWidget> parent;
|
||||
if (webWindow)
|
||||
webWindow->GetWidget(*getter_AddRefs(parent));
|
||||
|
||||
appShell->CreateTopLevelWindow(parent, urlObj, controllerCID, window,
|
||||
nsnull, nsnull, 615, 650);
|
||||
nsServiceManager::ReleaseService(kAppShellServiceCID, appShell);
|
||||
|
||||
if (window != nsnull)
|
||||
window->Show(PR_TRUE);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsToolkitCore::ShowWindow(const nsString& aUrl, nsIDOMWindow* aParent) {
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче