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

mshtml: HTMLWindow_item code clean up.

parent 816802cb
...@@ -323,8 +323,8 @@ static HRESULT WINAPI HTMLWindow2_item(IHTMLWindow2 *iface, VARIANT *pvarIndex, ...@@ -323,8 +323,8 @@ static HRESULT WINAPI HTMLWindow2_item(IHTMLWindow2 *iface, VARIANT *pvarIndex,
{ {
HTMLWindow *This = impl_from_IHTMLWindow2(iface); HTMLWindow *This = impl_from_IHTMLWindow2(iface);
nsIDOMWindowCollection *nsFrames; nsIDOMWindowCollection *nsFrames;
HTMLWindow *window; HTMLWindow *window = NULL;
HRESULT hres; HRESULT hres = S_OK;
nsresult nsres; nsresult nsres;
TRACE("(%p)->(%p %p)\n", This, pvarIndex, pvarResult); TRACE("(%p)->(%p %p)\n", This, pvarIndex, pvarResult);
...@@ -335,29 +335,28 @@ static HRESULT WINAPI HTMLWindow2_item(IHTMLWindow2 *iface, VARIANT *pvarIndex, ...@@ -335,29 +335,28 @@ static HRESULT WINAPI HTMLWindow2_item(IHTMLWindow2 *iface, VARIANT *pvarIndex,
return E_FAIL; return E_FAIL;
} }
if(V_VT(pvarIndex) == VT_I4) { switch(V_VT(pvarIndex)) {
case VT_I4: {
int index = V_I4(pvarIndex); int index = V_I4(pvarIndex);
TRACE("Getting index %d\n", index); TRACE("Getting index %d\n", index);
if(index < 0) { if(index < 0)
hres = DISP_E_MEMBERNOTFOUND; break;
goto cleanup;
}
hres = get_frame_by_index(nsFrames, index, &window); hres = get_frame_by_index(nsFrames, index, &window);
if(FAILED(hres)) break;
goto cleanup; }
}else if(V_VT(pvarIndex) == VT_UINT) { case VT_UINT: {
unsigned int index = V_UINT(pvarIndex); unsigned int index = V_UINT(pvarIndex);
TRACE("Getting index %u\n", index); TRACE("Getting index %u\n", index);
hres = get_frame_by_index(nsFrames, index, &window); hres = get_frame_by_index(nsFrames, index, &window);
if(FAILED(hres)) break;
goto cleanup; }
}else if(V_VT(pvarIndex) == VT_BSTR) { case VT_BSTR: {
BSTR str = V_BSTR(pvarIndex); BSTR str = V_BSTR(pvarIndex);
PRUint32 length, i; PRUint32 length, i;
TRACE("Getting name %s\n", wine_dbgstr_w(str)); TRACE("Getting name %s\n", wine_dbgstr_w(str));
nsres = nsIDOMWindowCollection_GetLength(nsFrames, &length); nsIDOMWindowCollection_GetLength(nsFrames, &length);
window = NULL; window = NULL;
for(i = 0; i < length && !window; ++i) { for(i = 0; i < length && !window; ++i) {
...@@ -369,7 +368,7 @@ static HRESULT WINAPI HTMLWindow2_item(IHTMLWindow2 *iface, VARIANT *pvarIndex, ...@@ -369,7 +368,7 @@ static HRESULT WINAPI HTMLWindow2_item(IHTMLWindow2 *iface, VARIANT *pvarIndex,
if(NS_FAILED(nsres)) { if(NS_FAILED(nsres)) {
FIXME("nsIDOMWindowCollection_Item failed: 0x%08x\n", nsres); FIXME("nsIDOMWindowCollection_Item failed: 0x%08x\n", nsres);
hres = E_FAIL; hres = E_FAIL;
goto cleanup; break;
} }
cur_window = nswindow_to_window(nsWindow); cur_window = nswindow_to_window(nsWindow);
...@@ -379,7 +378,7 @@ static HRESULT WINAPI HTMLWindow2_item(IHTMLWindow2 *iface, VARIANT *pvarIndex, ...@@ -379,7 +378,7 @@ static HRESULT WINAPI HTMLWindow2_item(IHTMLWindow2 *iface, VARIANT *pvarIndex,
hres = IHTMLElement_get_id(&cur_window->frame_element->element.IHTMLElement_iface, &id); hres = IHTMLElement_get_id(&cur_window->frame_element->element.IHTMLElement_iface, &id);
if(FAILED(hres)) { if(FAILED(hres)) {
FIXME("IHTMLElement_get_id failed: 0x%08x\n", hres); FIXME("IHTMLElement_get_id failed: 0x%08x\n", hres);
goto cleanup; break;
} }
if(!strcmpW(id, str)) if(!strcmpW(id, str))
...@@ -387,26 +386,22 @@ static HRESULT WINAPI HTMLWindow2_item(IHTMLWindow2 *iface, VARIANT *pvarIndex, ...@@ -387,26 +386,22 @@ static HRESULT WINAPI HTMLWindow2_item(IHTMLWindow2 *iface, VARIANT *pvarIndex,
SysFreeString(id); SysFreeString(id);
} }
break;
if(!window) {
hres = DISP_E_MEMBERNOTFOUND;
goto cleanup;
} }
}else { default:
hres = E_INVALIDARG; hres = E_INVALIDARG;
goto cleanup;
} }
nsIDOMWindowCollection_Release(nsFrames);
if(FAILED(hres))
return hres;
if(!window)
return DISP_E_MEMBERNOTFOUND;
IHTMLWindow2_AddRef(&window->IHTMLWindow2_iface); IHTMLWindow2_AddRef(&window->IHTMLWindow2_iface);
V_VT(pvarResult) = VT_DISPATCH; V_VT(pvarResult) = VT_DISPATCH;
V_DISPATCH(pvarResult) = (IDispatch*)window; V_DISPATCH(pvarResult) = (IDispatch*)window;
return S_OK;
hres = S_OK;
cleanup:
nsIDOMWindowCollection_Release(nsFrames);
return hres;
} }
static HRESULT WINAPI HTMLWindow2_get_length(IHTMLWindow2 *iface, LONG *p) static HRESULT WINAPI HTMLWindow2_get_length(IHTMLWindow2 *iface, LONG *p)
......
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