зеркало из https://github.com/mozilla/gecko-dev.git
add work around for problems in nsIWebBrowser by registering the chrome object as the URIContentListener of the docshell. this solves the problem where clicking in links creates a new toplevel window.
This commit is contained in:
Родитель
3bb2e243e1
Коммит
978f1937f1
|
@ -21,6 +21,7 @@
|
|||
|
||||
#include "GtkMozEmbedChrome.h"
|
||||
#include "nsCWebBrowser.h"
|
||||
#include "nsCRT.h"
|
||||
|
||||
static NS_DEFINE_CID(kWebBrowserCID, NS_WEBBROWSER_CID);
|
||||
|
||||
|
@ -64,6 +65,7 @@ NS_INTERFACE_MAP_BEGIN(GtkMozEmbedChrome)
|
|||
NS_INTERFACE_MAP_ENTRY(nsIGtkEmbed)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIInterfaceRequestor)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIWebBrowserChrome)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIURIContentListener)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIBaseWindow)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
|
@ -187,6 +189,86 @@ NS_IMETHODIMP GtkMozEmbedChrome::ShowAsModal(void)
|
|||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
// nsIURIContentListener
|
||||
|
||||
NS_IMETHODIMP GtkMozEmbedChrome::OnStartURIOpen(nsIURI *aURI, const char *aWindowTarget, PRBool *aAbortOpen)
|
||||
{
|
||||
g_print("GtkMozEmbedChrome::OnStartURIOpen\n");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP GtkMozEmbedChrome::GetProtocolHandler(nsIURI *aURI, nsIProtocolHandler **aProtocolHandler)
|
||||
{
|
||||
g_print("GtkMozEmbedChrome::GetProtocolHandler\n");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP GtkMozEmbedChrome::DoContent(const char *aContentType, nsURILoadCommand aCommand,
|
||||
const char *aWindowTarget, nsIChannel *aOpenedChannel,
|
||||
nsIStreamListener **aContentHandler, PRBool *aAbortProcess)
|
||||
{
|
||||
g_print("GtkMozEmbedChrome::DoContent\n");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP GtkMozEmbedChrome::IsPreferred(const char *aContentType, nsURILoadCommand aCommand,
|
||||
const char *aWindowTarget, char **aDesiredContentType,
|
||||
PRBool *aCanHandleContent)
|
||||
{
|
||||
g_print("GtkMozEmbedChrome::IsPreferred\n");
|
||||
NS_ENSURE_ARG_POINTER(aCanHandleContent);
|
||||
if (aContentType)
|
||||
{
|
||||
g_print("checking content type %s\n", aContentType);
|
||||
if (nsCRT::strcasecmp(aContentType, "text/html") == 0
|
||||
|| nsCRT::strcasecmp(aContentType, "text/xul") == 0
|
||||
|| nsCRT::strcasecmp(aContentType, "text/rdf") == 0
|
||||
|| nsCRT::strcasecmp(aContentType, "text/xml") == 0
|
||||
|| nsCRT::strcasecmp(aContentType, "text/css") == 0
|
||||
|| nsCRT::strcasecmp(aContentType, "image/gif") == 0
|
||||
|| nsCRT::strcasecmp(aContentType, "image/jpeg") == 0
|
||||
|| nsCRT::strcasecmp(aContentType, "image/png") == 0
|
||||
|| nsCRT::strcasecmp(aContentType, "image/tiff") == 0
|
||||
|| nsCRT::strcasecmp(aContentType, "application/http-index-format") == 0)
|
||||
*aCanHandleContent = PR_TRUE;
|
||||
}
|
||||
else
|
||||
*aCanHandleContent = PR_FALSE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP GtkMozEmbedChrome::CanHandleContent(const char *aContentType, nsURILoadCommand aCommand,
|
||||
const char *aWindowTarget, char **aDesiredContentType,
|
||||
PRBool *_retval)
|
||||
{
|
||||
g_print("GtkMozEmbedChrome::CanHandleContent\n");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP GtkMozEmbedChrome::GetLoadCookie(nsISupports * *aLoadCookie)
|
||||
{
|
||||
g_print("GtkMozEmbedChrome::GetLoadCookie\n");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP GtkMozEmbedChrome::SetLoadCookie(nsISupports * aLoadCookie)
|
||||
{
|
||||
g_print("GtkMozEmbedChrome::SetLoadCookie\n");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP GtkMozEmbedChrome::GetParentContentListener(nsIURIContentListener * *aParentContentListener)
|
||||
{
|
||||
g_print("GtkMozEmbedChrome::GetParentContentListener\n");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP GtkMozEmbedChrome::SetParentContentListener(nsIURIContentListener * aParentContentListener)
|
||||
{
|
||||
g_print("GtkMozEmbedChrome::SetParentContentListener\n");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
// nsIBaseWindow interface
|
||||
|
||||
|
|
|
@ -29,6 +29,8 @@
|
|||
#include "nsIGtkEmbed.h"
|
||||
#include "nsIWebBrowserChrome.h"
|
||||
#include "nsIBaseWindow.h"
|
||||
// this will go away when the URIContentListener crap can go away
|
||||
#include "nsIURIContentListener.h"
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
|
||||
// include our gtk stuff here
|
||||
|
@ -37,6 +39,8 @@
|
|||
class GtkMozEmbedChrome : public nsIGtkEmbed,
|
||||
public nsIWebBrowserChrome,
|
||||
public nsIBaseWindow,
|
||||
// this will go away when the URIContentListener crap can go away
|
||||
public nsIURIContentListener,
|
||||
public nsIInterfaceRequestor
|
||||
{
|
||||
public:
|
||||
|
@ -57,6 +61,9 @@ public:
|
|||
|
||||
NS_DECL_NSIWEBBROWSERCHROME
|
||||
|
||||
// this will go away when the URIContentListener crap can go away
|
||||
NS_DECL_NSIURICONTENTLISTENER
|
||||
|
||||
NS_DECL_NSIBASEWINDOW
|
||||
|
||||
private:
|
||||
|
|
|
@ -29,6 +29,8 @@
|
|||
#include "nsIEventQueueService.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsISupportsArray.h"
|
||||
// remove this when the nsIURIContentListener crap goes
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsVoidArray.h"
|
||||
|
||||
static NS_DEFINE_CID(kWebBrowserCID, NS_WEBBROWSER_CID);
|
||||
|
@ -40,6 +42,7 @@ public:
|
|||
nsCOMPtr<nsIWebBrowser> webBrowser;
|
||||
nsCOMPtr<nsIGtkEmbed> embed;
|
||||
nsCOMPtr<nsISupportsArray> topLevelWindowWebShells;
|
||||
nsCOMPtr<nsIDocShell> docShell;
|
||||
nsVoidArray topLevelWindows;
|
||||
GdkSuperWin *superwin;
|
||||
};
|
||||
|
@ -278,6 +281,14 @@ gtk_moz_embed_realize(GtkWidget *widget)
|
|||
}
|
||||
// set our callback for creating new browser windows
|
||||
embed_private->embed->SetNewBrowserCallback(gtk_moz_embed_handle_new_browser, widget);
|
||||
// get our hands on the docShell. we can't do this in the init()
|
||||
// function for this particular gtkmozembed object because the
|
||||
// docShell won't be there until after we call nsIWebBrowser->Create()
|
||||
embed_private->webBrowser->GetDocShell(getter_AddRefs(embed_private->docShell));
|
||||
// set our webBrowser object as the content listener object
|
||||
nsCOMPtr<nsIURIContentListener> uriListener;
|
||||
uriListener = do_QueryInterface(embed_private->embed);
|
||||
embed_private->docShell->SetParentURIContentListener(uriListener);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Загрузка…
Ссылка в новой задаче