Beginning implementation of onload routine.
This commit is contained in:
parent
2e401c675b
commit
c75127c5b9
|
@ -79,6 +79,7 @@ typedef struct {
|
|||
struct NSContainer {
|
||||
const nsIWebBrowserChromeVtbl *lpWebBrowserChromeVtbl;
|
||||
const nsIContextMenuListenerVtbl *lpContextMenuListenerVtbl;
|
||||
const nsIURIContentListenerVtbl *lpURIContentListenerVtbl;
|
||||
|
||||
nsIWebBrowser *webbrowser;
|
||||
nsIWebNavigation *navigation;
|
||||
|
@ -89,6 +90,8 @@ struct NSContainer {
|
|||
HTMLDocument *doc;
|
||||
|
||||
HWND hwnd;
|
||||
|
||||
LPOLESTR url; /* hack */
|
||||
};
|
||||
|
||||
#define HTMLDOC(x) ((IHTMLDocument2*) &(x)->lpHTMLDocument2Vtbl)
|
||||
|
@ -113,6 +116,7 @@ struct NSContainer {
|
|||
|
||||
#define NSWBCHROME(x) ((nsIWebBrowserChrome*) &(x)->lpWebBrowserChromeVtbl)
|
||||
#define NSCML(x) ((nsIContextMenuListener*) &(x)->lpContextMenuListenerVtbl)
|
||||
#define NSURICL(x) ((nsIURIContentListener*) &(x)->lpURIContentListenerVtbl)
|
||||
|
||||
#define DEFINE_THIS(cls,ifc,iface) ((cls*)((BYTE*)(iface)-offsetof(cls,lp ## ifc ## Vtbl)))
|
||||
|
||||
|
@ -130,6 +134,7 @@ 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**);
|
||||
|
||||
|
|
|
@ -35,9 +35,6 @@
|
|||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
|
||||
|
||||
DEFINE_GUID(CLSID_StartupNotifier, 0x1f59b001,0x02c9,0x11d5,0xae,0x76,0xcc,0x92,0xf7,0xdb,0x9e,0x03);
|
||||
DEFINE_GUID(CLSID_nsWebBrowser, 0xf1eac761,0x87e9,0x11d3,0xaf,0x80,0x00,0xa0,0x24,0xff,0xc0,0x8c);
|
||||
|
||||
#define NS_APPSTARTUPNOTIFIER_CONTRACTID "@mozilla.org/embedcomp/appstartup-notifier;1"
|
||||
#define NS_WEBBROWSER_CONTRACTID "@mozilla.org/embedding/browser/nsWebBrowser;1"
|
||||
#define NS_IOSERVICE_CONTRACTID "@mozilla.org/network/io-service;1"
|
||||
|
@ -59,8 +56,9 @@ static nsresult (*NS_CStringContainerInit)(nsACString*);
|
|||
static nsresult (*NS_StringContainerFinish)(nsString*);
|
||||
static nsresult (*NS_CStringContainerFinish)(nsACString*);
|
||||
static nsresult (*NS_StringSetData)(nsString*,const PRUnichar*,PRUint32);
|
||||
static nsresult (*NS_CStringSetData)(nsString*,const char*,PRUint32);
|
||||
static nsresult (*NS_CStringSetData)(nsACString*,const char*,PRUint32);
|
||||
static nsresult (*NS_NewLocalFile)(const nsString*,PRBool,nsIFile**);
|
||||
static PRUint32 (*NS_CStringGetData)(nsACString*,const char**,PRBool*);
|
||||
|
||||
static HINSTANCE hXPCOM = NULL;
|
||||
|
||||
|
@ -225,6 +223,7 @@ static BOOL load_gecko()
|
|||
NS_DLSYM(NS_StringSetData);
|
||||
NS_DLSYM(NS_CStringSetData);
|
||||
NS_DLSYM(NS_NewLocalFile);
|
||||
NS_DLSYM(NS_CStringGetData);
|
||||
|
||||
#undef NS_DLSYM
|
||||
|
||||
|
@ -277,6 +276,11 @@ void nsACString_SetData(nsACString *str, const char *data)
|
|||
NS_CStringSetData(str, data, PR_UINT32_MAX);
|
||||
}
|
||||
|
||||
static PRUint32 nsACString_GetData(nsACString *str, const char **data, PRBool *termited)
|
||||
{
|
||||
return NS_CStringGetData(str, data, termited);
|
||||
}
|
||||
|
||||
void nsACString_Destroy(nsACString *str)
|
||||
{
|
||||
NS_CStringContainerFinish(str);
|
||||
|
@ -329,6 +333,10 @@ nsIURI *get_nsIURI(LPCWSTR url)
|
|||
return ret;
|
||||
}
|
||||
|
||||
/**********************************************************
|
||||
* nsIWebBrowserChrome interface
|
||||
*/
|
||||
|
||||
#define NSWBCHROME_THIS(iface) DEFINE_THIS(NSContainer, WebBrowserChrome, iface)
|
||||
|
||||
static nsresult NSAPI nsWebBrowserChrome_QueryInterface(nsIWebBrowserChrome *iface,
|
||||
|
@ -475,6 +483,10 @@ static const nsIWebBrowserChromeVtbl nsWebBrowserChromeVtbl = {
|
|||
nsWebBrowserChrome_ExitModalEventLoop
|
||||
};
|
||||
|
||||
/**********************************************************
|
||||
* nsIContextMenuListener interface
|
||||
*/
|
||||
|
||||
#define NSCML_THIS(iface) DEFINE_THIS(NSContainer, ContextMenuListener, iface)
|
||||
|
||||
static nsresult NSAPI nsContextMenuListener_QueryInterface(nsIContextMenuListener *iface,
|
||||
|
@ -487,7 +499,7 @@ static nsresult NSAPI nsContextMenuListener_QueryInterface(nsIContextMenuListene
|
|||
static nsrefcnt NSAPI nsContextMenuListener_AddRef(nsIContextMenuListener *iface)
|
||||
{
|
||||
NSContainer *This = NSCML_THIS(iface);
|
||||
return nsIContextMenuListener_AddRef(NSWBCHROME(This));
|
||||
return nsIWebBrowserChrome_AddRef(NSWBCHROME(This));
|
||||
}
|
||||
|
||||
static nsrefcnt NSAPI nsContextMenuListener_Release(nsIContextMenuListener *iface)
|
||||
|
@ -551,6 +563,152 @@ static const nsIContextMenuListenerVtbl nsContextMenuListenerVtbl = {
|
|||
nsContextMenuListener_OnShowContextMenu
|
||||
};
|
||||
|
||||
/**********************************************************
|
||||
* nsIURIContentListener interface
|
||||
*/
|
||||
|
||||
#define NSURICL_THIS(iface) DEFINE_THIS(NSContainer, URIContentListener, iface)
|
||||
|
||||
static nsresult NSAPI nsURIContentListener_QueryInterface(nsIURIContentListener *iface,
|
||||
nsIIDRef riid, nsQIResult result)
|
||||
{
|
||||
NSContainer *This = NSURICL_THIS(iface);
|
||||
return nsIWebBrowserChrome_QueryInterface(NSWBCHROME(This), riid, result);
|
||||
}
|
||||
|
||||
static nsrefcnt NSAPI nsURIContentListener_AddRef(nsIURIContentListener *iface)
|
||||
{
|
||||
NSContainer *This = NSURICL_THIS(iface);
|
||||
return nsIWebBrowserChrome_AddRef(NSWBCHROME(This));
|
||||
}
|
||||
|
||||
static nsrefcnt NSAPI nsURIContentListener_Release(nsIURIContentListener *iface)
|
||||
{
|
||||
NSContainer *This = NSURICL_THIS(iface);
|
||||
return nsIWebBrowserChrome_Release(NSWBCHROME(This));
|
||||
}
|
||||
|
||||
static nsresult NSAPI nsURIContentListener_OnStartURIOpen(nsIURIContentListener *iface, nsIURI *aURI,
|
||||
PRBool *_retval)
|
||||
{
|
||||
NSContainer *This = NSURICL_THIS(iface);
|
||||
BOOL do_load = TRUE;
|
||||
nsresult nsres;
|
||||
|
||||
TRACE("(%p)->(%p %p)\n", This, aURI, _retval);
|
||||
|
||||
nsACString *spec_str = nsACString_Create();
|
||||
|
||||
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);
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, specw);
|
||||
}else {
|
||||
ERR("GetSpec failed: %08lx\n", nsres);
|
||||
}
|
||||
|
||||
nsACString_Destroy(spec_str);
|
||||
|
||||
if(!do_load) {
|
||||
*_retval = TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static nsresult NSAPI nsURIContentListener_DoContent(nsIURIContentListener *iface,
|
||||
const char *aContentType, PRBool aIsContentPreferred, nsIRequest *aRequest,
|
||||
nsIStreamListener **aContentHandler, PRBool *_retval)
|
||||
{
|
||||
NSContainer *This = NSURICL_THIS(iface);
|
||||
TRACE("(%p)->(%s %x %p %p %p)\n", This, debugstr_a(aContentType), aIsContentPreferred,
|
||||
aRequest, aContentHandler, _retval);
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static nsresult NSAPI nsURIContentListener_IsPreferred(nsIURIContentListener *iface,
|
||||
const char *aContentType, char **aDesiredContentType, PRBool *_retval)
|
||||
{
|
||||
NSContainer *This = NSURICL_THIS(iface);
|
||||
|
||||
TRACE("(%p)->(%s %p %p)\n", This, debugstr_a(aContentType), aDesiredContentType, _retval);
|
||||
|
||||
/* FIXME: Should we do something here? */
|
||||
*_retval = TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
static nsresult NSAPI nsURIContentListener_CanHandleContent(nsIURIContentListener *iface,
|
||||
const char *aContentType, PRBool aIsContentPreferred, char **aDesiredContentType,
|
||||
PRBool *_retval)
|
||||
{
|
||||
NSContainer *This = NSURICL_THIS(iface);
|
||||
TRACE("(%p)->(%s %x %p %p)\n", This, debugstr_a(aContentType), aIsContentPreferred,
|
||||
aDesiredContentType, _retval);
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static nsresult NSAPI nsURIContentListener_GetLoadCookie(nsIURIContentListener *iface,
|
||||
nsISupports **aLoadCookie)
|
||||
{
|
||||
NSContainer *This = NSURICL_THIS(iface);
|
||||
WARN("(%p)->(%p)\n", This, aLoadCookie);
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static nsresult NSAPI nsURIContentListener_SetLoadCookie(nsIURIContentListener *iface,
|
||||
nsISupports *aLoadCookie)
|
||||
{
|
||||
NSContainer *This = NSURICL_THIS(iface);
|
||||
WARN("(%p)->(%p)\n", This, aLoadCookie);
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static nsresult NSAPI nsURIContentListener_GetParentContentListener(nsIURIContentListener *iface,
|
||||
nsIURIContentListener **aParentContentListener)
|
||||
{
|
||||
NSContainer *This = NSURICL_THIS(iface);
|
||||
WARN("(%p)->(%p)\n", This, aParentContentListener);
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static nsresult NSAPI nsURIContentListener_SetParentContentListener(nsIURIContentListener *iface,
|
||||
nsIURIContentListener *aParentContentListener)
|
||||
{
|
||||
NSContainer *This = NSURICL_THIS(iface);
|
||||
WARN("(%p)->(%p)\n", This, aParentContentListener);
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
#undef NSURICL_THIS
|
||||
|
||||
static const nsIURIContentListenerVtbl nsURIContentListenerVtbl = {
|
||||
nsURIContentListener_QueryInterface,
|
||||
nsURIContentListener_AddRef,
|
||||
nsURIContentListener_Release,
|
||||
nsURIContentListener_OnStartURIOpen,
|
||||
nsURIContentListener_DoContent,
|
||||
nsURIContentListener_IsPreferred,
|
||||
nsURIContentListener_CanHandleContent,
|
||||
nsURIContentListener_GetLoadCookie,
|
||||
nsURIContentListener_SetLoadCookie,
|
||||
nsURIContentListener_GetParentContentListener,
|
||||
nsURIContentListener_SetParentContentListener
|
||||
};
|
||||
|
||||
void HTMLDocument_NSContainer_Init(HTMLDocument *This)
|
||||
{
|
||||
nsIWebBrowserSetup *wbsetup;
|
||||
|
@ -565,6 +723,7 @@ void HTMLDocument_NSContainer_Init(HTMLDocument *This)
|
|||
|
||||
This->nscontainer->lpWebBrowserChromeVtbl = &nsWebBrowserChromeVtbl;
|
||||
This->nscontainer->lpContextMenuListenerVtbl = &nsContextMenuListenerVtbl;
|
||||
This->nscontainer->lpURIContentListenerVtbl = &nsURIContentListenerVtbl;
|
||||
|
||||
This->nscontainer->doc = This;
|
||||
|
||||
|
@ -632,6 +791,13 @@ void HTMLDocument_NSContainer_Init(HTMLDocument *This)
|
|||
}else {
|
||||
ERR("InitWindow failed: %08lx\n", nsres);
|
||||
}
|
||||
|
||||
nsres = nsIWebBrowser_SetParentURIContentListener(This->nscontainer->webbrowser,
|
||||
NSURICL(This->nscontainer));
|
||||
if(NS_FAILED(nsres))
|
||||
ERR("SetParentURIContentListener failed: %08lx\n", nsres);
|
||||
|
||||
This->nscontainer->url = NULL;
|
||||
}
|
||||
|
||||
void HTMLDocument_NSContainer_Destroy(HTMLDocument *This)
|
||||
|
@ -646,4 +812,7 @@ void HTMLDocument_NSContainer_Destroy(HTMLDocument *This)
|
|||
nsIWebBrowserStream_Release(This->nscontainer->stream);
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, This->nscontainer);
|
||||
|
||||
if(This->nscontainer->url)
|
||||
CoTaskMemFree(This->nscontainer->url);
|
||||
}
|
||||
|
|
|
@ -64,7 +64,6 @@ interface nsISupports
|
|||
|
||||
/* Currently we don't need a full declaration of these interfaces */
|
||||
typedef nsISupports nsIWeakReference;
|
||||
typedef nsISupports nsIURIContentListener;
|
||||
typedef nsISupports nsIDOMWindow;
|
||||
typedef nsISupports nsIInputStream;
|
||||
typedef nsISupports nsIDOMDocument;
|
||||
|
@ -77,6 +76,8 @@ typedef nsISupports nsIDOMElement;
|
|||
typedef nsISupports nsIDOMNode;
|
||||
typedef nsISupports nsIDOMEventTarget;
|
||||
typedef nsISupports nsIDOMAbstractView;
|
||||
typedef nsISupports nsIRequest;
|
||||
typedef nsISupports nsIStreamListener;
|
||||
|
||||
[
|
||||
object,
|
||||
|
@ -147,6 +148,24 @@ interface nsIURI : nsISupports
|
|||
nsresult GetOriginCharset(nsACString *aOriginCharset);
|
||||
}
|
||||
|
||||
[
|
||||
object,
|
||||
uuid(94928ab3-8b63-11d3-989d-001083010e9b)
|
||||
]
|
||||
interface nsIURIContentListener : nsISupports
|
||||
{
|
||||
nsresult OnStartURIOpen(nsIURI *aURI, PRBool *_retval);
|
||||
nsresult DoContent(const char *aContentType, PRBool aIsContentPreferred, nsIRequest *aRequest,
|
||||
nsIStreamListener **aContentHandler, PRBool *_retval);
|
||||
nsresult IsPreferred(const char *aContentType, char **aDesiredContentType, PRBool *_retval);
|
||||
nsresult CanHandleContent(const char *aContentType, PRBool aIsContentPreferred,
|
||||
char **aDesiredContentType, PRBool *_retval);
|
||||
nsresult GetLoadCookie(nsISupports **aLoadCookie);
|
||||
nsresult SetLoadCookie(nsISupports *aLoadCookie);
|
||||
nsresult GetParentContentListener(nsIURIContentListener **aParentContentListener);
|
||||
nsresult SetParentContentListener(nsIURIContentListener *aParentContentListener);
|
||||
}
|
||||
|
||||
[
|
||||
object,
|
||||
uuid(69e5df00-7b8b-11d3-af61-00a024ffc08c)
|
||||
|
|
|
@ -362,13 +362,17 @@ 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;
|
||||
nsres = nsIWebNavigation_LoadURI(This->nscontainer->navigation, url,
|
||||
LOAD_FLAGS_NONE, NULL, NULL, NULL);
|
||||
if(NS_SUCCEEDED(nsres)) {
|
||||
CoTaskMemFree(url);
|
||||
CoTaskMemFree(old_url);
|
||||
return S_OK;
|
||||
}else {
|
||||
WARN("LoadURI failed: %08lx\n", nsres);
|
||||
This->nscontainer->url = old_url;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -559,6 +563,34 @@ 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;
|
||||
|
|
Loading…
Reference in New Issue