Commit b52bdff8 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

mshtml: Moved getting select's option element by index to separated function.

parent 061fee45
......@@ -42,6 +42,43 @@ typedef struct {
#define HTMLSELECT(x) ((IHTMLSelectElement*) &(x)->lpHTMLSelectElementVtbl)
static HRESULT htmlselect_item(HTMLSelectElement *This, int i, IDispatch **ret)
{
nsIDOMHTMLOptionsCollection *nscol;
nsIDOMNode *nsnode;
nsresult nsres;
nsres = nsIDOMHTMLSelectElement_GetOptions(This->nsselect, &nscol);
if(NS_FAILED(nsres)) {
ERR("GetOptions failed: %08x\n", nsres);
return E_FAIL;
}
nsres = nsIDOMHTMLOptionsCollection_Item(nscol, i, &nsnode);
nsIDOMHTMLOptionsCollection_Release(nscol);
if(NS_FAILED(nsres)) {
ERR("Item failed: %08x\n", nsres);
return E_FAIL;
}
if(nsnode) {
HTMLDOMNode *node;
node = get_node(This->element.node.doc, nsnode, TRUE);
nsIDOMNode_Release(nsnode);
if(!node) {
ERR("Could not find node\n");
return E_FAIL;
}
IHTMLDOMNode_AddRef(HTMLDOMNODE(node));
*ret = (IDispatch*)HTMLDOMNODE(node);
}else {
*ret = NULL;
}
return S_OK;
}
#define HTMLSELECT_THIS(iface) DEFINE_THIS(HTMLSelectElement, HTMLSelectElement, iface)
static HRESULT WINAPI HTMLSelectElement_QueryInterface(IHTMLSelectElement *iface,
......@@ -534,36 +571,16 @@ static HRESULT HTMLSelectElement_invoke(HTMLDOMNode *iface, DISPID id, LCID lcid
switch(flags) {
case DISPATCH_PROPERTYGET: {
nsIDOMHTMLOptionsCollection *nscol;
nsIDOMNode *nsnode;
nsresult nsres;
nsres = nsIDOMHTMLSelectElement_GetOptions(This->nsselect, &nscol);
if(NS_FAILED(nsres)) {
ERR("GetOptions failed: %08x\n", nsres);
return E_FAIL;
}
nsres = nsIDOMHTMLOptionsCollection_Item(nscol, id-DISPID_OPTIONCOL_0, &nsnode);
nsIDOMHTMLOptionsCollection_Release(nscol);
if(NS_FAILED(nsres)) {
ERR("Item failed: %08x\n", nsres);
return E_FAIL;
}
if(nsnode) {
HTMLDOMNode *node;
IDispatch *ret;
HRESULT hres;
node = get_node(This->element.node.doc, nsnode, TRUE);
nsIDOMNode_Release(nsnode);
if(!node) {
ERR("Could not find node\n");
return E_FAIL;
}
hres = htmlselect_item(This, id-DISPID_OPTIONCOL_0, &ret);
if(FAILED(hres))
return hres;
IHTMLDOMNode_AddRef(HTMLDOMNODE(node));
if(ret) {
V_VT(res) = VT_DISPATCH;
V_DISPATCH(res) = (IDispatch*)HTMLDOMNODE(node);
V_DISPATCH(res) = ret;
}else {
V_VT(res) = VT_NULL;
}
......
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