From 2f5123cbbc8655fc410ed47b0e7dff51d857a3ae Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Wed, 21 Nov 2012 15:06:46 +0100 Subject: [PATCH] mshtml: Added nsIURI::GetOriginCharset implementation. --- dlls/mshtml/nsio.c | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/dlls/mshtml/nsio.c b/dlls/mshtml/nsio.c index e3520d126b8..89a7fe8660e 100644 --- a/dlls/mshtml/nsio.c +++ b/dlls/mshtml/nsio.c @@ -63,6 +63,7 @@ struct nsWineURI { nsChannelBSC *channel_bsc; IUri *uri; IUriBuilder *uri_builder; + char *origin_charset; BOOL is_doc_uri; BOOL is_mutable; DWORD scheme; @@ -140,7 +141,7 @@ static BOOL compare_ignoring_frag(IUri *uri1, IUri *uri2) return ret; } -static nsresult create_nsuri(IUri*,HTMLOuterWindow*,NSContainer*,nsWineURI**); +static nsresult create_nsuri(IUri*,HTMLOuterWindow*,NSContainer*,const char*,nsWineURI**); static const char *debugstr_nsacstr(const nsACString *nsstr) { @@ -1847,6 +1848,7 @@ static nsrefcnt NSAPI nsURI_Release(nsIFileURL *iface) nsIWebBrowserChrome_Release(&This->container->nsIWebBrowserChrome_iface); if(This->uri) IUri_Release(This->uri); + heap_free(This->origin_charset); heap_free(This); } @@ -2309,7 +2311,8 @@ static nsresult NSAPI nsURI_Clone(nsIFileURL *iface, nsIURI **_retval) if(!ensure_uri(This)) return NS_ERROR_UNEXPECTED; - nsres = create_nsuri(This->uri, This->window_ref ? This->window_ref->window : NULL, This->container, &wine_uri); + nsres = create_nsuri(This->uri, This->window_ref ? This->window_ref->window : NULL, + This->container, This->origin_charset, &wine_uri); if(NS_FAILED(nsres)) { WARN("create_nsuri failed: %08x\n", nsres); return nsres; @@ -2384,8 +2387,11 @@ static nsresult NSAPI nsURI_GetAsciiHost(nsIFileURL *iface, nsACString *aAsciiHo static nsresult NSAPI nsURI_GetOriginCharset(nsIFileURL *iface, nsACString *aOriginCharset) { nsWineURI *This = impl_from_nsIFileURL(iface); - FIXME("(%p)->(%p)\n", This, aOriginCharset); - return NS_ERROR_NOT_IMPLEMENTED; + + TRACE("(%p)->(%p)\n", This, aOriginCharset); + + nsACString_SetData(aOriginCharset, This->origin_charset); + return NS_OK; } static nsresult NSAPI nsURL_GetRef(nsIFileURL *iface, nsACString *aRef) @@ -2481,7 +2487,8 @@ static nsresult NSAPI nsURI_CloneIgnoreRef(nsIFileURL *iface, nsIURI **_retval) if(!uri) return NS_ERROR_FAILURE; - nsres = create_nsuri(uri, This->window_ref ? This->window_ref->window : NULL, This->container, &wine_uri); + nsres = create_nsuri(uri, This->window_ref ? This->window_ref->window : NULL, This->container, + This->origin_charset, &wine_uri); IUri_Release(uri); if(NS_FAILED(nsres)) { WARN("create_nsuri failed: %08x\n", nsres); @@ -2850,7 +2857,8 @@ static const nsIStandardURLVtbl nsStandardURLVtbl = { nsStandardURL_Init }; -static nsresult create_nsuri(IUri *iuri, HTMLOuterWindow *window, NSContainer *container, nsWineURI **_retval) +static nsresult create_nsuri(IUri *iuri, HTMLOuterWindow *window, NSContainer *container, + const char *origin_charset, nsWineURI **_retval) { nsWineURI *ret; HRESULT hres; @@ -2874,6 +2882,14 @@ static nsresult create_nsuri(IUri *iuri, HTMLOuterWindow *window, NSContainer *c if(FAILED(hres)) ret->scheme = URL_SCHEME_UNKNOWN; + if(origin_charset && *origin_charset && strcmp(origin_charset, "UTF-8")) { + ret->origin_charset = heap_strdupA(origin_charset); + if(!ret->origin_charset) { + nsIFileURL_Release(&ret->nsIFileURL_iface); + return NS_ERROR_OUT_OF_MEMORY; + } + } + TRACE("retval=%p\n", ret); *_retval = ret; return NS_OK; @@ -2890,7 +2906,7 @@ HRESULT create_doc_uri(HTMLOuterWindow *window, const WCHAR *url, nsWineURI **re if(FAILED(hres)) return hres; - nsres = create_nsuri(iuri, window, window->doc_obj->nscontainer, &uri); + nsres = create_nsuri(iuri, window, window->doc_obj->nscontainer, NULL, &uri); IUri_Release(iuri); if(NS_FAILED(nsres)) return E_FAIL; @@ -2942,7 +2958,7 @@ HRESULT create_redirect_nschannel(const WCHAR *url, nsChannel *orig_channel, nsC if(orig_channel->uri->window_ref) window = orig_channel->uri->window_ref->window; - nsres = create_nsuri(iuri, window, NULL, &uri); + nsres = create_nsuri(iuri, window, NULL, NULL, &uri); IUri_Release(iuri); if(NS_FAILED(nsres)) return E_FAIL; @@ -3257,7 +3273,7 @@ static nsresult NSAPI nsIOService_NewURI(nsIIOService *iface, const nsACString * if(FAILED(hres)) return nsIIOService_NewURI(nsio, aSpec, aOriginCharset, aBaseURI, _retval); - nsres = create_nsuri(urlmon_uri, window, NULL, &wine_uri); + nsres = create_nsuri(urlmon_uri, window, NULL, NULL, &wine_uri); IUri_Release(urlmon_uri); if(base_wine_uri) nsIFileURL_Release(&base_wine_uri->nsIFileURL_iface);