Jacek Caban : mshtml: Moved getting form' s elements by index to separated function.
Alexandre Julliard
julliard at winehq.org
Tue May 11 12:09:40 CDT 2010
Module: wine
Branch: master
Commit: 68e9bd281eaa15e9a9e854b501ebe34b3b82e5cf
URL: http://source.winehq.org/git/wine.git/?a=commit;h=68e9bd281eaa15e9a9e854b501ebe34b3b82e5cf
Author: Jacek Caban <jacek at codeweavers.com>
Date: Tue May 11 17:57:54 2010 +0200
mshtml: Moved getting form's elements by index to separated function.
---
dlls/mshtml/htmlform.c | 68 +++++++++++++++++++++++++++++++----------------
1 files changed, 45 insertions(+), 23 deletions(-)
diff --git a/dlls/mshtml/htmlform.c b/dlls/mshtml/htmlform.c
index c33937d..bcb6e6e 100644
--- a/dlls/mshtml/htmlform.c
+++ b/dlls/mshtml/htmlform.c
@@ -41,6 +41,41 @@ struct HTMLFormElement {
#define HTMLFORM(x) (&(x)->lpHTMLFormElementVtbl)
+static HRESULT htmlform_item(HTMLFormElement *This, int i, IDispatch **ret)
+{
+ nsIDOMHTMLCollection *elements;
+ nsIDOMNode *item;
+ HTMLDOMNode *node;
+ nsresult nsres;
+
+ nsres = nsIDOMHTMLFormElement_GetElements(This->nsform, &elements);
+ if(NS_FAILED(nsres)) {
+ FIXME("GetElements failed: 0x%08x\n", nsres);
+ return E_FAIL;
+ }
+
+ nsres = nsIDOMHTMLCollection_Item(elements, i, &item);
+ nsIDOMHTMLCollection_Release(elements);
+ if(NS_FAILED(nsres)) {
+ FIXME("Item failed: 0x%08x\n", nsres);
+ return E_FAIL;
+ }
+
+ if(item) {
+ node = get_node(This->element.node.doc, item, TRUE);
+ if(!node)
+ return E_OUTOFMEMORY;
+
+ IHTMLDOMNode_AddRef(HTMLDOMNODE(node));
+ nsIDOMNode_Release(item);
+ *ret = (IDispatch*)HTMLDOMNODE(node);
+ }else {
+ *ret = NULL;
+ }
+
+ return S_OK;
+}
+
#define HTMLFORM_THIS(iface) DEFINE_THIS(HTMLFormElement, HTMLFormElement, iface)
static HRESULT WINAPI HTMLFormElement_QueryInterface(IHTMLFormElement *iface,
@@ -439,34 +474,21 @@ static HRESULT HTMLFormElement_invoke(HTMLDOMNode *iface,
EXCEPINFO *ei, IServiceProvider *caller)
{
HTMLFormElement *This = HTMLFORM_NODE_THIS(iface);
- nsIDOMHTMLCollection *elements;
- nsIDOMNode *item;
- HTMLDOMNode *node;
- nsresult nsres;
+ IDispatch *ret;
+ HRESULT hres;
TRACE("(%p)->(%x %x %x %p %p %p %p)\n", This, id, lcid, flags, params, res, ei, caller);
- nsres = nsIDOMHTMLFormElement_GetElements(This->nsform, &elements);
- if(NS_FAILED(nsres)) {
- FIXME("GetElements failed: 0x%08x\n", nsres);
- return E_FAIL;
- }
+ hres = htmlform_item(This, id - MSHTML_DISPID_CUSTOM_MIN, &ret);
+ if(FAILED(hres))
+ return hres;
- nsres = nsIDOMHTMLCollection_Item(elements, id - MSHTML_DISPID_CUSTOM_MIN, &item);
- nsIDOMHTMLCollection_Release(elements);
- if(NS_FAILED(nsres)) {
- FIXME("Item failed: 0x%08x\n", nsres);
- return E_FAIL;
+ if(ret) {
+ V_VT(res) = VT_DISPATCH;
+ V_DISPATCH(res) = ret;
+ }else {
+ V_VT(res) = VT_NULL;
}
-
- node = get_node(This->element.node.doc, item, TRUE);
-
- V_VT(res) = VT_DISPATCH;
- V_DISPATCH(res) = (IDispatch*)node;
-
- IHTMLDOMNode_AddRef(HTMLDOMNODE(node));
- nsIDOMNode_Release(item);
-
return S_OK;
}
More information about the wine-cvs
mailing list