Commit a9136b56 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

mshtml: Addeed IHTMLDocument5::createAttribute implementation.

parent 2a0fd1c9
...@@ -81,6 +81,7 @@ static ULONG WINAPI HTMLDOMAttribute_Release(IHTMLDOMAttribute *iface) ...@@ -81,6 +81,7 @@ static ULONG WINAPI HTMLDOMAttribute_Release(IHTMLDOMAttribute *iface)
if(!ref) { if(!ref) {
assert(!This->elem); assert(!This->elem);
release_dispex(&This->dispex); release_dispex(&This->dispex);
heap_free(This->name);
heap_free(This); heap_free(This);
} }
...@@ -124,6 +125,11 @@ static HRESULT WINAPI HTMLDOMAttribute_get_nodeName(IHTMLDOMAttribute *iface, BS ...@@ -124,6 +125,11 @@ static HRESULT WINAPI HTMLDOMAttribute_get_nodeName(IHTMLDOMAttribute *iface, BS
TRACE("(%p)->(%p)\n", This, p); TRACE("(%p)->(%p)\n", This, p);
if(!This->elem) {
FIXME("NULL This->elem\n");
return E_UNEXPECTED;
}
return IDispatchEx_GetMemberName(&This->elem->node.dispex.IDispatchEx_iface, This->dispid, p); return IDispatchEx_GetMemberName(&This->elem->node.dispex.IDispatchEx_iface, This->dispid, p);
} }
...@@ -163,16 +169,16 @@ static HRESULT WINAPI HTMLDOMAttribute_get_specified(IHTMLDOMAttribute *iface, V ...@@ -163,16 +169,16 @@ static HRESULT WINAPI HTMLDOMAttribute_get_specified(IHTMLDOMAttribute *iface, V
TRACE("(%p)->(%p)\n", This, p); TRACE("(%p)->(%p)\n", This, p);
if(get_dispid_type(This->dispid) != DISPEXPROP_BUILTIN) {
*p = VARIANT_TRUE;
return S_OK;
}
if(!This->elem || !This->elem->nselem) { if(!This->elem || !This->elem->nselem) {
FIXME("NULL This->elem\n"); FIXME("NULL This->elem\n");
return E_UNEXPECTED; return E_UNEXPECTED;
} }
if(get_dispid_type(This->dispid) != DISPEXPROP_BUILTIN) {
*p = VARIANT_TRUE;
return S_OK;
}
hres = IDispatchEx_GetMemberName(&This->elem->node.dispex.IDispatchEx_iface, This->dispid, &name); hres = IDispatchEx_GetMemberName(&This->elem->node.dispex.IDispatchEx_iface, This->dispid, &name);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
...@@ -221,7 +227,7 @@ static dispex_static_data_t HTMLDOMAttribute_dispex = { ...@@ -221,7 +227,7 @@ static dispex_static_data_t HTMLDOMAttribute_dispex = {
HTMLDOMAttribute_iface_tids HTMLDOMAttribute_iface_tids
}; };
HRESULT HTMLDOMAttribute_Create(HTMLElement *elem, DISPID dispid, HTMLDOMAttribute **attr) HRESULT HTMLDOMAttribute_Create(const WCHAR *name, HTMLElement *elem, DISPID dispid, HTMLDOMAttribute **attr)
{ {
HTMLAttributeCollection *col; HTMLAttributeCollection *col;
HTMLDOMAttribute *ret; HTMLDOMAttribute *ret;
...@@ -231,22 +237,34 @@ HRESULT HTMLDOMAttribute_Create(HTMLElement *elem, DISPID dispid, HTMLDOMAttribu ...@@ -231,22 +237,34 @@ HRESULT HTMLDOMAttribute_Create(HTMLElement *elem, DISPID dispid, HTMLDOMAttribu
if(!ret) if(!ret)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
ret->IHTMLDOMAttribute_iface.lpVtbl = &HTMLDOMAttributeVtbl;
ret->ref = 1;
ret->dispid = dispid;
ret->elem = elem;
init_dispex(&ret->dispex, (IUnknown*)&ret->IHTMLDOMAttribute_iface,
&HTMLDOMAttribute_dispex);
/* For attributes attached to an element, (elem,dispid) pair should be valid used for its operation. */
if(elem) {
hres = HTMLElement_get_attr_col(&elem->node, &col); hres = HTMLElement_get_attr_col(&elem->node, &col);
if(FAILED(hres)) { if(FAILED(hres)) {
heap_free(ret); IHTMLDOMAttribute_Release(&ret->IHTMLDOMAttribute_iface);
return hres; return hres;
} }
IHTMLAttributeCollection_Release(&col->IHTMLAttributeCollection_iface); IHTMLAttributeCollection_Release(&col->IHTMLAttributeCollection_iface);
ret->IHTMLDOMAttribute_iface.lpVtbl = &HTMLDOMAttributeVtbl;
ret->ref = 1;
ret->dispid = dispid;
ret->elem = elem;
list_add_tail(&elem->attrs->attrs, &ret->entry); list_add_tail(&elem->attrs->attrs, &ret->entry);
}
init_dispex(&ret->dispex, (IUnknown*)&ret->IHTMLDOMAttribute_iface, /* For detached attributes we may still do most operations if we have its name available. */
&HTMLDOMAttribute_dispex); if(name) {
ret->name = heap_strdupW(name);
if(!ret->name) {
IHTMLDOMAttribute_Release(&ret->IHTMLDOMAttribute_iface);
return E_OUTOFMEMORY;
}
}
*attr = ret; *attr = ret;
return S_OK; return S_OK;
......
...@@ -120,8 +120,17 @@ static HRESULT WINAPI HTMLDocument5_createAttribute(IHTMLDocument5 *iface, BSTR ...@@ -120,8 +120,17 @@ static HRESULT WINAPI HTMLDocument5_createAttribute(IHTMLDocument5 *iface, BSTR
IHTMLDOMAttribute **ppattribute) IHTMLDOMAttribute **ppattribute)
{ {
HTMLDocument *This = impl_from_IHTMLDocument5(iface); HTMLDocument *This = impl_from_IHTMLDocument5(iface);
FIXME("(%p)->(%s %p)\n", This, debugstr_w(bstrattrName), ppattribute); HTMLDOMAttribute *attr;
return E_NOTIMPL; HRESULT hres;
TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrattrName), ppattribute);
hres = HTMLDOMAttribute_Create(bstrattrName, NULL, 0, &attr);
if(FAILED(hres))
return hres;
*ppattribute = &attr->IHTMLDOMAttribute_iface;
return S_OK;
} }
static HRESULT WINAPI HTMLDocument5_createComment(IHTMLDocument5 *iface, BSTR bstrdata, static HRESULT WINAPI HTMLDocument5_createComment(IHTMLDocument5 *iface, BSTR bstrdata,
......
...@@ -2246,7 +2246,7 @@ static inline HRESULT get_domattr(HTMLAttributeCollection *This, DISPID id, LONG ...@@ -2246,7 +2246,7 @@ static inline HRESULT get_domattr(HTMLAttributeCollection *This, DISPID id, LONG
return E_UNEXPECTED; return E_UNEXPECTED;
} }
hres = HTMLDOMAttribute_Create(This->elem, id, attr); hres = HTMLDOMAttribute_Create(NULL, This->elem, id, attr);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
} }
......
...@@ -852,12 +852,14 @@ typedef struct { ...@@ -852,12 +852,14 @@ typedef struct {
LONG ref; LONG ref;
DISPID dispid; WCHAR *name;
HTMLElement *elem; HTMLElement *elem;
DISPID dispid;
struct list entry; struct list entry;
} HTMLDOMAttribute; } HTMLDOMAttribute;
HRESULT HTMLDOMAttribute_Create(HTMLElement*,DISPID,HTMLDOMAttribute**) DECLSPEC_HIDDEN; HRESULT HTMLDOMAttribute_Create(const WCHAR*,HTMLElement*,DISPID,HTMLDOMAttribute**) DECLSPEC_HIDDEN;
HRESULT HTMLElement_Create(HTMLDocumentNode*,nsIDOMNode*,BOOL,HTMLElement**) DECLSPEC_HIDDEN; HRESULT HTMLElement_Create(HTMLDocumentNode*,nsIDOMNode*,BOOL,HTMLElement**) DECLSPEC_HIDDEN;
HRESULT HTMLCommentElement_Create(HTMLDocumentNode*,nsIDOMNode*,HTMLElement**) DECLSPEC_HIDDEN; HRESULT HTMLCommentElement_Create(HTMLDocumentNode*,nsIDOMNode*,HTMLElement**) DECLSPEC_HIDDEN;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment