Gabriel Ivăncescu : mshtml: Implement value construction for HTMLOptionElementFactory.

Alexandre Julliard julliard at winehq.org
Fri Dec 3 15:18:59 CST 2021


Module: wine
Branch: master
Commit: 14177507170ddec2573948d5406e35f3290c4402
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=14177507170ddec2573948d5406e35f3290c4402

Author: Gabriel Ivăncescu <gabrielopcode at gmail.com>
Date:   Fri Dec  3 15:57:34 2021 +0200

mshtml: Implement value construction for HTMLOptionElementFactory.

Signed-off-by: Gabriel Ivăncescu <gabrielopcode at gmail.com>
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/mshtml/htmlselect.c | 46 +++++++++++++++++++++++++++++++++++++++++++++-
 dlls/mshtml/tests/dom.c  | 22 +++++++++++++++++++++-
 2 files changed, 66 insertions(+), 2 deletions(-)

diff --git a/dlls/mshtml/htmlselect.c b/dlls/mshtml/htmlselect.c
index 7869a8e628b..b2c10f725bb 100644
--- a/dlls/mshtml/htmlselect.c
+++ b/dlls/mshtml/htmlselect.c
@@ -590,14 +590,58 @@ static const IHTMLOptionElementFactoryVtbl HTMLOptionElementFactoryVtbl = {
     HTMLOptionElementFactory_create
 };
 
+static inline HTMLOptionElementFactory *HTMLOptionElementFactory_from_DispatchEx(DispatchEx *iface)
+{
+    return CONTAINING_RECORD(iface, HTMLOptionElementFactory, dispex);
+}
+
+static HRESULT HTMLOptionElementFactory_value(DispatchEx *dispex, LCID lcid,
+        WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei,
+        IServiceProvider *caller)
+{
+    HTMLOptionElementFactory *This = HTMLOptionElementFactory_from_DispatchEx(dispex);
+    unsigned int i, argc = params->cArgs - params->cNamedArgs;
+    IHTMLOptionElement *opt;
+    VARIANT empty, *arg[4];
+    HRESULT hres;
+
+    if(flags != DISPATCH_CONSTRUCT) {
+        FIXME("flags %x not supported\n", flags);
+        return E_NOTIMPL;
+    }
+
+    V_VT(res) = VT_NULL;
+    V_VT(&empty) = VT_EMPTY;
+
+    for(i = 0; i < ARRAY_SIZE(arg); i++)
+        arg[i] = argc > i ? &params->rgvarg[params->cArgs - 1 - i] : ∅
+
+    hres = IHTMLOptionElementFactory_create(&This->IHTMLOptionElementFactory_iface,
+                                            *arg[0], *arg[1], *arg[2], *arg[3], &opt);
+    if(FAILED(hres))
+        return hres;
+
+    V_VT(res) = VT_DISPATCH;
+    V_DISPATCH(res) = (IDispatch*)opt;
+
+    return S_OK;
+}
+
 static const tid_t HTMLOptionElementFactory_iface_tids[] = {
     IHTMLOptionElementFactory_tid,
     0
 };
 
+static const dispex_static_data_vtbl_t HTMLOptionElementFactory_dispex_vtbl = {
+    HTMLOptionElementFactory_value,
+    NULL,
+    NULL,
+    NULL
+};
+
 static dispex_static_data_t HTMLOptionElementFactory_dispex = {
     L"Function",
-    NULL,
+    &HTMLOptionElementFactory_dispex_vtbl,
     IHTMLOptionElementFactory_tid,
     HTMLOptionElementFactory_iface_tids,
     HTMLElement_init_dispex_info
diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c
index ea5b2108100..0c065a2da7e 100644
--- a/dlls/mshtml/tests/dom.c
+++ b/dlls/mshtml/tests/dom.c
@@ -2190,10 +2190,12 @@ static void _set_object_name(unsigned line, IHTMLElement *elem, const WCHAR *nam
 static IHTMLOptionElement *_create_option_elem(unsigned line, IHTMLDocument2 *doc,
         const WCHAR *txt, const WCHAR *val)
 {
+    VARIANT text, value, empty, option_var, args[2];
+    DISPPARAMS dp = { args, NULL, 2, 0 };
     IHTMLOptionElementFactory *factory;
     IHTMLOptionElement *option;
     IHTMLWindow2 *window;
-    VARIANT text, value, empty;
+    IDispatch *disp;
     HRESULT hres;
 
     hres = IHTMLDocument2_get_parentWindow(doc, &window);
@@ -2211,6 +2213,24 @@ static IHTMLOptionElement *_create_option_elem(unsigned line, IHTMLDocument2 *do
     V_BSTR(&value) = SysAllocString(val);
     V_VT(&empty) = VT_EMPTY;
 
+    hres = IHTMLOptionElementFactory_QueryInterface(factory, &IID_IDispatch, (void**)&disp);
+    ok_(__FILE__,line)(hres == S_OK, "Could not get IDispatch: %08x\n", hres);
+
+    args[1] = text;
+    args[0] = value;
+    hres = IDispatch_Invoke(disp, DISPID_VALUE, &IID_NULL, 0, DISPATCH_CONSTRUCT, &dp, &option_var, NULL, NULL);
+    IDispatch_Release(disp);
+    ok_(__FILE__,line)(hres == S_OK, "Invoke(DISPID_VALUE) returned: %08x\n", hres);
+    ok_(__FILE__,line)(V_VT(&option_var) == VT_DISPATCH, "VT(option_var) = %d\n", V_VT(&option_var));
+    hres = IDispatch_QueryInterface(V_DISPATCH(&option_var), &IID_IHTMLOptionElement, (void**)&option);
+    ok_(__FILE__,line)(hres == S_OK, "Could not get IHTMLOptionElement: %08x\n", hres);
+    VariantClear(&option_var);
+
+    _test_option_text(line, option, txt);
+    _test_option_value(line, option, val);
+    _test_option_selected(line, option, VARIANT_FALSE);
+    IHTMLOptionElement_Release(option);
+
     hres = IHTMLOptionElementFactory_create(factory, text, value, empty, empty, &option);
     ok_(__FILE__,line) (hres == S_OK, "create failed: %08x\n", hres);
 




More information about the wine-cvs mailing list