Commit 12f312da authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

mshtml: Added load event support.

parent 4c21a5d3
......@@ -86,6 +86,35 @@ void release_typelib(void)
ITypeLib_Release(typelib);
}
void call_disp_func(HTMLDocument *doc, IDispatch *disp)
{
DISPID named_arg = DISPID_THIS;
VARIANTARG arg;
DISPPARAMS params = {&arg, &named_arg, 1, 1};
EXCEPINFO ei;
IDispatchEx *dispex;
VARIANT res;
HRESULT hres;
hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex);
if(FAILED(hres)) {
FIXME("Could not get IDispatchEx interface: %08x\n", hres);
return;
}
V_VT(&arg) = VT_DISPATCH;
V_DISPATCH(&arg) = (IDispatch*)HTMLWINDOW2(doc->window);
VariantInit(&res);
memset(&ei, 0, sizeof(ei));
hres = IDispatchEx_InvokeEx(dispex, 0, GetUserDefaultLCID(), DISPATCH_METHOD, &params, &res, &ei, NULL);
IDispatchEx_Release(dispex);
TRACE("%p returned %08x\n", disp, hres);
VariantClear(&res);
}
#define DISPATCHEX_THIS(iface) DEFINE_THIS(DispatchEx, IDispatchEx, iface)
static HRESULT WINAPI DispatchEx_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv)
......
......@@ -1046,12 +1046,11 @@ void setup_nswindow(HTMLWindow *This)
HTMLWindow *HTMLWindow_Create(HTMLDocument *doc)
{
HTMLWindow *ret = heap_alloc(sizeof(HTMLWindow));
HTMLWindow *ret = heap_alloc_zero(sizeof(HTMLWindow));
ret->lpHTMLWindow2Vtbl = &HTMLWindow2Vtbl;
ret->lpHTMLWindow3Vtbl = &HTMLWindow3Vtbl;
ret->ref = 1;
ret->nswindow = NULL;
ret->doc = doc;
if(doc->nscontainer) {
......
......@@ -81,6 +81,8 @@ typedef struct {
HTMLDocument *doc;
nsIDOMWindow *nswindow;
IHTMLEventObj *event;
struct list entry;
} HTMLWindow;
......@@ -428,8 +430,14 @@ void get_editor_controller(NSContainer*);
void init_nsevents(NSContainer*);
nsresult get_nsinterface(nsISupports*,REFIID,void**);
typedef enum {
EVENTID_LOAD,
EVENTID_LAST
} eventid_t;
void check_event_attr(HTMLDocument*,nsIDOMElement*);
void release_event_target(event_target_t*);
void fire_event(HTMLDocument*,eventid_t,nsIDOMNode*);
void set_document_bscallback(HTMLDocument*,nsChannelBSC*);
void set_current_mon(HTMLDocument*,IMoniker*);
......@@ -540,6 +548,7 @@ void remove_doc_tasks(const HTMLDocument*);
HRESULT get_typeinfo(tid_t,ITypeInfo**);
void release_typelib(void);
void call_disp_func(HTMLDocument*,IDispatch*);
DEFINE_GUID(CLSID_AboutProtocol, 0x3050F406, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
DEFINE_GUID(CLSID_JSProtocol, 0x3050F3B2, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
......
......@@ -129,6 +129,9 @@ static nsresult NSAPI handle_keypress(nsIDOMEventListener *iface,
static nsresult NSAPI handle_load(nsIDOMEventListener *iface, nsIDOMEvent *event)
{
NSContainer *This = NSEVENTLIST_THIS(iface)->This;
nsIDOMHTMLDocument *nshtmldoc;
nsIDOMHTMLElement *nsbody = NULL;
nsIDOMDocument *nsdoc;
task_t *task;
TRACE("(%p)\n", This);
......@@ -159,6 +162,19 @@ static nsresult NSAPI handle_load(nsIDOMEventListener *iface, nsIDOMEvent *event
*/
push_task(task);
nsIWebNavigation_GetDocument(This->navigation, &nsdoc);
nsIDOMDocument_QueryInterface(nsdoc, &IID_nsIDOMHTMLDocument, (void**)&nshtmldoc);
nsIDOMDocument_Release(nsdoc);
nsIDOMHTMLDocument_GetBody(nshtmldoc, &nsbody);
nsIDOMHTMLDocument_Release(nshtmldoc);
if(nsbody) {
fire_event(This->doc, EVENTID_LOAD, (nsIDOMNode*)nsbody);
nsIDOMHTMLElement_Release(nsbody);
}
return NS_OK;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment