Jacek Caban : mshtml: Use helper to get IUri in HTMLLocation implementation .

Alexandre Julliard julliard at winehq.org
Tue Aug 14 12:59:52 CDT 2012


Module: wine
Branch: master
Commit: 28f35f86c64fdc1f973cbc968ad43057df920903
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=28f35f86c64fdc1f973cbc968ad43057df920903

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Tue Aug 14 11:29:02 2012 +0200

mshtml: Use helper to get IUri in HTMLLocation implementation.

---

 dlls/mshtml/htmllocation.c |   32 ++++++++++++++++++++++----------
 1 files changed, 22 insertions(+), 10 deletions(-)

diff --git a/dlls/mshtml/htmllocation.c b/dlls/mshtml/htmllocation.c
index 7a01039..1bcd048 100644
--- a/dlls/mshtml/htmllocation.c
+++ b/dlls/mshtml/htmllocation.c
@@ -46,6 +46,13 @@ static HRESULT get_url(HTMLLocation *This, const WCHAR **ret)
     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)
 {
     const WCHAR *doc_url;
@@ -278,6 +285,7 @@ static HRESULT WINAPI HTMLLocation_get_protocol(IHTMLLocation *iface, BSTR *p)
     HTMLLocation *This = impl_from_IHTMLLocation(iface);
     BSTR protocol, ret;
     unsigned len;
+    IUri *uri;
     HRESULT hres;
 
     TRACE("(%p)->(%p)\n", This, p);
@@ -285,12 +293,12 @@ static HRESULT WINAPI HTMLLocation_get_protocol(IHTMLLocation *iface, BSTR *p)
     if(!p)
         return E_POINTER;
 
-    if(!This->window || !This->window->uri) {
+    if(!(uri = get_uri(This))) {
         FIXME("No current URI\n");
         return E_NOTIMPL;
     }
 
-    hres = IUri_GetSchemeName(This->window->uri, &protocol);
+    hres = IUri_GetSchemeName(uri, &protocol);
     if(FAILED(hres))
         return hres;
     if(hres == S_FALSE) {
@@ -367,6 +375,7 @@ static HRESULT WINAPI HTMLLocation_get_hostname(IHTMLLocation *iface, BSTR *p)
 {
     HTMLLocation *This = impl_from_IHTMLLocation(iface);
     BSTR hostname;
+    IUri *uri;
     HRESULT hres;
 
     TRACE("(%p)->(%p)\n", This, p);
@@ -374,12 +383,12 @@ static HRESULT WINAPI HTMLLocation_get_hostname(IHTMLLocation *iface, BSTR *p)
     if(!p)
         return E_POINTER;
 
-    if(!This->window || !This->window->uri) {
+    if(!(uri = get_uri(This))) {
         FIXME("No current URI\n");
         return E_NOTIMPL;
     }
 
-    hres = IUri_GetHost(This->window->uri, &hostname);
+    hres = IUri_GetHost(uri, &hostname);
     if(hres == S_OK) {
         *p = hostname;
     }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);
     DWORD port;
+    IUri *uri;
     HRESULT hres;
 
     TRACE("(%p)->(%p)\n", This, p);
@@ -410,12 +420,12 @@ static HRESULT WINAPI HTMLLocation_get_port(IHTMLLocation *iface, BSTR *p)
     if(!p)
         return E_POINTER;
 
-    if(!This->window || !This->window->uri) {
+    if(!(uri = get_uri(This))) {
         FIXME("No current URI\n");
         return E_NOTIMPL;
     }
 
-    hres = IUri_GetPort(This->window->uri, &port);
+    hres = IUri_GetPort(uri, &port);
     if(FAILED(hres))
         return hres;
 
@@ -479,6 +489,7 @@ static HRESULT WINAPI HTMLLocation_get_search(IHTMLLocation *iface, BSTR *p)
 {
     HTMLLocation *This = impl_from_IHTMLLocation(iface);
     BSTR query;
+    IUri *uri;
     HRESULT hres;
 
     TRACE("(%p)->(%p)\n", This, p);
@@ -486,12 +497,12 @@ static HRESULT WINAPI HTMLLocation_get_search(IHTMLLocation *iface, BSTR *p)
     if(!p)
         return E_POINTER;
 
-    if(!This->window || !This->window->uri) {
+    if(!(uri = get_uri(This))) {
         FIXME("No current URI\n");
         return E_NOTIMPL;
     }
 
-    hres = IUri_GetQuery(This->window->uri, &query);
+    hres = IUri_GetQuery(uri, &query);
     if(hres == S_OK) {
         *p = query;
     }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);
     BSTR hash;
+    IUri *uri;
     HRESULT hres;
 
     TRACE("(%p)->(%p)\n", This, p);
@@ -522,12 +534,12 @@ static HRESULT WINAPI HTMLLocation_get_hash(IHTMLLocation *iface, BSTR *p)
     if(!p)
         return E_POINTER;
 
-    if(!This->window || !This->window->uri) {
+    if(!(uri = get_uri(This))) {
         FIXME("No current URI\n");
         return E_NOTIMPL;
     }
 
-    hres = IUri_GetFragment(This->window->uri, &hash);
+    hres = IUri_GetFragment(uri, &hash);
     if(hres == S_OK) {
         *p = hash;
     }else if(hres == S_FALSE) {




More information about the wine-cvs mailing list