static nsresult NSAPI handle_load(nsIDOMEventListener *iface, nsIDOMEvent *event) { nsEventListener *This = impl_from_nsIDOMEventListener(iface); HTMLDocumentNode *doc = This->This->doc; HTMLDocumentObj *doc_obj = NULL; nsresult nsres = NS_OK; TRACE("(%p)\n", doc); if(!doc || !doc->basedoc.window) return NS_ERROR_FAILURE; if(doc->basedoc.doc_obj && doc->basedoc.doc_obj->basedoc.doc_node == doc) doc_obj = doc->basedoc.doc_obj; connect_scripts(doc->window); htmldoc_addref(&doc->basedoc); if(doc_obj) handle_docobj_load(doc_obj); set_ready_state(doc->basedoc.window, READYSTATE_COMPLETE); if(doc_obj) { if(doc_obj->view_sink) IAdviseSink_OnViewChange(doc_obj->view_sink, DVASPECT_CONTENT, -1); set_statustext(doc_obj, IDS_STATUS_DONE, NULL); update_title(doc_obj); } if(doc_obj && doc_obj->usermode!=EDITMODE && doc_obj->doc_object_service && !(doc->basedoc.window->load_flags & BINDING_REFRESH)) IDocObjectService_FireDocumentComplete(doc_obj->doc_object_service, &doc->basedoc.window->base.IHTMLWindow2_iface, 0); if(doc->nsdoc) { nsIDOMHTMLElement *nsbody; flush_pending_tasks(doc->basedoc.task_magic); nsres = nsIDOMHTMLDocument_GetBody(doc->nsdoc, &nsbody); if(NS_SUCCEEDED(nsres) && nsbody) { fire_event(doc, EVENTID_LOAD, TRUE, (nsIDOMNode*)nsbody, event, (IDispatch*)&doc->window->base.IDispatchEx_iface); nsIDOMHTMLElement_Release(nsbody); } }else { ERR("NULL nsdoc\n"); nsres = NS_ERROR_FAILURE; } htmldoc_release(&doc->basedoc); return nsres; }
static nsresult NSAPI handle_load(nsIDOMEventListener *iface, nsIDOMEvent *event) { HTMLDocumentNode *doc = NSEVENTLIST_THIS(iface)->This->doc; HTMLDocumentObj *doc_obj; nsIDOMHTMLElement *nsbody = NULL; TRACE("(%p)\n", doc); if(!doc || !doc->basedoc.window) return NS_ERROR_FAILURE; doc_obj = doc->basedoc.doc_obj; connect_scripts(doc->basedoc.window); if(doc_obj->nscontainer->editor_controller) { nsIController_Release(doc_obj->nscontainer->editor_controller); doc_obj->nscontainer->editor_controller = NULL; } if(doc_obj->usermode == EDITMODE) handle_edit_load(&doc_obj->basedoc); if(doc == doc_obj->basedoc.doc_node) handle_docobj_load(doc_obj); set_ready_state(doc->basedoc.window, READYSTATE_COMPLETE); if(doc == doc_obj->basedoc.doc_node) { if(doc_obj->view_sink) IAdviseSink_OnViewChange(doc_obj->view_sink, DVASPECT_CONTENT, -1); if(doc_obj->frame) { static const WCHAR wszDone[] = {'D','o','n','e',0}; IOleInPlaceFrame_SetStatusText(doc_obj->frame, wszDone); } update_title(doc_obj); } if(!doc->nsdoc) { ERR("NULL nsdoc\n"); return NS_ERROR_FAILURE; } nsIDOMHTMLDocument_GetBody(doc->nsdoc, &nsbody); if(nsbody) { fire_event(doc, EVENTID_LOAD, TRUE, (nsIDOMNode*)nsbody, event); nsIDOMHTMLElement_Release(nsbody); } return NS_OK; }
static nsresult NSAPI handle_load(nsIDOMEventListener *iface, nsIDOMEvent *event) { nsEventListener *This = impl_from_nsIDOMEventListener(iface); HTMLDocumentNode *doc = This->This->doc; nsIDOMHTMLElement *nsbody = NULL; HTMLDocumentObj *doc_obj = NULL; TRACE("(%p)\n", doc); if(!doc || !doc->basedoc.window) return NS_ERROR_FAILURE; if(doc->basedoc.doc_obj && doc->basedoc.doc_obj->basedoc.doc_node == doc) doc_obj = doc->basedoc.doc_obj; connect_scripts(doc->basedoc.window); if(doc_obj) handle_docobj_load(doc_obj); set_ready_state(doc->basedoc.window, READYSTATE_COMPLETE); if(doc_obj) { if(doc_obj->view_sink) IAdviseSink_OnViewChange(doc_obj->view_sink, DVASPECT_CONTENT, -1); set_statustext(doc_obj, IDS_STATUS_DONE, NULL); update_title(doc_obj); } if(doc_obj && doc_obj->doc_object_service) IDocObjectService_FireDocumentComplete(doc_obj->doc_object_service, &doc->basedoc.window->IHTMLWindow2_iface, 0); if(!doc->nsdoc) { ERR("NULL nsdoc\n"); return NS_ERROR_FAILURE; } nsIDOMHTMLDocument_GetBody(doc->nsdoc, &nsbody); if(nsbody) { fire_event(doc, EVENTID_LOAD, TRUE, (nsIDOMNode*)nsbody, event); nsIDOMHTMLElement_Release(nsbody); } return NS_OK; }
static nsresult run_end_load(HTMLDocumentNode *This, nsISupports *arg1, nsISupports *arg2) { TRACE("(%p)\n", This); if(!This->basedoc.doc_obj) return NS_OK; if(This == This->basedoc.doc_obj->basedoc.doc_node) { /* * This should be done in the worker thread that parses HTML, * but we don't have such thread (Gecko parses HTML for us). */ parse_complete(This->basedoc.doc_obj); } bind_event_scripts(This); set_ready_state(This->basedoc.window, READYSTATE_INTERACTIVE); return NS_OK; }
HRESULT set_moniker(HTMLOuterWindow *window, IMoniker *mon, IUri *nav_uri, IBindCtx *pibc, nsChannelBSC *async_bsc, BOOL set_download) { download_proc_task_t *download_task; HTMLDocumentObj *doc_obj = NULL; nsChannelBSC *bscallback; nsWineURI *nsuri; LPOLESTR url; IUri *uri; HRESULT hres; if(window->doc_obj && window->doc_obj->basedoc.window == window) doc_obj = window->doc_obj; hres = IMoniker_GetDisplayName(mon, pibc, NULL, &url); if(FAILED(hres)) { WARN("GetDiaplayName failed: %08x\n", hres); return hres; } if(nav_uri) { uri = nav_uri; }else { hres = create_uri(url, 0, &uri); if(FAILED(hres)) { CoTaskMemFree(url); return hres; } } TRACE("got url: %s\n", debugstr_w(url)); set_ready_state(window, READYSTATE_LOADING); hres = create_doc_uri(window, uri, &nsuri); if(!nav_uri) IUri_Release(uri); if(SUCCEEDED(hres)) { if(async_bsc) bscallback = async_bsc; else hres = create_channelbsc(mon, NULL, NULL, 0, TRUE, &bscallback); } if(SUCCEEDED(hres)) { if(window->base.inner_window->doc) remove_target_tasks(window->base.inner_window->task_magic); abort_window_bindings(window->base.inner_window); hres = load_nsuri(window, nsuri, bscallback, LOAD_FLAGS_BYPASS_CACHE); nsISupports_Release((nsISupports*)nsuri); /* FIXME */ if(SUCCEEDED(hres)) { hres = create_pending_window(window, bscallback); TRACE("pending window for %p %p %p\n", window, bscallback, window->pending_window); } if(bscallback != async_bsc) IBindStatusCallback_Release(&bscallback->bsc.IBindStatusCallback_iface); } if(FAILED(hres)) { CoTaskMemFree(url); return hres; } if(doc_obj) { HTMLDocument_LockContainer(doc_obj, TRUE); if(doc_obj->frame) { docobj_task_t *task; task = heap_alloc(sizeof(docobj_task_t)); task->doc = doc_obj; hres = push_task(&task->header, set_progress_proc, NULL, doc_obj->basedoc.task_magic); if(FAILED(hres)) { CoTaskMemFree(url); return hres; } } download_task = heap_alloc(sizeof(download_proc_task_t)); download_task->doc = doc_obj; download_task->set_download = set_download; download_task->url = url; return push_task(&download_task->header, set_downloading_proc, set_downloading_task_destr, doc_obj->basedoc.task_magic); } return S_OK; }
HRESULT set_moniker(HTMLDocument *This, IMoniker *mon, IBindCtx *pibc, nsChannelBSC *async_bsc, BOOL set_download) { nsChannelBSC *bscallback; docobj_task_t *task; download_proc_task_t *download_task; nsWineURI *nsuri; LPOLESTR url; HRESULT hres; hres = IMoniker_GetDisplayName(mon, pibc, NULL, &url); if(FAILED(hres)) { WARN("GetDiaplayName failed: %08x\n", hres); return hres; } TRACE("got url: %s\n", debugstr_w(url)); if(This->doc_obj->client) { VARIANT silent, offline; hres = get_client_disp_property(This->doc_obj->client, DISPID_AMBIENT_SILENT, &silent); if(SUCCEEDED(hres)) { if(V_VT(&silent) != VT_BOOL) WARN("V_VT(silent) = %d\n", V_VT(&silent)); else if(V_BOOL(&silent)) FIXME("silent == true\n"); } hres = get_client_disp_property(This->doc_obj->client, DISPID_AMBIENT_OFFLINEIFNOTCONNECTED, &offline); if(SUCCEEDED(hres)) { if(V_VT(&offline) != VT_BOOL) WARN("V_VT(offline) = %d\n", V_VT(&offline)); else if(V_BOOL(&offline)) FIXME("offline == true\n"); } } if(This->window->mon) { update_doc(This, UPDATE_TITLE|UPDATE_UI); }else { update_doc(This, UPDATE_TITLE); set_current_mon(This->window, mon); } set_ready_state(This->window, READYSTATE_LOADING); if(This->doc_obj->client) { IOleCommandTarget *cmdtrg = NULL; hres = IOleClientSite_QueryInterface(This->doc_obj->client, &IID_IOleCommandTarget, (void**)&cmdtrg); if(SUCCEEDED(hres)) { VARIANT var, out; if(!async_bsc) { V_VT(&var) = VT_I4; V_I4(&var) = 0; IOleCommandTarget_Exec(cmdtrg, &CGID_ShellDocView, 37, 0, &var, NULL); }else { V_VT(&var) = VT_UNKNOWN; V_UNKNOWN(&var) = (IUnknown*)&This->window->IHTMLWindow2_iface; V_VT(&out) = VT_EMPTY; hres = IOleCommandTarget_Exec(cmdtrg, &CGID_ShellDocView, 63, 0, &var, &out); if(SUCCEEDED(hres)) VariantClear(&out); } IOleCommandTarget_Release(cmdtrg); } } hres = create_doc_uri(This->window, url, &nsuri); if(SUCCEEDED(hres)) { if(async_bsc) { bscallback = async_bsc; }else { hres = create_channelbsc(mon, NULL, NULL, 0, &bscallback); } } if(SUCCEEDED(hres)) { remove_target_tasks(This->task_magic); abort_document_bindings(This->doc_node); hres = load_nsuri(This->window, nsuri, bscallback, LOAD_INITIAL_DOCUMENT_URI); nsISupports_Release((nsISupports*)nsuri); /* FIXME */ if(SUCCEEDED(hres)) set_window_bscallback(This->window, bscallback); if(bscallback != async_bsc) IUnknown_Release((IUnknown*)bscallback); } if(FAILED(hres)) { CoTaskMemFree(url); return hres; } HTMLDocument_LockContainer(This->doc_obj, TRUE); if(This->doc_obj->frame) { task = heap_alloc(sizeof(docobj_task_t)); task->doc = This->doc_obj; push_task(&task->header, set_progress_proc, This->doc_obj->basedoc.task_magic); } download_task = heap_alloc(sizeof(download_proc_task_t)); download_task->doc = This->doc_obj; download_task->set_download = set_download; download_task->url = url; push_task(&download_task->header, set_downloading_proc, This->doc_obj->basedoc.task_magic); return S_OK; }
HRESULT set_moniker(HTMLDocument *This, IMoniker *mon, IBindCtx *pibc, nsChannelBSC *async_bsc, BOOL set_download) { download_proc_task_t *download_task; nsChannelBSC *bscallback; nsWineURI *nsuri; LPOLESTR url; HRESULT hres; hres = IMoniker_GetDisplayName(mon, pibc, NULL, &url); if(FAILED(hres)) { WARN("GetDiaplayName failed: %08x\n", hres); return hres; } TRACE("got url: %s\n", debugstr_w(url)); set_ready_state(This->window, READYSTATE_LOADING); hres = create_doc_uri(This->window, url, &nsuri); if(SUCCEEDED(hres)) { if(async_bsc) bscallback = async_bsc; else hres = create_channelbsc(mon, NULL, NULL, 0, &bscallback); } if(SUCCEEDED(hres)) { remove_target_tasks(This->task_magic); abort_document_bindings(This->doc_node); hres = load_nsuri(This->window, nsuri, bscallback, 0/*LOAD_INITIAL_DOCUMENT_URI*/); nsISupports_Release((nsISupports*)nsuri); /* FIXME */ if(SUCCEEDED(hres)) set_window_bscallback(This->window, bscallback); if(bscallback != async_bsc) IUnknown_Release((IUnknown*)bscallback); } if(FAILED(hres)) { CoTaskMemFree(url); return hres; } HTMLDocument_LockContainer(This->doc_obj, TRUE); if(This->doc_obj->frame) { docobj_task_t *task; task = heap_alloc(sizeof(docobj_task_t)); task->doc = This->doc_obj; push_task(&task->header, set_progress_proc, NULL, This->doc_obj->basedoc.task_magic); } download_task = heap_alloc(sizeof(download_proc_task_t)); download_task->doc = This->doc_obj; download_task->set_download = set_download; download_task->url = url; push_task(&download_task->header, set_downloading_proc, set_downloading_task_destr, This->doc_obj->basedoc.task_magic); return S_OK; }