From: Jacek Caban jacek@codeweavers.com
--- dlls/mshtml/htmldoc.c | 18 +++++++------- dlls/mshtml/htmlelem.c | 8 +++---- dlls/mshtml/htmlelemcol.c | 39 +++++++++---------------------- dlls/mshtml/htmlform.c | 2 +- dlls/mshtml/htmltable.c | 6 ++--- dlls/mshtml/mshtml_private.h | 4 ++-- dlls/mshtml/tests/documentmode.js | 2 +- 7 files changed, 31 insertions(+), 48 deletions(-)
diff --git a/dlls/mshtml/htmldoc.c b/dlls/mshtml/htmldoc.c index eaf3b352006..57851f20b52 100644 --- a/dlls/mshtml/htmldoc.c +++ b/dlls/mshtml/htmldoc.c @@ -491,7 +491,7 @@ static HRESULT WINAPI HTMLDocument_get_images(IHTMLDocument2 *iface, IHTMLElemen }
if(nscoll) { - *p = create_collection_from_htmlcol(nscoll, This->document_mode); + *p = create_collection_from_htmlcol(nscoll, &This->node.event_target.dispex); nsIDOMHTMLCollection_Release(nscoll); }
@@ -528,7 +528,7 @@ static HRESULT WINAPI HTMLDocument_get_applets(IHTMLDocument2 *iface, IHTMLEleme }
if(nscoll) { - *p = create_collection_from_htmlcol(nscoll, This->document_mode); + *p = create_collection_from_htmlcol(nscoll, &This->node.event_target.dispex); nsIDOMHTMLCollection_Release(nscoll); }
@@ -565,7 +565,7 @@ static HRESULT WINAPI HTMLDocument_get_links(IHTMLDocument2 *iface, IHTMLElement }
if(nscoll) { - *p = create_collection_from_htmlcol(nscoll, This->document_mode); + *p = create_collection_from_htmlcol(nscoll, &This->node.event_target.dispex); nsIDOMHTMLCollection_Release(nscoll); }
@@ -602,7 +602,7 @@ static HRESULT WINAPI HTMLDocument_get_forms(IHTMLDocument2 *iface, IHTMLElement }
if(nscoll) { - *p = create_collection_from_htmlcol(nscoll, This->document_mode); + *p = create_collection_from_htmlcol(nscoll, &This->node.event_target.dispex); nsIDOMHTMLCollection_Release(nscoll); }
@@ -639,7 +639,7 @@ static HRESULT WINAPI HTMLDocument_get_anchors(IHTMLDocument2 *iface, IHTMLEleme }
if(nscoll) { - *p = create_collection_from_htmlcol(nscoll, This->document_mode); + *p = create_collection_from_htmlcol(nscoll, &This->node.event_target.dispex); nsIDOMHTMLCollection_Release(nscoll); }
@@ -729,7 +729,7 @@ static HRESULT WINAPI HTMLDocument_get_scripts(IHTMLDocument2 *iface, IHTMLEleme }
if(nscoll) { - *p = create_collection_from_htmlcol(nscoll, This->document_mode); + *p = create_collection_from_htmlcol(nscoll, &This->node.event_target.dispex); nsIDOMHTMLCollection_Release(nscoll); }
@@ -2601,7 +2601,7 @@ static HRESULT WINAPI HTMLDocument3_getElementsByName(IHTMLDocument3 *iface, BST return E_FAIL; }
- *ppelColl = create_collection_from_nodelist(node_list, This->document_mode); + *ppelColl = create_collection_from_nodelist(node_list, &This->node.event_target.dispex); nsIDOMNodeList_Release(node_list); return S_OK; } @@ -2678,7 +2678,7 @@ static HRESULT WINAPI HTMLDocument3_getElementsByTagName(IHTMLDocument3 *iface, }
- *pelColl = create_collection_from_nodelist(nslist, This->document_mode); + *pelColl = create_collection_from_nodelist(nslist, &This->node.event_target.dispex); nsIDOMNodeList_Release(nslist);
return S_OK; @@ -3487,7 +3487,7 @@ static HRESULT WINAPI HTMLDocument7_getElementsByClassName(IHTMLDocument7 *iface }
- *pel = create_collection_from_nodelist(nslist, This->document_mode); + *pel = create_collection_from_nodelist(nslist, &This->node.event_target.dispex); nsIDOMNodeList_Release(nslist); return S_OK; } diff --git a/dlls/mshtml/htmlelem.c b/dlls/mshtml/htmlelem.c index bc140b14984..24ecf145752 100644 --- a/dlls/mshtml/htmlelem.c +++ b/dlls/mshtml/htmlelem.c @@ -2611,7 +2611,7 @@ static HRESULT WINAPI HTMLElement_get_children(IHTMLElement *iface, IDispatch ** return E_FAIL; }
- *p = (IDispatch*)create_collection_from_nodelist(nsnode_list, This->node.doc->document_mode); + *p = (IDispatch*)create_collection_from_nodelist(nsnode_list, &This->node.event_target.dispex);
nsIDOMNodeList_Release(nsnode_list); return S_OK; @@ -3792,7 +3792,7 @@ static HRESULT WINAPI HTMLElement2_getElementsByTagName(IHTMLElement2 *iface, BS TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pelColl);
if(!This->dom_element) { - *pelColl = create_collection_from_htmlcol(NULL, This->node.doc->document_mode); + *pelColl = create_collection_from_htmlcol(NULL, &This->node.event_target.dispex); return S_OK; }
@@ -3804,7 +3804,7 @@ static HRESULT WINAPI HTMLElement2_getElementsByTagName(IHTMLElement2 *iface, BS return E_FAIL; }
- *pelColl = create_collection_from_htmlcol(nscol, dispex_compat_mode(&This->node.event_target.dispex)); + *pelColl = create_collection_from_htmlcol(nscol, &This->node.event_target.dispex); nsIDOMHTMLCollection_Release(nscol); return S_OK; } @@ -4820,7 +4820,7 @@ static HRESULT WINAPI HTMLElement6_getElementsByClassName(IHTMLElement6 *iface, } }
- *pel = create_collection_from_htmlcol(nscol, dispex_compat_mode(&This->node.event_target.dispex)); + *pel = create_collection_from_htmlcol(nscol, &This->node.event_target.dispex); nsIDOMHTMLCollection_Release(nscol); return S_OK; } diff --git a/dlls/mshtml/htmlelemcol.c b/dlls/mshtml/htmlelemcol.c index a264813f9bb..625af9781b8 100644 --- a/dlls/mshtml/htmlelemcol.c +++ b/dlls/mshtml/htmlelemcol.c @@ -60,7 +60,7 @@ static inline HTMLElement *elem_from_HTMLDOMNode(HTMLDOMNode *iface) return CONTAINING_RECORD(iface, HTMLElement, node); }
-static IHTMLElementCollection *HTMLElementCollection_Create(HTMLElement**,DWORD,compat_mode_t); +static IHTMLElementCollection *HTMLElementCollection_Create(HTMLElement**,DWORD,DispatchEx*);
static void elem_vector_add(elem_vector_t *buf, HTMLElement *elem) { @@ -377,8 +377,7 @@ static HRESULT WINAPI HTMLElementCollection_item(IHTMLElementCollection *iface,
if(buf.len > 1) { elem_vector_normalize(&buf); - *pdisp = (IDispatch*)HTMLElementCollection_Create(buf.buf, buf.len, - dispex_compat_mode(&This->dispex)); + *pdisp = (IDispatch*)HTMLElementCollection_Create(buf.buf, buf.len, &This->dispex); }else { if(buf.len == 1) { /* Already AddRef-ed */ @@ -440,8 +439,7 @@ static HRESULT WINAPI HTMLElementCollection_tags(IHTMLElementCollection *iface,
TRACE("found %ld tags\n", buf.len);
- *pdisp = (IDispatch*)HTMLElementCollection_Create(buf.buf, buf.len, - dispex_compat_mode(&This->dispex)); + *pdisp = (IDispatch*)HTMLElementCollection_Create(buf.buf, buf.len, &This->dispex); return S_OK; }
@@ -535,20 +533,6 @@ static HRESULT HTMLElementCollection_get_dispid(DispatchEx *dispex, const WCHAR return S_OK; }
-static HRESULT HTMLElementCollection_get_name(DispatchEx *dispex, DISPID id, BSTR *name) -{ - HTMLElementCollection *This = impl_from_DispatchEx(dispex); - DWORD idx = id - MSHTML_DISPID_CUSTOM_MIN; - WCHAR buf[11]; - UINT len; - - if(idx >= This->len) - return DISP_E_MEMBERNOTFOUND; - - len = swprintf(buf, ARRAY_SIZE(buf), L"%u", idx); - return (*name = SysAllocStringLen(buf, len)) ? S_OK : E_OUTOFMEMORY; -} - static HRESULT HTMLElementCollection_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller) { @@ -581,7 +565,7 @@ static const dispex_static_data_vtbl_t HTMLElementColection_dispex_vtbl = { .traverse = HTMLElementCollection_traverse, .unlink = HTMLElementCollection_unlink, .get_dispid = HTMLElementCollection_get_dispid, - .get_name = HTMLElementCollection_get_name, + .get_prop_desc = dispex_index_prop_desc, .invoke = HTMLElementCollection_invoke, };
@@ -653,11 +637,10 @@ IHTMLElementCollection *create_all_collection(HTMLDOMNode *node, BOOL include_ro create_all_list(node, &buf); elem_vector_normalize(&buf);
- return HTMLElementCollection_Create(buf.buf, buf.len, - dispex_compat_mode(&node->event_target.dispex)); + return HTMLElementCollection_Create(buf.buf, buf.len, &node->event_target.dispex); }
-IHTMLElementCollection *create_collection_from_nodelist(nsIDOMNodeList *nslist, compat_mode_t compat_mode) +IHTMLElementCollection *create_collection_from_nodelist(nsIDOMNodeList *nslist, DispatchEx *owner) { UINT32 length = 0, i; HTMLDOMNode *node; @@ -689,10 +672,10 @@ IHTMLElementCollection *create_collection_from_nodelist(nsIDOMNodeList *nslist, buf.buf = NULL; }
- return HTMLElementCollection_Create(buf.buf, buf.len, compat_mode); + return HTMLElementCollection_Create(buf.buf, buf.len, owner); }
-IHTMLElementCollection *create_collection_from_htmlcol(nsIDOMHTMLCollection *nscol, compat_mode_t compat_mode) +IHTMLElementCollection *create_collection_from_htmlcol(nsIDOMHTMLCollection *nscol, DispatchEx *owner) { UINT32 length = 0, i; elem_vector_t buf; @@ -725,7 +708,7 @@ IHTMLElementCollection *create_collection_from_htmlcol(nsIDOMHTMLCollection *nsc return NULL; }
- return HTMLElementCollection_Create(buf.buf, buf.len, compat_mode); + return HTMLElementCollection_Create(buf.buf, buf.len, owner); }
HRESULT get_elem_source_index(HTMLElement *elem, LONG *ret) @@ -801,7 +784,7 @@ HRESULT get_elem_source_index(HTMLElement *elem, LONG *ret) }
static IHTMLElementCollection *HTMLElementCollection_Create(HTMLElement **elems, DWORD len, - compat_mode_t compat_mode) + DispatchEx *owner) { HTMLElementCollection *ret = calloc(1, sizeof(HTMLElementCollection));
@@ -812,7 +795,7 @@ static IHTMLElementCollection *HTMLElementCollection_Create(HTMLElement **elems, ret->elems = elems; ret->len = len;
- init_dispatch(&ret->dispex, &HTMLElementCollection_dispex, NULL, compat_mode); + init_dispatch_with_owner(&ret->dispex, &HTMLElementCollection_dispex, owner);
TRACE("ret=%p len=%ld\n", ret, len);
diff --git a/dlls/mshtml/htmlform.c b/dlls/mshtml/htmlform.c index a6a4bc0bce9..80a8d706054 100644 --- a/dlls/mshtml/htmlform.c +++ b/dlls/mshtml/htmlform.c @@ -401,7 +401,7 @@ static HRESULT WINAPI HTMLFormElement_get_elements(IHTMLFormElement *iface, IDis return E_FAIL; }
- *p = (IDispatch*)create_collection_from_htmlcol(elements, dispex_compat_mode(&This->element.node.event_target.dispex)); + *p = (IDispatch*)create_collection_from_htmlcol(elements, &This->element.node.event_target.dispex); nsIDOMHTMLCollection_Release(elements); return S_OK; } diff --git a/dlls/mshtml/htmltable.c b/dlls/mshtml/htmltable.c index 6c2d72cdcea..19d03387539 100644 --- a/dlls/mshtml/htmltable.c +++ b/dlls/mshtml/htmltable.c @@ -693,7 +693,7 @@ static HRESULT WINAPI HTMLTableRow_get_cells(IHTMLTableRow *iface, IHTMLElementC return E_FAIL; }
- *p = create_collection_from_htmlcol(nscol, dispex_compat_mode(&This->element.node.event_target.dispex)); + *p = create_collection_from_htmlcol(nscol, &This->element.node.event_target.dispex);
nsIDOMHTMLCollection_Release(nscol); return S_OK; @@ -1224,7 +1224,7 @@ static HRESULT WINAPI HTMLTable_get_rows(IHTMLTable *iface, IHTMLElementCollecti return E_FAIL; }
- *p = create_collection_from_htmlcol(nscol, dispex_compat_mode(&This->element.node.event_target.dispex)); + *p = create_collection_from_htmlcol(nscol, &This->element.node.event_target.dispex);
nsIDOMHTMLCollection_Release(nscol); return S_OK; @@ -1339,7 +1339,7 @@ static HRESULT WINAPI HTMLTable_get_tBodies(IHTMLTable *iface, IHTMLElementColle return E_FAIL; }
- *p = create_collection_from_htmlcol(nscol, dispex_compat_mode(&This->element.node.event_target.dispex)); + *p = create_collection_from_htmlcol(nscol, &This->element.node.event_target.dispex);
nsIDOMHTMLCollection_Release(nscol); return S_OK; diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h index d48ba2f32ac..f245acc8d75 100644 --- a/dlls/mshtml/mshtml_private.h +++ b/dlls/mshtml/mshtml_private.h @@ -1300,8 +1300,8 @@ ULONG WINAPI wrapper_Release(IUnknown *iface); extern const void *iface_wrapper_vtbl[];
IHTMLElementCollection *create_all_collection(HTMLDOMNode*,BOOL); -IHTMLElementCollection *create_collection_from_nodelist(nsIDOMNodeList*,compat_mode_t); -IHTMLElementCollection *create_collection_from_htmlcol(nsIDOMHTMLCollection*,compat_mode_t); +IHTMLElementCollection *create_collection_from_nodelist(nsIDOMNodeList*,DispatchEx*); +IHTMLElementCollection *create_collection_from_htmlcol(nsIDOMHTMLCollection*,DispatchEx*); HRESULT create_child_collection(nsIDOMNodeList*,compat_mode_t,IHTMLDOMChildrenCollection**);
HRESULT attr_value_to_string(VARIANT*); diff --git a/dlls/mshtml/tests/documentmode.js b/dlls/mshtml/tests/documentmode.js index 1586a7d5a4f..e676197d728 100644 --- a/dlls/mshtml/tests/documentmode.js +++ b/dlls/mshtml/tests/documentmode.js @@ -297,7 +297,7 @@ sync_test("builtin_toString", function() { if(clientRects) test("clientRects", clientRects, "ClientRectList"); if(currentStyle) test("currentStyle", currentStyle, "MSCurrentStyleCSSProperties", null, true); if(v >= 11 /* todo_wine */) test("document", document, v < 11 ? "Document" : "HTMLDocument"); - test("elements", document.getElementsByTagName("body"), "HTMLCollection", null, true); + test("elements", document.getElementsByTagName("body"), "HTMLCollection"); test("history", window.history, "History"); test("implementation", document.implementation, "DOMImplementation"); if(localStorage) test("localStorage", localStorage, "Storage");