mshtml: Use nsIDocShell to load a page in set_moniker.

This commit is contained in:
Jacek Caban 2010-01-04 00:38:57 +01:00 committed by Alexandre Julliard
parent d60ebb308f
commit 2e6353d4bc
6 changed files with 92 additions and 80 deletions

View File

@ -52,7 +52,6 @@
typedef struct HTMLDOMNode HTMLDOMNode;
typedef struct ConnectionPoint ConnectionPoint;
typedef struct BSCallback BSCallback;
typedef struct nsChannelBSC nsChannelBSC;
typedef struct event_target_t event_target_t;
/* NOTE: make sure to keep in sync with dispex.c */
@ -425,7 +424,6 @@ struct NSContainer {
HWND hwnd;
nsChannelBSC *bscallback; /* hack */
HWND reset_focus; /* hack */
};
@ -687,6 +685,7 @@ HRESULT create_doc_uri(HTMLWindow*,WCHAR*,nsIWineURI**);
HRESULT hlink_frame_navigate(HTMLDocument*,LPCWSTR,nsIInputStream*,DWORD);
HRESULT navigate_url(HTMLWindow*,const WCHAR*,const WCHAR*);
HRESULT set_frame_doc(HTMLFrameBase*,nsIDOMDocument*);
HRESULT load_nsuri(HTMLWindow*,nsIWineURI*,DWORD);
void call_property_onchanged(ConnectionPoint*,DISPID);
HRESULT call_set_active_object(IOleInPlaceUIWindow*,IOleInPlaceActiveObject*);

View File

@ -1253,14 +1253,39 @@ HRESULT hlink_frame_navigate(HTMLDocument *doc, LPCWSTR url,
return hres;
}
HRESULT load_nsuri(HTMLWindow *window, nsIWineURI *uri, DWORD flags)
{
nsIWebNavigation *web_navigation;
nsIDocShell *doc_shell;
nsresult nsres;
nsres = get_nsinterface((nsISupports*)window->nswindow, &IID_nsIWebNavigation, (void**)&web_navigation);
if(NS_FAILED(nsres)) {
ERR("Could not get nsIWebNavigation interface: %08x\n", nsres);
return E_FAIL;
}
nsres = nsIWebNavigation_QueryInterface(web_navigation, &IID_nsIDocShell, (void**)&doc_shell);
nsIWebNavigation_Release(web_navigation);
if(NS_FAILED(nsres)) {
ERR("Could not get nsIDocShell: %08x\n", nsres);
return E_FAIL;
}
nsres = nsIDocShell_LoadURI(doc_shell, (nsIURI*)uri, NULL, flags, FALSE);
nsIDocShell_Release(doc_shell);
if(NS_FAILED(nsres)) {
WARN("LoadURI failed: %08x\n", nsres);
return E_FAIL;
}
return S_OK;
}
HRESULT navigate_url(HTMLWindow *window, const WCHAR *new_url, const WCHAR *base_url)
{
WCHAR url[INTERNET_MAX_URL_LENGTH];
nsIWebNavigation *web_navigation;
nsIDocShell *doc_shell;
nsIWineURI *uri;
nsresult nsres;
HRESULT hres;
if(!new_url) {
@ -1294,31 +1319,11 @@ HRESULT navigate_url(HTMLWindow *window, const WCHAR *new_url, const WCHAR *base
TRACE("hlink_frame_navigate failed: %08x\n", hres);
}
nsres = get_nsinterface((nsISupports*)window->nswindow, &IID_nsIWebNavigation, (void**)&web_navigation);
if(NS_FAILED(nsres)) {
ERR("Could not get nsIWebNavigation interface: %08x\n", nsres);
return E_FAIL;
}
nsres = nsIWebNavigation_QueryInterface(web_navigation, &IID_nsIDocShell, (void**)&doc_shell);
nsIWebNavigation_Release(web_navigation);
if(NS_FAILED(nsres)) {
ERR("Could not get nsIDocShell: %08x\n", nsres);
return E_FAIL;
}
hres = create_doc_uri(window, url, &uri);
if(FAILED(hres)) {
nsIDocShell_Release(doc_shell);
if(FAILED(hres))
return hres;
hres = load_nsuri(window, uri, LOAD_FLAGS_NONE);
nsIWineURI_Release(uri);
return hres;
}
nsres = nsIDocShell_LoadURI(doc_shell, (nsIURI*)uri, NULL, 0, FALSE);
nsIDocShell_Release(doc_shell);
if(NS_FAILED(nsres)) {
WARN("LoadURI failed: %08x\n", nsres);
return E_FAIL;
}
return S_OK;
}

View File

@ -1172,29 +1172,8 @@ static nsresult NSAPI nsURIContentListener_OnStartURIOpen(nsIURIContentListener
nsIWineURI_SetNSContainer(wine_uri, This);
nsIWineURI_SetIsDocumentURI(wine_uri, TRUE);
if(This->bscallback) {
IMoniker *mon = get_channelbsc_mon(This->bscallback);
if(mon) {
LPWSTR wine_url;
HRESULT hres;
hres = IMoniker_GetDisplayName(mon, NULL, 0, &wine_url);
if(SUCCEEDED(hres)) {
nsIWineURI_SetWineURL(wine_uri, wine_url);
CoTaskMemFree(wine_url);
}else {
WARN("GetDisplayName failed: %08x\n", hres);
}
IMoniker_Release(mon);
}
*_retval = FALSE;
}else if(This->doc) {
*_retval = translate_url(This->doc->basedoc.doc_obj, wine_uri);
}
}
nsIWineURI_Release(wine_uri);

View File

@ -1706,7 +1706,8 @@ interface nsIBaseWindow : nsISupports
nsresult SetTitle(const PRUnichar *aTitle);
}
cpp_quote("#define LOAD_FLAGS_NONE 0")
cpp_quote("#define LOAD_FLAGS_NONE 0x00000")
cpp_quote("#define LOAD_INITIAL_DOCUMENT_URI 0x80000")
[
object,
@ -2835,11 +2836,14 @@ interface nsIWineURI : nsIURL
{
typedef struct NSContainer NSContainer;
typedef struct HTMLWindow HTMLWindow;
typedef struct nsChannelBSC nsChannelBSC;
nsresult GetNSContainer(NSContainer **aNSContainer);
nsresult SetNSContainer(NSContainer *aNSContainer);
nsresult GetWindow(HTMLWindow **aHTMLWindow);
nsresult SetWindow(HTMLWindow *aHTMLWindow);
nsresult GetChannelBSC(nsChannelBSC **aChannelBSC);
nsresult SetChannelBSC(nsChannelBSC *aChannelBSC);
nsresult GetIsDocumentURI(PRBool *aIsDocumentURI);
nsresult SetIsDocumentURI(PRBool aIsDocumentURI);
nsresult GetWineURL(LPCWSTR *aURL);

View File

@ -38,8 +38,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
#define LOAD_INITIAL_DOCUMENT_URI 0x80000
#define NS_IOSERVICE_CLASSNAME "nsIOService"
#define NS_IOSERVICE_CONTRACTID "@mozilla.org/network/io-service;1"
@ -60,6 +58,7 @@ typedef struct {
nsIURL *nsurl;
NSContainer *container;
windowref_t *window_ref;
nsChannelBSC *channel_bsc;
LPWSTR wine_url;
PRBool is_doc_uri;
BOOL use_wine_url;
@ -774,15 +773,17 @@ static nsresult NSAPI nsChannel_AsyncOpen(nsIHttpChannel *iface, nsIStreamListen
return NS_ERROR_UNEXPECTED;
}
if(is_doc_uri && (This->load_flags & LOAD_INITIAL_DOCUMENT_URI) && window == window->doc_obj->basedoc.window) {
if(window->doc_obj->nscontainer->bscallback) {
NSContainer *nscontainer = window->doc_obj->nscontainer;
if(is_doc_uri && window == window->doc_obj->basedoc.window) {
nsChannelBSC *channel_bsc;
channelbsc_set_channel(nscontainer->bscallback, This, aListener, aContext);
nsIWineURI_GetChannelBSC(This->uri, &channel_bsc);
if(channel_bsc) {
channelbsc_set_channel(channel_bsc, This, aListener, aContext);
IUnknown_Release((IUnknown*)channel_bsc);
if(nscontainer->doc->mime) {
if(window->doc_obj->mime) {
heap_free(This->content_type);
This->content_type = heap_strdupWtoA(nscontainer->doc->mime);
This->content_type = heap_strdupWtoA(window->doc_obj->mime);
}
open = FALSE;
@ -798,7 +799,6 @@ static nsresult NSAPI nsChannel_AsyncOpen(nsIHttpChannel *iface, nsIStreamListen
if(open)
nsres = async_open(This, window, is_doc_uri, aListener, aContext);
if(window)
IHTMLWindow2_Release(HTMLWINDOW2(window));
return nsres;
}
@ -2057,6 +2057,32 @@ static nsresult NSAPI nsURI_SetWindow(nsIWineURI *iface, HTMLWindow *aHTMLWindow
return NS_OK;
}
static nsresult NSAPI nsURI_GetChannelBSC(nsIWineURI *iface, nsChannelBSC **aChannelBSC)
{
nsURI *This = NSURI_THIS(iface);
TRACE("(%p)->(%p)\n", This, aChannelBSC);
if(This->channel_bsc)
IUnknown_AddRef((IUnknown*)This->channel_bsc);
*aChannelBSC = This->channel_bsc;
return NS_OK;
}
static nsresult NSAPI nsURI_SetChannelBSC(nsIWineURI *iface, nsChannelBSC *aChannelBSC)
{
nsURI *This = NSURI_THIS(iface);
TRACE("(%p)->(%p)\n", This, aChannelBSC);
if(This->channel_bsc)
IUnknown_Release((IUnknown*)This->channel_bsc);
if(aChannelBSC)
IUnknown_AddRef((IUnknown*)aChannelBSC);
This->channel_bsc = aChannelBSC;
return NS_OK;
}
static nsresult NSAPI nsURI_GetIsDocumentURI(nsIWineURI *iface, PRBool *aIsDocumentURI)
{
nsURI *This = NSURI_THIS(iface);
@ -2175,6 +2201,8 @@ static const nsIWineURIVtbl nsWineURIVtbl = {
nsURI_SetNSContainer,
nsURI_GetWindow,
nsURI_SetWindow,
nsURI_GetChannelBSC,
nsURI_SetChannelBSC,
nsURI_GetIsDocumentURI,
nsURI_SetIsDocumentURI,
nsURI_GetWineURL,

View File

@ -172,8 +172,8 @@ static HRESULT set_moniker(HTMLDocument *This, IMoniker *mon, IBindCtx *pibc, BO
LPOLESTR url = NULL;
docobj_task_t *task;
download_proc_task_t *download_task;
nsIWineURI *nsuri;
HRESULT hres;
nsresult nsres;
if(pibc) {
IUnknown *unk = NULL;
@ -254,8 +254,22 @@ static HRESULT set_moniker(HTMLDocument *This, IMoniker *mon, IBindCtx *pibc, BO
}
}
hres = create_doc_uri(This->window, url, &nsuri);
CoTaskMemFree(url);
if(FAILED(hres))
return hres;
bscallback = create_channelbsc(mon);
nsIWineURI_SetChannelBSC(nsuri, bscallback);
hres = load_nsuri(This->window, nsuri, LOAD_INITIAL_DOCUMENT_URI);
nsIWineURI_SetChannelBSC(nsuri, NULL);
if(SUCCEEDED(hres))
set_window_bscallback(This->window, bscallback);
IUnknown_Release((IUnknown*)bscallback);
if(FAILED(hres))
return hres;
if(This->doc_obj->frame) {
task = heap_alloc(sizeof(docobj_task_t));
task->doc = This->doc_obj;
@ -267,23 +281,6 @@ static HRESULT set_moniker(HTMLDocument *This, IMoniker *mon, IBindCtx *pibc, BO
download_task->set_download = set_download;
push_task(&download_task->header, set_downloading_proc, This->doc_obj->basedoc.task_magic);
if(This->doc_obj->nscontainer) {
This->doc_obj->nscontainer->bscallback = bscallback;
nsres = nsIWebNavigation_LoadURI(This->doc_obj->nscontainer->navigation, url,
LOAD_FLAGS_NONE, NULL, NULL, NULL);
This->doc_obj->nscontainer->bscallback = NULL;
if(NS_FAILED(nsres)) {
WARN("LoadURI failed: %08x\n", nsres);
IUnknown_Release((IUnknown*)bscallback);
CoTaskMemFree(url);
return E_FAIL;
}
}
set_window_bscallback(This->window, bscallback);
IUnknown_Release((IUnknown*)bscallback);
CoTaskMemFree(url);
return S_OK;
}