Module: wine Branch: master Commit: 2ca7683dfb03a286ec09f3d3d4039a9e844db78c URL: http://source.winehq.org/git/wine.git/?a=commit;h=2ca7683dfb03a286ec09f3d3d4...
Author: Jacek Caban jacek@codeweavers.com Date: Sun Aug 9 15:56:10 2009 +0200
mshtml: Added IHTMLLocation::get_pathname implementation.
---
dlls/mshtml/Makefile.in | 1 + dlls/mshtml/htmllocation.c | 40 ++++++++++++++++++++++++++++++++++++++-- dlls/mshtml/tests/dom.c | 5 +++++ 3 files changed, 44 insertions(+), 2 deletions(-)
diff --git a/dlls/mshtml/Makefile.in b/dlls/mshtml/Makefile.in index acda821..7f44bb1 100644 --- a/dlls/mshtml/Makefile.in +++ b/dlls/mshtml/Makefile.in @@ -6,6 +6,7 @@ MODULE = mshtml.dll IMPORTLIB = mshtml IMPORTS = strmiids uuid urlmon shlwapi ole32 oleaut32 user32 gdi32 advapi32 kernel32 EXTRADEFS = -DCOM_NO_WINDOWS_H +DELAYIMPORTS = wininet
C_SRCS = \ conpoint.c \ diff --git a/dlls/mshtml/htmllocation.c b/dlls/mshtml/htmllocation.c index 35f042a..e2001bb 100644 --- a/dlls/mshtml/htmllocation.c +++ b/dlls/mshtml/htmllocation.c @@ -23,7 +23,10 @@ #include "windef.h" #include "winbase.h" #include "winuser.h" +#include "winreg.h" #include "ole2.h" +#include "wininet.h" +#include "shlwapi.h"
#include "wine/debug.h"
@@ -195,8 +198,41 @@ static HRESULT WINAPI HTMLLocation_put_pathname(IHTMLLocation *iface, BSTR v) static HRESULT WINAPI HTMLLocation_get_pathname(IHTMLLocation *iface, BSTR *p) { HTMLLocation *This = HTMLLOCATION_THIS(iface); - FIXME("(%p)->(%p)\n", This, p); - return E_NOTIMPL; + WCHAR buf[INTERNET_MAX_PATH_LENGTH]; + URL_COMPONENTSW url = {sizeof(url)}; + DWORD size = 0; + HRESULT hres; + + TRACE("(%p)->(%p)\n", This, p); + + if(!This->doc || !This->doc->url) { + FIXME("No current URL\n"); + return E_NOTIMPL; + } + + hres = CoInternetParseUrl(This->doc->url, PARSE_PATH_FROM_URL, 0, buf, sizeof(buf), &size, 0); + if(SUCCEEDED(hres)) { + *p = SysAllocString(buf); + if(!*p) + return E_OUTOFMEMORY; + return S_OK; + } + + url.dwUrlPathLength = 1; + if(!InternetCrackUrlW(This->doc->url, 0, 0, &url)) { + FIXME("InternetCrackUrl failed\n"); + return E_FAIL; + } + + if(!url.dwUrlPathLength) { + *p = NULL; + return S_OK; + } + + *p = SysAllocStringLen(url.lpszUrlPath, url.dwUrlPathLength); + if(!*p) + return E_OUTOFMEMORY; + return S_OK; }
static HRESULT WINAPI HTMLLocation_put_search(IHTMLLocation *iface, BSTR v) diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c index 4846848..87581f1 100644 --- a/dlls/mshtml/tests/dom.c +++ b/dlls/mshtml/tests/dom.c @@ -2383,6 +2383,7 @@ static void test_location(IHTMLDocument2 *doc) { IHTMLLocation *location, *location2; IHTMLWindow2 *window; + BSTR str; ULONG ref; HRESULT hres;
@@ -2406,6 +2407,10 @@ static void test_location(IHTMLDocument2 *doc) test_ifaces((IUnknown*)location, location_iids); test_disp2((IUnknown*)location, &DIID_DispHTMLLocation, &IID_IHTMLLocation);
+ hres = IHTMLLocation_get_pathname(location, &str); + ok(hres == S_OK, "get_pathname failed: %08x\n", hres); + ok(!strcmp_wa(str, "blank"), "unexpected pathname %s\n", dbgstr_w(str)); + ref = IHTMLLocation_Release(location); ok(!ref, "location chould be destroyed here\n"); }