From 456e53bcf9122a2ea7a791831af492de642a803a Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Thu, 28 Jan 2010 23:55:51 +0100 Subject: [PATCH] mshtml: Optimize more nsAString handling. --- dlls/mshtml/editor.c | 12 ++++++------ dlls/mshtml/htmlbody.c | 13 ++++--------- dlls/mshtml/htmldoc.c | 2 +- dlls/mshtml/htmldoc3.c | 11 +++++------ dlls/mshtml/htmldoc5.c | 2 +- dlls/mshtml/htmlelemcol.c | 2 +- dlls/mshtml/htmlevent.c | 2 +- 7 files changed, 19 insertions(+), 25 deletions(-) diff --git a/dlls/mshtml/editor.c b/dlls/mshtml/editor.c index 568e127220..961bb91637 100644 --- a/dlls/mshtml/editor.c +++ b/dlls/mshtml/editor.c @@ -298,7 +298,7 @@ static void get_font_size(HTMLDocument *This, WCHAR *ret) TRACE("found font tag %p\n", elem); - nsAString_Init(&size_str, sizeW); + nsAString_InitDepend(&size_str, sizeW); nsAString_Init(&val_str, NULL); nsIDOMElement_GetAttribute(elem, &size_str, &val_str); @@ -360,10 +360,11 @@ static void set_font_size(HTMLDocument *This, LPCWSTR size) create_nselem(This->doc_node, fontW, &elem); - nsAString_Init(&size_str, sizeW); - nsAString_Init(&val_str, size); + nsAString_InitDepend(&size_str, sizeW); + nsAString_InitDepend(&val_str, size); nsIDOMElement_SetAttribute(elem, &size_str, &val_str); + nsAString_Finish(&val_str); nsISelection_GetRangeAt(nsselection, 0, &range); nsISelection_GetIsCollapsed(nsselection, &collapsed); @@ -384,7 +385,6 @@ static void set_font_size(HTMLDocument *This, LPCWSTR size) nsIDOMElement_Release(elem); nsAString_Finish(&size_str); - nsAString_Finish(&val_str); set_dirty(This, VARIANT_TRUE); } @@ -1167,8 +1167,8 @@ static HRESULT exec_hyperlink(HTMLDocument *This, DWORD cmdexecopt, VARIANT *in, /* create an element for the link */ create_nselem(This->doc_node, aW, &anchor_elem); - nsAString_Init(&href_str, hrefW); - nsAString_Init(&ns_url, url); + nsAString_InitDepend(&href_str, hrefW); + nsAString_InitDepend(&ns_url, url); nsIDOMElement_SetAttribute(anchor_elem, &href_str, &ns_url); nsAString_Finish(&href_str); diff --git a/dlls/mshtml/htmlbody.c b/dlls/mshtml/htmlbody.c index 5c0f7ca8bb..5c66e65a44 100644 --- a/dlls/mshtml/htmlbody.c +++ b/dlls/mshtml/htmlbody.c @@ -252,23 +252,18 @@ static HRESULT WINAPI HTMLBodyElement_Invoke(IHTMLBodyElement *iface, DISPID dis static HRESULT WINAPI HTMLBodyElement_put_background(IHTMLBodyElement *iface, BSTR v) { HTMLBodyElement *This = HTMLBODY_THIS(iface); - HRESULT hr = S_OK; nsAString nsstr; nsresult nsres; TRACE("(%p)->(%s)\n", This, debugstr_w(v)); - nsAString_Init(&nsstr, v); - + nsAString_InitDepend(&nsstr, v); nsres = nsIDOMHTMLBodyElement_SetBackground(This->nsbody, &nsstr); - if(!NS_SUCCEEDED(nsres)) - { - hr = E_FAIL; - } - nsAString_Finish(&nsstr); + if(NS_FAILED(nsres)) + return E_FAIL; - return hr; + return S_OK; } static HRESULT WINAPI HTMLBodyElement_get_background(IHTMLBodyElement *iface, BSTR *p) diff --git a/dlls/mshtml/htmldoc.c b/dlls/mshtml/htmldoc.c index ac67a84cc6..538a02f5b4 100644 --- a/dlls/mshtml/htmldoc.c +++ b/dlls/mshtml/htmldoc.c @@ -348,7 +348,7 @@ static HRESULT WINAPI HTMLDocument_put_title(IHTMLDocument2 *iface, BSTR v) return E_UNEXPECTED; } - nsAString_Init(&nsstr, v); + nsAString_InitDepend(&nsstr, v); nsres = nsIDOMHTMLDocument_SetTitle(This->doc_node->nsdoc, &nsstr); nsAString_Finish(&nsstr); if(NS_FAILED(nsres)) diff --git a/dlls/mshtml/htmldoc3.c b/dlls/mshtml/htmldoc3.c index de32302c93..9079bbc79c 100644 --- a/dlls/mshtml/htmldoc3.c +++ b/dlls/mshtml/htmldoc3.c @@ -116,7 +116,7 @@ static HRESULT WINAPI HTMLDocument3_createTextNode(IHTMLDocument3 *iface, BSTR t return E_UNEXPECTED; } - nsAString_Init(&text_str, text); + nsAString_InitDepend(&text_str, text); nsres = nsIDOMHTMLDocument_CreateTextNode(This->doc_node->nsdoc, &text_str, &nstext); nsAString_Finish(&text_str); if(NS_FAILED(nsres)) { @@ -443,7 +443,7 @@ static HRESULT WINAPI HTMLDocument3_getElementById(IHTMLDocument3 *iface, BSTR v return E_UNEXPECTED; } - nsAString_Init(&id_str, v); + nsAString_InitDepend(&id_str, v); /* get element by id attribute */ nsres = nsIDOMHTMLDocument_GetElementById(This->doc_node->nsdoc, &id_str, &nselem); if(FAILED(nsres)) { @@ -455,9 +455,9 @@ static HRESULT WINAPI HTMLDocument3_getElementById(IHTMLDocument3 *iface, BSTR v /* get first element by name attribute */ nsres = nsIDOMHTMLDocument_GetElementsByName(This->doc_node->nsdoc, &id_str, &nsnode_list); + nsAString_Finish(&id_str); if(FAILED(nsres)) { ERR("getElementsByName failed: %08x\n", nsres); - nsAString_Finish(&id_str); if(nsnode_by_id) nsIDOMNode_Release(nsnode_by_id); return E_FAIL; @@ -465,7 +465,6 @@ static HRESULT WINAPI HTMLDocument3_getElementById(IHTMLDocument3 *iface, BSTR v nsIDOMNodeList_Item(nsnode_list, 0, &nsnode_by_name); nsIDOMNodeList_Release(nsnode_list); - nsAString_Finish(&id_str); if(nsnode_by_name && nsnode_by_id) { nsIDOM3Node *node3; @@ -528,8 +527,8 @@ static HRESULT WINAPI HTMLDocument3_getElementsByTagName(IHTMLDocument3 *iface, return E_UNEXPECTED; } - nsAString_Init(&id_str, v); - nsAString_Init(&ns_str, str); + nsAString_InitDepend(&id_str, v); + nsAString_InitDepend(&ns_str, str); nsres = nsIDOMHTMLDocument_GetElementsByTagNameNS(This->doc_node->nsdoc, &ns_str, &id_str, &nslist); nsAString_Finish(&id_str); nsAString_Finish(&ns_str); diff --git a/dlls/mshtml/htmldoc5.c b/dlls/mshtml/htmldoc5.c index e3b14231e6..12742f6412 100644 --- a/dlls/mshtml/htmldoc5.c +++ b/dlls/mshtml/htmldoc5.c @@ -136,7 +136,7 @@ static HRESULT WINAPI HTMLDocument5_createComment(IHTMLDocument5 *iface, BSTR bs return E_UNEXPECTED; } - nsAString_Init(&str, bstrdata); + nsAString_InitDepend(&str, bstrdata); nsres = nsIDOMHTMLDocument_CreateComment(This->doc_node->nsdoc, &str, &nscomment); nsAString_Finish(&str); if(NS_FAILED(nsres)) { diff --git a/dlls/mshtml/htmlelemcol.c b/dlls/mshtml/htmlelemcol.c index c973707738..9c0fedde8d 100644 --- a/dlls/mshtml/htmlelemcol.c +++ b/dlls/mshtml/htmlelemcol.c @@ -245,7 +245,7 @@ static BOOL is_elem_name(HTMLElement *elem, LPCWSTR name) return TRUE; } - nsAString_Init(&nsname, nameW); + nsAString_InitDepend(&nsname, nameW); nsres = nsIDOMHTMLElement_GetAttribute(elem->nselem, &nsname, &nsstr); nsAString_Finish(&nsname); if(NS_SUCCEEDED(nsres)) { diff --git a/dlls/mshtml/htmlevent.c b/dlls/mshtml/htmlevent.c index 5184391438..3ff41a6579 100644 --- a/dlls/mshtml/htmlevent.c +++ b/dlls/mshtml/htmlevent.c @@ -743,7 +743,7 @@ static IHTMLEventObj *create_event(HTMLDOMNode *target, eventid_t eid, nsIDOMEve if(NS_SUCCEEDED(nsres)) { nsAString type_str; - nsAString_Init(&type_str, event_types[event_info[eid].type]); + nsAString_InitDepend(&type_str, event_types[event_info[eid].type]); nsres = nsIDOMDocumentEvent_CreateEvent(doc_event, &type_str, &ret->nsevent); nsAString_Finish(&type_str); nsIDOMDocumentEvent_Release(doc_event); -- 2.32.0.93.g670b81a890