static nsresult NSAPI nsInterfaceRequestor_GetInterface(nsIInterfaceRequestor *iface, nsIIDRef riid, nsQIResult result) { NSContainer *This = NSIFACEREQ_THIS(iface); if(IsEqualGUID(&IID_nsIDOMWindow, riid)) { TRACE("(%p)->(IID_nsIDOMWindow %p)\n", This, result); return nsIWebBrowser_GetContentDOMWindow(This->webbrowser, (nsIDOMWindow**)result); } return nsIWebBrowserChrome_QueryInterface(NSWBCHROME(This), riid, result); }
void init_nsevents(NSContainer *This) { nsIDOMWindow *dom_window; nsIDOMEventTarget *target; nsresult nsres; static const PRUnichar wsz_blur[] = {'b','l','u','r',0}; static const PRUnichar wsz_focus[] = {'f','o','c','u','s',0}; static const PRUnichar wsz_keypress[] = {'k','e','y','p','r','e','s','s',0}; static const PRUnichar wsz_load[] = {'l','o','a','d',0}; static const PRUnichar DOMNodeInsertedW[] = {'D','O','M','N','o','d','e','I','n','s','e','r','t','e','d',0}; init_listener(&This->blur_listener, This, &blur_vtbl); init_listener(&This->focus_listener, This, &focus_vtbl); init_listener(&This->keypress_listener, This, &keypress_vtbl); init_listener(&This->load_listener, This, &load_vtbl); init_listener(&This->node_insert_listener, This, &node_insert_vtbl); init_listener(&This->htmlevent_listener, This, &htmlevent_vtbl); nsres = nsIWebBrowser_GetContentDOMWindow(This->webbrowser, &dom_window); if(NS_FAILED(nsres)) { ERR("GetContentDOMWindow failed: %08x\n", nsres); return; } nsres = nsIDOMWindow_QueryInterface(dom_window, &IID_nsIDOMEventTarget, (void**)&target); nsIDOMWindow_Release(dom_window); if(NS_FAILED(nsres)) { ERR("Could not get nsIDOMEventTarget interface: %08x\n", nsres); return; } init_event(target, wsz_blur, NSEVENTLIST(&This->blur_listener), TRUE); init_event(target, wsz_focus, NSEVENTLIST(&This->focus_listener), TRUE); init_event(target, wsz_keypress, NSEVENTLIST(&This->keypress_listener), FALSE); init_event(target, wsz_load, NSEVENTLIST(&This->load_listener), TRUE); init_event(target, DOMNodeInsertedW,NSEVENTLIST(&This->node_insert_listener),TRUE); nsIDOMEventTarget_Release(target); }
void add_nsevent_listener(NSContainer *container, LPCWSTR type) { nsIDOMWindow *dom_window; nsIDOMEventTarget *target; nsresult nsres; nsres = nsIWebBrowser_GetContentDOMWindow(container->webbrowser, &dom_window); if(NS_FAILED(nsres)) { ERR("GetContentDOMWindow failed: %08x\n", nsres); return; } nsres = nsIDOMWindow_QueryInterface(dom_window, &IID_nsIDOMEventTarget, (void**)&target); nsIDOMWindow_Release(dom_window); if(NS_FAILED(nsres)) { ERR("Could not get nsIDOMEventTarget interface: %08x\n", nsres); return; } init_event(target, type, NSEVENTLIST(&container->htmlevent_listener), TRUE); nsIDOMEventTarget_Release(target); }