mshtml: Add IHTMLDocument4::namespaces property implementation.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2020-07-02 16:56:48 +02:00 committed by Alexandre Julliard
parent e89ef98094
commit 2406590472
4 changed files with 202 additions and 4 deletions

View file

@ -2662,11 +2662,23 @@ static HRESULT WINAPI HTMLDocument4_get_onselectionchange(IHTMLDocument4 *iface,
return get_doc_event(This, EVENTID_SELECTIONCHANGE, p);
}
static HRESULT WINAPI HTMLDocument4_get_namespace(IHTMLDocument4 *iface, IDispatch **p)
static HRESULT WINAPI HTMLDocument4_get_namespaces(IHTMLDocument4 *iface, IDispatch **p)
{
HTMLDocument *This = impl_from_IHTMLDocument4(iface);
FIXME("(%p)->(%p)\n", This, p);
return E_NOTIMPL;
TRACE("(%p)->(%p)\n", This, p);
if(!This->doc_node->namespaces) {
HRESULT hres;
hres = create_namespace_collection(&This->doc_node->namespaces);
if(FAILED(hres))
return hres;
}
IHTMLNamespaceCollection_AddRef(This->doc_node->namespaces);
*p = (IDispatch*)This->doc_node->namespaces;
return S_OK;
}
static HRESULT WINAPI HTMLDocument4_createDocumentFromUrl(IHTMLDocument4 *iface, BSTR bstrUrl,
@ -2757,7 +2769,7 @@ static const IHTMLDocument4Vtbl HTMLDocument4Vtbl = {
HTMLDocument4_hasFocus,
HTMLDocument4_put_onselectionchange,
HTMLDocument4_get_onselectionchange,
HTMLDocument4_get_namespace,
HTMLDocument4_get_namespaces,
HTMLDocument4_createDocumentFromUrl,
HTMLDocument4_put_media,
HTMLDocument4_get_media,
@ -5423,6 +5435,11 @@ void detach_document_node(HTMLDocumentNode *doc)
doc->dom_implementation = NULL;
}
if(doc->namespaces) {
IHTMLNamespaceCollection_Release(doc->namespaces);
doc->namespaces = NULL;
}
detach_events(doc);
detach_selection(doc);
detach_ranges(doc);

View file

@ -112,6 +112,7 @@ typedef struct EventTarget EventTarget;
XDIID(DispHTMLLinkElement) \
XDIID(DispHTMLLocation) \
XDIID(DispHTMLMetaElement) \
XDIID(DispHTMLNamespaceCollection) \
XDIID(DispHTMLNavigator) \
XDIID(DispHTMLObjectElement) \
XDIID(DispHTMLOptionElement) \
@ -210,6 +211,7 @@ typedef struct EventTarget EventTarget;
XIID(IHTMLLocation) \
XIID(IHTMLMetaElement) \
XIID(IHTMLMimeTypesCollection) \
XIID(IHTMLNamespaceCollection) \
XIID(IHTMLObjectElement) \
XIID(IHTMLObjectElement2) \
XIID(IHTMLOptionElement) \
@ -870,6 +872,7 @@ struct HTMLDocumentNode {
BOOL content_ready;
IHTMLDOMImplementation *dom_implementation;
IHTMLNamespaceCollection *namespaces;
ICatInformation *catmgr;
nsDocumentEventListener *nsevent_listener;
@ -908,6 +911,7 @@ IOmNavigator *OmNavigator_Create(void) DECLSPEC_HIDDEN;
HRESULT HTMLScreen_Create(IHTMLScreen**) DECLSPEC_HIDDEN;
HRESULT create_performance(IHTMLPerformance**) DECLSPEC_HIDDEN;
HRESULT create_history(HTMLInnerWindow*,OmHistory**) DECLSPEC_HIDDEN;
HRESULT create_namespace_collection(IHTMLNamespaceCollection**) DECLSPEC_HIDDEN;
HRESULT create_dom_implementation(HTMLDocumentNode*,IHTMLDOMImplementation**) DECLSPEC_HIDDEN;
void detach_dom_implementation(IHTMLDOMImplementation*) DECLSPEC_HIDDEN;

View file

@ -2203,3 +2203,157 @@ HRESULT create_performance(IHTMLPerformance **ret)
*ret = &performance->IHTMLPerformance_iface;
return S_OK;
}
typedef struct {
DispatchEx dispex;
IHTMLNamespaceCollection IHTMLNamespaceCollection_iface;
LONG ref;
} HTMLNamespaceCollection;
static inline HTMLNamespaceCollection *impl_from_IHTMLNamespaceCollection(IHTMLNamespaceCollection *iface)
{
return CONTAINING_RECORD(iface, HTMLNamespaceCollection, IHTMLNamespaceCollection_iface);
}
static HRESULT WINAPI HTMLNamespaceCollection_QueryInterface(IHTMLNamespaceCollection *iface, REFIID riid, void **ppv)
{
HTMLNamespaceCollection *This = impl_from_IHTMLNamespaceCollection(iface);
TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
if(IsEqualGUID(&IID_IUnknown, riid)) {
*ppv = &This->IHTMLNamespaceCollection_iface;
}else if(IsEqualGUID(&IID_IHTMLNamespaceCollection, riid)) {
*ppv = &This->IHTMLNamespaceCollection_iface;
}else if(dispex_query_interface(&This->dispex, riid, ppv)) {
return *ppv ? S_OK : E_NOINTERFACE;
}else {
WARN("Unsupported interface %s\n", debugstr_mshtml_guid(riid));
*ppv = NULL;
return E_NOINTERFACE;
}
IUnknown_AddRef((IUnknown*)*ppv);
return S_OK;
}
static ULONG WINAPI HTMLNamespaceCollection_AddRef(IHTMLNamespaceCollection *iface)
{
HTMLNamespaceCollection *This = impl_from_IHTMLNamespaceCollection(iface);
LONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p) ref=%d\n", This, ref);
return ref;
}
static ULONG WINAPI HTMLNamespaceCollection_Release(IHTMLNamespaceCollection *iface)
{
HTMLNamespaceCollection *This = impl_from_IHTMLNamespaceCollection(iface);
LONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p) ref=%d\n", This, ref);
if(!ref) {
release_dispex(&This->dispex);
heap_free(This);
}
return ref;
}
static HRESULT WINAPI HTMLNamespaceCollection_GetTypeInfoCount(IHTMLNamespaceCollection *iface, UINT *pctinfo)
{
HTMLNamespaceCollection *This = impl_from_IHTMLNamespaceCollection(iface);
FIXME("(%p)->(%p)\n", This, pctinfo);
return E_NOTIMPL;
}
static HRESULT WINAPI HTMLNamespaceCollection_GetTypeInfo(IHTMLNamespaceCollection *iface, UINT iTInfo,
LCID lcid, ITypeInfo **ppTInfo)
{
HTMLNamespaceCollection *This = impl_from_IHTMLNamespaceCollection(iface);
return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
}
static HRESULT WINAPI HTMLNamespaceCollection_GetIDsOfNames(IHTMLNamespaceCollection *iface, REFIID riid,
LPOLESTR *rgszNames, UINT cNames,
LCID lcid, DISPID *rgDispId)
{
HTMLNamespaceCollection *This = impl_from_IHTMLNamespaceCollection(iface);
return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
lcid, rgDispId);
}
static HRESULT WINAPI HTMLNamespaceCollection_Invoke(IHTMLNamespaceCollection *iface, DISPID dispIdMember,
REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
{
HTMLNamespaceCollection *This = impl_from_IHTMLNamespaceCollection(iface);
return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
pDispParams, pVarResult, pExcepInfo, puArgErr);
}
static HRESULT WINAPI HTMLNamespaceCollection_get_length(IHTMLNamespaceCollection *iface, LONG *p)
{
HTMLNamespaceCollection *This = impl_from_IHTMLNamespaceCollection(iface);
FIXME("(%p)->(%p) returning 0\n", This, p);
*p = 0;
return S_OK;
}
static HRESULT WINAPI HTMLNamespaceCollection_item(IHTMLNamespaceCollection *iface, VARIANT index, IDispatch **p)
{
HTMLNamespaceCollection *This = impl_from_IHTMLNamespaceCollection(iface);
FIXME("(%p)->(%s %p)\n", This, debugstr_variant(&index), p);
return E_NOTIMPL;
}
static HRESULT WINAPI HTMLNamespaceCollection_add(IHTMLNamespaceCollection *iface, BSTR namespace, BSTR urn,
VARIANT implementation_url, IDispatch **p)
{
HTMLNamespaceCollection *This = impl_from_IHTMLNamespaceCollection(iface);
FIXME("(%p)->(%s %s %s %p)\n", This, debugstr_w(namespace), debugstr_w(urn), debugstr_variant(&implementation_url), p);
return E_NOTIMPL;
}
static const IHTMLNamespaceCollectionVtbl HTMLNamespaceCollectionVtbl = {
HTMLNamespaceCollection_QueryInterface,
HTMLNamespaceCollection_AddRef,
HTMLNamespaceCollection_Release,
HTMLNamespaceCollection_GetTypeInfoCount,
HTMLNamespaceCollection_GetTypeInfo,
HTMLNamespaceCollection_GetIDsOfNames,
HTMLNamespaceCollection_Invoke,
HTMLNamespaceCollection_get_length,
HTMLNamespaceCollection_item,
HTMLNamespaceCollection_add
};
static const tid_t HTMLNamespaceCollection_iface_tids[] = {
IHTMLNamespaceCollection_tid,
0
};
static dispex_static_data_t HTMLNamespaceCollection_dispex = {
NULL,
DispHTMLNamespaceCollection_tid,
HTMLNamespaceCollection_iface_tids
};
HRESULT create_namespace_collection(IHTMLNamespaceCollection **ret)
{
HTMLNamespaceCollection *namespaces;
if (!(namespaces = heap_alloc_zero(sizeof(*namespaces))))
return E_OUTOFMEMORY;
namespaces->IHTMLNamespaceCollection_iface.lpVtbl = &HTMLNamespaceCollectionVtbl;
namespaces->ref = 1;
init_dispex(&namespaces->dispex, (IUnknown*)&namespaces->IHTMLNamespaceCollection_iface, &HTMLNamespaceCollection_dispex);
*ret = &namespaces->IHTMLNamespaceCollection_iface;
return S_OK;
}

