Bug #30553 --> new windows with window targets were getting the target associated with the

chrome window instead of with the content window. And the window sizes were coming from the
	       hidden window instead of the parent window the url originated from.
r=travis
a=jevering
This commit is contained in:
mscott%netscape.com 2000-03-09 08:17:40 +00:00
Родитель 04ca04b397
Коммит 333edb2c69
4 изменённых файлов: 51 добавлений и 20 удалений

Просмотреть файл

@ -26,11 +26,16 @@ interface nsIChannel;
[scriptable, uuid(2F0F927A-8677-11d3-989D-001083010E9B)]
interface nsIContentHandler : nsISupports
{
/* HandleContent works as the name implies =). aChannel is an open channel
whose content type is already known (aContentType) */
/* HandleContent works as the name implies =).
aSourceContext --> The context associated with the originator of the content we are
trying to display. When is this typically used? Well, if handle
content needs to create a new window in order to display the content,
it needs to know about the dom window where the content originated from.
aChannel is an open channel whose content type is already known (aContentType) */
void handleContent(in string aContentType,
in string aCommand,
in string aWindowTarget,
in nsISupports aSourceContext,
in nsIChannel aChannel);
};

Просмотреть файл

@ -120,6 +120,7 @@ interface nsIURILoader : nsISupports
in nsIChannel aChannel,
in nsISupports aCtxt,
in nsIURIContentListener aContentListener,
in nsISupports aSrcWindowContext,
out string aDesiredContentType,
out nsIURIContentListener aTargetListener,
out boolean abortDispatch);

Просмотреть файл

@ -148,7 +148,8 @@ class nsDocumentOpenInfo : public nsIStreamListener
public:
nsDocumentOpenInfo();
nsresult Init(nsISupports * aWindowContext);
nsresult Init(nsISupports * aRetargetedWindowContext,
nsISupports * aOriginalWindowContext);
NS_DECL_ISUPPORTS
@ -176,6 +177,7 @@ protected:
protected:
nsCOMPtr<nsIURIContentListener> m_contentListener;
nsCOMPtr<nsIStreamListener> m_targetStreamListener;
nsCOMPtr<nsISupports> m_originalContext;
nsURILoadCommand mCommand;
nsCString m_windowTarget;
};
@ -198,14 +200,13 @@ nsDocumentOpenInfo::~nsDocumentOpenInfo()
{
}
nsresult nsDocumentOpenInfo::Init(nsISupports * aWindowContext)
nsresult nsDocumentOpenInfo::Init(nsISupports * aCurrentWindowContext,
nsISupports * aOriginalWindowContext)
{
// ask the window context if it has a uri content listener...
nsresult rv = NS_OK;
m_contentListener = do_GetInterface(aWindowContext, &rv);
// now determine if the
m_contentListener = do_GetInterface(aCurrentWindowContext, &rv);
m_originalContext = aOriginalWindowContext;
return rv;
}
@ -302,9 +303,11 @@ nsresult nsDocumentOpenInfo::DispatchContent(nsIChannel * aChannel, nsISupports
rv = pURILoader->DispatchContent(contentType, mCommand, m_windowTarget,
aChannel, aCtxt,
m_contentListener,
m_originalContext,
getter_Copies(desiredContentType),
getter_AddRefs(contentListener),
&abortDispatch);
m_originalContext = nsnull; // we don't need this anymore....
// if the uri loader says to abort the dispatch then someone
// else must have stepped in and taken over for us...so stop..
@ -561,7 +564,7 @@ NS_IMETHODIMP nsURILoader::GetTarget(const char * aWindowTarget,
NS_IMETHODIMP nsURILoader::OpenURIVia(nsIChannel * aChannel,
nsURILoadCommand aCommand,
const char * aWindowTarget,
nsISupports * aWindowContext,
nsISupports * aOriginalWindowContext,
PRUint32 aLocalIP)
{
// we need to create a DocumentOpenInfo object which will go ahead and open the url
@ -573,7 +576,7 @@ NS_IMETHODIMP nsURILoader::OpenURIVia(nsIChannel * aChannel,
if (!aChannel) return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsISupports> retargetedWindowContext;
NS_ENSURE_SUCCESS(GetTarget(aWindowTarget, aWindowContext, getter_AddRefs(retargetedWindowContext)), NS_ERROR_FAILURE);
NS_ENSURE_SUCCESS(GetTarget(aWindowTarget, aOriginalWindowContext, getter_AddRefs(retargetedWindowContext)), NS_ERROR_FAILURE);
NS_NEWXPCOM(loader, nsDocumentOpenInfo);
if (!loader) return NS_ERROR_OUT_OF_MEMORY;
@ -582,7 +585,7 @@ NS_IMETHODIMP nsURILoader::OpenURIVia(nsIChannel * aChannel,
nsCOMPtr<nsISupports> loadCookie;
SetupLoadCookie(retargetedWindowContext, getter_AddRefs(loadCookie));
loader->Init(retargetedWindowContext); // Extra Info
loader->Init(retargetedWindowContext, aOriginalWindowContext); // Extra Info
// now instruct the loader to go ahead and open the url
rv = loader->Open(aChannel, aCommand, aWindowTarget, retargetedWindowContext);
@ -690,6 +693,7 @@ NS_IMETHODIMP nsURILoader::DispatchContent(const char * aContentType,
nsIChannel * aChannel,
nsISupports * aCtxt,
nsIURIContentListener * aContentListener,
nsISupports * aSrcWindowContext,
char ** aContentTypeToUse,
nsIURIContentListener ** aContentListenerToUse,
PRBool * aAbortProcess)
@ -775,7 +779,7 @@ NS_IMETHODIMP nsURILoader::DispatchContent(const char * aContentType,
rv = nsComponentManager::CreateInstance(handlerProgID, nsnull, NS_GET_IID(nsIContentHandler), getter_AddRefs(aContentHandler));
if (NS_SUCCEEDED(rv)) // we did indeed have a content handler for this type!! yippee...
{
rv = aContentHandler->HandleContent(aContentType, "view", aWindowTarget, aChannel);
rv = aContentHandler->HandleContent(aContentType, "view", aWindowTarget, aSrcWindowContext, aChannel);
*aAbortProcess = PR_TRUE;
}

Просмотреть файл

@ -2584,18 +2584,40 @@ NS_IMETHODIMP nsBrowserContentHandler::GetDefaultArgs(PRUnichar **aDefaultArgs)
NS_IMETHODIMP nsBrowserContentHandler::HandleContent(const char * aContentType,
const char * aCommand,
const char * aWindowTarget,
nsISupports * aWindowContext,
nsIChannel * aChannel)
{
// we need a dom window to create the new browser window...in order
// to do this, we need to get the window mediator service and ask it for a dom window
NS_ENSURE_ARG(aChannel);
nsCOMPtr<nsIAppShellService> windowService (do_GetService(kAppShellServiceCID));
nsCOMPtr<nsIDOMWindow> globalWindow;
nsCOMPtr<nsIDOMWindow> parentWindow;
JSContext* jsContext = nsnull;
NS_ENSURE_SUCCESS(windowService->GetHiddenWindowAndJSContext(getter_AddRefs(globalWindow), &jsContext),
NS_ERROR_FAILURE);
if (aWindowContext)
{
parentWindow = do_GetInterface(aWindowContext);
if (parentWindow)
{
nsCOMPtr<nsIScriptGlobalObject> sgo;
sgo = do_QueryInterface( parentWindow );
if (sgo)
{
nsCOMPtr<nsIScriptContext> scriptContext;
sgo->GetContext( getter_AddRefs( scriptContext ) );
if (scriptContext)
jsContext = (JSContext*)scriptContext->GetNativeContext();
}
}
}
// if we still don't have a parent window, try to use the hidden window...
if (!parentWindow || !jsContext)
{
nsCOMPtr<nsIAppShellService> windowService (do_GetService(kAppShellServiceCID));
NS_ENSURE_SUCCESS(windowService->GetHiddenWindowAndJSContext(getter_AddRefs(parentWindow), &jsContext),
NS_ERROR_FAILURE);
}
nsCOMPtr<nsIURI> uri;
aChannel->GetURI(getter_AddRefs(uri));
@ -2615,12 +2637,11 @@ NS_IMETHODIMP nsBrowserContentHandler::HandleContent(const char * aContentType,
if (!aWindowTarget || !nsCRT::strcasecmp(aWindowTarget, "_new") || !nsCRT::strcasecmp(aWindowTarget, "_blank"))
windowTarget = "";
argv = JS_PushArguments(jsContext, &mark, "sssW", "chrome://navigator/content/", windowTarget,
"chrome,dialog=no,all", value.GetUnicode());
argv = JS_PushArguments(jsContext, &mark, "Ws", value.GetUnicode(), windowTarget);
NS_ENSURE_TRUE(argv, NS_ERROR_FAILURE);
nsCOMPtr<nsIDOMWindow> newWindow;
globalWindow->OpenDialog(jsContext, argv, 4, getter_AddRefs(newWindow));
parentWindow->Open(jsContext, argv, 2, getter_AddRefs(newWindow));
JS_PopArguments(jsContext, mark);
// now abort the current channel load...