mshtml: Get rid of setup_nswindow.
It's no longer needed.
This commit is contained in:
parent
8162797af0
commit
27eb80cc3a
@ -1177,108 +1177,6 @@ static dispex_static_data_t HTMLWindow_dispex = {
|
||||
HTMLWindow_iface_tids
|
||||
};
|
||||
|
||||
static const char wineConfig_func[] =
|
||||
"window.__defineGetter__(\"external\",function() {\n"
|
||||
" return window.__wineWindow__.external;\n"
|
||||
"});\n"
|
||||
"window.__wineWindow__ = wineWindow;\n";
|
||||
|
||||
static void astr_to_nswstr(const char *str, nsAString *nsstr)
|
||||
{
|
||||
LPWSTR wstr;
|
||||
int len;
|
||||
|
||||
len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
|
||||
wstr = heap_alloc(len*sizeof(WCHAR));
|
||||
MultiByteToWideChar(CP_ACP, 0, str, -1, wstr, len);
|
||||
|
||||
nsAString_Init(nsstr, wstr);
|
||||
|
||||
heap_free(wstr);
|
||||
}
|
||||
|
||||
static nsresult call_js_func(nsIScriptContainer *script_container, nsISupports *target,
|
||||
const char *name, const char *body,
|
||||
PRUint32 argc, const char **arg_names, nsIArray *argv)
|
||||
{
|
||||
nsACString name_str;
|
||||
nsAString body_str;
|
||||
JSObject func_obj, jsglobal;
|
||||
nsIVariant *jsret;
|
||||
nsresult nsres;
|
||||
|
||||
nsres = nsIScriptContainer_GetGlobalObject(script_container, &jsglobal);
|
||||
if(NS_FAILED(nsres))
|
||||
ERR("GetGlobalObject: %08x\n", nsres);
|
||||
|
||||
nsACString_Init(&name_str, name);
|
||||
astr_to_nswstr(body, &body_str);
|
||||
|
||||
nsres = nsIScriptContainer_CompileFunction(script_container, jsglobal, &name_str, argc, arg_names,
|
||||
&body_str, NULL, 1, FALSE, &func_obj);
|
||||
|
||||
nsACString_Finish(&name_str);
|
||||
nsAString_Finish(&body_str);
|
||||
|
||||
if(NS_FAILED(nsres)) {
|
||||
ERR("CompileFunction failed: %08x\n", nsres);
|
||||
return nsres;
|
||||
}
|
||||
|
||||
nsres = nsIScriptContainer_CallFunction(script_container, target, jsglobal, func_obj, argv, &jsret);
|
||||
|
||||
nsIScriptContainer_DropScriptObject(script_container, func_obj);
|
||||
nsIScriptContainer_DropScriptObject(script_container, jsglobal);
|
||||
if(NS_FAILED(nsres)) {
|
||||
ERR("CallFunction failed: %08x\n", nsres);
|
||||
return nsres;
|
||||
}
|
||||
|
||||
nsIVariant_Release(jsret);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void setup_nswindow(HTMLWindow *This)
|
||||
{
|
||||
nsIScriptContainer *script_container;
|
||||
nsIDOMWindow *nswindow;
|
||||
nsIDOMDocument *domdoc;
|
||||
nsIWritableVariant *nsvar;
|
||||
nsIMutableArray *argv;
|
||||
nsresult nsres;
|
||||
|
||||
static const char *args[] = {"wineWindow"};
|
||||
|
||||
TRACE("(%p)\n", This);
|
||||
|
||||
nsIWebNavigation_GetDocument(This->doc->nscontainer->navigation, &domdoc);
|
||||
nsres = nsIDOMDocument_QueryInterface(domdoc, &IID_nsIScriptContainer, (void**)&script_container);
|
||||
nsIDOMDocument_Release(domdoc);
|
||||
if(NS_FAILED(nsres)) {
|
||||
TRACE("Could not get nsIDOMScriptContainer: %08x\n", nsres);
|
||||
return;
|
||||
}
|
||||
|
||||
nsIWebBrowser_GetContentDOMWindow(This->doc->nscontainer->webbrowser, &nswindow);
|
||||
|
||||
nsvar = create_nsvariant();
|
||||
nsres = nsIWritableVariant_SetAsInterface(nsvar, &IID_IDispatch, HTMLWINDOW2(This));
|
||||
if(NS_FAILED(nsres))
|
||||
ERR("SetAsInterface failed: %08x\n", nsres);
|
||||
|
||||
argv = create_nsarray();
|
||||
nsres = nsIMutableArray_AppendElement(argv, (nsISupports*)nsvar, FALSE);
|
||||
nsIWritableVariant_Release(nsvar);
|
||||
if(NS_FAILED(nsres))
|
||||
ERR("AppendElement failed: %08x\n", nsres);
|
||||
|
||||
call_js_func(script_container, (nsISupports*)nswindow/*HTMLWINDOW2(This)*/, "wineConfig",
|
||||
wineConfig_func, 1, args, (nsIArray*)argv);
|
||||
|
||||
nsIMutableArray_Release(argv);
|
||||
nsIScriptContainer_Release(script_container);
|
||||
}
|
||||
|
||||
HTMLWindow *HTMLWindow_Create(HTMLDocument *doc)
|
||||
{
|
||||
HTMLWindow *ret = heap_alloc_zero(sizeof(HTMLWindow));
|
||||
|
@ -467,7 +467,6 @@ HTMLWindow *nswindow_to_window(const nsIDOMWindow*);
|
||||
HTMLOptionElementFactory *HTMLOptionElementFactory_Create(HTMLDocument*);
|
||||
HTMLLocation *HTMLLocation_Create(HTMLDocument*);
|
||||
IOmNavigator *OmNavigator_Create(void);
|
||||
void setup_nswindow(HTMLWindow*);
|
||||
|
||||
void HTMLDocument_HTMLDocument3_Init(HTMLDocument*);
|
||||
void HTMLDocument_HTMLDocument5_Init(HTMLDocument*);
|
||||
|
@ -139,7 +139,6 @@ static nsresult NSAPI handle_load(nsIDOMEventListener *iface, nsIDOMEvent *event
|
||||
|
||||
update_nsdocument(This->doc);
|
||||
connect_scripts(This->doc);
|
||||
setup_nswindow(This->doc->window);
|
||||
|
||||
if(This->editor_controller) {
|
||||
nsIController_Release(This->editor_controller);
|
||||
|
Loading…
x
Reference in New Issue
Block a user