mshtml: Use IUriBuilder for IURI::SetQuery implementation.
This commit is contained in:
parent
16fbd05080
commit
98f5bc384b
@ -63,8 +63,9 @@ struct nsWineURI {
|
|||||||
NSContainer *container;
|
NSContainer *container;
|
||||||
windowref_t *window_ref;
|
windowref_t *window_ref;
|
||||||
nsChannelBSC *channel_bsc;
|
nsChannelBSC *channel_bsc;
|
||||||
LPWSTR wine_url;
|
BSTR wine_url;
|
||||||
IUri *uri;
|
IUri *uri;
|
||||||
|
IUriBuilder *uri_builder;
|
||||||
BOOL is_doc_uri;
|
BOOL is_doc_uri;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -248,12 +249,12 @@ HRESULT set_wine_url(nsWineURI *This, LPCWSTR url)
|
|||||||
TRACE("(%p)->(%s)\n", This, debugstr_w(url));
|
TRACE("(%p)->(%s)\n", This, debugstr_w(url));
|
||||||
|
|
||||||
if(url) {
|
if(url) {
|
||||||
WCHAR *new_url;
|
BSTR new_url;
|
||||||
|
|
||||||
new_url = heap_strdupW(url);
|
new_url = SysAllocString(url);
|
||||||
if(!new_url)
|
if(!new_url)
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
heap_free(This->wine_url);
|
SysFreeString(This->wine_url);
|
||||||
This->wine_url = new_url;
|
This->wine_url = new_url;
|
||||||
}else {
|
}else {
|
||||||
heap_free(This->wine_url);
|
heap_free(This->wine_url);
|
||||||
@ -1529,19 +1530,74 @@ static const nsIHttpChannelInternalVtbl nsHttpChannelInternalVtbl = {
|
|||||||
|
|
||||||
static BOOL ensure_uri(nsWineURI *This)
|
static BOOL ensure_uri(nsWineURI *This)
|
||||||
{
|
{
|
||||||
if(!This->uri) {
|
HRESULT hres;
|
||||||
|
|
||||||
|
if(This->uri)
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
if(This->uri_builder) {
|
||||||
|
hres = IUriBuilder_CreateUriSimple(This->uri_builder, 0, 0, &This->uri);
|
||||||
|
if(FAILED(hres)) {
|
||||||
|
WARN("CreateUriSimple failed: %08x\n", hres);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
hres = CreateUri(This->wine_url, 0, 0, &This->uri);
|
||||||
|
if(FAILED(hres)) {
|
||||||
|
WARN("CreateUri failed: %08x\n", hres);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void invalidate_uri(nsWineURI *This)
|
||||||
|
{
|
||||||
|
if(This->uri) {
|
||||||
|
IUri_Release(This->uri);
|
||||||
|
This->uri = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static BOOL ensure_uri_builder(nsWineURI *This)
|
||||||
|
{
|
||||||
|
if(!This->uri_builder) {
|
||||||
HRESULT hres;
|
HRESULT hres;
|
||||||
|
|
||||||
hres = CreateUri(This->wine_url, 0, 0, &This->uri);
|
if(!ensure_uri(This))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
hres = CreateIUriBuilder(This->uri, 0, 0, &This->uri_builder);
|
||||||
if(FAILED(hres)) {
|
if(FAILED(hres)) {
|
||||||
WARN("CreateUri failed: %08x\n", hres);
|
WARN("CreateIUriBulder failed: %08x\n", hres);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
invalidate_uri(This);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Temporary helper */
|
||||||
|
static void sync_wine_url(nsWineURI *This)
|
||||||
|
{
|
||||||
|
BSTR new_url;
|
||||||
|
HRESULT hres;
|
||||||
|
|
||||||
|
if(!ensure_uri(This))
|
||||||
|
return;
|
||||||
|
|
||||||
|
hres = IUri_GetDisplayUri(This->uri, &new_url);
|
||||||
|
if(FAILED(hres))
|
||||||
|
return;
|
||||||
|
|
||||||
|
SysFreeString(This->wine_url);
|
||||||
|
This->wine_url = new_url;
|
||||||
|
}
|
||||||
|
|
||||||
static nsresult get_uri_string(nsWineURI *This, Uri_PROPERTY prop, nsACString *ret)
|
static nsresult get_uri_string(nsWineURI *This, Uri_PROPERTY prop, nsACString *ret)
|
||||||
{
|
{
|
||||||
char *vala;
|
char *vala;
|
||||||
@ -1568,14 +1624,6 @@ static nsresult get_uri_string(nsWineURI *This, Uri_PROPERTY prop, nsACString *r
|
|||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void invalidate_uri(nsWineURI *This)
|
|
||||||
{
|
|
||||||
if(This->uri) {
|
|
||||||
IUri_Release(This->uri);
|
|
||||||
This->uri = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#define NSURI_THIS(iface) DEFINE_THIS(nsWineURI, IURL, iface)
|
#define NSURI_THIS(iface) DEFINE_THIS(nsWineURI, IURL, iface)
|
||||||
|
|
||||||
static nsresult NSAPI nsURI_QueryInterface(nsIURL *iface, nsIIDRef riid, void **result)
|
static nsresult NSAPI nsURI_QueryInterface(nsIURL *iface, nsIIDRef riid, void **result)
|
||||||
@ -1635,7 +1683,7 @@ static nsrefcnt NSAPI nsURI_Release(nsIURL *iface)
|
|||||||
nsIURI_Release(This->nsuri);
|
nsIURI_Release(This->nsuri);
|
||||||
if(This->uri)
|
if(This->uri)
|
||||||
IUri_Release(This->uri);
|
IUri_Release(This->uri);
|
||||||
heap_free(This->wine_url);
|
SysFreeString(This->wine_url);
|
||||||
heap_free(This);
|
heap_free(This);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2189,55 +2237,26 @@ static nsresult NSAPI nsURL_GetQuery(nsIURL *iface, nsACString *aQuery)
|
|||||||
static nsresult NSAPI nsURL_SetQuery(nsIURL *iface, const nsACString *aQuery)
|
static nsresult NSAPI nsURL_SetQuery(nsIURL *iface, const nsACString *aQuery)
|
||||||
{
|
{
|
||||||
nsWineURI *This = NSURI_THIS(iface);
|
nsWineURI *This = NSURI_THIS(iface);
|
||||||
const WCHAR *ptr1, *ptr2;
|
const char *querya;
|
||||||
const char *query;
|
WCHAR *query;
|
||||||
WCHAR *new_url, *ptr;
|
HRESULT hres;
|
||||||
DWORD len, size;
|
|
||||||
|
|
||||||
TRACE("(%p)->(%s)\n", This, debugstr_nsacstr(aQuery));
|
TRACE("(%p)->(%s)\n", This, debugstr_nsacstr(aQuery));
|
||||||
|
|
||||||
invalidate_uri(This);
|
if(!ensure_uri_builder(This))
|
||||||
|
return NS_ERROR_UNEXPECTED;
|
||||||
|
|
||||||
if(This->nsurl)
|
nsACString_GetData(aQuery, &querya);
|
||||||
nsIURL_SetQuery(This->nsurl, aQuery);
|
query = heap_strdupAtoW(querya);
|
||||||
|
if(!query)
|
||||||
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
|
|
||||||
if(!This->wine_url)
|
hres = IUriBuilder_SetQuery(This->uri_builder, query);
|
||||||
return NS_OK;
|
heap_free(query);
|
||||||
|
if(FAILED(hres))
|
||||||
|
return NS_ERROR_UNEXPECTED;
|
||||||
|
|
||||||
nsACString_GetData(aQuery, &query);
|
sync_wine_url(This);
|
||||||
size = len = MultiByteToWideChar(CP_ACP, 0, query, -1, NULL, 0);
|
|
||||||
ptr1 = strchrW(This->wine_url, '?');
|
|
||||||
if(ptr1) {
|
|
||||||
size += ptr1-This->wine_url;
|
|
||||||
ptr2 = strchrW(ptr1, '#');
|
|
||||||
if(ptr2)
|
|
||||||
size += strlenW(ptr2);
|
|
||||||
}else {
|
|
||||||
ptr1 = This->wine_url + strlenW(This->wine_url);
|
|
||||||
ptr2 = NULL;
|
|
||||||
size += strlenW(This->wine_url);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(*query)
|
|
||||||
size++;
|
|
||||||
|
|
||||||
new_url = heap_alloc(size*sizeof(WCHAR));
|
|
||||||
memcpy(new_url, This->wine_url, (ptr1-This->wine_url)*sizeof(WCHAR));
|
|
||||||
ptr = new_url + (ptr1-This->wine_url);
|
|
||||||
if(*query) {
|
|
||||||
*ptr++ = '?';
|
|
||||||
MultiByteToWideChar(CP_ACP, 0, query, -1, ptr, len);
|
|
||||||
ptr += len-1;
|
|
||||||
}
|
|
||||||
if(ptr2)
|
|
||||||
strcpyW(ptr, ptr2);
|
|
||||||
else
|
|
||||||
*ptr = 0;
|
|
||||||
|
|
||||||
TRACE("setting %s\n", debugstr_w(new_url));
|
|
||||||
|
|
||||||
heap_free(This->wine_url);
|
|
||||||
This->wine_url = new_url;
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user