Commit e75683b8 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

mshtml: Use IUri as base URL in navigate_url.

parent 40e7f752
......@@ -103,7 +103,7 @@ HRESULT create_redirect_nschannel(const WCHAR*,nsChannel*,nsChannel**) DECLSPEC_
nsresult on_start_uri_open(NSContainer*,nsIURI*,cpp_bool*) DECLSPEC_HIDDEN;
HRESULT hlink_frame_navigate(HTMLDocument*,LPCWSTR,nsChannel*,DWORD,BOOL*) DECLSPEC_HIDDEN;
HRESULT create_doc_uri(HTMLOuterWindow*,WCHAR*,nsWineURI**) DECLSPEC_HIDDEN;
HRESULT create_doc_uri(HTMLOuterWindow*,const WCHAR*,nsWineURI**) DECLSPEC_HIDDEN;
HRESULT load_nsuri(HTMLOuterWindow*,nsWineURI*,nsChannelBSC*,DWORD) DECLSPEC_HIDDEN;
HRESULT set_moniker(HTMLDocument*,IMoniker*,IBindCtx*,nsChannelBSC*,BOOL) DECLSPEC_HIDDEN;
void prepare_for_binding(HTMLDocument*,IMoniker*,BOOL) DECLSPEC_HIDDEN;
......
......@@ -121,7 +121,7 @@ static HRESULT navigate_anchor(HTMLAnchorElement *This)
if(*href) {
if(!window)
window = This->element.node.doc->basedoc.window;
hres = navigate_url(window, href, window->url);
hres = navigate_url(window, href, window->uri);
}else {
TRACE("empty href\n");
hres = S_OK;
......
......@@ -609,7 +609,7 @@ static HRESULT WINAPI HTMLDocument_put_URL(IHTMLDocument2 *iface, BSTR v)
return E_FAIL;
}
return navigate_url(This->window, v, This->window->url);
return navigate_url(This->window, v, This->window->uri);
}
static HRESULT WINAPI HTMLDocument_get_URL(IHTMLDocument2 *iface, BSTR *p)
......
......@@ -135,7 +135,7 @@ static HRESULT WINAPI HTMLFrameBase_put_src(IHTMLFrameBase *iface, BSTR v)
return E_FAIL;
}
return navigate_url(This->content_window, v, This->element.node.doc->basedoc.window->url);
return navigate_url(This->content_window, v, This->element.node.doc->basedoc.window->uri);
}
static HRESULT WINAPI HTMLFrameBase_get_src(IHTMLFrameBase *iface, BSTR *p)
......
......@@ -170,7 +170,7 @@ static HRESULT WINAPI HTMLLocation_put_href(IHTMLLocation *iface, BSTR v)
return E_FAIL;
}
return navigate_url(This->window->base.outer_window, v, This->window->base.outer_window->url);
return navigate_url(This->window->base.outer_window, v, This->window->base.outer_window->uri);
}
static HRESULT WINAPI HTMLLocation_get_href(IHTMLLocation *iface, BSTR *p)
......@@ -570,7 +570,7 @@ static HRESULT WINAPI HTMLLocation_replace(IHTMLLocation *iface, BSTR bstr)
return E_FAIL;
}
return navigate_url(This->window->base.outer_window, bstr, This->window->base.outer_window->url);
return navigate_url(This->window->base.outer_window, bstr, This->window->base.outer_window->uri);
}
static HRESULT WINAPI HTMLLocation_assign(IHTMLLocation *iface, BSTR bstr)
......
......@@ -775,7 +775,7 @@ void init_node_cc(void);
HRESULT nsuri_to_url(LPCWSTR,BOOL,BSTR*) DECLSPEC_HIDDEN;
BOOL compare_ignoring_frag(IUri*,IUri*) DECLSPEC_HIDDEN;
HRESULT navigate_url(HTMLOuterWindow*,const WCHAR*,const WCHAR*) DECLSPEC_HIDDEN;
HRESULT navigate_url(HTMLOuterWindow*,const WCHAR*,IUri*) DECLSPEC_HIDDEN;
HRESULT set_frame_doc(HTMLFrameBase*,nsIDOMDocument*) DECLSPEC_HIDDEN;
void call_property_onchanged(ConnectionPoint*,DISPID) DECLSPEC_HIDDEN;
......
......@@ -2245,61 +2245,28 @@ HRESULT hlink_frame_navigate(HTMLDocument *doc, LPCWSTR url, nsChannel *nschanne
return hres;
}
HRESULT navigate_url(HTMLOuterWindow *window, const WCHAR *new_url, const WCHAR *base_url)
HRESULT navigate_uri(HTMLOuterWindow *window, IUri *uri, const WCHAR *display_uri)
{
WCHAR url[INTERNET_MAX_URL_LENGTH];
nsWineURI *uri;
nsWineURI *nsuri;
HRESULT hres;
if(!new_url) {
*url = 0;
}else if(base_url) {
DWORD len = 0;
hres = CoInternetCombineUrl(base_url, new_url, URL_ESCAPE_SPACES_ONLY|URL_DONT_ESCAPE_EXTRA_INFO,
url, sizeof(url)/sizeof(WCHAR), &len, 0);
if(FAILED(hres))
return hres;
}else {
strcpyW(url, new_url);
}
if(window->doc_obj && window->doc_obj->hostui) {
OLECHAR *translated_url = NULL;
hres = IDocHostUIHandler_TranslateUrl(window->doc_obj->hostui, 0, url,
&translated_url);
if(hres == S_OK) {
TRACE("%08x %s -> %s\n", hres, debugstr_w(url), debugstr_w(translated_url));
strcpyW(url, translated_url);
CoTaskMemFree(translated_url);
}
}
if(window->doc_obj && window->doc_obj->is_webbrowser && window == window->doc_obj->basedoc.window) {
BOOL cancel = FALSE;
IUri *uri;
hres = IDocObjectService_FireBeforeNavigate2(window->doc_obj->doc_object_service, NULL, url, 0x40,
hres = IDocObjectService_FireBeforeNavigate2(window->doc_obj->doc_object_service, NULL, display_uri, 0x40,
NULL, NULL, 0, NULL, TRUE, &cancel);
if(SUCCEEDED(hres) && cancel) {
TRACE("Navigation canceled\n");
return S_OK;
}
hres = CreateUri(url, 0, 0, &uri);
if(FAILED(hres))
return hres;
hres = super_navigate(window, uri, NULL, NULL, 0);
IUri_Release(uri);
return hres;
return super_navigate(window, uri, NULL, NULL, 0);
}
if(window->doc_obj && window == window->doc_obj->basedoc.window) {
BOOL cancel;
hres = hlink_frame_navigate(&window->base.inner_window->doc->basedoc, url, NULL, 0, &cancel);
hres = hlink_frame_navigate(&window->base.inner_window->doc->basedoc, display_uri, NULL, 0, &cancel);
if(FAILED(hres))
return hres;
......@@ -2309,11 +2276,60 @@ HRESULT navigate_url(HTMLOuterWindow *window, const WCHAR *new_url, const WCHAR
}
}
hres = create_doc_uri(window, url, &uri);
hres = create_doc_uri(window, display_uri, &nsuri);
if(FAILED(hres))
return hres;
hres = load_nsuri(window, nsuri, NULL, LOAD_FLAGS_NONE);
nsISupports_Release((nsISupports*)nsuri);
return hres;
}
HRESULT navigate_url(HTMLOuterWindow *window, const WCHAR *new_url, IUri *base_uri)
{
BSTR display_uri;
IUri *uri;
HRESULT hres;
if(new_url && base_uri)
hres = CoInternetCombineUrlEx(base_uri, new_url, URL_ESCAPE_SPACES_ONLY|URL_DONT_ESCAPE_EXTRA_INFO,
&uri, 0);
else
hres = CreateUri(new_url, 0, 0, &uri);
if(FAILED(hres))
return hres;
hres = load_nsuri(window, uri, NULL, LOAD_FLAGS_NONE);
nsISupports_Release((nsISupports*)uri);
hres = IUri_GetDisplayUri(uri, &display_uri);
if(FAILED(hres)) {
IUri_Release(uri);
return hres;
}
if(window->doc_obj && window->doc_obj->hostui) {
OLECHAR *translated_url = NULL;
hres = IDocHostUIHandler_TranslateUrl(window->doc_obj->hostui, 0, display_uri,
&translated_url);
if(hres == S_OK) {
TRACE("%08x %s -> %s\n", hres, debugstr_w(display_uri), debugstr_w(translated_url));
SysFreeString(display_uri);
IUri_Release(uri);
hres = CreateUri(translated_url, 0, 0, &uri);
CoTaskMemFree(translated_url);
if(FAILED(hres))
return hres;
hres = IUri_GetDisplayUri(uri, &display_uri);
if(FAILED(hres)) {
IUri_Release(uri);
return hres;
}
}
}
hres = navigate_uri(window, uri, display_uri);
IUri_Release(uri);
SysFreeString(display_uri);
return hres;
}
......@@ -2867,7 +2867,7 @@ static nsresult create_nsuri(IUri *iuri, HTMLOuterWindow *window, NSContainer *c
return NS_OK;
}
HRESULT create_doc_uri(HTMLOuterWindow *window, WCHAR *url, nsWineURI **ret)
HRESULT create_doc_uri(HTMLOuterWindow *window, const WCHAR *url, nsWineURI **ret)
{
nsWineURI *uri;
IUri *iuri;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment