Jacek Caban : mshtml: Moved creating new element to separated function.

Alexandre Julliard julliard at winehq.org
Tue Oct 20 10:33:37 CDT 2009


Module: wine
Branch: master
Commit: 9ce3e6b7c2bd952a360018b862e27b314de9ee4c
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=9ce3e6b7c2bd952a360018b862e27b314de9ee4c

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Mon Oct 19 23:04:19 2009 +0200

mshtml: Moved creating new element to separated function.

---

 dlls/mshtml/htmldoc.c        |   22 ++++++----------------
 dlls/mshtml/htmlelem.c       |   29 +++++++++++++++++++++++++++++
 dlls/mshtml/mshtml_private.h |    2 ++
 3 files changed, 37 insertions(+), 16 deletions(-)

diff --git a/dlls/mshtml/htmldoc.c b/dlls/mshtml/htmldoc.c
index ef3085e..f0c6360 100644
--- a/dlls/mshtml/htmldoc.c
+++ b/dlls/mshtml/htmldoc.c
@@ -911,28 +911,18 @@ static HRESULT WINAPI HTMLDocument_createElement(IHTMLDocument2 *iface, BSTR eTa
                                                  IHTMLElement **newElem)
 {
     HTMLDocument *This = HTMLDOC_THIS(iface);
-    nsIDOMElement *nselem;
+    nsIDOMHTMLElement *nselem;
     HTMLElement *elem;
-    nsAString tag_str;
-    nsresult nsres;
+    HRESULT hres;
 
     TRACE("(%p)->(%s %p)\n", This, debugstr_w(eTag), newElem);
 
-    if(!This->nsdoc) {
-        WARN("NULL nsdoc\n");
-        return E_UNEXPECTED;
-    }
-
-    nsAString_Init(&tag_str, eTag);
-    nsres = nsIDOMDocument_CreateElement(This->nsdoc, &tag_str, &nselem);
-    nsAString_Finish(&tag_str);
-    if(NS_FAILED(nsres)) {
-        ERR("CreateElement failed: %08x\n", nsres);
-        return E_FAIL;
-    }
+    hres = create_nselem(This->doc_node, eTag, &nselem);
+    if(FAILED(hres))
+        return hres;
 
     elem = HTMLElement_Create(This->doc_node, (nsIDOMNode*)nselem, TRUE);
-    nsIDOMElement_Release(nselem);
+    nsIDOMHTMLElement_Release(nselem);
 
     *newElem = HTMLELEM(elem);
     IHTMLElement_AddRef(HTMLELEM(elem));
diff --git a/dlls/mshtml/htmlelem.c b/dlls/mshtml/htmlelem.c
index d019634..24e8e15 100644
--- a/dlls/mshtml/htmlelem.c
+++ b/dlls/mshtml/htmlelem.c
@@ -38,6 +38,35 @@ WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
 
 #define HTMLELEM_THIS(iface) DEFINE_THIS(HTMLElement, HTMLElement, iface)
 
+HRESULT create_nselem(HTMLDocumentNode *doc, const WCHAR *tag, nsIDOMHTMLElement **ret)
+{
+    nsIDOMElement *nselem;
+    nsAString tag_str;
+    nsresult nsres;
+
+    if(!doc->basedoc.nsdoc) {
+        WARN("NULL nsdoc\n");
+        return E_UNEXPECTED;
+    }
+
+    nsAString_Init(&tag_str, tag);
+    nsres = nsIDOMDocument_CreateElement(doc->basedoc.nsdoc, &tag_str, &nselem);
+    nsAString_Finish(&tag_str);
+    if(NS_FAILED(nsres)) {
+        ERR("CreateElement failed: %08x\n", nsres);
+        return E_FAIL;
+    }
+
+    nsres = nsIDOMElement_QueryInterface(nselem, &IID_nsIDOMHTMLElement, (void**)ret);
+    nsIDOMElement_Release(nselem);
+    if(NS_FAILED(nsres)) {
+        ERR("Could not get nsIDOMHTMLElement iface: %08x\n", nsres);
+        return E_FAIL;
+    }
+
+    return S_OK;
+}
+
 #define HTMLELEM_NODE_THIS(iface) DEFINE_THIS2(HTMLElement, node, iface)
 
 static HRESULT WINAPI HTMLElement_QueryInterface(IHTMLElement *iface,
diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h
index 4106500..6fa6ec4 100644
--- a/dlls/mshtml/mshtml_private.h
+++ b/dlls/mshtml/mshtml_private.h
@@ -659,6 +659,8 @@ void detach_selection(HTMLDocumentNode*);
 void detach_ranges(HTMLDocumentNode*);
 HRESULT get_node_text(HTMLDOMNode*,BSTR*);
 
+HRESULT create_nselem(HTMLDocumentNode*,const WCHAR*,nsIDOMHTMLElement**);
+
 HTMLDOMNode *HTMLDOMTextNode_Create(HTMLDocumentNode*,nsIDOMNode*);
 
 HTMLElement *HTMLElement_Create(HTMLDocumentNode*,nsIDOMNode*,BOOL);




More information about the wine-cvs mailing list