static HRESULT WINAPI HTMLDocument3_createTextNode(IHTMLDocument3 *iface, BSTR text, IHTMLDOMNode **newTextNode) { HTMLDocument *This = impl_from_IHTMLDocument3(iface); nsIDOMText *nstext; HTMLDOMNode *node; nsAString text_str; nsresult nsres; HRESULT hres; TRACE("(%p)->(%s %p)\n", This, debugstr_w(text), newTextNode); if(!This->doc_node->nsdoc) { WARN("NULL nsdoc\n"); return E_UNEXPECTED; } nsAString_InitDepend(&text_str, text); nsres = nsIDOMHTMLDocument_CreateTextNode(This->doc_node->nsdoc, &text_str, &nstext); nsAString_Finish(&text_str); if(NS_FAILED(nsres)) { ERR("CreateTextNode failed: %08x\n", nsres); return E_FAIL; } hres = HTMLDOMTextNode_Create(This->doc_node, (nsIDOMNode*)nstext, &node); nsIDOMText_Release(nstext); if(FAILED(hres)) return hres; *newTextNode = &node->IHTMLDOMNode_iface; return S_OK; }
static HRESULT WINAPI HTMLDocument3_getElementsByTagName(IHTMLDocument3 *iface, BSTR v, IHTMLElementCollection **pelColl) { HTMLDocument *This = impl_from_IHTMLDocument3(iface); nsIDOMNodeList *nslist; nsAString id_str; nsresult nsres; TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pelColl); if(!This->doc_node->nsdoc) { WARN("NULL nsdoc\n"); return E_UNEXPECTED; } nsAString_InitDepend(&id_str, v); nsres = nsIDOMHTMLDocument_GetElementsByTagName(This->doc_node->nsdoc, &id_str, &nslist); nsAString_Finish(&id_str); if(FAILED(nsres)) { ERR("GetElementByName failed: %08x\n", nsres); return E_FAIL; } *pelColl = create_collection_from_nodelist(This->doc_node, nslist); nsIDOMNodeList_Release(nslist); return S_OK; }
static HRESULT WINAPI HTMLDocument3_createDocumentFragment(IHTMLDocument3 *iface, IHTMLDocument2 **ppNewDoc) { HTMLDocument *This = impl_from_IHTMLDocument3(iface); nsIDOMDocumentFragment *doc_frag; HTMLDocumentNode *docnode; nsresult nsres; HRESULT hres; TRACE("(%p)->(%p)\n", This, ppNewDoc); if(!This->doc_node->nsdoc) { FIXME("NULL nsdoc\n"); return E_NOTIMPL; } nsres = nsIDOMHTMLDocument_CreateDocumentFragment(This->doc_node->nsdoc, &doc_frag); if(NS_FAILED(nsres)) { ERR("CreateDocumentFragment failed: %08x\n", nsres); return E_FAIL; } hres = create_document_fragment((nsIDOMNode*)doc_frag, This->doc_node, &docnode); nsIDOMDocumentFragment_Release(doc_frag); if(FAILED(hres)) return hres; *ppNewDoc = &docnode->basedoc.IHTMLDocument2_iface; return S_OK; }
static HRESULT WINAPI HTMLDocument3_get_enableDownload(IHTMLDocument3 *iface, VARIANT_BOOL *p) { HTMLDocument *This = impl_from_IHTMLDocument3(iface); FIXME("(%p)->(%p)\n", This, p); return E_NOTIMPL; }
static HRESULT WINAPI HTMLDocument3_get_parentDocument(IHTMLDocument3 *iface, IHTMLDocument2 **p) { HTMLDocument *This = impl_from_IHTMLDocument3(iface); FIXME("(%p)->(%p)\n", This, p); return E_NOTIMPL; }
static HRESULT WINAPI HTMLDocument3_get_inheritStyleSheets(IHTMLDocument3 *iface, VARIANT_BOOL *p) { HTMLDocument *This = impl_from_IHTMLDocument3(iface); FIXME("(%p)->(%p)\n", This, p); return E_NOTIMPL; }
static HRESULT WINAPI HTMLDocument3_getElementsByName(IHTMLDocument3 *iface, BSTR v, IHTMLElementCollection **ppelColl) { HTMLDocument *This = impl_from_IHTMLDocument3(iface); FIXME("(%p)->(%s %p)\n", This, debugstr_w(v), ppelColl); return E_NOTIMPL; }
static HRESULT WINAPI HTMLDocument3_get_oncontextmenu(IHTMLDocument3 *iface, VARIANT *p) { HTMLDocument *This = impl_from_IHTMLDocument3(iface); TRACE("(%p)->(%p)\n", This, p); return get_doc_event(This, EVENTID_CONTEXTMENU, p); }
static HRESULT WINAPI HTMLDocument3_Invoke(IHTMLDocument3 *iface, DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr) { HTMLDocument *This = impl_from_IHTMLDocument3(iface); return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr); }
static HRESULT WINAPI HTMLDocument3_GetIDsOfNames(IHTMLDocument3 *iface, REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId) { HTMLDocument *This = impl_from_IHTMLDocument3(iface); return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid, rgDispId); }
static HRESULT WINAPI HTMLDocument3_get_childNodes(IHTMLDocument3 *iface, IDispatch **p) { HTMLDocument *This = impl_from_IHTMLDocument3(iface); TRACE("(%p)->(%p)\n", This, p); return IHTMLDOMNode_get_childNodes(&This->doc_node->node.IHTMLDOMNode_iface, p); }
static HRESULT WINAPI HTMLDocument3_attachEvent(IHTMLDocument3 *iface, BSTR event, IDispatch* pDisp, VARIANT_BOOL *pfResult) { HTMLDocument *This = impl_from_IHTMLDocument3(iface); TRACE("(%p)->(%s %p %p)\n", This, debugstr_w(event), pDisp, pfResult); return attach_event(&This->doc_node->node.event_target, This->doc_node->node.nsnode, This, event, pDisp, pfResult); }
static HRESULT WINAPI HTMLDocument3_detachEvent(IHTMLDocument3 *iface, BSTR event, IDispatch *pDisp) { HTMLDocument *This = impl_from_IHTMLDocument3(iface); TRACE("(%p)->(%s %p)\n", This, debugstr_w(event), pDisp); return detach_event(This->doc_node->node.event_target, This, event, pDisp); }
static HRESULT WINAPI HTMLDocument3_getElementById(IHTMLDocument3 *iface, BSTR v, IHTMLElement **pel) { HTMLDocument *This = impl_from_IHTMLDocument3(iface); HTMLElement *elem; HRESULT hres; TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel); hres = get_doc_elem_by_id(This->doc_node, v, &elem); if(FAILED(hres) || !elem) { *pel = NULL; return hres; } *pel = &elem->IHTMLElement_iface; return S_OK; }
static HRESULT WINAPI HTMLDocument3_getElementsByName(IHTMLDocument3 *iface, BSTR v, IHTMLElementCollection **ppelColl) { HTMLDocument *This = impl_from_IHTMLDocument3(iface); nsIDOMNodeList *node_list; nsAString selector_str; WCHAR *selector; nsresult nsres; static const WCHAR formatW[] = {'*','[','i','d','=','%','s',']',',','*','[','n','a','m','e','=','%','s',']',0}; TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), ppelColl); if(!This->doc_node || !This->doc_node->nsdoc) { /* We should probably return an empty collection. */ FIXME("No nsdoc\n"); return E_NOTIMPL; } selector = heap_alloc(2*SysStringLen(v)*sizeof(WCHAR) + sizeof(formatW)); if(!selector) return E_OUTOFMEMORY; sprintfW(selector, formatW, v, v); /* * NOTE: IE getElementsByName implementation differs from Gecko. It searches both name and id attributes. * That's why we use CSS selector instead. We should also use name only when it applies to given element * types and search should be case insensitive. Those are currently not supported properly. */ nsAString_InitDepend(&selector_str, selector); nsres = nsIDOMNodeSelector_QuerySelectorAll(This->doc_node->nsnode_selector, &selector_str, &node_list); nsAString_Finish(&selector_str); heap_free(selector); if(NS_FAILED(nsres)) { ERR("QuerySelectorAll failed: %08x\n", nsres); return E_FAIL; } *ppelColl = create_collection_from_nodelist(This->doc_node, node_list); nsIDOMNodeList_Release(node_list); return S_OK; }
static HRESULT WINAPI HTMLDocument3_get_documentElement(IHTMLDocument3 *iface, IHTMLElement **p) { HTMLDocument *This = impl_from_IHTMLDocument3(iface); nsIDOMElement *nselem = NULL; HTMLDOMNode *node; nsresult nsres; HRESULT hres; TRACE("(%p)->(%p)\n", This, p); if(This->window->readystate == READYSTATE_UNINITIALIZED) { *p = NULL; return S_OK; } if(!This->doc_node->nsdoc) { WARN("NULL nsdoc\n"); return E_UNEXPECTED; } nsres = nsIDOMHTMLDocument_GetDocumentElement(This->doc_node->nsdoc, &nselem); if(NS_FAILED(nsres)) { ERR("GetDocumentElement failed: %08x\n", nsres); return E_FAIL; } if(!nselem) { *p = NULL; return S_OK; } hres = get_node(This->doc_node, (nsIDOMNode *)nselem, TRUE, &node); nsIDOMElement_Release(nselem); if(FAILED(hres)) return hres; hres = IHTMLDOMNode_QueryInterface(&node->IHTMLDOMNode_iface, &IID_IHTMLElement, (void**)p); node_release(node); return hres; }
static HRESULT WINAPI HTMLDocument3_getElementById(IHTMLDocument3 *iface, BSTR v, IHTMLElement **pel) { HTMLDocument *This = impl_from_IHTMLDocument3(iface); nsIDOMElement *nselem; HTMLDOMNode *node; nsIDOMNode *nsnode, *nsnode_by_id, *nsnode_by_name; nsIDOMNodeList *nsnode_list; nsAString id_str; nsresult nsres; HRESULT hres; TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel); if(!This->doc_node->nsdoc) { WARN("NULL nsdoc\n"); return E_UNEXPECTED; } nsAString_InitDepend(&id_str, v); /* get element by id attribute */ nsres = nsIDOMHTMLDocument_GetElementById(This->doc_node->nsdoc, &id_str, &nselem); if(FAILED(nsres)) { ERR("GetElementById failed: %08x\n", nsres); nsAString_Finish(&id_str); return E_FAIL; } nsnode_by_id = (nsIDOMNode*)nselem; /* get first element by name attribute */ nsres = nsIDOMHTMLDocument_GetElementsByName(This->doc_node->nsdoc, &id_str, &nsnode_list); nsAString_Finish(&id_str); if(FAILED(nsres)) { ERR("getElementsByName failed: %08x\n", nsres); if(nsnode_by_id) nsIDOMNode_Release(nsnode_by_id); return E_FAIL; } nsIDOMNodeList_Item(nsnode_list, 0, &nsnode_by_name); nsIDOMNodeList_Release(nsnode_list); if(nsnode_by_name && nsnode_by_id) { PRUint16 pos; nsres = nsIDOMNode_CompareDocumentPosition(nsnode_by_name, nsnode_by_id, &pos); if(NS_FAILED(nsres)) { FIXME("CompareDocumentPosition failed: 0x%08x\n", nsres); nsIDOMNode_Release(nsnode_by_name); nsIDOMNode_Release(nsnode_by_id); return E_FAIL; } TRACE("CompareDocumentPosition gave: 0x%x\n", pos); if(pos & (DOCUMENT_POSITION_PRECEDING | DOCUMENT_POSITION_CONTAINS)) { nsnode = nsnode_by_id; nsIDOMNode_Release(nsnode_by_name); }else { nsnode = nsnode_by_name; nsIDOMNode_Release(nsnode_by_id); } }else nsnode = nsnode_by_name ? nsnode_by_name : nsnode_by_id; if(nsnode) { hres = get_node(This->doc_node, nsnode, TRUE, &node); nsIDOMNode_Release(nsnode); if(SUCCEEDED(hres)) { hres = IHTMLDOMNode_QueryInterface(&node->IHTMLDOMNode_iface, &IID_IHTMLElement, (void**)pel); node_release(node); } }else { *pel = NULL; hres = S_OK; } return hres; }
static HRESULT WINAPI HTMLDocument3_get_onbeforeeditfocus(IHTMLDocument3 *iface, VARIANT *p) { HTMLDocument *This = impl_from_IHTMLDocument3(iface); FIXME("(%p)->(%p)\n", This, p); return E_NOTIMPL; }
static ULONG WINAPI HTMLDocument3_AddRef(IHTMLDocument3 *iface) { HTMLDocument *This = impl_from_IHTMLDocument3(iface); return htmldoc_addref(This); }
static ULONG WINAPI HTMLDocument3_Release(IHTMLDocument3 *iface) { HTMLDocument *This = impl_from_IHTMLDocument3(iface); return htmldoc_release(This); }
static HRESULT WINAPI HTMLDocument3_get_baseUrl(IHTMLDocument3 *iface, BSTR *p) { HTMLDocument *This = impl_from_IHTMLDocument3(iface); FIXME("(%p)->(%p)\n", This, p); return E_NOTIMPL; }
static HRESULT WINAPI HTMLDocument3_put_baseUrl(IHTMLDocument3 *iface, BSTR v) { HTMLDocument *This = impl_from_IHTMLDocument3(iface); FIXME("(%p)->(%s)\n", This, debugstr_w(v)); return E_NOTIMPL; }
static HRESULT WINAPI HTMLDocument3_GetTypeInfoCount(IHTMLDocument3 *iface, UINT *pctinfo) { HTMLDocument *This = impl_from_IHTMLDocument3(iface); return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo); }
static HRESULT WINAPI HTMLDocument3_GetTypeInfo(IHTMLDocument3 *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo) { HTMLDocument *This = impl_from_IHTMLDocument3(iface); return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo); }
static HRESULT WINAPI HTMLDocument3_releaseCapture(IHTMLDocument3 *iface) { HTMLDocument *This = impl_from_IHTMLDocument3(iface); FIXME("(%p)\n", This); return E_NOTIMPL; }
static HRESULT WINAPI HTMLDocument3_put_onstop(IHTMLDocument3 *iface, VARIANT v) { HTMLDocument *This = impl_from_IHTMLDocument3(iface); FIXME("(%p)->()\n", This); return E_NOTIMPL; }
static HRESULT WINAPI HTMLDocument3_recalc(IHTMLDocument3 *iface, VARIANT_BOOL fForce) { HTMLDocument *This = impl_from_IHTMLDocument3(iface); FIXME("(%p)->(%x)\n", This, fForce); return E_NOTIMPL; }
static HRESULT WINAPI HTMLDocument3_get_childNodes(IHTMLDocument3 *iface, IDispatch **p) { HTMLDocument *This = impl_from_IHTMLDocument3(iface); FIXME("(%p)->(%p)\n", This, p); return E_NOTIMPL; }
static HRESULT WINAPI HTMLDocument3_QueryInterface(IHTMLDocument3 *iface, REFIID riid, void **ppv) { HTMLDocument *This = impl_from_IHTMLDocument3(iface); return htmldoc_query_interface(This, riid, ppv); }
static HRESULT WINAPI HTMLDocument3_get_onpropertychange(IHTMLDocument3 *iface, VARIANT *p) { HTMLDocument *This = impl_from_IHTMLDocument3(iface); FIXME("(%p)->(%p)\n", This, p); return E_NOTIMPL; }