Commit e8c68785 authored by Zhenbo Li's avatar Zhenbo Li Committed by Alexandre Julliard

mshtml: Add IHTMLOptionElement::form property implementation.

parent 85c31979
......@@ -307,8 +307,42 @@ static HRESULT WINAPI HTMLOptionElement_get_text(IHTMLOptionElement *iface, BSTR
static HRESULT WINAPI HTMLOptionElement_get_form(IHTMLOptionElement *iface, IHTMLFormElement **p)
{
HTMLOptionElement *This = impl_from_IHTMLOptionElement(iface);
FIXME("(%p)->(%p)\n", This, p);
return E_NOTIMPL;
nsIDOMHTMLFormElement *nsform;
nsIDOMNode *form_node;
HTMLDOMNode *node;
HRESULT hres;
nsresult nsres;
TRACE("(%p)->(%p)\n", This, p);
if(!p)
return E_POINTER;
nsres = nsIDOMHTMLOptionElement_GetForm(This->nsoption, &nsform);
if (NS_FAILED(nsres)) {
ERR("GetForm failed: %08x, nsform: %p\n", nsres, nsform);
*p = NULL;
return E_FAIL;
}
if (nsform == NULL) {
TRACE("nsform not found\n");
*p = NULL;
return S_OK;
}
nsres = nsIDOMHTMLFormElement_QueryInterface(nsform, &IID_nsIDOMNode, (void**)&form_node);
nsIDOMHTMLFormElement_Release(nsform);
assert(nsres == NS_OK);
hres = get_node(This->element.node.doc, form_node, TRUE, &node);
nsIDOMNode_Release(form_node);
if (FAILED(hres))
return hres;
hres = IHTMLDOMNode_QueryInterface(&node->IHTMLDOMNode_iface, &IID_IHTMLElement, (void**)p);
node_release(node);
return hres;
}
static const IHTMLOptionElementVtbl HTMLOptionElementVtbl = {
......
......@@ -891,6 +891,17 @@ static IHTMLSelectElement *_get_select_iface(unsigned line, IUnknown *unk)
return select;
}
#define get_option_iface(u) _get_option_iface(__LINE__,u)
static IHTMLOptionElement *_get_option_iface(unsigned line, IUnknown *unk)
{
IHTMLOptionElement *option;
HRESULT hres;
hres = IUnknown_QueryInterface(unk, &IID_IHTMLOptionElement, (void**)&option);
ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLOptionElement: %08x\n", hres);
return option;
}
#define get_form_iface(u) _get_form_iface(__LINE__,u)
static IHTMLFormElement *_get_form_iface(unsigned line, IUnknown *unk)
{
......@@ -5146,6 +5157,25 @@ static void test_create_option_elem(IHTMLDocument2 *doc)
IHTMLOptionElement_Release(option);
}
static void test_option_form(IUnknown *uoption, IUnknown *uform)
{
IHTMLOptionElement *option = get_option_iface(uoption);
IHTMLFormElement *form;
HRESULT hres;
hres = IHTMLOptionElement_get_form(option, NULL);
ok(hres == E_POINTER, "got %08x\n, expected E_POINTER\n", hres);
hres = IHTMLOptionElement_get_form(option, &form);
ok(hres == S_OK, "get_form failed: %08x\n", hres);
ok(form != NULL, "form == NULL\n");
ok(iface_cmp(uform, (IUnknown*)form), "Expected %p, got %p\n", uform, form);
IHTMLOptionElement_Release(option);
IHTMLFormElement_Release(form);
}
static void test_create_img_elem(IHTMLDocument2 *doc)
{
IHTMLImgElement *img;
......@@ -8582,12 +8612,18 @@ static void test_elems2(IHTMLDocument2 *doc)
}
test_elem_set_innerhtml((IUnknown*)div,
"<form id=\"form\" name=\"form_name\"><select id=\"sform\"></select></form>");
"<form id=\"form\" name=\"form_name\"><select id=\"sform\"><option id=\"oform\"></option></select></form>");
elem = get_elem_by_id(doc, "sform", TRUE);
elem2 = get_elem_by_id(doc, "form", TRUE);
if(elem && elem2) {
test_select_form((IUnknown*)elem, (IUnknown*)elem2);
IHTMLElement_Release(elem);
elem = get_elem_by_id(doc, "oform", TRUE);
if(elem) {
test_option_form((IUnknown*)elem, (IUnknown*)elem2);
IHTMLElement_Release(elem);
}
IHTMLElement_Release(elem2);
}
......
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