mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-30 00:01:50 +00:00
Changed calls to nsIWebShell::GetRootWebShellEvenIfChrome() and further QI's to use the new nsIWebShell::GetTopLevelWindow().
This commit is contained in:
parent
f61ba08549
commit
3caae87616
@ -1096,31 +1096,30 @@ GlobalWindowImpl::Alert(JSContext *cx, jsval *argv, PRUint32 argc)
|
||||
nsresult ret = NS_OK;
|
||||
nsAutoString str;
|
||||
|
||||
if (nsnull != mWebShell) {
|
||||
if (argc > 0) {
|
||||
nsJSUtils::nsConvertJSValToString(str, cx, argv[0]);
|
||||
}
|
||||
else {
|
||||
str.SetString("undefined");
|
||||
}
|
||||
|
||||
nsIWebShell *rootWebShell;
|
||||
ret = mWebShell->GetRootWebShellEvenIfChrome(rootWebShell);
|
||||
if (nsnull != rootWebShell) {
|
||||
nsIWebShellContainer *rootContainer;
|
||||
ret = rootWebShell->GetContainer(rootContainer);
|
||||
if (nsnull != rootContainer) {
|
||||
nsIPrompt *prompter;
|
||||
if (NS_OK == (ret = rootContainer->QueryInterface(nsIPrompt::GetIID(), (void**)&prompter))) {
|
||||
ret = prompter->Alert(str.GetUnicode());
|
||||
NS_RELEASE(prompter);
|
||||
}
|
||||
NS_RELEASE(rootContainer);
|
||||
}
|
||||
NS_RELEASE(rootWebShell);
|
||||
}
|
||||
NS_ENSURE_STATE(mWebShell);
|
||||
if (argc > 0) {
|
||||
nsJSUtils::nsConvertJSValToString(str, cx, argv[0]);
|
||||
}
|
||||
return ret;
|
||||
else {
|
||||
str.SetString("undefined");
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIWebShellContainer> topLevelWindow;
|
||||
NS_ENSURE_SUCCESS(mWebShell->GetTopLevelWindow(
|
||||
getter_AddRefs(topLevelWindow)), NS_ERROR_FAILURE);
|
||||
|
||||
//XXXWEBSHELL this should be a request off nsIInterfaceRequestor
|
||||
nsCOMPtr<nsIPrompt> prompter(do_QueryInterface(topLevelWindow));
|
||||
/*XXXEMBEDDING If it fails to get a prompter, it should use an internal
|
||||
// one
|
||||
if(!prompter)
|
||||
{
|
||||
prompter = Create our internal prompter
|
||||
}
|
||||
*/
|
||||
NS_ENSURE_TRUE(prompter, NS_ERROR_FAILURE);
|
||||
|
||||
return prompter->Alert(str.GetUnicode());
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -1130,32 +1129,30 @@ GlobalWindowImpl::Confirm(JSContext *cx, jsval *argv, PRUint32 argc, PRBool* aRe
|
||||
nsAutoString str;
|
||||
|
||||
*aReturn = PR_FALSE;
|
||||
if (nsnull != mWebShell) {
|
||||
if (argc > 0) {
|
||||
nsJSUtils::nsConvertJSValToString(str, cx, argv[0]);
|
||||
}
|
||||
else {
|
||||
str.SetString("undefined");
|
||||
}
|
||||
|
||||
nsIWebShell *rootWebShell;
|
||||
ret = mWebShell->GetRootWebShellEvenIfChrome(rootWebShell);
|
||||
if (nsnull != rootWebShell) {
|
||||
nsIWebShellContainer *rootContainer;
|
||||
ret = rootWebShell->GetContainer(rootContainer);
|
||||
if (nsnull != rootContainer) {
|
||||
nsIPrompt *prompter;
|
||||
ret = rootContainer->QueryInterface(NS_GET_IID(nsIPrompt), (void**)&prompter);
|
||||
if (NS_SUCCEEDED(ret)) {
|
||||
ret = prompter->Confirm(str.GetUnicode(), aReturn);
|
||||
NS_RELEASE(prompter);
|
||||
}
|
||||
NS_RELEASE(rootContainer);
|
||||
}
|
||||
NS_RELEASE(rootWebShell);
|
||||
}
|
||||
NS_ENSURE_STATE(mWebShell);
|
||||
if (argc > 0) {
|
||||
nsJSUtils::nsConvertJSValToString(str, cx, argv[0]);
|
||||
}
|
||||
return ret;
|
||||
else {
|
||||
str.SetString("undefined");
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIWebShellContainer> topLevelWindow;
|
||||
NS_ENSURE_SUCCESS(mWebShell->GetTopLevelWindow(
|
||||
getter_AddRefs(topLevelWindow)), NS_ERROR_FAILURE);
|
||||
|
||||
//XXXWEBSHELL this should be a request off nsIInterfaceRequestor
|
||||
nsCOMPtr<nsIPrompt> prompter(do_QueryInterface(topLevelWindow));
|
||||
/*XXXEMBEDDING If it fails to get a prompter, it should use an internal
|
||||
// one
|
||||
if(!prompter)
|
||||
{
|
||||
prompter = Create our internal prompter
|
||||
}
|
||||
*/
|
||||
NS_ENSURE_TRUE(prompter, NS_ERROR_FAILURE);
|
||||
|
||||
return prompter->Confirm(str.GetUnicode(), aReturn);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -1165,46 +1162,47 @@ GlobalWindowImpl::Prompt(JSContext *cx, jsval *argv, PRUint32 argc, nsString& aR
|
||||
nsAutoString str, initial;
|
||||
|
||||
aReturn.Truncate();
|
||||
if (nsnull != mWebShell) {
|
||||
if (argc > 0) {
|
||||
nsJSUtils::nsConvertJSValToString(str, cx, argv[0]);
|
||||
|
||||
if (argc > 1) {
|
||||
nsJSUtils::nsConvertJSValToString(initial, cx, argv[1]);
|
||||
}
|
||||
else {
|
||||
initial.SetString("undefined");
|
||||
}
|
||||
}
|
||||
|
||||
nsIWebShell *rootWebShell;
|
||||
ret = mWebShell->GetRootWebShellEvenIfChrome(rootWebShell);
|
||||
if (nsnull != rootWebShell) {
|
||||
nsIWebShellContainer *rootContainer;
|
||||
ret = rootWebShell->GetContainer(rootContainer);
|
||||
if (nsnull != rootContainer) {
|
||||
nsIPrompt *prompter;
|
||||
if (NS_OK == (ret = rootContainer->QueryInterface(NS_GET_IID(nsIPrompt), (void**)&prompter))) {
|
||||
PRBool b;
|
||||
PRUnichar* uniResult = nsnull;
|
||||
ret = prompter->Prompt(str.GetUnicode(), initial.GetUnicode(), &uniResult, &b);
|
||||
aReturn = uniResult;
|
||||
if (uniResult) {
|
||||
nsAllocator::Free(uniResult);
|
||||
}
|
||||
if (NS_FAILED(ret) || !b) {
|
||||
// XXX Need to check return value and return null if the
|
||||
// user hits cancel. Currently, we can only return a
|
||||
// string reference.
|
||||
aReturn.SetString("");
|
||||
}
|
||||
NS_RELEASE(prompter);
|
||||
}
|
||||
NS_RELEASE(rootContainer);
|
||||
}
|
||||
NS_RELEASE(rootWebShell);
|
||||
}
|
||||
NS_ENSURE_STATE(mWebShell);
|
||||
if (argc > 0) {
|
||||
nsJSUtils::nsConvertJSValToString(str, cx, argv[0]);
|
||||
|
||||
if (argc > 1) {
|
||||
nsJSUtils::nsConvertJSValToString(initial, cx, argv[1]);
|
||||
}
|
||||
else {
|
||||
initial.SetString("undefined");
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIWebShellContainer> topLevelWindow;
|
||||
NS_ENSURE_SUCCESS(mWebShell->GetTopLevelWindow(
|
||||
getter_AddRefs(topLevelWindow)), NS_ERROR_FAILURE);
|
||||
|
||||
//XXXWEBSHELL this should be a request off nsIInterfaceRequestor
|
||||
nsCOMPtr<nsIPrompt> prompter(do_QueryInterface(topLevelWindow));
|
||||
/*XXXEMBEDDING If it fails to get a prompter, it should use an internal
|
||||
// one
|
||||
if(!prompter)
|
||||
{
|
||||
prompter = Create our internal prompter
|
||||
}
|
||||
*/
|
||||
NS_ENSURE_TRUE(prompter, NS_ERROR_FAILURE);
|
||||
|
||||
PRBool b;
|
||||
PRUnichar* uniResult = nsnull;
|
||||
ret = prompter->Prompt(str.GetUnicode(), initial.GetUnicode(), &uniResult, &b);
|
||||
aReturn = uniResult;
|
||||
if (uniResult) {
|
||||
nsAllocator::Free(uniResult);
|
||||
}
|
||||
if (NS_FAILED(ret) || !b) {
|
||||
// XXX Need to check return value and return null if the
|
||||
// user hits cancel. Currently, we can only return a
|
||||
// string reference.
|
||||
aReturn.SetString("");
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -2607,27 +2605,17 @@ GlobalWindowImpl::GetBrowserWindowInterface(
|
||||
nsIBrowserWindow*& aBrowser,
|
||||
nsIWebShell *aWebShell)
|
||||
{
|
||||
nsresult ret = NS_ERROR_FAILURE;
|
||||
aBrowser = nsnull;
|
||||
|
||||
if (nsnull == aWebShell)
|
||||
aWebShell = mWebShell;
|
||||
if (nsnull != aWebShell) {
|
||||
nsIWebShell *rootWebShell;
|
||||
aWebShell->GetRootWebShellEvenIfChrome(rootWebShell);
|
||||
if (nsnull != rootWebShell) {
|
||||
nsIWebShellContainer *rootContainer;
|
||||
rootWebShell->GetContainer(rootContainer);
|
||||
if (nsnull != rootContainer) {
|
||||
ret = rootContainer->QueryInterface(kIBrowserWindowIID, (void**)&aBrowser);
|
||||
if (NS_FAILED(ret))
|
||||
aBrowser = nsnull;
|
||||
NS_RELEASE(rootContainer);
|
||||
}
|
||||
NS_RELEASE(rootWebShell);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
NS_ENSURE_TRUE(aWebShell, NS_ERROR_UNEXPECTED);
|
||||
|
||||
nsCOMPtr<nsIWebShellContainer> topLevelWindow;
|
||||
NS_ENSURE_SUCCESS(mWebShell->GetTopLevelWindow(
|
||||
getter_AddRefs(topLevelWindow)), NS_ERROR_FAILURE);
|
||||
|
||||
return topLevelWindow->QueryInterface(NS_GET_IID(nsIBrowserWindow), (void**)&aBrowser);
|
||||
}
|
||||
|
||||
PRBool
|
||||
|
@ -109,14 +109,11 @@ static void DOMWindowToWebShellWindow(
|
||||
if (globalScript) {
|
||||
globalScript->GetWebShell(getter_AddRefs(webshell));
|
||||
}
|
||||
if (webshell) {
|
||||
webshell->GetRootWebShellEvenIfChrome(*getter_AddRefs(rootWebshell));
|
||||
}
|
||||
if (rootWebshell) {
|
||||
nsCOMPtr<nsIWebShellContainer> webshellContainer;
|
||||
rootWebshell->GetContainer(*getter_AddRefs(webshellContainer));
|
||||
*webWindow = do_QueryInterface(webshellContainer);
|
||||
}
|
||||
if(!webshell)
|
||||
return;
|
||||
nsCOMPtr<nsIWebShellContainer> topLevelWindow;
|
||||
webshell->GetTopLevelWindow(getter_AddRefs(topLevelWindow));
|
||||
*webWindow = do_QueryInterface(topLevelWindow);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -109,14 +109,11 @@ static void DOMWindowToWebShellWindow(
|
||||
if (globalScript) {
|
||||
globalScript->GetWebShell(getter_AddRefs(webshell));
|
||||
}
|
||||
if (webshell) {
|
||||
webshell->GetRootWebShellEvenIfChrome(*getter_AddRefs(rootWebshell));
|
||||
}
|
||||
if (rootWebshell) {
|
||||
nsCOMPtr<nsIWebShellContainer> webshellContainer;
|
||||
rootWebshell->GetContainer(*getter_AddRefs(webshellContainer));
|
||||
*webWindow = do_QueryInterface(webshellContainer);
|
||||
}
|
||||
if(!webshell)
|
||||
return;
|
||||
nsCOMPtr<nsIWebShellContainer> topLevelWindow;
|
||||
webshell->GetTopLevelWindow(getter_AddRefs(topLevelWindow));
|
||||
*webWindow = do_QueryInterface(topLevelWindow);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -361,12 +361,10 @@ void nsToolkitCore::DOMWindowToWebShellWindow(
|
||||
nsCOMPtr<nsIWebShell> webshell, rootWebshell;
|
||||
if (globalScript)
|
||||
globalScript->GetWebShell(getter_AddRefs(webshell));
|
||||
if (webshell)
|
||||
webshell->GetRootWebShellEvenIfChrome(*getter_AddRefs(rootWebshell));
|
||||
if (rootWebshell) {
|
||||
nsCOMPtr<nsIWebShellContainer> webshellContainer;
|
||||
rootWebshell->GetContainer(*getter_AddRefs(webshellContainer));
|
||||
*webWindow = do_QueryInterface(webshellContainer);
|
||||
}
|
||||
if(!webshell)
|
||||
return;
|
||||
nsCOMPtr<nsIWebShellContainer> topLevelWindow;
|
||||
webshell->GetTopLevelWindow(getter_AddRefs(topLevelWindow));
|
||||
*webWindow = do_QueryInterface(topLevelWindow);
|
||||
}
|
||||
|
||||
|
@ -45,6 +45,7 @@ public:
|
||||
NS_IMETHOD Close() = 0;
|
||||
NS_IMETHOD GetWebShell(nsIWebShell *& aWebShell) = 0;
|
||||
NS_IMETHOD GetWidget(nsIWidget *& aWidget) = 0;
|
||||
NS_IMETHOD GetDOMWindow(nsIDOMWindow** aDOMWindow) = 0;
|
||||
NS_IMETHOD ConvertWebShellToDOMWindow(nsIWebShell* aShell, nsIDOMWindow** aDOMWindow) = 0;
|
||||
|
||||
NS_IMETHOD AddWebShellInfo(const nsString& aID, PRBool aPrimary, nsIWebShell* aChildShell) = 0;
|
||||
|
@ -1906,6 +1906,12 @@ nsWebShellWindow::GetWidget(nsIWidget *& aWidget)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWebShellWindow::GetDOMWindow(nsIDOMWindow** aDOMWindow)
|
||||
{
|
||||
return ConvertWebShellToDOMWindow(mWebShell, aDOMWindow);
|
||||
}
|
||||
|
||||
void *
|
||||
nsWebShellWindow::HandleModalDialogEvent(PLEvent *aEvent)
|
||||
{
|
||||
|
@ -132,6 +132,7 @@ public:
|
||||
NS_IMETHOD GetWebShell(nsIWebShell *& aWebShell);
|
||||
NS_IMETHOD GetContentWebShell(nsIWebShell **aResult);
|
||||
NS_IMETHOD GetWidget(nsIWidget *& aWidget);
|
||||
NS_IMETHOD GetDOMWindow(nsIDOMWindow** aDOMWindow);
|
||||
NS_IMETHOD ConvertWebShellToDOMWindow(nsIWebShell* aShell, nsIDOMWindow** aDOMWindow);
|
||||
// nsWebShellWindow methods...
|
||||
nsresult Initialize(nsIWebShellWindow * aParent, nsIAppShell* aShell, nsIURI* aUrl,
|
||||
|
@ -779,13 +779,11 @@ static void DOMWindowToWebShellWindow(
|
||||
nsCOMPtr<nsIWebShell> webshell, rootWebshell;
|
||||
if (globalScript)
|
||||
globalScript->GetWebShell(getter_AddRefs(webshell));
|
||||
if (webshell)
|
||||
webshell->GetRootWebShellEvenIfChrome(*getter_AddRefs(rootWebshell));
|
||||
if (rootWebshell) {
|
||||
nsCOMPtr<nsIWebShellContainer> webshellContainer;
|
||||
rootWebshell->GetContainer(*getter_AddRefs(webshellContainer));
|
||||
*webWindow = do_QueryInterface(webshellContainer);
|
||||
}
|
||||
if(!webshell)
|
||||
return;
|
||||
nsCOMPtr<nsIWebShellContainer> topLevelWindow;
|
||||
webshell->GetTopLevelWindow(getter_AddRefs(topLevelWindow));
|
||||
*webWindow = do_QueryInterface(topLevelWindow);
|
||||
}
|
||||
|
||||
|
||||
|
@ -852,43 +852,27 @@ nsFindComponent::Find(nsISupports *aContext, PRBool *aDidFind)
|
||||
char * urlStr = "chrome://global/content/finddialog.xul";
|
||||
|
||||
// We need the parent's nsIDOMWindow...
|
||||
// 1. Get root nsIWebShell (chrome included).
|
||||
// 1. Get topLevelWindow nsIWebShellContainer (chrome included).
|
||||
nsCOMPtr<nsIWebShell> ws;
|
||||
rv = context->GetTargetWebShell( getter_AddRefs( ws ) );
|
||||
if ( NS_SUCCEEDED( rv ) && ws ) {
|
||||
nsCOMPtr<nsIWebShell> rootws;
|
||||
rv = ws->GetRootWebShellEvenIfChrome( *getter_AddRefs( rootws ) );
|
||||
if ( NS_SUCCEEDED( rv ) && rootws ) {
|
||||
// 2. Get container for the root web shell.
|
||||
nsCOMPtr<nsIWebShellContainer> rootwsContainer;
|
||||
rv = rootws->GetContainer( *getter_AddRefs( rootwsContainer ) );
|
||||
if ( NS_SUCCEEDED( rv ) && rootwsContainer ) {
|
||||
// 3. Convert that to an nsIWebShellWindow.
|
||||
nsCOMPtr<nsIWebShellWindow> rootWindow;
|
||||
rv = rootwsContainer->QueryInterface( nsIWebShellWindow::GetIID(),
|
||||
getter_AddRefs( rootWindow ) );
|
||||
if ( NS_SUCCEEDED( rv ) && rootWindow ) {
|
||||
// 4. Convert window to nsIDOMWindow.
|
||||
nsCOMPtr<nsIDOMWindow> domWindow;
|
||||
rv = rootWindow->ConvertWebShellToDOMWindow( rootws,
|
||||
getter_AddRefs( domWindow ) );
|
||||
if ( NS_SUCCEEDED( rv ) && domWindow ) {
|
||||
// Whew. Now open dialog with search context as argument.
|
||||
rv = OpenDialogWithArg( domWindow, context, urlStr );
|
||||
} else {
|
||||
DEBUG_PRINTF( PR_STDOUT, "%s %d: Error getting DOM window from web shell, rv=0x%08X\n",
|
||||
(char*)__FILE__, (int)__LINE__, (int)rv );
|
||||
}
|
||||
} else {
|
||||
DEBUG_PRINTF( PR_STDOUT, "%s %d: QueryInterface (for nsIWebShellWindow) failed, rv=0x%08X\n",
|
||||
(char*)__FILE__, (int)__LINE__, (int)rv );
|
||||
}
|
||||
nsCOMPtr<nsIWebShellContainer> topLevelWindow;
|
||||
rv = ws->GetTopLevelWindow(getter_AddRefs(topLevelWindow));
|
||||
// 3. Convert that to an nsIWebShellWindow.
|
||||
nsCOMPtr<nsIWebShellWindow> rootWindow(do_QueryInterface(topLevelWindow));
|
||||
if ( rootWindow ) {
|
||||
// 4. Convert window to nsIDOMWindow.
|
||||
nsCOMPtr<nsIDOMWindow> domWindow;
|
||||
rv = rootWindow->GetDOMWindow(getter_AddRefs( domWindow ) );
|
||||
if ( NS_SUCCEEDED( rv ) && domWindow ) {
|
||||
// Whew. Now open dialog with search context as argument.
|
||||
rv = OpenDialogWithArg( domWindow, context, urlStr );
|
||||
} else {
|
||||
DEBUG_PRINTF( PR_STDOUT, "%s %d: GetContainer failed, rv=0x%08X\n",
|
||||
DEBUG_PRINTF( PR_STDOUT, "%s %d: Error getting DOM window from web shell, rv=0x%08X\n",
|
||||
(char*)__FILE__, (int)__LINE__, (int)rv );
|
||||
}
|
||||
} else {
|
||||
DEBUG_PRINTF( PR_STDOUT, "%s %d: GetRootWebShellEvenIfChrome failed, rv=0x%08X\n",
|
||||
DEBUG_PRINTF( PR_STDOUT, "%s %d: QueryInterface (for nsIWebShellWindow) failed, rv=0x%08X\n",
|
||||
(char*)__FILE__, (int)__LINE__, (int)rv );
|
||||
}
|
||||
} else {
|
||||
|
@ -855,14 +855,11 @@ static void DOMWindowToWebShellWindow(
|
||||
nsCOMPtr<nsIWebShell> webshell, rootWebshell;
|
||||
if (globalScript)
|
||||
globalScript->GetWebShell(getter_AddRefs(webshell));
|
||||
if (webshell)
|
||||
webshell->GetRootWebShellEvenIfChrome(*getter_AddRefs(rootWebshell));
|
||||
if (rootWebshell)
|
||||
{
|
||||
nsCOMPtr<nsIWebShellContainer> webshellContainer;
|
||||
rootWebshell->GetContainer(*getter_AddRefs(webshellContainer));
|
||||
*webWindow = do_QueryInterface(webshellContainer);
|
||||
}
|
||||
if(!webshell)
|
||||
return;
|
||||
nsCOMPtr<nsIWebShellContainer> topLevelWindow;
|
||||
webshell->GetTopLevelWindow(getter_AddRefs(topLevelWindow));
|
||||
*webWindow = do_QueryInterface(topLevelWindow);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user