From f351dc5e7401a7cfa30ea3f5a966865df8bf4758 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Sun, 14 Nov 2010 14:41:39 +0100 Subject: [PATCH] mshtml: Moved cloneNode implementation to vtbl. --- dlls/mshtml/htmlanchor.c | 3 ++- dlls/mshtml/htmlbody.c | 1 + dlls/mshtml/htmlcomment.c | 3 ++- dlls/mshtml/htmldoc.c | 10 +++++++++- dlls/mshtml/htmlelem.c | 15 ++++++++++++++- dlls/mshtml/htmlembed.c | 3 ++- dlls/mshtml/htmlform.c | 1 + dlls/mshtml/htmlframe.c | 1 + dlls/mshtml/htmlgeneric.c | 3 ++- dlls/mshtml/htmliframe.c | 1 + dlls/mshtml/htmlimg.c | 1 + dlls/mshtml/htmlinput.c | 1 + dlls/mshtml/htmlnode.c | 22 +++++++++++++++++----- dlls/mshtml/htmlobject.c | 3 ++- dlls/mshtml/htmloption.c | 3 ++- dlls/mshtml/htmlscript.c | 1 + dlls/mshtml/htmlselect.c | 1 + dlls/mshtml/htmlstyleelem.c | 3 ++- dlls/mshtml/htmltable.c | 3 ++- dlls/mshtml/htmltablerow.c | 3 ++- dlls/mshtml/htmltextarea.c | 1 + dlls/mshtml/htmltextnode.c | 12 +++++++++++- dlls/mshtml/mshtml_private.h | 2 ++ 23 files changed, 80 insertions(+), 17 deletions(-) diff --git a/dlls/mshtml/htmlanchor.c b/dlls/mshtml/htmlanchor.c index ae269ee252..9c4a48edd3 100644 --- a/dlls/mshtml/htmlanchor.c +++ b/dlls/mshtml/htmlanchor.c @@ -515,7 +515,8 @@ static void HTMLAnchorElement_destructor(HTMLDOMNode *iface) static const NodeImplVtbl HTMLAnchorElementImplVtbl = { HTMLAnchorElement_QI, - HTMLAnchorElement_destructor + HTMLAnchorElement_destructor, + HTMLElement_clone }; static const tid_t HTMLAnchorElement_iface_tids[] = { diff --git a/dlls/mshtml/htmlbody.c b/dlls/mshtml/htmlbody.c index 18a60418ce..110c2c87ec 100644 --- a/dlls/mshtml/htmlbody.c +++ b/dlls/mshtml/htmlbody.c @@ -792,6 +792,7 @@ static event_target_t **HTMLBodyElement_get_event_target(HTMLDOMNode *iface) static const NodeImplVtbl HTMLBodyElementImplVtbl = { HTMLBodyElement_QI, HTMLBodyElement_destructor, + HTMLElement_clone, HTMLBodyElement_get_event_target }; diff --git a/dlls/mshtml/htmlcomment.c b/dlls/mshtml/htmlcomment.c index 7040d18407..077a746c27 100644 --- a/dlls/mshtml/htmlcomment.c +++ b/dlls/mshtml/htmlcomment.c @@ -169,7 +169,8 @@ static void HTMLCommentElement_destructor(HTMLDOMNode *iface) static const NodeImplVtbl HTMLCommentElementImplVtbl = { HTMLCommentElement_QI, - HTMLCommentElement_destructor + HTMLCommentElement_destructor, + HTMLElement_clone }; static const tid_t HTMLCommentElement_iface_tids[] = { diff --git a/dlls/mshtml/htmldoc.c b/dlls/mshtml/htmldoc.c index 61476328dd..dfa2a8b54a 100644 --- a/dlls/mshtml/htmldoc.c +++ b/dlls/mshtml/htmldoc.c @@ -1898,11 +1898,19 @@ static void HTMLDocumentNode_destructor(HTMLDOMNode *iface) destroy_htmldoc(&This->basedoc); } +static HRESULT HTMLDocumentNode_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret) +{ + HTMLDocumentNode *This = HTMLDOCNODE_NODE_THIS(iface); + FIXME("%p\n", This); + return E_NOTIMPL; +} + #undef HTMLDOCNODE_NODE_THIS static const NodeImplVtbl HTMLDocumentNodeImplVtbl = { HTMLDocumentNode_QI, - HTMLDocumentNode_destructor + HTMLDocumentNode_destructor, + HTMLDocumentNode_clone }; static const tid_t HTMLDocumentNode_iface_tids[] = { diff --git a/dlls/mshtml/htmlelem.c b/dlls/mshtml/htmlelem.c index d291b036a9..78b9e0964f 100644 --- a/dlls/mshtml/htmlelem.c +++ b/dlls/mshtml/htmlelem.c @@ -1601,9 +1601,22 @@ void HTMLElement_destructor(HTMLDOMNode *iface) HTMLDOMNode_destructor(&This->node); } +HRESULT HTMLElement_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret) +{ + HTMLElement *This = HTMLELEM_NODE_THIS(iface); + HTMLElement *new_elem; + + new_elem = HTMLElement_Create(This->node.doc, nsnode, FALSE); + IHTMLElement_AddRef(HTMLELEM(new_elem)); + + *ret = &new_elem->node; + return S_OK; +} + static const NodeImplVtbl HTMLElementImplVtbl = { HTMLElement_QI, - HTMLElement_destructor + HTMLElement_destructor, + HTMLElement_clone }; static const tid_t HTMLElement_iface_tids[] = { diff --git a/dlls/mshtml/htmlembed.c b/dlls/mshtml/htmlembed.c index f72f15d60d..cc04b0efd2 100644 --- a/dlls/mshtml/htmlembed.c +++ b/dlls/mshtml/htmlembed.c @@ -251,7 +251,8 @@ static void HTMLEmbedElement_destructor(HTMLDOMNode *iface) static const NodeImplVtbl HTMLEmbedElementImplVtbl = { HTMLEmbedElement_QI, - HTMLEmbedElement_destructor + HTMLEmbedElement_destructor, + HTMLElement_clone }; static const tid_t HTMLEmbedElement_iface_tids[] = { diff --git a/dlls/mshtml/htmlform.c b/dlls/mshtml/htmlform.c index 27aef797e3..c71e2ac960 100644 --- a/dlls/mshtml/htmlform.c +++ b/dlls/mshtml/htmlform.c @@ -638,6 +638,7 @@ static HRESULT HTMLFormElement_invoke(HTMLDOMNode *iface, static const NodeImplVtbl HTMLFormElementImplVtbl = { HTMLFormElement_QI, HTMLFormElement_destructor, + HTMLElement_clone, NULL, NULL, NULL, diff --git a/dlls/mshtml/htmlframe.c b/dlls/mshtml/htmlframe.c index 8d458f7a77..ece349dccf 100644 --- a/dlls/mshtml/htmlframe.c +++ b/dlls/mshtml/htmlframe.c @@ -258,6 +258,7 @@ static HRESULT HTMLFrameElement_bind_to_tree(HTMLDOMNode *iface) static const NodeImplVtbl HTMLFrameElementImplVtbl = { HTMLFrameElement_QI, HTMLFrameElement_destructor, + HTMLElement_clone, NULL, NULL, NULL, diff --git a/dlls/mshtml/htmlgeneric.c b/dlls/mshtml/htmlgeneric.c index 82075b8d32..1580929ed1 100644 --- a/dlls/mshtml/htmlgeneric.c +++ b/dlls/mshtml/htmlgeneric.c @@ -149,7 +149,8 @@ static void HTMLGenericElement_destructor(HTMLDOMNode *iface) static const NodeImplVtbl HTMLGenericElementImplVtbl = { HTMLGenericElement_QI, - HTMLGenericElement_destructor + HTMLGenericElement_destructor, + HTMLElement_clone }; static const tid_t HTMLGenericElement_iface_tids[] = { diff --git a/dlls/mshtml/htmliframe.c b/dlls/mshtml/htmliframe.c index 12cd427517..fd7096abb4 100644 --- a/dlls/mshtml/htmliframe.c +++ b/dlls/mshtml/htmliframe.c @@ -243,6 +243,7 @@ static HRESULT HTMLIFrame_bind_to_tree(HTMLDOMNode *iface) static const NodeImplVtbl HTMLIFrameImplVtbl = { HTMLIFrame_QI, HTMLIFrame_destructor, + HTMLElement_clone, NULL, NULL, NULL, diff --git a/dlls/mshtml/htmlimg.c b/dlls/mshtml/htmlimg.c index a4448f9588..b0ec04e9d9 100644 --- a/dlls/mshtml/htmlimg.c +++ b/dlls/mshtml/htmlimg.c @@ -645,6 +645,7 @@ static HRESULT HTMLImgElement_get_readystate(HTMLDOMNode *iface, BSTR *p) static const NodeImplVtbl HTMLImgElementImplVtbl = { HTMLImgElement_QI, HTMLImgElement_destructor, + HTMLElement_clone, NULL, NULL, NULL, diff --git a/dlls/mshtml/htmlinput.c b/dlls/mshtml/htmlinput.c index 76a5063bc2..fac320e52a 100644 --- a/dlls/mshtml/htmlinput.c +++ b/dlls/mshtml/htmlinput.c @@ -1193,6 +1193,7 @@ static HRESULT HTMLInputElementImpl_get_disabled(HTMLDOMNode *iface, VARIANT_BOO static const NodeImplVtbl HTMLInputElementImplVtbl = { HTMLInputElement_QI, HTMLInputElement_destructor, + HTMLElement_clone, NULL, HTMLInputElementImpl_call_event, HTMLInputElementImpl_put_disabled, diff --git a/dlls/mshtml/htmlnode.c b/dlls/mshtml/htmlnode.c index a5ea3f4dd0..932577e23c 100644 --- a/dlls/mshtml/htmlnode.c +++ b/dlls/mshtml/htmlnode.c @@ -33,6 +33,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(mshtml); static HTMLDOMNode *get_node_obj(HTMLDocumentNode*,IUnknown*); +static HTMLDOMNode *create_node(HTMLDocumentNode*,nsIDOMNode*); typedef struct { DispatchEx dispex; @@ -536,9 +537,10 @@ static HRESULT WINAPI HTMLDOMNode_cloneNode(IHTMLDOMNode *iface, VARIANT_BOOL fD IHTMLDOMNode **clonedNode) { HTMLDOMNode *This = HTMLDOMNODE_THIS(iface); + HTMLDOMNode *new_node; nsIDOMNode *nsnode; - HTMLDOMNode *node; nsresult nsres; + HRESULT hres; TRACE("(%p)->(%x %p)\n", This, fDeep, clonedNode); @@ -548,9 +550,11 @@ static HRESULT WINAPI HTMLDOMNode_cloneNode(IHTMLDOMNode *iface, VARIANT_BOOL fD return E_FAIL; } - node = get_node(This->doc, nsnode, TRUE); - IHTMLDOMNode_AddRef(HTMLDOMNODE(node)); - *clonedNode = HTMLDOMNODE(node); + hres = This->vtbl->clone(This, nsnode, &new_node); + if(FAILED(hres)) + return hres; + + *clonedNode = HTMLDOMNODE(new_node); return S_OK; } @@ -904,9 +908,17 @@ void HTMLDOMNode_destructor(HTMLDOMNode *This) release_event_target(This->event_target); } +static HRESULT HTMLDOMNode_clone(HTMLDOMNode *This, nsIDOMNode *nsnode, HTMLDOMNode **ret) +{ + *ret = create_node(This->doc, nsnode); + IHTMLDOMNode_AddRef(HTMLDOMNODE(*ret)); + return S_OK; +} + static const NodeImplVtbl HTMLDOMNodeImplVtbl = { HTMLDOMNode_QI, - HTMLDOMNode_destructor + HTMLDOMNode_destructor, + HTMLDOMNode_clone }; void HTMLDOMNode_Init(HTMLDocumentNode *doc, HTMLDOMNode *node, nsIDOMNode *nsnode) diff --git a/dlls/mshtml/htmlobject.c b/dlls/mshtml/htmlobject.c index 2af4faacf6..f7f6d4534f 100644 --- a/dlls/mshtml/htmlobject.c +++ b/dlls/mshtml/htmlobject.c @@ -428,7 +428,8 @@ static void HTMLObjectElement_destructor(HTMLDOMNode *iface) static const NodeImplVtbl HTMLObjectElementImplVtbl = { HTMLObjectElement_QI, - HTMLObjectElement_destructor + HTMLObjectElement_destructor, + HTMLElement_clone }; static const tid_t HTMLObjectElement_iface_tids[] = { diff --git a/dlls/mshtml/htmloption.c b/dlls/mshtml/htmloption.c index b8166341bd..1d03ad1cd6 100644 --- a/dlls/mshtml/htmloption.c +++ b/dlls/mshtml/htmloption.c @@ -340,7 +340,8 @@ static void HTMLOptionElement_destructor(HTMLDOMNode *iface) static const NodeImplVtbl HTMLOptionElementImplVtbl = { HTMLOptionElement_QI, - HTMLOptionElement_destructor + HTMLOptionElement_destructor, + HTMLElement_clone }; static const tid_t HTMLOptionElement_iface_tids[] = { diff --git a/dlls/mshtml/htmlscript.c b/dlls/mshtml/htmlscript.c index f39e3061c5..c4a9bf6ae5 100644 --- a/dlls/mshtml/htmlscript.c +++ b/dlls/mshtml/htmlscript.c @@ -321,6 +321,7 @@ static HRESULT HTMLScriptElement_get_readystate(HTMLDOMNode *iface, BSTR *p) static const NodeImplVtbl HTMLScriptElementImplVtbl = { HTMLScriptElement_QI, HTMLScriptElement_destructor, + HTMLElement_clone, NULL, NULL, NULL, diff --git a/dlls/mshtml/htmlselect.c b/dlls/mshtml/htmlselect.c index f3aa36f650..10c2dff21c 100644 --- a/dlls/mshtml/htmlselect.c +++ b/dlls/mshtml/htmlselect.c @@ -613,6 +613,7 @@ static HRESULT HTMLSelectElement_invoke(HTMLDOMNode *iface, DISPID id, LCID lcid static const NodeImplVtbl HTMLSelectElementImplVtbl = { HTMLSelectElement_QI, HTMLSelectElement_destructor, + HTMLElement_clone, NULL, NULL, HTMLSelectElementImpl_put_disabled, diff --git a/dlls/mshtml/htmlstyleelem.c b/dlls/mshtml/htmlstyleelem.c index f0076bf99f..2edd6c14a9 100644 --- a/dlls/mshtml/htmlstyleelem.c +++ b/dlls/mshtml/htmlstyleelem.c @@ -251,7 +251,8 @@ static void HTMLStyleElement_destructor(HTMLDOMNode *iface) static const NodeImplVtbl HTMLStyleElementImplVtbl = { HTMLStyleElement_QI, - HTMLStyleElement_destructor + HTMLStyleElement_destructor, + HTMLElement_clone }; static const tid_t HTMLStyleElement_iface_tids[] = { diff --git a/dlls/mshtml/htmltable.c b/dlls/mshtml/htmltable.c index 12869523db..045e02fcc1 100644 --- a/dlls/mshtml/htmltable.c +++ b/dlls/mshtml/htmltable.c @@ -554,7 +554,8 @@ static void HTMLTable_destructor(HTMLDOMNode *iface) static const NodeImplVtbl HTMLTableImplVtbl = { HTMLTable_QI, - HTMLTable_destructor + HTMLTable_destructor, + HTMLElement_clone, }; static const tid_t HTMLTable_iface_tids[] = { diff --git a/dlls/mshtml/htmltablerow.c b/dlls/mshtml/htmltablerow.c index 950535af25..8610b655da 100644 --- a/dlls/mshtml/htmltablerow.c +++ b/dlls/mshtml/htmltablerow.c @@ -297,7 +297,8 @@ static void HTMLTableRow_destructor(HTMLDOMNode *iface) static const NodeImplVtbl HTMLTableRowImplVtbl = { HTMLTableRow_QI, - HTMLTableRow_destructor + HTMLTableRow_destructor, + HTMLElement_clone }; static const tid_t HTMLTableRow_iface_tids[] = { diff --git a/dlls/mshtml/htmltextarea.c b/dlls/mshtml/htmltextarea.c index 3ea510ee10..819fd0eb9b 100644 --- a/dlls/mshtml/htmltextarea.c +++ b/dlls/mshtml/htmltextarea.c @@ -444,6 +444,7 @@ static HRESULT HTMLTextAreaElementImpl_get_disabled(HTMLDOMNode *iface, VARIANT_ static const NodeImplVtbl HTMLTextAreaElementImplVtbl = { HTMLTextAreaElement_QI, HTMLTextAreaElement_destructor, + HTMLElement_clone, NULL, NULL, HTMLTextAreaElementImpl_put_disabled, diff --git a/dlls/mshtml/htmltextnode.c b/dlls/mshtml/htmltextnode.c index 1c2c2daca8..1bbca532e6 100644 --- a/dlls/mshtml/htmltextnode.c +++ b/dlls/mshtml/htmltextnode.c @@ -187,11 +187,21 @@ static void HTMLDOMTextNode_destructor(HTMLDOMNode *iface) HTMLDOMNode_destructor(&This->node); } +static HRESULT HTMLDOMTextNode_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret) +{ + HTMLDOMTextNode *This = HTMLTEXT_NODE_THIS(iface); + + *ret = HTMLDOMTextNode_Create(This->node.doc, nsnode); + IHTMLDOMNode_AddRef(HTMLDOMNODE(*ret)); + return S_OK; +} + #undef HTMLTEXT_NODE_THIS static const NodeImplVtbl HTMLDOMTextNodeImplVtbl = { HTMLDOMTextNode_QI, - HTMLDOMTextNode_destructor + HTMLDOMTextNode_destructor, + HTMLDOMTextNode_clone }; static const tid_t HTMLDOMTextNode_iface_tids[] = { diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h index f694dac924..e99ecfd81e 100644 --- a/dlls/mshtml/mshtml_private.h +++ b/dlls/mshtml/mshtml_private.h @@ -513,6 +513,7 @@ HRESULT set_http_header(struct list*,const WCHAR*,int,const WCHAR*,int); typedef struct { HRESULT (*qi)(HTMLDOMNode*,REFIID,void**); void (*destructor)(HTMLDOMNode*); + HRESULT (*clone)(HTMLDOMNode*,nsIDOMNode*,HTMLDOMNode**); event_target_t **(*get_event_target)(HTMLDOMNode*); HRESULT (*call_event)(HTMLDOMNode*,DWORD,BOOL*); HRESULT (*put_disabled)(HTMLDOMNode*,VARIANT_BOOL); @@ -849,6 +850,7 @@ void HTMLDOMNode_destructor(HTMLDOMNode*); HRESULT HTMLElement_QI(HTMLDOMNode*,REFIID,void**); void HTMLElement_destructor(HTMLDOMNode*); +HRESULT HTMLElement_clone(HTMLDOMNode*,nsIDOMNode*,HTMLDOMNode**); HRESULT HTMLFrameBase_QI(HTMLFrameBase*,REFIID,void**); void HTMLFrameBase_destructor(HTMLFrameBase*);