Commit 990e20c9 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

mshtml: Get rid of HTMLDocument_OnLoad and move its job to AsyncOpen.

parent ae23f8d8
......@@ -32,6 +32,7 @@
#define NS_NOINTERFACE ((nsresult)0x80004002L)
#define NS_ERROR_NOT_IMPLEMENTED ((nsresult)0x80004001L)
#define NS_ERROR_INVALID_ARG ((nsresult)0x80070057L)
#define NS_ERROR_UNEXPECTED ((nsresult)0x8000ffffL)
#define NS_FAILED(res) ((res) & 0x80000000)
#define NS_SUCCEEDED(res) (!NS_FAILED(res))
......@@ -93,7 +94,7 @@ struct NSContainer {
HWND hwnd;
LPOLESTR url; /* hack */
BOOL load_call; /* hack */
};
#define HTMLDOC(x) ((IHTMLDocument2*) &(x)->lpHTMLDocument2Vtbl)
......@@ -139,7 +140,6 @@ void HTMLDocument_NSContainer_Destroy(HTMLDocument*);
void HTMLDocument_LockContainer(HTMLDocument*,BOOL);
void HTMLDocument_ShowContextMenu(HTMLDocument*,DWORD,POINT*);
BOOL HTMLDocument_OnLoad(HTMLDocument*,LPCWSTR);
HRESULT ProtocolFactory_Create(REFCLSID,REFIID,void**);
......
......@@ -663,41 +663,28 @@ static nsrefcnt NSAPI nsURIContentListener_Release(nsIURIContentListener *iface)
return nsIWebBrowserChrome_Release(NSWBCHROME(This));
}
static nsresult NSAPI nsURIContentListener_OnStartURIOpen(nsIURIContentListener *iface, nsIURI *aURI,
PRBool *_retval)
static nsresult NSAPI nsURIContentListener_OnStartURIOpen(nsIURIContentListener *iface,
nsIURI *aURI, PRBool *_retval)
{
NSContainer *This = NSURICL_THIS(iface);
BOOL do_load = TRUE;
nsresult nsres;
nsIWineURI *wine_uri;
nsACString *spec_str = nsACString_Create();
const char *spec;
nsresult nsres;
TRACE("(%p)->(%p %p)\n", This, aURI, _retval);
nsres = nsIURI_GetSpec(aURI, spec_str);
if(NS_SUCCEEDED(nsres)) {
const char *spec = NULL;
LPWSTR specw;
int len;
nsACString_GetData(spec_str, &spec, NULL);
len = MultiByteToWideChar(CP_ACP, 0, spec, -1, NULL, 0);
specw = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
MultiByteToWideChar(CP_ACP, 0, spec, -1, specw, -1);
if(strcmpW(This->url, specw)) /* hack */
do_load = HTMLDocument_OnLoad(This->doc, specw);
nsIURI_GetSpec(aURI, spec_str);
nsACString_GetData(spec_str, &spec, NULL);
HeapFree(GetProcessHeap(), 0, specw);
}else {
ERR("GetSpec failed: %08lx\n", nsres);
}
TRACE("(%p)->(%p(%s) %p)\n", This, aURI, debugstr_a(spec), _retval);
nsACString_Destroy(spec_str);
if(!do_load) {
*_retval = TRUE;
return NS_OK;
nsres = nsIURI_QueryInterface(aURI, &IID_nsIWineURI, (void**)&wine_uri);
if(NS_SUCCEEDED(nsres)) {
nsIWineURI_SetNSContainer(wine_uri, This);
nsIWineURI_Release(wine_uri);
}else {
WARN("Could not get nsIWineURI interface: %08lx\n", nsres);
}
return NS_ERROR_NOT_IMPLEMENTED;
......@@ -977,7 +964,7 @@ void HTMLDocument_NSContainer_Init(HTMLDocument *This)
if(NS_FAILED(nsres))
ERR("SetParentURIContentListener failed: %08lx\n", nsres);
This->nscontainer->url = NULL;
This->nscontainer->load_call = FALSE;
}
void HTMLDocument_NSContainer_Destroy(HTMLDocument *This)
......@@ -992,7 +979,4 @@ void HTMLDocument_NSContainer_Destroy(HTMLDocument *This)
nsIWebBrowserStream_Release(This->nscontainer->stream);
HeapFree(GetProcessHeap(), 0, This->nscontainer);
if(This->nscontainer->url)
CoTaskMemFree(This->nscontainer->url);
}
......@@ -26,6 +26,7 @@
#include "winbase.h"
#include "winuser.h"
#include "ole2.h"
#include "shlguid.h"
#include "wine/debug.h"
#include "wine/unicode.h"
......@@ -34,6 +35,8 @@
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"
......@@ -65,6 +68,76 @@ typedef struct {
#define NSHTTPCHANNEL(x) ((nsIHttpChannel*) &(x)->lpHttpChannelVtbl)
#define NSURI(x) ((nsIURI*) &(x)->lpWineURIVtbl)
static BOOL exec_shldocvw_67(NSContainer *container, LPCWSTR url)
{
IOleCommandTarget *cmdtrg = NULL;
HRESULT hres;
hres = IOleClientSite_QueryInterface(container->doc->client, &IID_IOleCommandTarget,
(void**)&cmdtrg);
if(SUCCEEDED(hres)) {
VARIANT varUrl, varRes;
V_VT(&varUrl) = VT_BSTR;
V_BSTR(&varUrl) = SysAllocString(url);
V_VT(&varRes) = VT_BOOL;
hres = IOleCommandTarget_Exec(cmdtrg, &CGID_ShellDocView, 67, 0, &varUrl, &varRes);
IOleCommandTarget_Release(cmdtrg);
SysFreeString(V_BSTR(&varUrl));
if(SUCCEEDED(hres) && !V_BOOL(&varRes)) {
TRACE("got VARIANT_FALSE, do not load\n");
return FALSE;
}
}
return TRUE;
}
static BOOL before_async_open(nsChannel *This)
{
nsACString *uri_str;
NSContainer *container;
PRUint32 load_flags = 0;
const char *uria;
LPWSTR uri;
DWORD len;
BOOL ret = TRUE;
nsIChannel_GetLoadFlags(This->channel, &load_flags);
TRACE("load_flags = %08lx\n", load_flags);
if(!(load_flags & LOAD_INITIAL_DOCUMENT_URI))
return TRUE;
nsIWineURI_GetNSContainer(This->uri, &container);
if(!container) {
WARN("container = NULL\n");
return TRUE;
}
if(container->load_call) {
nsIWebBrowserChrome_Release(NSWBCHROME(container));
return TRUE;
}
uri_str = nsACString_Create();
nsIWineURI_GetSpec(This->uri, uri_str);
nsACString_GetData(uri_str, &uria, NULL);
len = MultiByteToWideChar(CP_ACP, 0, uria, -1, NULL, 0);
uri = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
MultiByteToWideChar(CP_ACP, 0, uria, -1, uri, len);
nsACString_Destroy(uri_str);
ret = exec_shldocvw_67(container, uri);
nsIWebBrowserChrome_Release(NSWBCHROME(container));
HeapFree(GetProcessHeap(), 0, uri);
return ret;
}
#define NSCHANNEL_THIS(iface) DEFINE_THIS(nsChannel, HttpChannel, iface)
static nsresult NSAPI nsChannel_QueryInterface(nsIHttpChannel *iface, nsIIDRef riid, nsQIResult result)
......@@ -311,7 +384,14 @@ static nsresult NSAPI nsChannel_AsyncOpen(nsIHttpChannel *iface, nsIStreamListen
nsISupports *aContext)
{
nsChannel *This = NSCHANNEL_THIS(iface);
TRACE("(%p)->(%p %p)\n", This, aListener, aContext);
if(!before_async_open(This)) {
TRACE("canceled\n");
return NS_ERROR_UNEXPECTED;
}
return nsIChannel_AsyncOpen(This->channel, aListener, aContext);
}
......
......@@ -362,18 +362,15 @@ static HRESULT WINAPI PersistMoniker_Load(IPersistMoniker *iface, BOOL fFullyAva
* It uses Gecko's LoadURI instead of IMoniker's BindToStorage. Should we improve
* it (to do so we'd have to use not frozen interfaces)?
*/
LPOLESTR old_url = This->nscontainer->url;
This->nscontainer->url = url;
This->nscontainer->load_call = TRUE;
nsres = nsIWebNavigation_LoadURI(This->nscontainer->navigation, url,
LOAD_FLAGS_NONE, NULL, NULL, NULL);
if(NS_SUCCEEDED(nsres)) {
CoTaskMemFree(old_url);
This->nscontainer->load_call = FALSE;
if(NS_SUCCEEDED(nsres))
return S_OK;
}else {
else
WARN("LoadURI failed: %08lx\n", nsres);
This->nscontainer->url = old_url;
}
}
/* FIXME: Use grfMode */
......@@ -563,34 +560,6 @@ static const IPersistFileVtbl PersistFileVtbl = {
PersistFile_GetCurFile
};
BOOL HTMLDocument_OnLoad(HTMLDocument *This, LPCWSTR url)
{
IOleCommandTarget *cmdtrg = NULL;
HRESULT hres;
TRACE("(%p)->(%s)\n", This, debugstr_w(url));
hres = IOleClientSite_QueryInterface(This->client, &IID_IOleCommandTarget, (void**)&cmdtrg);
if(SUCCEEDED(hres)) {
VARIANT varUrl, varRes;
V_VT(&varUrl) = VT_BSTR;
V_BSTR(&varUrl) = SysAllocString(url);
V_VT(&varRes) = VT_BOOL;
hres = IOleCommandTarget_Exec(cmdtrg, &CGID_ShellDocView, 67, 0, &varUrl, &varRes);
SysFreeString(V_BSTR(&varUrl));
if(SUCCEEDED(hres) && !V_BOOL(&varRes)) {
TRACE("got VARIANT_FALSE, do not load\n");
IOleCommandTarget_Release(cmdtrg);
return FALSE;
}
}
return TRUE;
}
void HTMLDocument_Persist_Init(HTMLDocument *This)
{
This->lpPersistMonikerVtbl = &PersistMonikerVtbl;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment