This gets prototype/constructor hierarchy right, but there is more work needed to get it fully right (the same is true for some other objects as well, to lesser extend). Comment and document fragment nodes should not expose element/document properties, attribute nodes should be actual nodes and legacy unknown elements seem to be some parser quirk (so `use_generic` is not exactly right even in legacy modes).
From: Jacek Caban jacek@codeweavers.com
--- dlls/mshtml/dispex.c | 2 +- dlls/mshtml/tests/documentmode.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/dlls/mshtml/dispex.c b/dlls/mshtml/dispex.c index 0e8d27773cc..49ed4790d94 100644 --- a/dlls/mshtml/dispex.c +++ b/dlls/mshtml/dispex.c @@ -1763,7 +1763,7 @@ HRESULT dispex_to_string(DispatchEx *dispex, BSTR *ret) { static const WCHAR prefix[8] = L"[object "; static const WCHAR suffix[] = L"]"; - WCHAR buf[ARRAY_SIZE(prefix) + 28 + ARRAY_SIZE(suffix)], *p = buf; + WCHAR buf[ARRAY_SIZE(prefix) + ARRAY_SIZE(dispex->info->desc->prototype_name) + ARRAY_SIZE(suffix)], *p = buf; compat_mode_t compat_mode = dispex_compat_mode(dispex); const char *name = dispex->info->name;
diff --git a/dlls/mshtml/tests/documentmode.js b/dlls/mshtml/tests/documentmode.js index 13cef923018..c0c671dfdfa 100644 --- a/dlls/mshtml/tests/documentmode.js +++ b/dlls/mshtml/tests/documentmode.js @@ -3120,7 +3120,8 @@ sync_test("prototypes", function() { return;
function check(obj, proto, name) { - ok(Object.getPrototypeOf(obj) === proto, "unexpected " + name + " prototype object"); + var p = Object.getPrototypeOf(obj); + ok(p === proto, "unexpected " + name + " prototype object " + Object.prototype.toString.call(p)); }
check(document.implementation, DOMImplementation.prototype, "implementation");
From: Jacek Caban jacek@codeweavers.com
Based on patch by Gabriel Ivăncescu. --- dlls/mshtml/htmlelem.c | 6 +++--- dlls/mshtml/htmlgeneric.c | 17 +++++++++-------- dlls/mshtml/mshtml_private.h | 1 + dlls/mshtml/tests/documentmode.js | 2 ++ 4 files changed, 15 insertions(+), 11 deletions(-)
diff --git a/dlls/mshtml/htmlelem.c b/dlls/mshtml/htmlelem.c index e9ecfc77a65..0cc41bf41a3 100644 --- a/dlls/mshtml/htmlelem.c +++ b/dlls/mshtml/htmlelem.c @@ -7250,7 +7250,7 @@ dispex_static_data_t HTMLElement_dispex = { .init_info = HTMLElement_init_dispex_info, };
-static dispex_static_data_t HTMLUnknownElement_dispex = { +static dispex_static_data_t LegacyUnknownElement_dispex = { "HTMLUnknownElement", &HTMLElement_event_target_vtbl.dispex_vtbl, DispHTMLUnknownElement_tid, @@ -7325,13 +7325,13 @@ HRESULT HTMLElement_Create(HTMLDocumentNode *doc, nsIDOMNode *nsnode, BOOL use_g if(NS_SUCCEEDED(nsres)) { hres = create_svg_element(doc, svg_element, tag_name, &elem); nsIDOMSVGElement_Release(svg_element); - }else if(use_generic) { + }else if(use_generic || dispex_compat_mode(&doc->node.event_target.dispex) >= COMPAT_MODE_IE9) { hres = HTMLGenericElement_Create(doc, nselem, &elem); }else { elem = calloc(1, sizeof(HTMLElement)); if(elem) { elem->node.vtbl = &HTMLElementImplVtbl; - HTMLElement_Init(elem, doc, nselem, &HTMLUnknownElement_dispex); + HTMLElement_Init(elem, doc, nselem, &LegacyUnknownElement_dispex); hres = S_OK; }else { hres = E_OUTOFMEMORY; diff --git a/dlls/mshtml/htmlgeneric.c b/dlls/mshtml/htmlgeneric.c index 88237fac403..acd4998832b 100644 --- a/dlls/mshtml/htmlgeneric.c +++ b/dlls/mshtml/htmlgeneric.c @@ -108,18 +108,19 @@ static const event_target_vtbl_t HTMLGenericElement_event_target_vtbl = { .handle_event = HTMLElement_handle_event };
-static const tid_t HTMLGenericElement_iface_tids[] = { +static const tid_t HTMLUnknownElement_iface_tids[] = { HTMLELEMENT_TIDS, IHTMLGenericElement_tid, 0 };
-static dispex_static_data_t HTMLGenericElement_dispex = { - "HTMLUnknownElement", - &HTMLGenericElement_event_target_vtbl.dispex_vtbl, - DispHTMLGenericElement_tid, - HTMLGenericElement_iface_tids, - HTMLElement_init_dispex_info +dispex_static_data_t HTMLUnknownElement_dispex = { + .id = PROT_HTMLUnknownElement, + .prototype_id = PROT_HTMLElement, + .vtbl = &HTMLGenericElement_event_target_vtbl.dispex_vtbl, + .disp_tid = DispHTMLGenericElement_tid, + .iface_tids = HTMLUnknownElement_iface_tids, + .init_info = HTMLElement_init_dispex_info, };
HRESULT HTMLGenericElement_Create(HTMLDocumentNode *doc, nsIDOMElement *nselem, HTMLElement **elem) @@ -133,7 +134,7 @@ HRESULT HTMLGenericElement_Create(HTMLDocumentNode *doc, nsIDOMElement *nselem, ret->IHTMLGenericElement_iface.lpVtbl = &HTMLGenericElementVtbl; ret->element.node.vtbl = &HTMLGenericElementImplVtbl;
- HTMLElement_Init(&ret->element, doc, nselem, &HTMLGenericElement_dispex); + HTMLElement_Init(&ret->element, doc, nselem, &HTMLUnknownElement_dispex);
*elem = &ret->element; return S_OK; diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h index 0220285ac8e..ff9335be2fe 100644 --- a/dlls/mshtml/mshtml_private.h +++ b/dlls/mshtml/mshtml_private.h @@ -451,6 +451,7 @@ typedef struct { X(HTMLTableRowElement) \ X(HTMLTextAreaElement) \ X(HTMLTitleElement) \ + X(HTMLUnknownElement) \ X(History) \ X(KeyboardEvent) \ X(MSCSSProperties) \ diff --git a/dlls/mshtml/tests/documentmode.js b/dlls/mshtml/tests/documentmode.js index c0c671dfdfa..459ac523239 100644 --- a/dlls/mshtml/tests/documentmode.js +++ b/dlls/mshtml/tests/documentmode.js @@ -3201,6 +3201,8 @@ sync_test("prototypes", function() { check(HTMLTableCellElement.prototype, HTMLElement.prototype, "table cell prototype"); check(document.createElement("textarea"), HTMLTextAreaElement.prototype, "textarea element"); check(HTMLTextAreaElement.prototype, HTMLElement.prototype, "textarea element prototype"); + check(document.createElement("test"), HTMLUnknownElement.prototype, "unknown element"); + check(HTMLUnknownElement.prototype, HTMLElement.prototype, "unknown element prototype"); check(document.createElementNS(svg_ns, "svg"), SVGSVGElement.prototype, "svg:svg element"); check(SVGSVGElement.prototype, SVGElement.prototype, "svg:svg element prototype"); check(SVGElement.prototype, Element.prototype, "svg element prototype");
From: Jacek Caban jacek@codeweavers.com
--- dlls/mshtml/htmlcomment.c | 19 ++++++++++--------- dlls/mshtml/mshtml_private.h | 1 + dlls/mshtml/tests/documentmode.js | 2 ++ 3 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/dlls/mshtml/htmlcomment.c b/dlls/mshtml/htmlcomment.c index a96915a58cc..b2507385623 100644 --- a/dlls/mshtml/htmlcomment.c +++ b/dlls/mshtml/htmlcomment.c @@ -143,17 +143,18 @@ static const event_target_vtbl_t HTMLCommentElement_event_target_vtbl = { .handle_event = HTMLElement_handle_event };
-static const tid_t HTMLCommentElement_iface_tids[] = { +static const tid_t Comment_iface_tids[] = { HTMLELEMENT_TIDS, IHTMLCommentElement_tid, 0 }; -static dispex_static_data_t HTMLCommentElement_dispex = { - "Comment", - &HTMLCommentElement_event_target_vtbl.dispex_vtbl, - DispHTMLCommentElement_tid, - HTMLCommentElement_iface_tids, - HTMLElement_init_dispex_info +dispex_static_data_t Comment_dispex = { + .id = PROT_Comment, + .prototype_id = PROT_CharacterData, + .vtbl = &HTMLCommentElement_event_target_vtbl.dispex_vtbl, + .disp_tid = DispHTMLCommentElement_tid, + .iface_tids = Comment_iface_tids, + .init_info = HTMLElement_init_dispex_info, };
HRESULT HTMLCommentElement_Create(HTMLDocumentNode *doc, nsIDOMNode *nsnode, HTMLElement **elem) @@ -167,8 +168,8 @@ HRESULT HTMLCommentElement_Create(HTMLDocumentNode *doc, nsIDOMNode *nsnode, HTM ret->element.node.vtbl = &HTMLCommentElementImplVtbl; ret->IHTMLCommentElement_iface.lpVtbl = &HTMLCommentElementVtbl;
- HTMLElement_Init(&ret->element, doc, NULL, &HTMLCommentElement_dispex); - HTMLDOMNode_Init(doc, &ret->element.node, nsnode, &HTMLCommentElement_dispex); + HTMLElement_Init(&ret->element, doc, NULL, &Comment_dispex); + HTMLDOMNode_Init(doc, &ret->element.node, nsnode, &Comment_dispex);
*elem = &ret->element; return S_OK; diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h index ff9335be2fe..ddedf8a4035 100644 --- a/dlls/mshtml/mshtml_private.h +++ b/dlls/mshtml/mshtml_private.h @@ -414,6 +414,7 @@ typedef struct { X(CharacterData) \ X(ClientRect) \ X(ClientRectList) \ + X(Comment) \ X(Console) \ X(CustomEvent) \ X(DOMImplementation) \ diff --git a/dlls/mshtml/tests/documentmode.js b/dlls/mshtml/tests/documentmode.js index 459ac523239..612bfe02d75 100644 --- a/dlls/mshtml/tests/documentmode.js +++ b/dlls/mshtml/tests/documentmode.js @@ -3323,4 +3323,6 @@ sync_test("prototypes", function() { }else { ok(!("MSSelection" in window), "MSSelection found in window"); } + check(document.createComment(""), Comment.prototype, "comment"); + check(Comment.prototype, CharacterData.prototype, "comment prototype"); });
From: Jacek Caban jacek@codeweavers.com
--- dlls/mshtml/htmlattr.c | 13 +++++++------ dlls/mshtml/mshtml_private.h | 1 + dlls/mshtml/tests/documentmode.js | 2 ++ 3 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/dlls/mshtml/htmlattr.c b/dlls/mshtml/htmlattr.c index 31837f06284..9b306eff406 100644 --- a/dlls/mshtml/htmlattr.c +++ b/dlls/mshtml/htmlattr.c @@ -405,11 +405,12 @@ static const tid_t HTMLDOMAttribute_iface_tids[] = { IHTMLDOMAttribute2_tid, 0 }; -static dispex_static_data_t HTMLDOMAttribute_dispex = { - "Attr", - &HTMLDOMAttribute_dispex_vtbl, - DispHTMLDOMAttribute_tid, - HTMLDOMAttribute_iface_tids +dispex_static_data_t Attr_dispex = { + .id = PROT_Attr, + .prototype_id = PROT_Node, + .vtbl = &HTMLDOMAttribute_dispex_vtbl, + .disp_tid = DispHTMLDOMAttribute_tid, + .iface_tids = HTMLDOMAttribute_iface_tids, };
HTMLDOMAttribute *unsafe_impl_from_IHTMLDOMAttribute(IHTMLDOMAttribute *iface) @@ -433,7 +434,7 @@ HRESULT HTMLDOMAttribute_Create(const WCHAR *name, HTMLElement *elem, DISPID dis ret->dispid = dispid; ret->elem = elem;
- init_dispatch(&ret->dispex, &HTMLDOMAttribute_dispex, doc->script_global, + init_dispatch(&ret->dispex, &Attr_dispex, doc->script_global, dispex_compat_mode(&doc->script_global->event_target.dispex));
/* For attributes attached to an element, (elem,dispid) pair should be valid used for its operation. */ diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h index ddedf8a4035..463e486366c 100644 --- a/dlls/mshtml/mshtml_private.h +++ b/dlls/mshtml/mshtml_private.h @@ -407,6 +407,7 @@ typedef struct { } dispex_static_data_vtbl_t;
#define ALL_PROTOTYPES \ + X(Attr) \ X(CSSRule) \ X(CSSStyleDeclaration) \ X(CSSStyleRule) \ diff --git a/dlls/mshtml/tests/documentmode.js b/dlls/mshtml/tests/documentmode.js index 612bfe02d75..fe82105ea8c 100644 --- a/dlls/mshtml/tests/documentmode.js +++ b/dlls/mshtml/tests/documentmode.js @@ -3325,4 +3325,6 @@ sync_test("prototypes", function() { } check(document.createComment(""), Comment.prototype, "comment"); check(Comment.prototype, CharacterData.prototype, "comment prototype"); + check(document.createAttribute("test"), Attr.prototype, "attr"); + check(Attr.prototype, Node.prototype, "attr prototype"); });
From: Jacek Caban jacek@codeweavers.com
--- dlls/mshtml/htmldoc.c | 12 +++++++++++- dlls/mshtml/mshtml_private.h | 1 + dlls/mshtml/tests/documentmode.js | 2 ++ 3 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/dlls/mshtml/htmldoc.c b/dlls/mshtml/htmldoc.c index 3f74dbd2826..260264642b2 100644 --- a/dlls/mshtml/htmldoc.c +++ b/dlls/mshtml/htmldoc.c @@ -5823,6 +5823,15 @@ HRESULT create_document_node(nsIDOMDocument *nsdoc, GeckoBrowser *browser, HTMLI return S_OK; }
+dispex_static_data_t DocumentFragment_dispex = { + .id = PROT_DocumentFragment, + .prototype_id = PROT_Node, + .vtbl = &HTMLDocument_event_target_vtbl.dispex_vtbl, + .disp_tid = DispHTMLDocument_tid, + .iface_tids = HTMLDocumentNode_iface_tids, + .init_info = HTMLDocumentNode_init_dispex_info, +}; + static HRESULT create_document_fragment(nsIDOMNode *nsnode, HTMLDocumentNode *doc_node, HTMLDocumentNode **ret) { HTMLDocumentNode *doc_frag; @@ -5831,9 +5840,10 @@ static HRESULT create_document_fragment(nsIDOMNode *nsnode, HTMLDocumentNode *do if(!doc_frag) return E_OUTOFMEMORY;
- HTMLDOMNode_Init(doc_node, &doc_frag->node, nsnode, &HTMLDocument_dispex); + HTMLDOMNode_Init(doc_node, &doc_frag->node, nsnode, &DocumentFragment_dispex); doc_frag->node.vtbl = &HTMLDocumentFragmentImplVtbl; doc_frag->document_mode = lock_document_mode(doc_node); + dispex_compat_mode(&doc_frag->node.event_target.dispex); /* make sure the object is fully initialized */
*ret = doc_frag; return S_OK; diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h index 463e486366c..e63a05f4314 100644 --- a/dlls/mshtml/mshtml_private.h +++ b/dlls/mshtml/mshtml_private.h @@ -421,6 +421,7 @@ typedef struct { X(DOMImplementation) \ X(DOMTokenList) \ X(Document) \ + X(DocumentFragment) \ X(DocumentType) \ X(Element) \ X(Event) \ diff --git a/dlls/mshtml/tests/documentmode.js b/dlls/mshtml/tests/documentmode.js index fe82105ea8c..97941bb81c2 100644 --- a/dlls/mshtml/tests/documentmode.js +++ b/dlls/mshtml/tests/documentmode.js @@ -3327,4 +3327,6 @@ sync_test("prototypes", function() { check(Comment.prototype, CharacterData.prototype, "comment prototype"); check(document.createAttribute("test"), Attr.prototype, "attr"); check(Attr.prototype, Node.prototype, "attr prototype"); + check(document.createDocumentFragment(), DocumentFragment.prototype, "fragment"); + check(DocumentFragment.prototype, Node.prototype, "fragment prototype"); });
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=147771
Your paranoid android.
=== build (build log) ===
error: patch failed: dlls/mshtml/htmlelem.c:7250 error: patch failed: dlls/mshtml/htmlgeneric.c:108 error: patch failed: dlls/mshtml/mshtml_private.h:451 error: patch failed: dlls/mshtml/tests/documentmode.js:3201 Task: Patch failed to apply
=== debian11 (build log) ===
error: patch failed: dlls/mshtml/htmlelem.c:7250 error: patch failed: dlls/mshtml/htmlgeneric.c:108 error: patch failed: dlls/mshtml/mshtml_private.h:451 error: patch failed: dlls/mshtml/tests/documentmode.js:3201 Task: Patch failed to apply
=== debian11b (build log) ===
error: patch failed: dlls/mshtml/htmlelem.c:7250 error: patch failed: dlls/mshtml/htmlgeneric.c:108 error: patch failed: dlls/mshtml/mshtml_private.h:451 error: patch failed: dlls/mshtml/tests/documentmode.js:3201 Task: Patch failed to apply