From: Gabriel Ivăncescu gabrielopcode@gmail.com
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/mshtml/editor.c | 13 +- dlls/mshtml/htmlbody.c | 6 +- dlls/mshtml/htmlcurstyle.c | 6 +- dlls/mshtml/htmldoc.c | 389 ++++++++++++++++++++++------------- dlls/mshtml/htmlelem.c | 44 ++-- dlls/mshtml/htmlevent.c | 6 +- dlls/mshtml/htmlselect.c | 6 +- dlls/mshtml/htmlwindow.c | 12 +- dlls/mshtml/mshtml_private.h | 9 +- dlls/mshtml/mutation.c | 10 +- dlls/mshtml/navigate.c | 2 +- dlls/mshtml/nsembed.c | 7 +- dlls/mshtml/nsevents.c | 6 +- dlls/mshtml/omnavigator.c | 9 +- dlls/mshtml/persist.c | 6 +- dlls/mshtml/range.c | 13 +- dlls/mshtml/script.c | 4 +- dlls/mshtml/selection.c | 11 +- 18 files changed, 330 insertions(+), 229 deletions(-)
diff --git a/dlls/mshtml/editor.c b/dlls/mshtml/editor.c index b176eb8763b..cadfadb826e 100644 --- a/dlls/mshtml/editor.c +++ b/dlls/mshtml/editor.c @@ -183,8 +183,13 @@ static DWORD query_align_status(HTMLDocumentNode *doc, const WCHAR *align) if(doc->browser->usermode != EDITMODE || doc->outer_window->readystate < READYSTATE_INTERACTIVE) return OLECMDF_SUPPORTED;
+ if(!doc->html_document) { + FIXME("Not implemented for XML document\n"); + return E_NOTIMPL; + } + nsAString_Init(&justify_str, align); - nsres = nsIDOMHTMLDocument_QueryCommandState(doc->nsdoc, &justify_str, &b); + nsres = nsIDOMHTMLDocument_QueryCommandState(doc->html_document, &justify_str, &b); nsAString_Finish(&justify_str); if(NS_SUCCEEDED(nsres) && b) ret |= OLECMDF_LATCHED; @@ -1081,8 +1086,8 @@ static HRESULT exec_hyperlink(HTMLDocumentNode *doc, DWORD cmdexecopt, VARIANT * return OLECMDERR_E_CANCELED; }
- if(!doc->nsdoc) { - WARN("NULL nsdoc\n"); + if(!doc->dom_document) { + WARN("NULL dom_document\n"); return E_UNEXPECTED; }
@@ -1105,7 +1110,7 @@ static HRESULT exec_hyperlink(HTMLDocumentNode *doc, DWORD cmdexecopt, VARIANT * nsIDOMNode *unused_node; nsIDOMText *text_node;
- nsIDOMHTMLDocument_CreateTextNode(doc->nsdoc, &ns_url, &text_node); + nsIDOMDocument_CreateTextNode(doc->dom_document, &ns_url, &text_node);
/* wrap the <a> tags around the text element */ nsIDOMElement_AppendChild(anchor_elem, (nsIDOMNode*)text_node, &unused_node); diff --git a/dlls/mshtml/htmlbody.c b/dlls/mshtml/htmlbody.c index 163099114c5..25cb9421cc3 100644 --- a/dlls/mshtml/htmlbody.c +++ b/dlls/mshtml/htmlbody.c @@ -669,12 +669,12 @@ static HRESULT WINAPI HTMLBodyElement_createTextRange(IHTMLBodyElement *iface, I
TRACE("(%p)->(%p)\n", This, range);
- if(!This->element.node.doc->nsdoc) { - WARN("No nsdoc\n"); + if(!This->element.node.doc->dom_document) { + WARN("No dom_document\n"); return E_UNEXPECTED; }
- nsres = nsIDOMHTMLDocument_CreateRange(This->element.node.doc->nsdoc, &nsrange); + nsres = nsIDOMDocument_CreateRange(This->element.node.doc->dom_document, &nsrange); if(NS_SUCCEEDED(nsres)) { nsres = nsIDOMRange_SelectNodeContents(nsrange, This->element.node.nsnode); if(NS_FAILED(nsres)) diff --git a/dlls/mshtml/htmlcurstyle.c b/dlls/mshtml/htmlcurstyle.c index 852b9059917..f38381e530f 100644 --- a/dlls/mshtml/htmlcurstyle.c +++ b/dlls/mshtml/htmlcurstyle.c @@ -1316,12 +1316,12 @@ HRESULT HTMLCurrentStyle_Create(HTMLElement *elem, IHTMLCurrentStyle **p) HTMLCurrentStyle *ret; nsresult nsres;
- if(!elem->node.doc->nsdoc) { - WARN("NULL nsdoc\n"); + if(!elem->node.doc->dom_document) { + WARN("NULL dom_document\n"); return E_UNEXPECTED; }
- nsres = nsIDOMHTMLDocument_GetDefaultView(elem->node.doc->nsdoc, &nsview); + nsres = nsIDOMDocument_GetDefaultView(elem->node.doc->dom_document, &nsview); if(NS_FAILED(nsres)) { ERR("GetDefaultView failed: %08lx\n", nsres); return E_FAIL; diff --git a/dlls/mshtml/htmldoc.c b/dlls/mshtml/htmldoc.c index 0988d34f85b..81960f53400 100644 --- a/dlls/mshtml/htmldoc.c +++ b/dlls/mshtml/htmldoc.c @@ -44,20 +44,20 @@ static HRESULT create_document_fragment(nsIDOMNode *nsnode, HTMLDocumentNode *do HRESULT get_doc_elem_by_id(HTMLDocumentNode *doc, const WCHAR *id, HTMLElement **ret) { nsIDOMNodeList *nsnode_list; + nsIDOMNode *nsnode = NULL; nsIDOMElement *nselem; - nsIDOMNode *nsnode; nsAString id_str; nsresult nsres; HRESULT hres;
- if(!doc->nsdoc) { - WARN("NULL nsdoc\n"); + if(!doc->dom_document) { + WARN("NULL dom_document\n"); return E_UNEXPECTED; }
nsAString_InitDepend(&id_str, id); /* get element by id attribute */ - nsres = nsIDOMHTMLDocument_GetElementById(doc->nsdoc, &id_str, &nselem); + nsres = nsIDOMDocument_GetElementById(doc->dom_document, &id_str, &nselem); if(FAILED(nsres)) { ERR("GetElementById failed: %08lx\n", nsres); nsAString_Finish(&id_str); @@ -65,18 +65,20 @@ HRESULT get_doc_elem_by_id(HTMLDocumentNode *doc, const WCHAR *id, HTMLElement * }
/* get first element by name attribute */ - nsres = nsIDOMHTMLDocument_GetElementsByName(doc->nsdoc, &id_str, &nsnode_list); - nsAString_Finish(&id_str); - if(FAILED(nsres)) { - ERR("getElementsByName failed: %08lx\n", nsres); - if(nselem) - nsIDOMElement_Release(nselem); - return E_FAIL; - } + if(doc->html_document) { + nsres = nsIDOMHTMLDocument_GetElementsByName(doc->html_document, &id_str, &nsnode_list); + nsAString_Finish(&id_str); + if(FAILED(nsres)) { + ERR("getElementsByName failed: %08lx\n", nsres); + if(nselem) + nsIDOMElement_Release(nselem); + return E_FAIL; + }
- nsres = nsIDOMNodeList_Item(nsnode_list, 0, &nsnode); - nsIDOMNodeList_Release(nsnode_list); - assert(nsres == NS_OK); + nsres = nsIDOMNodeList_Item(nsnode_list, 0, &nsnode); + nsIDOMNodeList_Release(nsnode_list); + assert(nsres == NS_OK); + }
if(nsnode && nselem) { UINT16 pos; @@ -124,7 +126,7 @@ UINT get_document_charset(HTMLDocumentNode *doc) return doc->charset;
nsAString_Init(&charset_str, NULL); - nsres = nsIDOMHTMLDocument_GetCharacterSet(doc->nsdoc, &charset_str); + nsres = nsIDOMDocument_GetCharacterSet(doc->dom_document, &charset_str); if(NS_SUCCEEDED(nsres)) { const PRUnichar *charset;
@@ -491,12 +493,12 @@ static HRESULT WINAPI HTMLDocument_get_all(IHTMLDocument2 *iface, IHTMLElementCo
TRACE("(%p)->(%p)\n", This, p);
- if(!This->nsdoc) { - WARN("NULL nsdoc\n"); + if(!This->dom_document) { + WARN("NULL dom_document\n"); return E_UNEXPECTED; }
- nsres = nsIDOMHTMLDocument_GetDocumentElement(This->nsdoc, &nselem); + nsres = nsIDOMDocument_GetDocumentElement(This->dom_document, &nselem); if(NS_FAILED(nsres)) { ERR("GetDocumentElement failed: %08lx\n", nsres); return E_FAIL; @@ -526,10 +528,10 @@ static HRESULT WINAPI HTMLDocument_get_body(IHTMLDocument2 *iface, IHTMLElement
TRACE("(%p)->(%p)\n", This, p);
- if(This->nsdoc) { + if(This->html_document) { nsresult nsres;
- nsres = nsIDOMHTMLDocument_GetBody(This->nsdoc, &nsbody); + nsres = nsIDOMHTMLDocument_GetBody(This->html_document, &nsbody); if(NS_FAILED(nsres)) { TRACE("Could not get body: %08lx\n", nsres); return E_UNEXPECTED; @@ -560,7 +562,7 @@ static HRESULT WINAPI HTMLDocument_get_activeElement(IHTMLDocument2 *iface, IHTM
TRACE("(%p)->(%p)\n", This, p);
- if(!This->nsdoc) { + if(!This->dom_document) { *p = NULL; return S_OK; } @@ -569,7 +571,7 @@ static HRESULT WINAPI HTMLDocument_get_activeElement(IHTMLDocument2 *iface, IHTM * NOTE: Gecko may return an active element even if the document is not visible. * IE returns NULL in this case. */ - nsres = nsIDOMHTMLDocument_GetActiveElement(This->nsdoc, &nselem); + nsres = nsIDOMDocument_GetActiveElement(This->dom_document, &nselem); if(NS_FAILED(nsres)) { ERR("GetActiveElement failed: %08lx\n", nsres); return E_FAIL; @@ -602,12 +604,17 @@ static HRESULT WINAPI HTMLDocument_get_images(IHTMLDocument2 *iface, IHTMLElemen
*p = NULL;
- if(!This->nsdoc) { - WARN("NULL nsdoc\n"); + if(!This->dom_document) { + WARN("NULL dom_document\n"); return E_UNEXPECTED; }
- nsres = nsIDOMHTMLDocument_GetImages(This->nsdoc, &nscoll); + if(!This->html_document) { + FIXME("Not implemented for XML document\n"); + return E_NOTIMPL; + } + + nsres = nsIDOMHTMLDocument_GetImages(This->html_document, &nscoll); if(NS_FAILED(nsres)) { ERR("GetImages failed: %08lx\n", nsres); return E_FAIL; @@ -634,12 +641,17 @@ static HRESULT WINAPI HTMLDocument_get_applets(IHTMLDocument2 *iface, IHTMLEleme
*p = NULL;
- if(!This->nsdoc) { - WARN("NULL nsdoc\n"); + if(!This->dom_document) { + WARN("NULL dom_document\n"); return E_UNEXPECTED; }
- nsres = nsIDOMHTMLDocument_GetApplets(This->nsdoc, &nscoll); + if(!This->html_document) { + FIXME("Not implemented for XML document\n"); + return E_NOTIMPL; + } + + nsres = nsIDOMHTMLDocument_GetApplets(This->html_document, &nscoll); if(NS_FAILED(nsres)) { ERR("GetApplets failed: %08lx\n", nsres); return E_FAIL; @@ -666,12 +678,17 @@ static HRESULT WINAPI HTMLDocument_get_links(IHTMLDocument2 *iface, IHTMLElement
*p = NULL;
- if(!This->nsdoc) { - WARN("NULL nsdoc\n"); + if(!This->dom_document) { + WARN("NULL dom_document\n"); return E_UNEXPECTED; }
- nsres = nsIDOMHTMLDocument_GetLinks(This->nsdoc, &nscoll); + if(!This->html_document) { + FIXME("Not implemented for XML document\n"); + return E_NOTIMPL; + } + + nsres = nsIDOMHTMLDocument_GetLinks(This->html_document, &nscoll); if(NS_FAILED(nsres)) { ERR("GetLinks failed: %08lx\n", nsres); return E_FAIL; @@ -698,12 +715,17 @@ static HRESULT WINAPI HTMLDocument_get_forms(IHTMLDocument2 *iface, IHTMLElement
*p = NULL;
- if(!This->nsdoc) { - WARN("NULL nsdoc\n"); + if(!This->dom_document) { + WARN("NULL dom_document\n"); return E_UNEXPECTED; }
- nsres = nsIDOMHTMLDocument_GetForms(This->nsdoc, &nscoll); + if(!This->html_document) { + FIXME("Not implemented for XML document\n"); + return E_NOTIMPL; + } + + nsres = nsIDOMHTMLDocument_GetForms(This->html_document, &nscoll); if(NS_FAILED(nsres)) { ERR("GetForms failed: %08lx\n", nsres); return E_FAIL; @@ -730,12 +752,17 @@ static HRESULT WINAPI HTMLDocument_get_anchors(IHTMLDocument2 *iface, IHTMLEleme
*p = NULL;
- if(!This->nsdoc) { - WARN("NULL nsdoc\n"); + if(!This->dom_document) { + WARN("NULL dom_document\n"); return E_UNEXPECTED; }
- nsres = nsIDOMHTMLDocument_GetAnchors(This->nsdoc, &nscoll); + if(!This->html_document) { + FIXME("Not implemented for XML document\n"); + return E_NOTIMPL; + } + + nsres = nsIDOMHTMLDocument_GetAnchors(This->html_document, &nscoll); if(NS_FAILED(nsres)) { ERR("GetAnchors failed: %08lx\n", nsres); return E_FAIL; @@ -757,13 +784,13 @@ static HRESULT WINAPI HTMLDocument_put_title(IHTMLDocument2 *iface, BSTR v)
TRACE("(%p)->(%s)\n", This, debugstr_w(v));
- if(!This->nsdoc) { - WARN("NULL nsdoc\n"); + if(!This->dom_document) { + WARN("NULL dom_document\n"); return E_UNEXPECTED; }
nsAString_InitDepend(&nsstr, v); - nsres = nsIDOMHTMLDocument_SetTitle(This->nsdoc, &nsstr); + nsres = nsIDOMDocument_SetTitle(This->dom_document, &nsstr); nsAString_Finish(&nsstr); if(NS_FAILED(nsres)) ERR("SetTitle failed: %08lx\n", nsres); @@ -780,14 +807,14 @@ static HRESULT WINAPI HTMLDocument_get_title(IHTMLDocument2 *iface, BSTR *p)
TRACE("(%p)->(%p)\n", This, p);
- if(!This->nsdoc) { - WARN("NULL nsdoc\n"); + if(!This->dom_document) { + WARN("NULL dom_document\n"); return E_UNEXPECTED; }
nsAString_Init(&nsstr, NULL); - nsres = nsIDOMHTMLDocument_GetTitle(This->nsdoc, &nsstr); + nsres = nsIDOMDocument_GetTitle(This->dom_document, &nsstr); if (NS_SUCCEEDED(nsres)) { nsAString_GetData(&nsstr, &ret); *p = SysAllocString(ret); @@ -815,12 +842,17 @@ static HRESULT WINAPI HTMLDocument_get_scripts(IHTMLDocument2 *iface, IHTMLEleme
*p = NULL;
- if(!This->nsdoc) { - WARN("NULL nsdoc\n"); + if(!This->dom_document) { + WARN("NULL dom_document\n"); return E_UNEXPECTED; }
- nsres = nsIDOMHTMLDocument_GetScripts(This->nsdoc, &nscoll); + if(!This->html_document) { + FIXME("Not implemented for XML document\n"); + return E_NOTIMPL; + } + + nsres = nsIDOMHTMLDocument_GetScripts(This->html_document, &nscoll); if(NS_FAILED(nsres)) { ERR("GetImages failed: %08lx\n", nsres); return E_FAIL; @@ -875,7 +907,12 @@ static HRESULT WINAPI HTMLDocument_get_selection(IHTMLDocument2 *iface, IHTMLSel
TRACE("(%p)->(%p)\n", This, p);
- nsres = nsIDOMHTMLDocument_GetSelection(This->nsdoc, &nsselection); + if(!This->html_document) { + FIXME("Not implemented for XML document\n"); + return E_NOTIMPL; + } + + nsres = nsIDOMHTMLDocument_GetSelection(This->html_document, &nsselection); if(NS_FAILED(nsres)) { ERR("GetSelection failed: %08lx\n", nsres); return E_FAIL; @@ -979,13 +1016,18 @@ static HRESULT WINAPI HTMLDocument_get_bgColor(IHTMLDocument2 *iface, VARIANT *p
TRACE("(%p)->(%p)\n", This, p);
- if(!This->nsdoc) { - WARN("NULL nsdoc\n"); + if(!This->dom_document) { + WARN("NULL dom_document\n"); return E_UNEXPECTED; }
+ if(!This->html_document) { + FIXME("Not implemented for XML document\n"); + return E_NOTIMPL; + } + nsAString_Init(&nsstr, NULL); - nsres = nsIDOMHTMLDocument_GetBgColor(This->nsdoc, &nsstr); + nsres = nsIDOMHTMLDocument_GetBgColor(This->html_document, &nsstr); hres = return_nsstr_variant(nsres, &nsstr, NSSTR_COLOR, p); if(hres == S_OK && V_VT(p) == VT_BSTR && !V_BSTR(p)) { TRACE("default #ffffff\n"); @@ -1046,7 +1088,7 @@ static HRESULT WINAPI HTMLDocument_get_referrer(IHTMLDocument2 *iface, BSTR *p) TRACE("(%p)->(%p)\n", This, p);
nsAString_InitDepend(&nsstr, NULL); - nsres = nsIDOMHTMLDocument_GetReferrer(This->nsdoc, &nsstr); + nsres = nsIDOMDocument_GetReferrer(This->dom_document, &nsstr); return return_nsstr(nsres, &nsstr, p); }
@@ -1056,7 +1098,7 @@ static HRESULT WINAPI HTMLDocument_get_location(IHTMLDocument2 *iface, IHTMLLoca
TRACE("(%p)->(%p)\n", This, p);
- if(!This->nsdoc || !This->window) { + if(!This->dom_document || !This->window) { WARN("NULL window\n"); return E_UNEXPECTED; } @@ -1103,8 +1145,13 @@ static HRESULT WINAPI HTMLDocument_put_domain(IHTMLDocument2 *iface, BSTR v)
TRACE("(%p)->(%s)\n", This, debugstr_w(v));
+ if(!This->html_document) { + FIXME("Not implemented for XML document\n"); + return E_NOTIMPL; + } + nsAString_InitDepend(&nsstr, v); - nsres = nsIDOMHTMLDocument_SetDomain(This->nsdoc, &nsstr); + nsres = nsIDOMHTMLDocument_SetDomain(This->html_document, &nsstr); nsAString_Finish(&nsstr); if(NS_FAILED(nsres)) { ERR("SetDomain failed: %08lx\n", nsres); @@ -1122,8 +1169,13 @@ static HRESULT WINAPI HTMLDocument_get_domain(IHTMLDocument2 *iface, BSTR *p)
TRACE("(%p)->(%p)\n", This, p);
+ if(!This->html_document) { + FIXME("Not implemented for XML document\n"); + return E_NOTIMPL; + } + nsAString_Init(&nsstr, NULL); - nsres = nsIDOMHTMLDocument_GetDomain(This->nsdoc, &nsstr); + nsres = nsIDOMHTMLDocument_GetDomain(This->html_document, &nsstr); if(NS_SUCCEEDED(nsres) && This->outer_window && This->outer_window->uri) { const PRUnichar *str; HRESULT hres; @@ -1261,7 +1313,7 @@ static HRESULT WINAPI HTMLDocument_get_mimeType(IHTMLDocument2 *iface, BSTR *p) return (*p = SysAllocString(L"")) ? S_OK : E_FAIL;
nsAString_InitDepend(&nsstr, NULL); - nsres = nsIDOMHTMLDocument_GetContentType(This->nsdoc, &nsstr); + nsres = nsIDOMDocument_GetContentType(This->dom_document, &nsstr); if(NS_FAILED(nsres)) return map_nsresult(nsres);
@@ -1329,11 +1381,16 @@ static HRESULT document_write(HTMLDocumentNode *This, SAFEARRAY *psarray, BOOL l nsresult nsres; HRESULT hres;
- if(!This->nsdoc) { - WARN("NULL nsdoc\n"); + if(!This->dom_document) { + WARN("NULL dom_document\n"); return E_UNEXPECTED; }
+ if(!This->html_document) { + FIXME("Not implemented for XML document\n"); + return E_NOTIMPL; + } + if (!psarray) return S_OK;
@@ -1350,7 +1407,7 @@ static HRESULT document_write(HTMLDocumentNode *This, SAFEARRAY *psarray, BOOL l
V_VT(&tmp) = VT_EMPTY;
- jsctx = get_context_from_document(This->nsdoc); + jsctx = get_context_from_document(This->dom_document); argc = psarray->rgsabound[0].cElements; for(i=0; i < argc; i++) { if(V_VT(var+i) == VT_BSTR) { @@ -1365,9 +1422,9 @@ static HRESULT document_write(HTMLDocumentNode *This, SAFEARRAY *psarray, BOOL l }
if(!ln || i != argc-1) - nsres = nsIDOMHTMLDocument_Write(This->nsdoc, &nsstr, jsctx); + nsres = nsIDOMHTMLDocument_Write(This->html_document, &nsstr, jsctx); else - nsres = nsIDOMHTMLDocument_Writeln(This->nsdoc, &nsstr, jsctx); + nsres = nsIDOMHTMLDocument_Writeln(This->html_document, &nsstr, jsctx); nsAString_Finish(&nsstr); if(V_VT(var+i) != VT_BSTR) VariantClear(&tmp); @@ -1416,8 +1473,13 @@ static HRESULT WINAPI HTMLDocument_open(IHTMLDocument2 *iface, BSTR url, VARIANT if(!This->outer_window) return E_FAIL;
- if(!This->nsdoc) { - ERR("!nsdoc\n"); + if(!This->dom_document) { + ERR("!dom_document\n"); + return E_NOTIMPL; + } + + if(!This->html_document) { + FIXME("Not implemented for XML document\n"); return E_NOTIMPL; }
@@ -1425,8 +1487,8 @@ static HRESULT WINAPI HTMLDocument_open(IHTMLDocument2 *iface, BSTR url, VARIANT || V_VT(&features) != VT_ERROR || V_VT(&replace) != VT_ERROR) FIXME("unsupported args\n");
- nsres = nsIDOMHTMLDocument_Open(This->nsdoc, NULL, NULL, NULL, - get_context_from_document(This->nsdoc), 0, &tmp); + nsres = nsIDOMHTMLDocument_Open(This->html_document, NULL, NULL, NULL, + get_context_from_document(This->dom_document), 0, &tmp); if(NS_FAILED(nsres)) { ERR("Open failed: %08lx\n", nsres); return E_FAIL; @@ -1447,12 +1509,17 @@ static HRESULT WINAPI HTMLDocument_close(IHTMLDocument2 *iface)
TRACE("(%p)\n", This);
- if(!This->nsdoc) { - ERR("!nsdoc\n"); + if(!This->dom_document) { + ERR("!dom_document\n"); return E_NOTIMPL; }
- nsres = nsIDOMHTMLDocument_Close(This->nsdoc); + if(!This->html_document) { + FIXME("Not implemented for XML document\n"); + return E_NOTIMPL; + } + + nsres = nsIDOMHTMLDocument_Close(This->html_document); if(NS_FAILED(nsres)) { ERR("Close failed: %08lx\n", nsres); return E_FAIL; @@ -1468,7 +1535,12 @@ static HRESULT WINAPI HTMLDocument_clear(IHTMLDocument2 *iface)
TRACE("(%p)\n", This);
- nsres = nsIDOMHTMLDocument_Clear(This->nsdoc); + if(!This->html_document) { + FIXME("Not implemented for XML document\n"); + return E_NOTIMPL; + } + + nsres = nsIDOMHTMLDocument_Clear(This->html_document); if(NS_FAILED(nsres)) { ERR("Clear failed: %08lx\n", nsres); return E_FAIL; @@ -1910,7 +1982,7 @@ static HRESULT WINAPI HTMLDocument_elementFromPoint(IHTMLDocument2 *iface, LONG
TRACE("(%p)->(%ld %ld %p)\n", This, x, y, elementHit);
- nsres = nsIDOMHTMLDocument_ElementFromPoint(This->nsdoc, x, y, &nselem); + nsres = nsIDOMDocument_ElementFromPoint(This->dom_document, x, y, &nselem); if(NS_FAILED(nsres)) { ERR("ElementFromPoint failed: %08lx\n", nsres); return E_FAIL; @@ -1953,12 +2025,12 @@ static HRESULT WINAPI HTMLDocument_get_styleSheets(IHTMLDocument2 *iface,
*p = NULL;
- if(!This->nsdoc) { - WARN("NULL nsdoc\n"); + if(!This->dom_document) { + WARN("NULL dom_document\n"); return E_UNEXPECTED; }
- nsres = nsIDOMHTMLDocument_GetStyleSheets(This->nsdoc, &nsstylelist); + nsres = nsIDOMDocument_GetStyleSheets(This->dom_document, &nsstylelist); if(NS_FAILED(nsres)) { ERR("GetStyleSheets failed: %08lx\n", nsres); return map_nsresult(nsres); @@ -2019,11 +2091,16 @@ static HRESULT WINAPI HTMLDocument_createStyleSheet(IHTMLDocument2 *iface, BSTR
TRACE("(%p)->(%s %ld %p)\n", This, debugstr_w(bstrHref), lIndex, ppnewStyleSheet);
- if(!This->nsdoc) { + if(!This->dom_document) { FIXME("not a real doc object\n"); return E_NOTIMPL; }
+ if(!This->html_document) { + FIXME("Not implemented for XML document\n"); + return E_NOTIMPL; + } + if(lIndex != -1) FIXME("Unsupported lIndex %ld\n", lIndex);
@@ -2037,7 +2114,7 @@ static HRESULT WINAPI HTMLDocument_createStyleSheet(IHTMLDocument2 *iface, BSTR if(FAILED(hres)) return hres;
- nsres = nsIDOMHTMLDocument_GetHead(This->nsdoc, &head_elem); + nsres = nsIDOMHTMLDocument_GetHead(This->html_document, &head_elem); if(NS_SUCCEEDED(nsres)) { nsIDOMNode *head_node, *tmp_node;
@@ -2262,13 +2339,13 @@ static HRESULT WINAPI HTMLDocument3_createTextNode(IHTMLDocument3 *iface, BSTR t
TRACE("(%p)->(%s %p)\n", This, debugstr_w(text), newTextNode);
- if(!This->nsdoc) { - WARN("NULL nsdoc\n"); + if(!This->dom_document) { + WARN("NULL dom_document\n"); return E_UNEXPECTED; }
nsAString_InitDepend(&text_str, text); - nsres = nsIDOMHTMLDocument_CreateTextNode(This->nsdoc, &text_str, &nstext); + nsres = nsIDOMDocument_CreateTextNode(This->dom_document, &text_str, &nstext); nsAString_Finish(&text_str); if(NS_FAILED(nsres)) { ERR("CreateTextNode failed: %08lx\n", nsres); @@ -2299,12 +2376,12 @@ static HRESULT WINAPI HTMLDocument3_get_documentElement(IHTMLDocument3 *iface, I return S_OK; }
- if(!This->nsdoc) { - WARN("NULL nsdoc\n"); + if(!This->dom_document) { + WARN("NULL dom_document\n"); return E_UNEXPECTED; }
- nsres = nsIDOMHTMLDocument_GetDocumentElement(This->nsdoc, &nselem); + nsres = nsIDOMDocument_GetDocumentElement(This->dom_document, &nselem); if(NS_FAILED(nsres)) { ERR("GetDocumentElement failed: %08lx\n", nsres); return E_FAIL; @@ -2458,13 +2535,13 @@ static HRESULT WINAPI HTMLDocument3_put_dir(IHTMLDocument3 *iface, BSTR v)
TRACE("(%p)->(%s)\n", This, debugstr_w(v));
- if(!This->nsdoc) { - FIXME("NULL nsdoc\n"); + if(!This->dom_document) { + FIXME("NULL dom_document\n"); return E_UNEXPECTED; }
nsAString_InitDepend(&dir_str, v); - nsres = nsIDOMHTMLDocument_SetDir(This->nsdoc, &dir_str); + nsres = nsIDOMDocument_SetDir(This->dom_document, &dir_str); nsAString_Finish(&dir_str); if(NS_FAILED(nsres)) { ERR("SetDir failed: %08lx\n", nsres); @@ -2482,13 +2559,13 @@ static HRESULT WINAPI HTMLDocument3_get_dir(IHTMLDocument3 *iface, BSTR *p)
TRACE("(%p)->(%p)\n", This, p);
- if(!This->nsdoc) { - FIXME("NULL nsdoc\n"); + if(!This->dom_document) { + FIXME("NULL dom_document\n"); return E_UNEXPECTED; }
nsAString_Init(&dir_str, NULL); - nsres = nsIDOMHTMLDocument_GetDir(This->nsdoc, &dir_str); + nsres = nsIDOMDocument_GetDir(This->dom_document, &dir_str); return return_nsstr(nsres, &dir_str, p); }
@@ -2534,12 +2611,12 @@ static HRESULT WINAPI HTMLDocument3_createDocumentFragment(IHTMLDocument3 *iface
TRACE("(%p)->(%p)\n", This, ppNewDoc);
- if(!This->nsdoc) { - FIXME("NULL nsdoc\n"); + if(!This->dom_document) { + FIXME("NULL dom_document\n"); return E_NOTIMPL; }
- nsres = nsIDOMHTMLDocument_CreateDocumentFragment(This->nsdoc, &doc_frag); + nsres = nsIDOMDocument_CreateDocumentFragment(This->dom_document, &doc_frag); if(NS_FAILED(nsres)) { ERR("CreateDocumentFragment failed: %08lx\n", nsres); return E_FAIL; @@ -2638,9 +2715,9 @@ static HRESULT WINAPI HTMLDocument3_getElementsByName(IHTMLDocument3 *iface, BST
TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), ppelColl);
- if(!This->nsdoc) { + if(!This->dom_document) { /* We should probably return an empty collection. */ - FIXME("No nsdoc\n"); + FIXME("No dom_document\n"); return E_NOTIMPL; }
@@ -2655,7 +2732,7 @@ static HRESULT WINAPI HTMLDocument3_getElementsByName(IHTMLDocument3 *iface, BST * types and search should be case insensitive. Those are currently not supported properly. */ nsAString_InitDepend(&selector_str, selector); - nsres = nsIDOMHTMLDocument_QuerySelectorAll(This->nsdoc, &selector_str, &node_list); + nsres = nsIDOMDocument_QuerySelectorAll(This->dom_document, &selector_str, &node_list); nsAString_Finish(&selector_str); heap_free(selector); if(NS_FAILED(nsres)) { @@ -2698,9 +2775,9 @@ static HRESULT WINAPI HTMLDocument3_getElementsByTagName(IHTMLDocument3 *iface,
TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pelColl);
- if(This->nsdoc) { + if(This->dom_document) { nsAString_InitDepend(&id_str, v); - nsres = nsIDOMHTMLDocument_GetElementsByTagName(This->nsdoc, &id_str, &nslist); + nsres = nsIDOMDocument_GetElementsByTagName(This->dom_document, &id_str, &nslist); nsAString_Finish(&id_str); if(FAILED(nsres)) { ERR("GetElementByName failed: %08lx\n", nsres); @@ -2853,7 +2930,12 @@ static HRESULT WINAPI HTMLDocument4_focus(IHTMLDocument4 *iface)
TRACE("(%p)->()\n", This);
- nsres = nsIDOMHTMLDocument_GetBody(This->nsdoc, &nsbody); + if(!This->html_document) { + FIXME("Not implemented for XML document\n"); + return E_NOTIMPL; + } + + nsres = nsIDOMHTMLDocument_GetBody(This->html_document, &nsbody); if(NS_FAILED(nsres) || !nsbody) { ERR("GetBody failed: %08lx\n", nsres); return E_FAIL; @@ -2877,12 +2959,12 @@ static HRESULT WINAPI HTMLDocument4_hasFocus(IHTMLDocument4 *iface, VARIANT_BOOL
TRACE("(%p)->(%p)\n", This, pfFocus);
- if(!This->nsdoc) { + if(!This->dom_document) { FIXME("Unimplemented for fragments.\n"); return E_NOTIMPL; }
- nsres = nsIDOMHTMLDocument_HasFocus(This->nsdoc, &has_focus); + nsres = nsIDOMDocument_HasFocus(This->dom_document, &has_focus); assert(nsres == NS_OK);
*pfFocus = variant_bool(has_focus); @@ -3111,7 +3193,7 @@ static HRESULT WINAPI HTMLDocument5_get_doctype(IHTMLDocument5 *iface, IHTMLDOMN return S_OK; }
- nsres = nsIDOMHTMLDocument_GetDoctype(This->nsdoc, &nsdoctype); + nsres = nsIDOMDocument_GetDoctype(This->dom_document, &nsdoctype); if(NS_FAILED(nsres)) return map_nsresult(nsres); if(!nsdoctype) { @@ -3175,13 +3257,13 @@ static HRESULT WINAPI HTMLDocument5_createComment(IHTMLDocument5 *iface, BSTR bs
TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrdata), ppRetNode);
- if(!This->nsdoc) { - WARN("NULL nsdoc\n"); + if(!This->dom_document) { + WARN("NULL dom_document\n"); return E_UNEXPECTED; }
nsAString_InitDepend(&str, bstrdata); - nsres = nsIDOMHTMLDocument_CreateComment(This->nsdoc, &str, &nscomment); + nsres = nsIDOMDocument_CreateComment(This->dom_document, &str, &nscomment); nsAString_Finish(&str); if(NS_FAILED(nsres)) { ERR("CreateTextNode failed: %08lx\n", nsres); @@ -3453,13 +3535,13 @@ static HRESULT WINAPI HTMLDocument6_getElementById(IHTMLDocument6 *iface, * not search for name attributes, so we may simply let Gecko do the right thing. */
- if(!This->nsdoc) { + if(!This->dom_document) { FIXME("Not a document\n"); return E_FAIL; }
nsAString_InitDepend(&nsstr, bstrId); - nsres = nsIDOMHTMLDocument_GetElementById(This->nsdoc, &nsstr, &nselem); + nsres = nsIDOMDocument_GetElementById(This->dom_document, &nsstr, &nselem); nsAString_Finish(&nsstr); if(NS_FAILED(nsres)) { ERR("GetElementById failed: %08lx\n", nsres); @@ -3604,8 +3686,8 @@ static HRESULT WINAPI HTMLDocument7_createElementNS(IHTMLDocument7 *iface, VARIA
TRACE("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(bstrTag), newElem);
- if(!This->nsdoc) { - FIXME("NULL nsdoc\n"); + if(!This->dom_document) { + FIXME("NULL dom_document\n"); return E_FAIL; }
@@ -3614,7 +3696,7 @@ static HRESULT WINAPI HTMLDocument7_createElementNS(IHTMLDocument7 *iface, VARIA
nsAString_InitDepend(&ns, pvarNS && V_VT(pvarNS) == VT_BSTR ? V_BSTR(pvarNS) : NULL); nsAString_InitDepend(&tag, bstrTag); - nsres = nsIDOMHTMLDocument_CreateElementNS(This->nsdoc, &ns, &tag, &dom_element); + nsres = nsIDOMDocument_CreateElementNS(This->dom_document, &ns, &tag, &dom_element); nsAString_Finish(&ns); nsAString_Finish(&tag); if(NS_FAILED(nsres)) { @@ -3663,13 +3745,13 @@ static HRESULT WINAPI HTMLDocument7_get_characterSet(IHTMLDocument7 *iface, BSTR
TRACE("(%p)->(%p)\n", This, p);
- if(!This->nsdoc) { - FIXME("NULL nsdoc\n"); + if(!This->dom_document) { + FIXME("NULL dom_document\n"); return E_FAIL; }
nsAString_Init(&charset_str, NULL); - nsres = nsIDOMHTMLDocument_GetCharacterSet(This->nsdoc, &charset_str); + nsres = nsIDOMDocument_GetCharacterSet(This->dom_document, &charset_str); return return_nsstr(nsres, &charset_str, p); }
@@ -3700,13 +3782,13 @@ static HRESULT WINAPI HTMLDocument7_getElementsByClassName(IHTMLDocument7 *iface
TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
- if(!This->nsdoc) { - FIXME("NULL nsdoc not supported\n"); + if(!This->dom_document) { + FIXME("NULL dom_document not supported\n"); return E_NOTIMPL; }
nsAString_InitDepend(&nsstr, v); - nsres = nsIDOMHTMLDocument_GetElementsByClassName(This->nsdoc, &nsstr, &nslist); + nsres = nsIDOMDocument_GetElementsByClassName(This->dom_document, &nsstr, &nslist); nsAString_Finish(&nsstr); if(FAILED(nsres)) { ERR("GetElementByClassName failed: %08lx\n", nsres); @@ -4382,8 +4464,8 @@ static HRESULT WINAPI HTMLDocument7_importNode(IHTMLDocument7 *iface, IHTMLDOMNo
TRACE("(%p)->(%p %x %p)\n", This, pNodeSource, fDeep, ppNodeDest);
- if(!This->nsdoc) { - WARN("NULL nsdoc\n"); + if(!This->dom_document) { + WARN("NULL dom_document\n"); return E_UNEXPECTED; }
@@ -4392,7 +4474,7 @@ static HRESULT WINAPI HTMLDocument7_importNode(IHTMLDocument7 *iface, IHTMLDOMNo return E_FAIL; }
- nsres = nsIDOMHTMLDocument_ImportNode(This->nsdoc, node->nsnode, !!fDeep, 1, &nsnode); + nsres = nsIDOMDocument_ImportNode(This->dom_document, node->nsnode, !!fDeep, 1, &nsnode); if(NS_FAILED(nsres)) { ERR("ImportNode failed: %08lx\n", nsres); return map_nsresult(nsres); @@ -4448,12 +4530,17 @@ static HRESULT WINAPI HTMLDocument7_get_head(IHTMLDocument7 *iface, IHTMLElement
TRACE("(%p)->(%p)\n", This, p);
- if(!This->nsdoc) { + if(!This->dom_document) { FIXME("No document\n"); return E_FAIL; }
- nsres = nsIDOMHTMLDocument_GetHead(This->nsdoc, &nshead); + if(!This->html_document) { + FIXME("Not implemented for XML document\n"); + return E_NOTIMPL; + } + + nsres = nsIDOMHTMLDocument_GetHead(This->html_document, &nshead); assert(nsres == NS_OK);
if(!nshead) { @@ -4652,7 +4739,7 @@ static HRESULT WINAPI DocumentSelector_querySelector(IDocumentSelector *iface, B TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
nsAString_InitDepend(&nsstr, v); - nsres = nsIDOMHTMLDocument_QuerySelector(This->nsdoc, &nsstr, &nselem); + nsres = nsIDOMDocument_QuerySelector(This->dom_document, &nsstr, &nselem); nsAString_Finish(&nsstr); if(NS_FAILED(nsres)) { ERR("QuerySelector failed: %08lx\n", nsres); @@ -4683,7 +4770,7 @@ static HRESULT WINAPI DocumentSelector_querySelectorAll(IDocumentSelector *iface TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
nsAString_InitDepend(&nsstr, v); - hres = map_nsresult(nsIDOMHTMLDocument_QuerySelectorAll(This->nsdoc, &nsstr, &node_list)); + hres = map_nsresult(nsIDOMDocument_QuerySelectorAll(This->dom_document, &nsstr, &node_list)); nsAString_Finish(&nsstr); if(FAILED(hres)) { ERR("QuerySelectorAll failed: %08lx\n", hres); @@ -4828,7 +4915,7 @@ static inline HTMLDocumentNode *impl_from_IDispatchEx(IDispatchEx *iface) return CONTAINING_RECORD(iface, HTMLDocumentNode, IDispatchEx_iface); }
-static HRESULT has_elem_name(nsIDOMHTMLDocument *nsdoc, const WCHAR *name) +static HRESULT has_elem_name(nsIDOMHTMLDocument *html_document, const WCHAR *name) { static const WCHAR fmt[] = L":-moz-any(applet,embed,form,iframe,img,object)[name="%s"]"; WCHAR buf[128], *selector = buf; @@ -4843,7 +4930,7 @@ static HRESULT has_elem_name(nsIDOMHTMLDocument *nsdoc, const WCHAR *name) swprintf(selector, len, fmt, name);
nsAString_InitDepend(&selector_str, selector); - nsres = nsIDOMHTMLDocument_QuerySelector(nsdoc, &selector_str, &nselem); + nsres = nsIDOMHTMLDocument_QuerySelector(html_document, &selector_str, &nselem); nsAString_Finish(&selector_str); if(selector != buf) heap_free(selector); @@ -4856,7 +4943,7 @@ static HRESULT has_elem_name(nsIDOMHTMLDocument *nsdoc, const WCHAR *name) return S_OK; }
-static HRESULT get_elem_by_name_or_id(nsIDOMHTMLDocument *nsdoc, const WCHAR *name, nsIDOMElement **ret) +static HRESULT get_elem_by_name_or_id(nsIDOMHTMLDocument *html_document, const WCHAR *name, nsIDOMElement **ret) { static const WCHAR fmt[] = L":-moz-any(embed,form,iframe,img):-moz-any([name="%s"],[id="%s"][name])," L":-moz-any(applet,object):-moz-any([name="%s"],[id="%s"])"; @@ -4872,7 +4959,7 @@ static HRESULT get_elem_by_name_or_id(nsIDOMHTMLDocument *nsdoc, const WCHAR *na swprintf(selector, len, fmt, name, name, name, name);
nsAString_InitDepend(&selector_str, selector); - nsres = nsIDOMHTMLDocument_QuerySelector(nsdoc, &selector_str, &nselem); + nsres = nsIDOMHTMLDocument_QuerySelector(html_document, &selector_str, &nselem); nsAString_Finish(&selector_str); if(selector != buf) heap_free(selector); @@ -4995,8 +5082,8 @@ static HRESULT WINAPI DocDispatchEx_GetDispID(IDispatchEx *iface, BSTR bstrName, if(hres != DISP_E_UNKNOWNNAME) return hres;
- if(This->nsdoc) { - hres = get_elem_by_name_or_id(This->nsdoc, bstrName, NULL); + if(This->html_document) { + hres = get_elem_by_name_or_id(This->html_document, bstrName, NULL); if(SUCCEEDED(hres)) hres = dispid_from_elem_name(This, bstrName, pid); } @@ -5570,12 +5657,12 @@ static HRESULT WINAPI DocumentRange_createRange(IDocumentRange *iface, IHTMLDOMR
TRACE("(%p)->(%p)\n", This, p);
- if(!This->nsdoc) { - WARN("NULL nsdoc\n"); + if(!This->dom_document) { + WARN("NULL dom_document\n"); return E_UNEXPECTED; }
- if(NS_FAILED(nsIDOMHTMLDocument_CreateRange(This->nsdoc, &nsrange))) + if(NS_FAILED(nsIDOMDocument_CreateRange(This->dom_document, &nsrange))) return E_FAIL;
hres = create_dom_range(nsrange, dispex_compat_mode(&This->node.event_target.dispex), p); @@ -5757,7 +5844,7 @@ void detach_document_node(HTMLDocumentNode *doc) doc->catmgr = NULL; }
- if(!doc->nsdoc && doc->window) { + if(!doc->dom_document && doc->window) { /* document fragments own reference to inner window */ IHTMLWindow2_Release(&doc->window->base.IHTMLWindow2_iface); doc->window = NULL; @@ -5790,21 +5877,22 @@ static void HTMLDocumentNode_traverse(HTMLDOMNode *iface, nsCycleCollectionTrave { HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
- if(This->nsdoc) - note_cc_edge((nsISupports*)This->nsdoc, "This->nsdoc", cb); + if(This->dom_document) + note_cc_edge((nsISupports*)This->dom_document, "This->dom_document", cb); }
static void HTMLDocumentNode_unlink(HTMLDOMNode *iface) { HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
- if(This->nsdoc) { - nsIDOMHTMLDocument *nsdoc = This->nsdoc; + if(This->dom_document) { + nsIDOMDocument *dom_document = This->dom_document;
release_document_mutation(This); detach_document_node(This); - This->nsdoc = NULL; - nsIDOMHTMLDocument_Release(nsdoc); + This->dom_document = NULL; + This->html_document = NULL; + nsIDOMDocument_Release(dom_document); This->window = NULL; } } @@ -5854,7 +5942,7 @@ static HRESULT HTMLDocumentNode_get_name(DispatchEx *dispex, DISPID id, BSTR *na HTMLDocumentNode *This = impl_from_DispatchEx(dispex); DWORD idx = id - MSHTML_DISPID_CUSTOM_MIN;
- if(!This->nsdoc || idx >= This->elem_vars_cnt) + if(!This->dom_document || idx >= This->elem_vars_cnt) return DISP_E_MEMBERNOTFOUND;
return (*name = SysAllocString(This->elem_vars[idx])) ? S_OK : E_OUTOFMEMORY; @@ -5874,10 +5962,10 @@ static HRESULT HTMLDocumentNode_invoke(DispatchEx *dispex, DISPID id, LCID lcid,
i = id - MSHTML_DISPID_CUSTOM_MIN;
- if(!This->nsdoc || i >= This->elem_vars_cnt) + if(!This->html_document || i >= This->elem_vars_cnt) return DISP_E_MEMBERNOTFOUND;
- hres = get_elem_by_name_or_id(This->nsdoc, This->elem_vars[i], &nselem); + hres = get_elem_by_name_or_id(This->html_document, This->elem_vars[i], &nselem); if(FAILED(hres)) return hres; if(!nselem) @@ -5906,11 +5994,11 @@ static HRESULT HTMLDocumentNode_next_dispid(DispatchEx *dispex, DISPID id, DISPI HRESULT hres; UINT32 i;
- if(!This->nsdoc) + if(!This->html_document) return S_FALSE;
while(idx < This->elem_vars_cnt) { - hres = has_elem_name(This->nsdoc, This->elem_vars[idx]); + hres = has_elem_name(This->html_document, This->elem_vars[idx]); if(SUCCEEDED(hres)) { *pid = idx + MSHTML_DISPID_CUSTOM_MIN; return S_OK; @@ -5922,7 +6010,7 @@ static HRESULT HTMLDocumentNode_next_dispid(DispatchEx *dispex, DISPID id, DISPI
/* Populate possibly missing DISPIDs */ nsAString_InitDepend(&nsstr, L":-moz-any(applet,embed,form,iframe,img,object)[name]"); - nsres = nsIDOMHTMLDocument_QuerySelectorAll(This->nsdoc, &nsstr, &node_list); + nsres = nsIDOMHTMLDocument_QuerySelectorAll(This->html_document, &nsstr, &node_list); nsAString_Finish(&nsstr); if(NS_FAILED(nsres)) return map_nsresult(nsres); @@ -6136,7 +6224,7 @@ static HTMLDocumentNode *alloc_doc_node(HTMLDocumentObj *doc_obj, HTMLInnerWindo return doc; }
-HRESULT create_document_node(nsIDOMHTMLDocument *nsdoc, GeckoBrowser *browser, HTMLInnerWindow *window, +HRESULT create_document_node(nsIDOMDocument *nsdoc, GeckoBrowser *browser, HTMLInnerWindow *window, compat_mode_t parent_mode, HTMLDocumentNode **ret) { HTMLDocumentObj *doc_obj = browser->doc; @@ -6155,10 +6243,15 @@ HRESULT create_document_node(nsIDOMHTMLDocument *nsdoc, GeckoBrowser *browser, H if(!doc_obj->window || (window && is_main_content_window(window->base.outer_window))) doc->cp_container.forward_container = &doc_obj->cp_container;
- HTMLDOMNode_Init(doc, &doc->node, (nsIDOMNode*)nsdoc, &HTMLDocumentNode_dispex); + if(NS_SUCCEEDED(nsIDOMDocument_QueryInterface(nsdoc, &IID_nsIDOMHTMLDocument, (void**)&doc->html_document))) + doc->dom_document = (nsIDOMDocument*)doc->html_document; + else { + nsIDOMDocument_AddRef(nsdoc); + doc->dom_document = nsdoc; + doc->html_document = NULL; + }
- nsIDOMHTMLDocument_AddRef(nsdoc); - doc->nsdoc = nsdoc; + HTMLDOMNode_Init(doc, &doc->node, (nsIDOMNode*)doc->dom_document, &HTMLDocumentNode_dispex);
init_document_mutation(doc); doc_init_events(doc); @@ -6168,12 +6261,12 @@ HRESULT create_document_node(nsIDOMHTMLDocument *nsdoc, GeckoBrowser *browser, H list_add_head(&browser->document_nodes, &doc->browser_entry); doc->browser = browser;
- if(browser->usermode == EDITMODE) { + if(browser->usermode == EDITMODE && doc->html_document) { nsAString mode_str; nsresult nsres;
nsAString_InitDepend(&mode_str, L"on"); - nsres = nsIDOMHTMLDocument_SetDesignMode(doc->nsdoc, &mode_str); + nsres = nsIDOMHTMLDocument_SetDesignMode(doc->html_document, &mode_str); nsAString_Finish(&mode_str); if(NS_FAILED(nsres)) ERR("SetDesignMode failed: %08lx\n", nsres); diff --git a/dlls/mshtml/htmlelem.c b/dlls/mshtml/htmlelem.c index 4d92929b985..f1b039f05e5 100644 --- a/dlls/mshtml/htmlelem.c +++ b/dlls/mshtml/htmlelem.c @@ -181,7 +181,7 @@ static const tag_desc_t *get_tag_desc(const WCHAR *tag_name) return NULL; }
-HRESULT replace_node_by_html(nsIDOMHTMLDocument *nsdoc, nsIDOMNode *nsnode, const WCHAR *html) +HRESULT replace_node_by_html(nsIDOMDocument *nsdoc, nsIDOMNode *nsnode, const WCHAR *html) { nsIDOMDocumentFragment *nsfragment; nsIDOMNode *nsparent; @@ -190,7 +190,7 @@ HRESULT replace_node_by_html(nsIDOMHTMLDocument *nsdoc, nsIDOMNode *nsnode, cons nsresult nsres; HRESULT hres = S_OK;
- nsres = nsIDOMHTMLDocument_CreateRange(nsdoc, &range); + nsres = nsIDOMDocument_CreateRange(nsdoc, &range); if(NS_FAILED(nsres)) { ERR("CreateRange failed: %08lx\n", nsres); return E_FAIL; @@ -410,8 +410,8 @@ static HRESULT create_nselem_parse(HTMLDocumentNode *doc, const WCHAR *tag, nsID
if(!p || p[1] || wcschr(tag + 1, '<')) return E_FAIL; - if(!doc->nsdoc) { - WARN("NULL nsdoc\n"); + if(!doc->dom_document) { + WARN("NULL dom_document\n"); return E_UNEXPECTED; }
@@ -430,7 +430,7 @@ static HRESULT create_nselem_parse(HTMLDocumentNode *doc, const WCHAR *tag, nsID size = (p + 2 - (tag + 1 + name_len)) * sizeof(WCHAR);
/* Parse the input via a contextual fragment, using a dummy unknown tag */ - nsres = nsIDOMHTMLDocument_CreateRange(doc->nsdoc, &nsrange); + nsres = nsIDOMDocument_CreateRange(doc->dom_document, &nsrange); if(NS_FAILED(nsres)) return map_nsresult(nsres);
@@ -467,7 +467,7 @@ static HRESULT create_nselem_parse(HTMLDocumentNode *doc, const WCHAR *tag, nsID p[name_len] = '\0';
nsAString_InitDepend(&str, p); - nsres = nsIDOMHTMLDocument_CreateElement(doc->nsdoc, &str, ret); + nsres = nsIDOMDocument_CreateElement(doc->dom_document, &str, ret); nsAString_Finish(&str); heap_free(p);
@@ -488,13 +488,13 @@ HRESULT create_nselem(HTMLDocumentNode *doc, const WCHAR *tag, nsIDOMElement **r nsAString tag_str; nsresult nsres;
- if(!doc->nsdoc) { - WARN("NULL nsdoc\n"); + if(!doc->dom_document) { + WARN("NULL dom_document\n"); return E_UNEXPECTED; }
nsAString_InitDepend(&tag_str, tag); - nsres = nsIDOMHTMLDocument_CreateElement(doc->nsdoc, &tag_str, ret); + nsres = nsIDOMDocument_CreateElement(doc->dom_document, &tag_str, ret); nsAString_Finish(&tag_str); if(NS_FAILED(nsres)) { ERR("CreateElement failed: %08lx\n", nsres); @@ -510,7 +510,7 @@ HRESULT create_element(HTMLDocumentNode *doc, const WCHAR *tag, HTMLElement **re HRESULT hres;
/* Use owner doc if called on document fragment */ - if(!doc->nsdoc) + if(!doc->dom_document) doc = doc->node.doc;
/* IE8 and below allow creating elements with attributes, such as <div class="a"> */ @@ -2223,7 +2223,7 @@ static HRESULT WINAPI HTMLElement_put_innerText(IHTMLElement *iface, BSTR v) }
nsAString_InitDepend(&text_str, v); - nsres = nsIDOMHTMLDocument_CreateTextNode(This->node.doc->nsdoc, &text_str, &text_node); + nsres = nsIDOMDocument_CreateTextNode(This->node.doc->dom_document, &text_str, &text_node); nsAString_Finish(&text_str); if(NS_FAILED(nsres)) { ERR("CreateTextNode failed: %08lx\n", nsres); @@ -2255,7 +2255,7 @@ static HRESULT WINAPI HTMLElement_put_outerHTML(IHTMLElement *iface, BSTR v)
TRACE("(%p)->(%s)\n", This, debugstr_w(v));
- return replace_node_by_html(This->node.doc->nsdoc, This->node.nsnode, v); + return replace_node_by_html(This->node.doc->dom_document, This->node.nsnode, v); }
static HRESULT WINAPI HTMLElement_get_outerHTML(IHTMLElement *iface, BSTR *p) @@ -2298,20 +2298,20 @@ static HRESULT WINAPI HTMLElement_put_outerText(IHTMLElement *iface, BSTR v) return 0x800a0258; /* undocumented error code */ }
- if(!This->node.doc->nsdoc) { - FIXME("NULL nsdoc\n"); + if(!This->node.doc->dom_document) { + FIXME("NULL dom_document\n"); return E_FAIL; }
nsAString_InitDepend(&nsstr, v); - nsres = nsIDOMHTMLDocument_CreateTextNode(This->node.doc->nsdoc, &nsstr, &text_node); + nsres = nsIDOMDocument_CreateTextNode(This->node.doc->dom_document, &nsstr, &text_node); nsAString_Finish(&nsstr); if(NS_FAILED(nsres)) { ERR("CreateTextNode failed\n"); return E_FAIL; }
- nsres = nsIDOMHTMLDocument_CreateRange(This->node.doc->nsdoc, &range); + nsres = nsIDOMDocument_CreateRange(This->node.doc->dom_document, &range); if(NS_SUCCEEDED(nsres)) { nsres = nsIDOMRange_SelectNode(range, This->node.nsnode); if(NS_SUCCEEDED(nsres)) @@ -2422,12 +2422,12 @@ static HRESULT WINAPI HTMLElement_insertAdjacentHTML(IHTMLElement *iface, BSTR w
TRACE("(%p)->(%s %s)\n", This, debugstr_w(where), debugstr_w(html));
- if(!This->node.doc->nsdoc) { - WARN("NULL nsdoc\n"); + if(!This->node.doc->dom_document) { + WARN("NULL dom_document\n"); return E_UNEXPECTED; }
- nsres = nsIDOMHTMLDocument_CreateRange(This->node.doc->nsdoc, &range); + nsres = nsIDOMDocument_CreateRange(This->node.doc->dom_document, &range); if(NS_FAILED(nsres)) { ERR("CreateRange failed: %08lx\n", nsres); @@ -2463,14 +2463,14 @@ static HRESULT WINAPI HTMLElement_insertAdjacentText(IHTMLElement *iface, BSTR w
TRACE("(%p)->(%s %s)\n", This, debugstr_w(where), debugstr_w(text));
- if(!This->node.doc->nsdoc) { - WARN("NULL nsdoc\n"); + if(!This->node.doc->dom_document) { + WARN("NULL dom_document\n"); return E_UNEXPECTED; }
nsAString_InitDepend(&ns_text, text); - nsres = nsIDOMHTMLDocument_CreateTextNode(This->node.doc->nsdoc, &ns_text, (nsIDOMText **)&nsnode); + nsres = nsIDOMDocument_CreateTextNode(This->node.doc->dom_document, &ns_text, (nsIDOMText **)&nsnode); nsAString_Finish(&ns_text);
if(NS_FAILED(nsres) || !nsnode) diff --git a/dlls/mshtml/htmlevent.c b/dlls/mshtml/htmlevent.c index 835e11c74aa..f2c862c5b0a 100644 --- a/dlls/mshtml/htmlevent.c +++ b/dlls/mshtml/htmlevent.c @@ -3085,7 +3085,7 @@ HRESULT create_document_event_str(HTMLDocumentNode *doc, const WCHAR *type, IDOM unsigned i;
nsAString_InitDepend(&nsstr, type); - nsres = nsIDOMHTMLDocument_CreateEvent(doc->nsdoc, &nsstr, &nsevent); + nsres = nsIDOMDocument_CreateEvent(doc->dom_document, &nsstr, &nsevent); nsAString_Finish(&nsstr); if(NS_FAILED(nsres)) { FIXME("CreateEvent(%s) failed: %08lx\n", debugstr_w(type), nsres); @@ -3117,7 +3117,7 @@ HRESULT create_document_event(HTMLDocumentNode *doc, eventid_t event_id, DOMEven nsresult nsres;
nsAString_InitDepend(&nsstr, event_types[event_info[event_id].type]); - nsres = nsIDOMHTMLDocument_CreateEvent(doc->nsdoc, &nsstr, &nsevent); + nsres = nsIDOMDocument_CreateEvent(doc->dom_document, &nsstr, &nsevent); nsAString_Finish(&nsstr); if(NS_FAILED(nsres)) { FIXME("CreateEvent(%s) failed: %08lx\n", debugstr_w(event_types[event_info[event_id].type]), nsres); @@ -3665,7 +3665,7 @@ HRESULT ensure_doc_nsevent_handler(HTMLDocumentNode *doc, nsIDOMNode *nsnode, ev { TRACE("%s\n", debugstr_w(event_info[eid].name));
- if(!doc->nsdoc) + if(!doc->dom_document) return S_OK;
switch(eid) { diff --git a/dlls/mshtml/htmlselect.c b/dlls/mshtml/htmlselect.c index f8305542fae..95bddb3c7e7 100644 --- a/dlls/mshtml/htmlselect.c +++ b/dlls/mshtml/htmlselect.c @@ -252,8 +252,8 @@ static HRESULT WINAPI HTMLOptionElement_put_text(IHTMLOptionElement *iface, BSTR
TRACE("(%p)->(%s)\n", This, debugstr_w(v));
- if(!This->element.node.doc->nsdoc) { - WARN("NULL nsdoc\n"); + if(!This->element.node.doc->dom_document) { + WARN("NULL dom_document\n"); return E_UNEXPECTED; }
@@ -275,7 +275,7 @@ static HRESULT WINAPI HTMLOptionElement_put_text(IHTMLOptionElement *iface, BSTR }
nsAString_InitDepend(&text_str, v); - nsres = nsIDOMHTMLDocument_CreateTextNode(This->element.node.doc->nsdoc, &text_str, &text_node); + nsres = nsIDOMDocument_CreateTextNode(This->element.node.doc->dom_document, &text_str, &text_node); nsAString_Finish(&text_str); if(NS_FAILED(nsres)) { ERR("CreateTextNode failed: %08lx\n", nsres); diff --git a/dlls/mshtml/htmlwindow.c b/dlls/mshtml/htmlwindow.c index 14fa17ace1b..7014a4cd4b4 100644 --- a/dlls/mshtml/htmlwindow.c +++ b/dlls/mshtml/htmlwindow.c @@ -4143,7 +4143,6 @@ HRESULT update_window_doc(HTMLInnerWindow *window) { HTMLOuterWindow *outer_window = window->base.outer_window; compat_mode_t parent_mode = COMPAT_MODE_QUIRKS; - nsIDOMHTMLDocument *nshtmldoc; nsIDOMDocument *nsdoc; nsresult nsres; HRESULT hres; @@ -4159,18 +4158,11 @@ HRESULT update_window_doc(HTMLInnerWindow *window) return E_FAIL; }
- nsres = nsIDOMDocument_QueryInterface(nsdoc, &IID_nsIDOMHTMLDocument, (void**)&nshtmldoc); - nsIDOMDocument_Release(nsdoc); - if(NS_FAILED(nsres)) { - ERR("Could not get nsIDOMHTMLDocument iface: %08lx\n", nsres); - return E_FAIL; - } - if(outer_window->parent) parent_mode = outer_window->parent->base.inner_window->doc->document_mode;
- hres = create_document_node(nshtmldoc, outer_window->browser, window, parent_mode, &window->doc); - nsIDOMHTMLDocument_Release(nshtmldoc); + hres = create_document_node(nsdoc, outer_window->browser, window, parent_mode, &window->doc); + nsIDOMDocument_Release(nsdoc); if(FAILED(hres)) return hres;
diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h index 23eeb0ec11b..7df5c5e8b30 100644 --- a/dlls/mshtml/mshtml_private.h +++ b/dlls/mshtml/mshtml_private.h @@ -921,7 +921,8 @@ struct HTMLDocumentNode { compat_mode_t document_mode; BOOL document_mode_locked;
- nsIDOMHTMLDocument *nsdoc; + nsIDOMDocument *dom_document; + nsIDOMHTMLDocument *html_document; BOOL content_ready;
IHTMLDOMImplementation *dom_implementation; @@ -949,7 +950,7 @@ struct HTMLDocumentNode { HRESULT HTMLDocument_Create(IUnknown*,REFIID,void**) DECLSPEC_HIDDEN; HRESULT MHTMLDocument_Create(IUnknown*,REFIID,void**) DECLSPEC_HIDDEN; HRESULT HTMLLoadOptions_Create(IUnknown*,REFIID,void**) DECLSPEC_HIDDEN; -HRESULT create_document_node(nsIDOMHTMLDocument*,GeckoBrowser*,HTMLInnerWindow*, +HRESULT create_document_node(nsIDOMDocument*,GeckoBrowser*,HTMLInnerWindow*, compat_mode_t,HTMLDocumentNode**) DECLSPEC_HIDDEN; HRESULT create_doctype_node(HTMLDocumentNode*,nsIDOMNode*,HTMLDOMNode**) DECLSPEC_HIDDEN;
@@ -997,7 +998,7 @@ compat_mode_t lock_document_mode(HTMLDocumentNode*) DECLSPEC_HIDDEN; void init_mutation(nsIComponentManager*) DECLSPEC_HIDDEN; void init_document_mutation(HTMLDocumentNode*) DECLSPEC_HIDDEN; void release_document_mutation(HTMLDocumentNode*) DECLSPEC_HIDDEN; -JSContext *get_context_from_document(nsIDOMHTMLDocument*) DECLSPEC_HIDDEN; +JSContext *get_context_from_document(nsIDOMDocument*) DECLSPEC_HIDDEN;
void HTMLDocument_LockContainer(HTMLDocumentObj*,BOOL) DECLSPEC_HIDDEN; void show_context_menu(HTMLDocumentObj*,DWORD,POINT*,IDispatch*) DECLSPEC_HIDDEN; @@ -1082,7 +1083,7 @@ void detach_document_node(HTMLDocumentNode*) DECLSPEC_HIDDEN; void detach_selection(HTMLDocumentNode*) DECLSPEC_HIDDEN; void detach_ranges(HTMLDocumentNode*) DECLSPEC_HIDDEN; HRESULT get_node_text(HTMLDOMNode*,BSTR*) DECLSPEC_HIDDEN; -HRESULT replace_node_by_html(nsIDOMHTMLDocument*,nsIDOMNode*,const WCHAR*) DECLSPEC_HIDDEN; +HRESULT replace_node_by_html(nsIDOMDocument*,nsIDOMNode*,const WCHAR*) DECLSPEC_HIDDEN;
HRESULT create_nselem(HTMLDocumentNode*,const WCHAR*,nsIDOMElement**) DECLSPEC_HIDDEN; HRESULT create_element(HTMLDocumentNode*,const WCHAR*,HTMLElement**) DECLSPEC_HIDDEN; diff --git a/dlls/mshtml/mutation.c b/dlls/mshtml/mutation.c index 605f6fd7565..7166d74cf0c 100644 --- a/dlls/mshtml/mutation.c +++ b/dlls/mshtml/mutation.c @@ -211,7 +211,7 @@ static nsresult run_insert_comment(HTMLDocumentNode *doc, nsISupports *comment_i if(replace_html) { HRESULT hres;
- hres = replace_node_by_html(doc->nsdoc, (nsIDOMNode*)nscomment, replace_html); + hres = replace_node_by_html(doc->dom_document, (nsIDOMNode*)nscomment, replace_html); heap_free(replace_html); if(FAILED(hres)) nsres = NS_ERROR_FAILURE; @@ -971,7 +971,7 @@ void init_document_mutation(HTMLDocumentNode *doc)
doc->nsIDocumentObserver_iface.lpVtbl = &nsDocumentObserverVtbl;
- nsres = nsIDOMHTMLDocument_QueryInterface(doc->nsdoc, &IID_nsIDocument, (void**)&nsdoc); + nsres = nsIDOMDocument_QueryInterface(doc->dom_document, &IID_nsIDocument, (void**)&nsdoc); if(NS_FAILED(nsres)) { ERR("Could not get nsIDocument: %08lx\n", nsres); return; @@ -986,7 +986,7 @@ void release_document_mutation(HTMLDocumentNode *doc) nsIDocument *nsdoc; nsresult nsres;
- nsres = nsIDOMHTMLDocument_QueryInterface(doc->nsdoc, &IID_nsIDocument, (void**)&nsdoc); + nsres = nsIDOMDocument_QueryInterface(doc->dom_document, &IID_nsIDocument, (void**)&nsdoc); if(NS_FAILED(nsres)) { ERR("Could not get nsIDocument: %08lx\n", nsres); return; @@ -996,13 +996,13 @@ void release_document_mutation(HTMLDocumentNode *doc) nsIDocument_Release(nsdoc); }
-JSContext *get_context_from_document(nsIDOMHTMLDocument *nsdoc) +JSContext *get_context_from_document(nsIDOMDocument *nsdoc) { nsIDocument *doc; JSContext *ctx; nsresult nsres;
- nsres = nsIDOMHTMLDocument_QueryInterface(nsdoc, &IID_nsIDocument, (void**)&doc); + nsres = nsIDOMDocument_QueryInterface(nsdoc, &IID_nsIDocument, (void**)&doc); assert(nsres == NS_OK);
ctx = nsIContentUtils_GetContextFromDocument(content_utils, doc); diff --git a/dlls/mshtml/navigate.c b/dlls/mshtml/navigate.c index 68f249d914a..5825e0f27c0 100644 --- a/dlls/mshtml/navigate.c +++ b/dlls/mshtml/navigate.c @@ -2152,7 +2152,7 @@ static HRESULT navigate_fragment(HTMLOuterWindow *window, IUri *uri) swprintf(selector, ARRAY_SIZE(selector_formatW)+SysStringLen(frag), selector_formatW, frag); nsAString_InitDepend(&selector_str, selector); /* NOTE: Gecko doesn't set result to NULL if there is no match, so nselem must be initialized */ - nsres = nsIDOMHTMLDocument_QuerySelector(window->base.inner_window->doc->nsdoc, &selector_str, &nselem); + nsres = nsIDOMDocument_QuerySelector(window->base.inner_window->doc->dom_document, &selector_str, &nselem); nsAString_Finish(&selector_str); heap_free(selector); if(NS_SUCCEEDED(nsres) && nselem) { diff --git a/dlls/mshtml/nsembed.c b/dlls/mshtml/nsembed.c index 0b16cd90306..e720884bcc6 100644 --- a/dlls/mshtml/nsembed.c +++ b/dlls/mshtml/nsembed.c @@ -1683,7 +1683,12 @@ static nsresult NSAPI nsContextMenuListener_OnShowContextMenu(nsIContextMenuList case CONTEXT_TEXT: { nsISelection *selection;
- nsres = nsIDOMHTMLDocument_GetSelection(This->doc->doc_node->nsdoc, &selection); + if(!This->doc->doc_node->html_document) { + FIXME("Not implemented for XML document\n"); + break; + } + + nsres = nsIDOMHTMLDocument_GetSelection(This->doc->doc_node->html_document, &selection); if(NS_SUCCEEDED(nsres) && selection) { cpp_bool is_collapsed;
diff --git a/dlls/mshtml/nsevents.c b/dlls/mshtml/nsevents.c index 83653b46e35..a8e3d503921 100644 --- a/dlls/mshtml/nsevents.c +++ b/dlls/mshtml/nsevents.c @@ -258,14 +258,14 @@ static nsresult NSAPI handle_load(nsIDOMEventListener *iface, nsIDOMEvent *event IDocObjectService_FireDocumentComplete(doc_obj->doc_object_service, &doc->outer_window->base.IHTMLWindow2_iface, 0);
- if(doc->nsdoc) { + if(doc->dom_document) { hres = create_document_event(doc, EVENTID_LOAD, &load_event); if(SUCCEEDED(hres)) { dispatch_event(&doc->node.event_target, load_event); IDOMEvent_Release(&load_event->IDOMEvent_iface); } }else { - WARN("no nsdoc\n"); + WARN("no dom_document\n"); }
if(doc->window) { @@ -383,7 +383,7 @@ static nsIDOMEventTarget *get_default_document_target(HTMLDocumentNode *doc) nsISupports *target_iface; nsresult nsres;
- target_iface = doc->window ? (nsISupports*)doc->outer_window->nswindow : (nsISupports*)doc->nsdoc; + target_iface = doc->window ? (nsISupports*)doc->outer_window->nswindow : (nsISupports*)doc->dom_document; nsres = nsISupports_QueryInterface(target_iface, &IID_nsIDOMEventTarget, (void**)&target); return NS_SUCCEEDED(nsres) ? target : NULL; } diff --git a/dlls/mshtml/omnavigator.c b/dlls/mshtml/omnavigator.c index d3ffc29af4b..db48cc6213b 100644 --- a/dlls/mshtml/omnavigator.c +++ b/dlls/mshtml/omnavigator.c @@ -242,7 +242,6 @@ static HRESULT WINAPI HTMLDOMImplementation2_createHTMLDocument(IHTMLDOMImplemen { HTMLDOMImplementation *This = impl_from_IHTMLDOMImplementation2(iface); HTMLDocumentNode *new_document_node; - nsIDOMHTMLDocument *html_doc; nsIDOMDocument *doc; nsAString title_str; nsresult nsres; @@ -261,12 +260,8 @@ static HRESULT WINAPI HTMLDOMImplementation2_createHTMLDocument(IHTMLDOMImplemen return E_FAIL; }
- nsres = nsIDOMDocument_QueryInterface(doc, &IID_nsIDOMHTMLDocument, (void**)&html_doc); + hres = create_document_node(doc, This->browser, NULL, dispex_compat_mode(&This->dispex), &new_document_node); nsIDOMDocument_Release(doc); - assert(nsres == NS_OK); - - hres = create_document_node(html_doc, This->browser, NULL, dispex_compat_mode(&This->dispex), &new_document_node); - nsIDOMHTMLDocument_Release(html_doc); if(FAILED(hres)) return hres;
@@ -337,7 +332,7 @@ HRESULT create_dom_implementation(HTMLDocumentNode *doc_node, IHTMLDOMImplementa init_dispatch(&dom_implementation->dispex, (IUnknown*)&dom_implementation->IHTMLDOMImplementation_iface, &HTMLDOMImplementation_dispex, doc_node->document_mode);
- nsres = nsIDOMHTMLDocument_GetImplementation(doc_node->nsdoc, &dom_implementation->implementation); + nsres = nsIDOMDocument_GetImplementation(doc_node->dom_document, &dom_implementation->implementation); if(NS_FAILED(nsres)) { ERR("GetDOMImplementation failed: %08lx\n", nsres); IHTMLDOMImplementation_Release(&dom_implementation->IHTMLDOMImplementation_iface); diff --git a/dlls/mshtml/persist.c b/dlls/mshtml/persist.c index 12a74393739..262633deb9f 100644 --- a/dlls/mshtml/persist.c +++ b/dlls/mshtml/persist.c @@ -503,12 +503,12 @@ static HRESULT get_doc_string(HTMLDocumentNode *This, char **str) nsresult nsres; HRESULT hres;
- if(!This->nsdoc) { - WARN("NULL nsdoc\n"); + if(!This->dom_document) { + WARN("NULL dom_document\n"); return E_UNEXPECTED; }
- nsres = nsIDOMHTMLDocument_QueryInterface(This->nsdoc, &IID_nsIDOMNode, (void**)&nsnode); + nsres = nsIDOMDocument_QueryInterface(This->dom_document, &IID_nsIDOMNode, (void**)&nsnode); if(NS_FAILED(nsres)) { ERR("Could not get nsIDOMNode failed: %08lx\n", nsres); return E_FAIL; diff --git a/dlls/mshtml/range.c b/dlls/mshtml/range.c index c98ba331b12..5c93b39f4ab 100644 --- a/dlls/mshtml/range.c +++ b/dlls/mshtml/range.c @@ -949,7 +949,7 @@ static HRESULT WINAPI HTMLTxtRange_put_text(IHTMLTxtRange *iface, BSTR v) return MSHTML_E_NODOC;
nsAString_InitDepend(&text_str, v); - nsres = nsIDOMHTMLDocument_CreateTextNode(This->doc->nsdoc, &text_str, &text_node); + nsres = nsIDOMDocument_CreateTextNode(This->doc->dom_document, &text_str, &text_node); nsAString_Finish(&text_str); if(NS_FAILED(nsres)) { ERR("CreateTextNode failed: %08lx\n", nsres); @@ -1159,7 +1159,12 @@ static HRESULT WINAPI HTMLTxtRange_expand(IHTMLTxtRange *iface, BSTR Unit, VARIA nsIDOMHTMLElement *nsbody = NULL; nsresult nsres;
- nsres = nsIDOMHTMLDocument_GetBody(This->doc->nsdoc, &nsbody); + if(!This->doc->html_document) { + FIXME("Not implemented for XML document\n"); + return E_NOTIMPL; + } + + nsres = nsIDOMHTMLDocument_GetBody(This->doc->html_document, &nsbody); if(NS_FAILED(nsres) || !nsbody) { ERR("Could not get body: %08lx\n", nsres); break; @@ -1657,8 +1662,8 @@ static HRESULT exec_indent(HTMLTxtRange *This, VARIANT *in, VARIANT *out)
TRACE("(%p)->(%p %p)\n", This, in, out);
- if(!This->doc->nsdoc) { - WARN("NULL nsdoc\n"); + if(!This->doc->dom_document) { + WARN("NULL dom_document\n"); return E_NOTIMPL; }
diff --git a/dlls/mshtml/script.c b/dlls/mshtml/script.c index 1d555706e6a..11f289aa2d3 100644 --- a/dlls/mshtml/script.c +++ b/dlls/mshtml/script.c @@ -1596,11 +1596,11 @@ void bind_event_scripts(HTMLDocumentNode *doc)
TRACE("%p\n", doc);
- if(!doc->nsdoc) + if(!doc->dom_document) return;
nsAString_InitDepend(&selector_str, L"script[event]"); - nsres = nsIDOMHTMLDocument_QuerySelectorAll(doc->nsdoc, &selector_str, &node_list); + nsres = nsIDOMDocument_QuerySelectorAll(doc->dom_document, &selector_str, &node_list); nsAString_Finish(&selector_str); if(NS_FAILED(nsres)) { ERR("QuerySelectorAll failed: %08lx\n", nsres); diff --git a/dlls/mshtml/selection.c b/dlls/mshtml/selection.c index 307b7c922a0..052dc2fcfe6 100644 --- a/dlls/mshtml/selection.c +++ b/dlls/mshtml/selection.c @@ -160,12 +160,17 @@ static HRESULT WINAPI HTMLSelectionObject_createRange(IHTMLSelectionObject *ifac
TRACE("nsrange_cnt = 0\n");
- if(!This->doc->nsdoc) { - WARN("nsdoc is NULL\n"); + if(!This->doc->dom_document) { + WARN("dom_document is NULL\n"); return E_UNEXPECTED; }
- nsres = nsIDOMHTMLDocument_GetBody(This->doc->nsdoc, &nsbody); + if(!This->doc->html_document) { + FIXME("Not implemented for XML document\n"); + return E_NOTIMPL; + } + + nsres = nsIDOMHTMLDocument_GetBody(This->doc->html_document, &nsbody); if(NS_FAILED(nsres) || !nsbody) { ERR("Could not get body: %08lx\n", nsres); return E_FAIL;