View file

@ -6577,9 +6577,13 @@ static void test_unique_id(IHTMLDocument2 *doc, IHTMLElement *elem)
static void test_doc_elem(IHTMLDocument2 *doc)
{
IHTMLNamespaceCollection *namespaces;
IHTMLDocument2 *doc_node, *owner_doc;
IHTMLDocument4 *doc4;
IHTMLElement *elem;
IHTMLDocument3 *doc3;
IDispatch *disp;
LONG l;
HRESULT hres;
BSTR bstr;
@ -6614,6 +6618,25 @@ static void test_doc_elem(IHTMLDocument2 *doc)
test_doc_dir(doc);
IHTMLElement_Release(elem);
hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument4, (void**)&doc4);
ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument4) failed: %08x\n", hres);
hres = IHTMLDocument4_get_namespaces(doc4, &disp);
ok(hres == S_OK, "get_namespaces failed: %08x\n", hres);
test_disp((IUnknown*)disp, &DIID_DispHTMLNamespaceCollection, NULL, L"[object]");
hres = IDispatch_QueryInterface(disp, &IID_IHTMLNamespaceCollection, (void**)&namespaces);
ok(hres == S_OK, "Could not get IHTMLNamespaceCollection iface: %08x\n", hres);
hres = IHTMLNamespaceCollection_get_length(namespaces, &l);
ok(hres == S_OK, "get_length failed: %08x\n", hres);
ok(l == 0, "length = %d\n", l);
IHTMLNamespaceCollection_Release(namespaces);
IDispatch_Release(disp);
IHTMLDocument4_Release(doc4);
}
static void test_default_body(IHTMLBodyElement *body)