mshtml: Use helper to get IUri in HTMLLocation implementation.

This commit is contained in:
Jacek Caban 2012-08-14 11:29:02 +02:00 committed by Alexandre Julliard
parent 3918213586
commit 28f35f86c6
1 changed files with 22 additions and 10 deletions

View File

@ -46,6 +46,13 @@ static HRESULT get_url(HTMLLocation *This, const WCHAR **ret)
return S_OK; return S_OK;
} }
static IUri *get_uri(HTMLLocation *This)
{
if(!This->window)
return NULL;
return This->window->uri;
}
static HRESULT get_url_components(HTMLLocation *This, URL_COMPONENTSW *url) static HRESULT get_url_components(HTMLLocation *This, URL_COMPONENTSW *url)
{ {
const WCHAR *doc_url; const WCHAR *doc_url;
@ -278,6 +285,7 @@ static HRESULT WINAPI HTMLLocation_get_protocol(IHTMLLocation *iface, BSTR *p)
HTMLLocation *This = impl_from_IHTMLLocation(iface); HTMLLocation *This = impl_from_IHTMLLocation(iface);
BSTR protocol, ret; BSTR protocol, ret;
unsigned len; unsigned len;
IUri *uri;
HRESULT hres; HRESULT hres;
TRACE("(%p)->(%p)\n", This, p); TRACE("(%p)->(%p)\n", This, p);
@ -285,12 +293,12 @@ static HRESULT WINAPI HTMLLocation_get_protocol(IHTMLLocation *iface, BSTR *p)
if(!p) if(!p)
return E_POINTER; return E_POINTER;
if(!This->window || !This->window->uri) { if(!(uri = get_uri(This))) {
FIXME("No current URI\n"); FIXME("No current URI\n");
return E_NOTIMPL; return E_NOTIMPL;
} }
hres = IUri_GetSchemeName(This->window->uri, &protocol); hres = IUri_GetSchemeName(uri, &protocol);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
if(hres == S_FALSE) { if(hres == S_FALSE) {
@ -367,6 +375,7 @@ static HRESULT WINAPI HTMLLocation_get_hostname(IHTMLLocation *iface, BSTR *p)
{ {
HTMLLocation *This = impl_from_IHTMLLocation(iface); HTMLLocation *This = impl_from_IHTMLLocation(iface);
BSTR hostname; BSTR hostname;
IUri *uri;
HRESULT hres; HRESULT hres;
TRACE("(%p)->(%p)\n", This, p); TRACE("(%p)->(%p)\n", This, p);
@ -374,12 +383,12 @@ static HRESULT WINAPI HTMLLocation_get_hostname(IHTMLLocation *iface, BSTR *p)
if(!p) if(!p)
return E_POINTER; return E_POINTER;
if(!This->window || !This->window->uri) { if(!(uri = get_uri(This))) {
FIXME("No current URI\n"); FIXME("No current URI\n");
return E_NOTIMPL; return E_NOTIMPL;
} }
hres = IUri_GetHost(This->window->uri, &hostname); hres = IUri_GetHost(uri, &hostname);
if(hres == S_OK) { if(hres == S_OK) {
*p = hostname; *p = hostname;
}else if(hres == S_FALSE) { }else if(hres == S_FALSE) {
@ -403,6 +412,7 @@ static HRESULT WINAPI HTMLLocation_get_port(IHTMLLocation *iface, BSTR *p)
{ {
HTMLLocation *This = impl_from_IHTMLLocation(iface); HTMLLocation *This = impl_from_IHTMLLocation(iface);
DWORD port; DWORD port;
IUri *uri;
HRESULT hres; HRESULT hres;
TRACE("(%p)->(%p)\n", This, p); TRACE("(%p)->(%p)\n", This, p);
@ -410,12 +420,12 @@ static HRESULT WINAPI HTMLLocation_get_port(IHTMLLocation *iface, BSTR *p)
if(!p) if(!p)
return E_POINTER; return E_POINTER;
if(!This->window || !This->window->uri) { if(!(uri = get_uri(This))) {
FIXME("No current URI\n"); FIXME("No current URI\n");
return E_NOTIMPL; return E_NOTIMPL;
} }
hres = IUri_GetPort(This->window->uri, &port); hres = IUri_GetPort(uri, &port);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -479,6 +489,7 @@ static HRESULT WINAPI HTMLLocation_get_search(IHTMLLocation *iface, BSTR *p)
{ {
HTMLLocation *This = impl_from_IHTMLLocation(iface); HTMLLocation *This = impl_from_IHTMLLocation(iface);
BSTR query; BSTR query;
IUri *uri;
HRESULT hres; HRESULT hres;
TRACE("(%p)->(%p)\n", This, p); TRACE("(%p)->(%p)\n", This, p);
@ -486,12 +497,12 @@ static HRESULT WINAPI HTMLLocation_get_search(IHTMLLocation *iface, BSTR *p)
if(!p) if(!p)
return E_POINTER; return E_POINTER;
if(!This->window || !This->window->uri) { if(!(uri = get_uri(This))) {
FIXME("No current URI\n"); FIXME("No current URI\n");
return E_NOTIMPL; return E_NOTIMPL;
} }
hres = IUri_GetQuery(This->window->uri, &query); hres = IUri_GetQuery(uri, &query);
if(hres == S_OK) { if(hres == S_OK) {
*p = query; *p = query;
}else if(hres == S_FALSE) { }else if(hres == S_FALSE) {
@ -515,6 +526,7 @@ static HRESULT WINAPI HTMLLocation_get_hash(IHTMLLocation *iface, BSTR *p)
{ {
HTMLLocation *This = impl_from_IHTMLLocation(iface); HTMLLocation *This = impl_from_IHTMLLocation(iface);
BSTR hash; BSTR hash;
IUri *uri;
HRESULT hres; HRESULT hres;
TRACE("(%p)->(%p)\n", This, p); TRACE("(%p)->(%p)\n", This, p);
@ -522,12 +534,12 @@ static HRESULT WINAPI HTMLLocation_get_hash(IHTMLLocation *iface, BSTR *p)
if(!p) if(!p)
return E_POINTER; return E_POINTER;
if(!This->window || !This->window->uri) { if(!(uri = get_uri(This))) {
FIXME("No current URI\n"); FIXME("No current URI\n");
return E_NOTIMPL; return E_NOTIMPL;
} }
hres = IUri_GetFragment(This->window->uri, &hash); hres = IUri_GetFragment(uri, &hash);
if(hres == S_OK) { if(hres == S_OK) {
*p = hash; *p = hash;
}else if(hres == S_FALSE) { }else if(hres == S_FALSE) {