From 679591ff87d2874aa94dad1194de01ac44cafaf1 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Mon, 30 Nov 2009 18:00:38 +0100 Subject: [PATCH] mshtml: Added support for relative URLs in navigate_url. --- dlls/mshtml/htmllocation.c | 6 ++--- dlls/mshtml/mshtml_private.h | 2 +- dlls/mshtml/navigate.c | 44 ++++++++++++++++++++++-------------- 3 files changed, 31 insertions(+), 21 deletions(-) diff --git a/dlls/mshtml/htmllocation.c b/dlls/mshtml/htmllocation.c index 3b91429bdb9..93df9e0ee2a 100644 --- a/dlls/mshtml/htmllocation.c +++ b/dlls/mshtml/htmllocation.c @@ -154,12 +154,12 @@ static HRESULT WINAPI HTMLLocation_put_href(IHTMLLocation *iface, BSTR v) TRACE("(%p)->(%s)\n", This, debugstr_w(v)); - if(!This->window || !This->window->doc) { - FIXME("No document available\n"); + if(!This->window) { + FIXME("No window available\n"); return E_FAIL; } - return navigate_url(This->window->doc, v); + return navigate_url(This->window, v, This->window->url); } static HRESULT WINAPI HTMLLocation_get_href(IHTMLLocation *iface, BSTR *p) diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h index cee256eb4c2..5fed4af2c2f 100644 --- a/dlls/mshtml/mshtml_private.h +++ b/dlls/mshtml/mshtml_private.h @@ -668,7 +668,7 @@ BOOL install_wine_gecko(BOOL); HRESULT nsuri_to_url(LPCWSTR,BOOL,BSTR*); HRESULT hlink_frame_navigate(HTMLDocument*,LPCWSTR,nsIInputStream*,DWORD); -HRESULT navigate_url(HTMLDocumentNode*,OLECHAR*); +HRESULT navigate_url(HTMLWindow*,const WCHAR*,const WCHAR*); void call_property_onchanged(ConnectionPoint*,DISPID); HRESULT call_set_active_object(IOleInPlaceUIWindow*,IOleInPlaceActiveObject*); diff --git a/dlls/mshtml/navigate.c b/dlls/mshtml/navigate.c index c6d398ed05b..66be2fc2d36 100644 --- a/dlls/mshtml/navigate.c +++ b/dlls/mshtml/navigate.c @@ -27,9 +27,12 @@ #include "windef.h" #include "winbase.h" #include "winuser.h" +#include "winreg.h" #include "ole2.h" #include "hlguids.h" #include "shlguid.h" +#include "wininet.h" +#include "shlwapi.h" #include "wine/debug.h" #include "wine/unicode.h" @@ -41,8 +44,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(mshtml); #define CONTENT_LENGTH "Content-Length" #define UTF16_STR "utf-16" -static WCHAR emptyW[] = {0}; - typedef struct { const nsIInputStreamVtbl *lpInputStreamVtbl; @@ -1231,30 +1232,39 @@ HRESULT hlink_frame_navigate(HTMLDocument *doc, LPCWSTR url, return hres; } -HRESULT navigate_url(HTMLDocumentNode *doc, OLECHAR *url) + +HRESULT navigate_url(HTMLWindow *window, const WCHAR *new_url, const WCHAR *base_url) { - OLECHAR *translated_url = NULL; + WCHAR url[INTERNET_MAX_URL_LENGTH]; HRESULT hres; - if(!url) - url = emptyW; + if(!new_url) { + *url = 0; + }else if(base_url) { + DWORD len = 0; - if(doc->basedoc.doc_obj->hostui) { - hres = IDocHostUIHandler_TranslateUrl(doc->basedoc.doc_obj->hostui, 0, url, + 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) - url = translated_url; + if(hres == S_OK) { + strcpyW(url, translated_url); + CoTaskMemFree(translated_url); + } } - if(doc != doc->basedoc.doc_obj->basedoc.doc_node) { - FIXME("navigation in frame\n"); - return E_NOTIMPL; - } - - hres = hlink_frame_navigate(&doc->basedoc, url, NULL, 0); + hres = hlink_frame_navigate(&window->doc->basedoc, url, NULL, 0); if(FAILED(hres)) FIXME("hlink_frame_navigate failed: %08x\n", hres); - CoTaskMemFree(translated_url); return hres; }