mshtml: Added IHTMLDocument3::createDocumentFragment implementation.

This commit is contained in:
Jacek Caban 2010-11-14 14:42:20 +01:00 committed by Alexandre Julliard
parent cb99f716a7
commit d9aacfd989
3 changed files with 70 additions and 17 deletions

View File

@ -1930,35 +1930,47 @@ static dispex_static_data_t HTMLDocumentNode_dispex = {
HTMLDocumentNode_iface_tids
};
static HTMLDocumentNode *alloc_doc_node(HTMLDocumentObj *doc_obj, HTMLWindow *window)
{
HTMLDocumentNode *doc;
doc = heap_alloc_zero(sizeof(HTMLDocumentNode));
if(!doc)
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);
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 = heap_alloc_zero(sizeof(HTMLDocumentNode));
doc = alloc_doc_node(doc_obj, window);
if(!doc)
return E_OUTOFMEMORY;
doc->basedoc.doc_node = doc;
doc->basedoc.doc_obj = doc_obj;
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;
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
*/

View File

@ -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,

View File

@ -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*);