Module: wine Branch: master Commit: d9aacfd989199fee4a69c4c08564993ee52bfc99 URL: http://source.winehq.org/git/wine.git/?a=commit;h=d9aacfd989199fee4a69c4c085...
Author: Jacek Caban jacek@codeweavers.com Date: Sun Nov 14 14:42:20 2010 +0100
mshtml: Added IHTMLDocument3::createDocumentFragment implementation.
---
dlls/mshtml/htmldoc.c | 49 +++++++++++++++++++++++++++++++++-------- dlls/mshtml/htmldoc3.c | 27 +++++++++++++++++++++- dlls/mshtml/mshtml_private.h | 1 + 3 files changed, 65 insertions(+), 12 deletions(-)
diff --git a/dlls/mshtml/htmldoc.c b/dlls/mshtml/htmldoc.c index dfa2a8b..9299170 100644 --- a/dlls/mshtml/htmldoc.c +++ b/dlls/mshtml/htmldoc.c @@ -1930,35 +1930,47 @@ static dispex_static_data_t HTMLDocumentNode_dispex = { HTMLDocumentNode_iface_tids };
-HRESULT create_doc_from_nsdoc(nsIDOMHTMLDocument *nsdoc, HTMLDocumentObj *doc_obj, HTMLWindow *window, HTMLDocumentNode **ret) +static HTMLDocumentNode *alloc_doc_node(HTMLDocumentObj *doc_obj, HTMLWindow *window) { HTMLDocumentNode *doc; - HRESULT hres;
doc = heap_alloc_zero(sizeof(HTMLDocumentNode)); if(!doc) - return E_OUTOFMEMORY; + return NULL;
+ doc->ref = 1; doc->basedoc.doc_node = doc; doc->basedoc.doc_obj = doc_obj; + doc->basedoc.window = window;
init_dispex(&doc->node.dispex, (IUnknown*)HTMLDOMNODE(&doc->node), &HTMLDocumentNode_dispex); init_doc(&doc->basedoc, (IUnknown*)HTMLDOMNODE(&doc->node), DISPATCHEX(&doc->node.dispex)); HTMLDocumentNode_SecMgr_Init(doc); - doc->ref = 1;
- doc->basedoc.window = window; + init_nsevents(doc); + + list_init(&doc->bindings); + list_init(&doc->selection_list); + list_init(&doc->range_list); + + return doc; +} + +HRESULT create_doc_from_nsdoc(nsIDOMHTMLDocument *nsdoc, HTMLDocumentObj *doc_obj, HTMLWindow *window, HTMLDocumentNode **ret) +{ + HTMLDocumentNode *doc; + HRESULT hres; + + doc = alloc_doc_node(doc_obj, window); + if(!doc) + return E_OUTOFMEMORY; + if(window == doc_obj->basedoc.window) doc->basedoc.cp_container.forward_container = &doc_obj->basedoc.cp_container;
nsIDOMHTMLDocument_AddRef(nsdoc); doc->nsdoc = nsdoc; init_mutation(doc); - init_nsevents(doc); - - list_init(&doc->bindings); - list_init(&doc->selection_list); - list_init(&doc->range_list);
HTMLDOMNode_Init(doc, &doc->node, (nsIDOMNode*)nsdoc); doc->node.vtbl = &HTMLDocumentNodeImplVtbl; @@ -1974,6 +1986,23 @@ HRESULT create_doc_from_nsdoc(nsIDOMHTMLDocument *nsdoc, HTMLDocumentObj *doc_ob return S_OK; }
+HRESULT create_document_fragment(nsIDOMNode *nsnode, HTMLDocumentNode *doc_node, HTMLDocumentNode **ret) +{ + HTMLDocumentNode *doc_frag; + + doc_frag = alloc_doc_node(doc_node->basedoc.doc_obj, doc_node->basedoc.window); + if(!doc_frag) + return E_OUTOFMEMORY; + + HTMLDOMNode_Init(doc_node, &doc_frag->node, nsnode); + doc_frag->node.vtbl = &HTMLDocumentNodeImplVtbl; + doc_frag->node.cp_container = &doc_frag->basedoc.cp_container; + + htmldoc_addref(&doc_frag->basedoc); + *ret = doc_frag; + return S_OK; +} + /********************************************************** * ICustomDoc implementation */ diff --git a/dlls/mshtml/htmldoc3.c b/dlls/mshtml/htmldoc3.c index 8d135ff..550cf5d 100644 --- a/dlls/mshtml/htmldoc3.c +++ b/dlls/mshtml/htmldoc3.c @@ -343,8 +343,31 @@ static HRESULT WINAPI HTMLDocument3_createDocumentFragment(IHTMLDocument3 *iface IHTMLDocument2 **ppNewDoc) { HTMLDocument *This = HTMLDOC3_THIS(iface); - FIXME("(%p)->(%p)\n", This, ppNewDoc); - return E_NOTIMPL; + 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 = HTMLDOC(&docnode->basedoc); + return S_OK; }
static HRESULT WINAPI HTMLDocument3_get_parentDocument(IHTMLDocument3 *iface, diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h index e99ecfd..5af4247 100644 --- a/dlls/mshtml/mshtml_private.h +++ b/dlls/mshtml/mshtml_private.h @@ -701,6 +701,7 @@ struct HTMLDocumentNode { HRESULT HTMLDocument_Create(IUnknown*,REFIID,void**); HRESULT HTMLLoadOptions_Create(IUnknown*,REFIID,void**); HRESULT create_doc_from_nsdoc(nsIDOMHTMLDocument*,HTMLDocumentObj*,HTMLWindow*,HTMLDocumentNode**); +HRESULT create_document_fragment(nsIDOMNode*,HTMLDocumentNode*,HTMLDocumentNode**);
HRESULT HTMLWindow_Create(HTMLDocumentObj*,nsIDOMWindow*,HTMLWindow*,HTMLWindow**); void update_window_doc(HTMLWindow*);