static HRESULT WINAPI HTMLDocument3_get_documentElement(IHTMLDocument3 *iface, IHTMLElement **p) { HTMLDocument *This = HTMLDOC3_THIS(iface); nsIDOMDocument *nsdoc; HTMLDOMNode *node; nsresult nsres; TRACE("(%p)->(%p)\n", This, p); if(!This->nscontainer) { *p = NULL; return S_OK; } nsres = nsIWebNavigation_GetDocument(This->nscontainer->navigation, &nsdoc); if(NS_FAILED(nsres)) ERR("GetDocument failed: %08lx\n", nsres); if(nsdoc) { node = get_node(This, (nsIDOMNode*)nsdoc); nsIDOMDocument_Release(nsdoc); IHTMLDOMNode_QueryInterface(HTMLDOMNODE(node), &IID_IHTMLElement, (void**)p); }else { *p = NULL; } return S_OK; }
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); if(!This->doc) return NS_OK; connect_scripts(This->doc); setup_nswindow(This->doc->window); if(This->editor_controller) { nsIController_Release(This->editor_controller); This->editor_controller = NULL; } if(This->doc->usermode == EDITMODE) handle_edit_load(This->doc); task = heap_alloc(sizeof(task_t)); task->doc = This->doc; task->task_id = TASK_PARSECOMPLETE; task->next = NULL; /* * This should be done in the worker thread that parses HTML, * but we don't have such thread (Gecko parses HTML for us). */ 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; }
static HRESULT HTMLIFrame_bind_to_tree(HTMLDOMNode *iface) { HTMLIFrame *This = impl_from_HTMLDOMNode(iface); nsIDOMDocument *nsdoc; nsresult nsres; HRESULT hres; nsres = nsIDOMHTMLIFrameElement_GetContentDocument(This->framebase.nsiframe, &nsdoc); if(NS_FAILED(nsres) || !nsdoc) { ERR("GetContentDocument failed: %08x\n", nsres); return E_FAIL; } hres = set_frame_doc(&This->framebase, nsdoc); nsIDOMDocument_Release(nsdoc); return hres; }