mshtml: Optimize nsACString handling.
This commit is contained in:
parent
3d9d384486
commit
dbd582cf84
|
@ -198,10 +198,9 @@ void hlink_frame_navigate(HTMLDocument*,IHlinkFrame*,LPCWSTR,nsIInputStream*,DWO
|
|||
|
||||
nsIURI *get_nsIURI(LPCWSTR);
|
||||
|
||||
nsACString *nsACString_Create(void);
|
||||
void nsACString_Init(nsACString*,const char*);
|
||||
PRUint32 nsACString_GetData(const nsACString*,const char**,PRBool*);
|
||||
void nsACString_SetData(nsACString*,const char*);
|
||||
void nsACString_Destroy(nsACString*);
|
||||
void nsACString_Finish(nsACString*);
|
||||
|
||||
void nsAString_Init(nsAString*,const PRUnichar*);
|
||||
PRUint32 nsAString_GetData(const nsAString*,const PRUnichar**,PRBool*);
|
||||
|
|
|
@ -361,17 +361,11 @@ static BOOL load_gecko(void)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
nsACString *nsACString_Create(void)
|
||||
void nsACString_Init(nsACString *str, const char *data)
|
||||
{
|
||||
nsACString *ret;
|
||||
ret = HeapAlloc(GetProcessHeap(), 0, sizeof(nsACString));
|
||||
NS_CStringContainerInit(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void nsACString_SetData(nsACString *str, const char *data)
|
||||
{
|
||||
NS_CStringSetData(str, data, PR_UINT32_MAX);
|
||||
NS_CStringContainerInit(str);
|
||||
if(data)
|
||||
NS_CStringSetData(str, data, PR_UINT32_MAX);
|
||||
}
|
||||
|
||||
PRUint32 nsACString_GetData(const nsACString *str, const char **data, PRBool *termited)
|
||||
|
@ -379,10 +373,9 @@ PRUint32 nsACString_GetData(const nsACString *str, const char **data, PRBool *te
|
|||
return NS_CStringGetData(str, data, termited);
|
||||
}
|
||||
|
||||
void nsACString_Destroy(nsACString *str)
|
||||
void nsACString_Finish(nsACString *str)
|
||||
{
|
||||
NS_CStringContainerFinish(str);
|
||||
HeapFree(GetProcessHeap(), 0, str);
|
||||
}
|
||||
|
||||
void nsAString_Init(nsAString *str, const PRUnichar *data)
|
||||
|
@ -727,16 +720,17 @@ static nsresult NSAPI nsURIContentListener_OnStartURIOpen(nsIURIContentListener
|
|||
{
|
||||
NSContainer *This = NSURICL_THIS(iface);
|
||||
nsIWineURI *wine_uri;
|
||||
nsACString *spec_str = nsACString_Create();
|
||||
nsACString spec_str;
|
||||
const char *spec;
|
||||
nsresult nsres;
|
||||
|
||||
nsIURI_GetSpec(aURI, spec_str);
|
||||
nsACString_GetData(spec_str, &spec, NULL);
|
||||
nsACString_Init(&spec_str, NULL);
|
||||
nsIURI_GetSpec(aURI, &spec_str);
|
||||
nsACString_GetData(&spec_str, &spec, NULL);
|
||||
|
||||
TRACE("(%p)->(%p(%s) %p)\n", This, aURI, debugstr_a(spec), _retval);
|
||||
|
||||
nsACString_Destroy(spec_str);
|
||||
nsACString_Finish(&spec_str);
|
||||
|
||||
nsres = nsIURI_QueryInterface(aURI, &IID_nsIWineURI, (void**)&wine_uri);
|
||||
if(NS_SUCCEEDED(nsres)) {
|
||||
|
|
|
@ -47,6 +47,13 @@ typedef ULARGE_INTEGER PRUint64;
|
|||
typedef PRUint64 DOMTimeStamp;
|
||||
typedef PRUint32 nsLoadFlags;
|
||||
|
||||
typedef struct {
|
||||
void *v;
|
||||
void *d1;
|
||||
PRUint32 d2;
|
||||
void *d3;
|
||||
} nsCStringContainer;
|
||||
|
||||
typedef struct {
|
||||
void *v;
|
||||
void *d1;
|
||||
|
@ -54,7 +61,6 @@ typedef struct {
|
|||
void *d3;
|
||||
} nsStringContainer;
|
||||
|
||||
typedef struct nsCStringContainer nsCStringContainer;
|
||||
typedef nsCStringContainer nsACString;
|
||||
typedef nsStringContainer nsAString;
|
||||
|
||||
|
|
|
@ -146,7 +146,7 @@ static BOOL handle_uri(NSContainer *container, nsChannel *channel, LPCWSTR uri)
|
|||
|
||||
static BOOL before_async_open(nsChannel *This)
|
||||
{
|
||||
nsACString *uri_str;
|
||||
nsACString uri_str;
|
||||
NSContainer *container;
|
||||
const char *uria;
|
||||
LPWSTR uri;
|
||||
|
@ -167,13 +167,13 @@ static BOOL before_async_open(nsChannel *This)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
uri_str = nsACString_Create();
|
||||
nsIWineURI_GetSpec(This->uri, uri_str);
|
||||
nsACString_GetData(uri_str, &uria, NULL);
|
||||
nsACString_Init(&uri_str, NULL);
|
||||
nsIWineURI_GetSpec(This->uri, &uri_str);
|
||||
nsACString_GetData(&uri_str, &uria, NULL);
|
||||
len = MultiByteToWideChar(CP_ACP, 0, uria, -1, NULL, 0);
|
||||
uri = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
|
||||
MultiByteToWideChar(CP_ACP, 0, uria, -1, uri, len);
|
||||
nsACString_Destroy(uri_str);
|
||||
nsACString_Finish(&uri_str);
|
||||
|
||||
ret = handle_uri(container, This, uri);
|
||||
|
||||
|
@ -613,13 +613,15 @@ static nsresult NSAPI nsChannel_AsyncOpen(nsIHttpChannel *iface, nsIStreamListen
|
|||
nsres = nsIChannel_QueryInterface(This->channel, &IID_nsIUploadChannel,
|
||||
(void**)&upload_channel);
|
||||
if(NS_SUCCEEDED(nsres)) {
|
||||
nsACString *empty_string = nsACString_Create();
|
||||
nsACString_SetData(empty_string, "");
|
||||
nsACString empty_string;
|
||||
nsACString_Init(&empty_string, "");
|
||||
|
||||
nsres = nsIUploadChannel_SetUploadStream(upload_channel, This->post_data_stream,
|
||||
empty_string, -1);
|
||||
&empty_string, -1);
|
||||
if(NS_FAILED(nsres))
|
||||
WARN("SetUploadStream failed: %08lx\n", nsres);
|
||||
|
||||
nsACString_Finish(&empty_string);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1380,18 +1382,20 @@ static nsresult NSAPI nsIOService_NewURI(nsIIOService *iface, const nsACString *
|
|||
aBaseURI, _retval);
|
||||
|
||||
if(aBaseURI) {
|
||||
nsACString *base_uri_str = nsACString_Create();
|
||||
nsACString base_uri_str;
|
||||
const char *base_uri = NULL;
|
||||
|
||||
nsres = nsIURI_GetSpec(aBaseURI, base_uri_str);
|
||||
nsACString_Init(&base_uri_str, NULL);
|
||||
|
||||
nsres = nsIURI_GetSpec(aBaseURI, &base_uri_str);
|
||||
if(NS_SUCCEEDED(nsres)) {
|
||||
nsACString_GetData(base_uri_str, &base_uri, NULL);
|
||||
nsACString_GetData(&base_uri_str, &base_uri, NULL);
|
||||
TRACE("uri=%s\n", debugstr_a(base_uri));
|
||||
}else {
|
||||
ERR("GetSpec failed: %08lx\n", nsres);
|
||||
}
|
||||
|
||||
nsACString_Destroy(base_uri_str);
|
||||
nsACString_Finish(&base_uri_str);
|
||||
}
|
||||
|
||||
nsres = nsIIOService_NewURI(nsio, aSpec, aOriginCharset, aBaseURI, &uri);
|
||||
|
@ -1603,7 +1607,7 @@ void init_nsio(nsIComponentManager *component_manager, nsIComponentRegistrar *re
|
|||
nsIURI *get_nsIURI(LPCWSTR url)
|
||||
{
|
||||
nsIURI *ret;
|
||||
nsACString *acstr;
|
||||
nsACString acstr;
|
||||
nsresult nsres;
|
||||
char *urla;
|
||||
int len;
|
||||
|
@ -1612,14 +1616,13 @@ nsIURI *get_nsIURI(LPCWSTR url)
|
|||
urla = HeapAlloc(GetProcessHeap(), 0, len);
|
||||
WideCharToMultiByte(CP_ACP, 0, url, -1, urla, -1, NULL, NULL);
|
||||
|
||||
acstr = nsACString_Create();
|
||||
nsACString_SetData(acstr, urla);
|
||||
nsACString_Init(&acstr, urla);
|
||||
|
||||
nsres = nsIIOService_NewURI(nsio, acstr, NULL, NULL, &ret);
|
||||
nsres = nsIIOService_NewURI(nsio, &acstr, NULL, NULL, &ret);
|
||||
if(NS_FAILED(nsres))
|
||||
FIXME("NewURI failed: %08lx\n", nsres);
|
||||
|
||||
nsACString_Destroy(acstr);
|
||||
nsACString_Finish(&acstr);
|
||||
HeapFree(GetProcessHeap(), 0, urla);
|
||||
|
||||
return ret;
|
||||
|
|
|
@ -115,18 +115,18 @@ static HRESULT WINAPI BindStatusCallback_OnStartBinding(IBindStatusCallback *ifa
|
|||
IBinding_AddRef(pbind);
|
||||
|
||||
if(This->doc->nscontainer && This->doc->nscontainer->stream) {
|
||||
nsACString *strTextHtml;
|
||||
nsACString strTextHtml;
|
||||
nsresult nsres;
|
||||
nsIURI *uri = get_nsIURI(This->url);
|
||||
|
||||
strTextHtml = nsACString_Create();
|
||||
/* FIXME: Set it correctly */
|
||||
nsACString_SetData(strTextHtml, "text/html");
|
||||
nsACString_Init(&strTextHtml, "text/html");
|
||||
|
||||
nsres = nsIWebBrowserStream_OpenStream(This->doc->nscontainer->stream, uri, strTextHtml);
|
||||
nsres = nsIWebBrowserStream_OpenStream(This->doc->nscontainer->stream, uri, &strTextHtml);
|
||||
if(NS_FAILED(nsres))
|
||||
ERR("OpenStream failed: %08lx\n", nsres);
|
||||
|
||||
nsACString_Finish(&strTextHtml);
|
||||
nsIURI_Release(uri);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue