Module: wine Branch: master Commit: 74f28d4a20947dfbbda21993e94c242e3f1a920f URL: http://source.winehq.org/git/wine.git/?a=commit;h=74f28d4a20947dfbbda21993e9...
Author: Jacek Caban jacek@codeweavers.com Date: Wed Sep 16 22:05:50 2009 +0200
mshtml: Moved HTMLLocation object to HTMLWindow.
---
dlls/mshtml/htmldoc.c | 11 +------- dlls/mshtml/htmllocation.c | 61 ++++++++++++++++++++++++++--------------- dlls/mshtml/htmlwindow.c | 19 ++++++++++--- dlls/mshtml/mshtml_private.h | 23 +++++++-------- 4 files changed, 66 insertions(+), 48 deletions(-)
diff --git a/dlls/mshtml/htmldoc.c b/dlls/mshtml/htmldoc.c index 1c35b4b..e34e9dd 100644 --- a/dlls/mshtml/htmldoc.c +++ b/dlls/mshtml/htmldoc.c @@ -196,9 +196,6 @@ static ULONG WINAPI HTMLDocument_Release(IHTMLDocument2 *iface) if(This->hwnd) DestroyWindow(This->hwnd);
- if(This->location) - This->location->doc = NULL; - if(This->window) IHTMLWindow2_Release(HTMLWINDOW2(This->window));
@@ -733,13 +730,7 @@ static HRESULT WINAPI HTMLDocument_get_location(IHTMLDocument2 *iface, IHTMLLoca
TRACE("(%p)->(%p)\n", This, p);
- if(This->location) - IHTMLLocation_AddRef(HTMLLOCATION(This->location)); - else - This->location = HTMLLocation_Create(This); - - *p = HTMLLOCATION(This->location); - return S_OK; + return IHTMLWindow2_get_location(HTMLWINDOW2(This->window), p); }
static HRESULT WINAPI HTMLDocument_get_lastModified(IHTMLDocument2 *iface, BSTR *p) diff --git a/dlls/mshtml/htmllocation.c b/dlls/mshtml/htmllocation.c index 8637838..6a3e194 100644 --- a/dlls/mshtml/htmllocation.c +++ b/dlls/mshtml/htmllocation.c @@ -35,6 +35,18 @@
WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
+static HRESULT get_url(HTMLLocation *This, const WCHAR **ret) +{ + if(!This->window || !This->window->doc || !This->window->doc->url) { + FIXME("No current URL\n"); + return E_NOTIMPL; + } + + *ret = This->window->doc->url; + return S_OK; +} + + #define HTMLLOCATION_THIS(iface) DEFINE_THIS(HTMLLocation, HTMLLocation, iface)
static HRESULT WINAPI HTMLLocation_QueryInterface(IHTMLLocation *iface, REFIID riid, void **ppv) @@ -80,8 +92,8 @@ static ULONG WINAPI HTMLLocation_Release(IHTMLLocation *iface) TRACE("(%p) ref=%d\n", This, ref);
if(!ref) { - if(This->doc && This->doc->location == This) - This->doc->location = NULL; + if(This->window) + This->window->location = NULL; release_dispex(&This->dispex); heap_free(This); } @@ -129,20 +141,20 @@ static HRESULT WINAPI HTMLLocation_put_href(IHTMLLocation *iface, BSTR v) static HRESULT WINAPI HTMLLocation_get_href(IHTMLLocation *iface, BSTR *p) { HTMLLocation *This = HTMLLOCATION_THIS(iface); + const WCHAR *url; + HRESULT hres;
TRACE("(%p)->(%p)\n", This, p);
if(!p) return E_POINTER;
- if(!This->doc || !This->doc->url) { - FIXME("No current URL\n"); - return E_NOTIMPL; - } - - *p = SysAllocString(This->doc->url); + hres = get_url(This, &url); + if(FAILED(hres)) + return hres;
- return S_OK; + *p = SysAllocString(url); + return *p ? S_OK : E_OUTOFMEMORY; }
static HRESULT WINAPI HTMLLocation_put_protocol(IHTMLLocation *iface, BSTR v) @@ -213,17 +225,17 @@ static HRESULT WINAPI HTMLLocation_get_pathname(IHTMLLocation *iface, BSTR *p) HTMLLocation *This = HTMLLOCATION_THIS(iface); WCHAR buf[INTERNET_MAX_PATH_LENGTH]; URL_COMPONENTSW url = {sizeof(url)}; + const WCHAR *doc_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 = get_url(This, &doc_url); + if(FAILED(hres)) + return hres;
- hres = CoInternetParseUrl(This->doc->url, PARSE_PATH_FROM_URL, 0, buf, sizeof(buf), &size, 0); + hres = CoInternetParseUrl(doc_url, PARSE_PATH_FROM_URL, 0, buf, sizeof(buf), &size, 0); if(SUCCEEDED(hres)) { *p = SysAllocString(buf); if(!*p) @@ -232,7 +244,7 @@ static HRESULT WINAPI HTMLLocation_get_pathname(IHTMLLocation *iface, BSTR *p) }
url.dwUrlPathLength = 1; - if(!InternetCrackUrlW(This->doc->url, 0, 0, &url)) { + if(!InternetCrackUrlW(doc_url, 0, 0, &url)) { FIXME("InternetCrackUrl failed\n"); return E_FAIL; } @@ -382,15 +394,20 @@ static dispex_static_data_t HTMLLocation_dispex = { };
-HTMLLocation *HTMLLocation_Create(HTMLDocument *doc) +HRESULT HTMLLocation_Create(HTMLWindow *window, HTMLLocation **ret) { - HTMLLocation *ret = heap_alloc(sizeof(*ret)); + HTMLLocation *location;
- ret->lpHTMLLocationVtbl = &HTMLLocationVtbl; - ret->ref = 1; - ret->doc = doc; + location = heap_alloc(sizeof(*location)); + if(!location) + return E_OUTOFMEMORY;
- init_dispex(&ret->dispex, (IUnknown*)HTMLLOCATION(ret), &HTMLLocation_dispex); + location->lpHTMLLocationVtbl = &HTMLLocationVtbl; + location->ref = 1; + location->window = window;
- return ret; + init_dispex(&location->dispex, (IUnknown*)HTMLLOCATION(location), &HTMLLocation_dispex); + + *ret = location; + return S_OK; } diff --git a/dlls/mshtml/htmlwindow.c b/dlls/mshtml/htmlwindow.c index 60a46a1..c08929b 100644 --- a/dlls/mshtml/htmlwindow.c +++ b/dlls/mshtml/htmlwindow.c @@ -100,6 +100,11 @@ static ULONG WINAPI HTMLWindow2_Release(IHTMLWindow2 *iface) IHTMLOptionElementFactory_Release(HTMLOPTFACTORY(This->option_factory)); }
+ if(This->location) { + This->location->window = NULL; + IHTMLLocation_Release(HTMLLOCATION(This->location)); + } + if(This->event_target) release_event_target(This->event_target); for(i=0; i < This->global_prop_cnt; i++) @@ -364,12 +369,18 @@ static HRESULT WINAPI HTMLWindow2_get_location(IHTMLWindow2 *iface, IHTMLLocatio
TRACE("(%p)->(%p)\n", This, p);
- if(!This->doc) { - FIXME("This->doc is NULL\n"); - return E_FAIL; + if(This->location) { + IHTMLLocation_AddRef(HTMLLOCATION(This->location)); + }else { + HRESULT hres; + + hres = HTMLLocation_Create(This, &This->location); + if(FAILED(hres)) + return hres; }
- return IHTMLDocument2_get_location(HTMLDOC(This->doc), p); + *p = HTMLLOCATION(This->location); + return S_OK; }
static HRESULT WINAPI HTMLWindow2_get_history(IHTMLWindow2 *iface, IOmHistory **p) diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h index f5cb291..9508847 100644 --- a/dlls/mshtml/mshtml_private.h +++ b/dlls/mshtml/mshtml_private.h @@ -176,6 +176,15 @@ typedef struct { HTMLWindow *window; } HTMLOptionElementFactory;
+struct HTMLLocation { + DispatchEx dispex; + const IHTMLLocationVtbl *lpHTMLLocationVtbl; + + LONG ref; + + HTMLWindow *window; +}; + struct HTMLWindow { DispatchEx dispex; const IHTMLWindow2Vtbl *lpHTMLWindow2Vtbl; @@ -194,6 +203,7 @@ struct HTMLWindow { struct list script_hosts;
HTMLOptionElementFactory *option_factory; + HTMLLocation *location;
global_prop_t *global_props; DWORD global_prop_cnt; @@ -232,15 +242,6 @@ struct ConnectionPoint { ConnectionPoint *next; };
-struct HTMLLocation { - DispatchEx dispex; - const IHTMLLocationVtbl *lpHTMLLocationVtbl; - - LONG ref; - - HTMLDocument *doc; -}; - struct HTMLDocument { DispatchEx dispex; const IHTMLDocument2Vtbl *lpHTMLDocument2Vtbl; @@ -307,8 +308,6 @@ struct HTMLDocument { ConnectionPoint cp_htmldocevents2; ConnectionPoint cp_propnotif;
- HTMLLocation *location; - struct list selection_list; struct list range_list;
@@ -514,7 +513,7 @@ HRESULT create_doc_from_nsdoc(nsIDOMHTMLDocument*,HTMLDocument**); HRESULT HTMLWindow_Create(HTMLDocument*,nsIDOMWindow*,HTMLWindow**); HTMLWindow *nswindow_to_window(const nsIDOMWindow*); HTMLOptionElementFactory *HTMLOptionElementFactory_Create(HTMLWindow*); -HTMLLocation *HTMLLocation_Create(HTMLDocument*); +HRESULT HTMLLocation_Create(HTMLWindow*,HTMLLocation**); IOmNavigator *OmNavigator_Create(void);
void HTMLDocument_HTMLDocument3_Init(HTMLDocument*);