--- editor/ui/composer/content/ComposerCommands.js 2006-01-06 15:46:19.000000000 -0500 +++ editor/ui/composer/content/ComposerCommands.js 2006-09-02 22:05:51.000000000 -0400 @@ -2174,12 +2174,32 @@ doCommand: function(aCommand) { - /* The last parameter is the current browser window. - Use 0 and the default checkbox will be to load into an editor - and loading into existing browser option is removed - */ - window.openDialog( "chrome://communicator/content/openLocation.xul", "_blank", "chrome,modal,titlebar", 0); - window.content.focus(); + var params = { browser: null, action: null, url: "" }; + openDialog( "chrome://communicator/content/openLocation.xul", "_blank", "chrome,modal,titlebar", params); + var win = getTopWin(); + switch (params.action) { + case "0": // current window + win.focus(); + win.loadURI(params.url, null, + nsIWebNavigation.LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP); + break; + case "1": // new window + openDialog(getBrowserURL(), "_blank", "all,dialog=no", params.url, null, + null, nsIWebNavigation.LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP); + break; + case "2": // edit + editPage(params.url); + break; + case "3": // new tab + win.focus(); + var browser = win.getBrowser(); + browser.selectedTab = browser.addTab(params.url, null, null, false, + nsIWebNavigation.LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP); + break; + default: + window.content.focus(); + break; + } } }; --- editor/ui/composer/content/editorApplicationOverlay.js 2006-01-06 15:46:19.000000000 -0500 +++ editor/ui/composer/content/editorApplicationOverlay.js 2006-09-02 22:08:48.000000000 -0400 @@ -63,7 +63,7 @@ if (!aDocument) aDocument = window.content.document; - editPage(aDocument.URL, window, false); + editPage(aDocument.URL); } function editPageOrFrame() @@ -72,42 +72,25 @@ // if the uri is a specific frame, grab it, else use the frameset uri // and let Composer handle error if necessary - var url = getContentFrameURI(focusedWindow); - editPage(url, window, false) + editPage(getContentFrameURI(focusedWindow)); } // Any non-editor window wanting to create an editor with a URL // should use this instead of "window.openDialog..." // We must always find an existing window with requested URL -// (When calling from a dialog, "launchWindow" is dialog's "opener" -// and we need a delay to let dialog close) -function editPage(url, launchWindow, delay) +function editPage(url) { // Always strip off "view-source:" and #anchors url = url.replace(/^view-source:/, "").replace(/#.*/, ""); - // User may not have supplied a window - if (!launchWindow) - { - if (window) - { - launchWindow = window; - } - else - { - dump("No window to launch an editor from!\n"); - return; - } - } - // if the current window is a browser window, then extract the current charset menu setting from the current // document and use it to initialize the new composer window... var wintype = document.documentElement.getAttribute('windowtype'); var charsetArg; - if (launchWindow && (wintype == "navigator:browser") && launchWindow.content.document) - charsetArg = "charset=" + launchWindow.content.document.characterSet; + if (wintype == "navigator:browser" && content.document) + charsetArg = "charset=" + content.document.characterSet; try { var uri = createURI(url, null, null); @@ -146,12 +129,7 @@ } // Create new Composer window - if (delay) - { - launchWindow.delayedOpenWindow("chrome://editor/content", "chrome,all,dialog=no", url); - } - else - launchWindow.openDialog("chrome://editor/content", "_blank", "chrome,all,dialog=no", url, charsetArg); + openDialog("chrome://editor/content", "_blank", "chrome,all,dialog=no", url, charsetArg); } catch(e) {} } --- editor/ui/composer/content/editor.js 2006-01-10 18:32:12.000000000 -0500 +++ editor/ui/composer/content/editor.js 2006-09-02 22:05:54.000000000 -0400 @@ -839,14 +839,6 @@ // --------------------------- File menu --------------------------- - -// used by openLocation. see openLocation.js for additional notes. -function delayedOpenWindow(chrome, flags, url) -{ - dump("setting timeout\n"); - setTimeout("window.openDialog('"+chrome+"','_blank','"+flags+"','"+url+"')", 10); -} - function EditorNewPlaintext() { window.openDialog( "chrome://editor/content/TextEditorAppShell.xul", --- xpfe/browser/resources/content/navigator.js 2006-05-30 03:13:11.000000000 -0400 +++ xpfe/browser/resources/content/navigator.js 2006-09-02 22:06:37.000000000 -0400 @@ -1248,7 +1248,25 @@ function BrowserOpenWindow() { //opens a window where users can select a web location to open - openDialog("chrome://communicator/content/openLocation.xul", "_blank", "chrome,modal,titlebar", window); + var params = { browser: window, action: null, url: "" }; + openDialog("chrome://communicator/content/openLocation.xul", "_blank", "chrome,modal,titlebar", params); + var url = getShortcutOrURI(params.url); + switch (params.action) { + case "0": // current window + loadURI(url, null, nsIWebNavigation.LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP); + break; + case "1": // new window + openDialog(getBrowserURL(), "_blank", "all,dialog=no", url, null, null, + nsIWebNavigation.LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP); + break; + case "2": // edit + editPage(url); + break; + case "3": // new tab + gBrowser.selectedTab = gBrowser.addTab(url, null, null, false, + nsIWebNavigation.LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP); + break; + } } function BrowserOpenTab() @@ -1288,22 +1306,6 @@ } } -/* Called from the openLocation dialog. This allows that dialog to instruct - its opener to open a new window and then step completely out of the way. - Anything less byzantine is causing horrible crashes, rather believably, - though oddly only on Linux. */ -function delayedOpenWindow(chrome,flags,url) -{ - setTimeout("openDialog('"+chrome+"','_blank','"+flags+"','"+url+"')", 10); -} - -/* Required because the tab needs time to set up its content viewers and get the load of - the URI kicked off before becoming the active content area. */ -function delayedOpenTab(url) -{ - setTimeout(function(aTabElt) { getBrowser().selectedTab = aTabElt; }, 0, getBrowser().addTab(url)); -} - /* Show file picker dialog configured for opening a file, and return * the selected nsIFileURL instance. */ function selectFileToOpen(label, prefRoot) --- xpfe/browser/resources/content/viewsource.js 2004-12-21 14:31:06.000000000 -0500 +++ xpfe/browser/resources/content/viewsource.js 2006-09-02 22:06:44.000000000 -0400 @@ -245,7 +245,7 @@ // Strips the |view-source:| for editPage() function ViewSourceEditPage() { - editPage(window.content.location.href.substring(12), window, false); + editPage(window.content.location.href.substring(12)); } // Strips the |view-source:| for saveURL() --- xpfe/communicator/resources/content/openLocation.js 2004-11-27 16:56:49.000000000 -0500 +++ xpfe/communicator/resources/content/openLocation.js 2006-09-02 22:11:54.000000000 -0400 @@ -41,7 +41,6 @@ var browser; var dialog = {}; -var gNavigatorBundle; var pref = null; try { pref = Components.classes["@mozilla.org/preferences-service;1"] @@ -58,10 +57,8 @@ dialog.openTopWindow = document.getElementById("currentWindow"); dialog.openEditWindow = document.getElementById("editWindow"); dialog.bundle = document.getElementById("openLocationBundle"); - gNavigatorBundle = document.getElementById("navigatorBundle"); - if ("arguments" in window && window.arguments.length >= 1) - browser = window.arguments[0]; + browser = window.arguments[0].browser; if (!browser) { // No browser supplied - we are calling from Composer @@ -86,10 +83,7 @@ if (pref) { try { - var value = pref.getIntPref("general.open_location.last_window_choice"); - var element = dialog.openAppList.getElementsByAttribute("value", value)[0]; - if (element) - dialog.openAppList.selectedItem = element; + dialog.openAppList.value = pref.getIntPref("general.open_location.last_window_choice"); dialog.input.value = pref.getComplexValue("general.open_location.last_url", Components.interfaces.nsISupportsString).data; } @@ -109,36 +103,11 @@ function open() { - var url; - if (browser) - url = browser.getShortcutOrURI(dialog.input.value); - else - url = dialog.input.value; - - try { - switch (dialog.openAppList.value) { - case "0": - browser.loadURI(url); - break; - case "1": - window.opener.delayedOpenWindow(getBrowserURL(), "all,dialog=no", url); - break; - case "2": - // editPage is in editorApplicationOverlay.js - // 3rd param tells editPage to use "delayedOpenWindow" - if ("editPage" in window.opener) - window.opener.editPage(url, window.opener, true); - break; - case "3": - if (browser.getBrowser && browser.getBrowser().localName == "tabbrowser") - browser.delayedOpenTab(url); - else - browser.loadURI(url); // Just do a normal load. - break; - } - } - catch(exception) { - } + var params = window.arguments[0]; + params.url = dialog.input.value; + params.action = dialog.openAppList.value; + if (!browser && params.action != "2") + params.action = "1"; if (pref) { var str = Components.classes["@mozilla.org/supports-string;1"] @@ -148,16 +117,6 @@ Components.interfaces.nsISupportsString, str); pref.setIntPref("general.open_location.last_window_choice", dialog.openAppList.value); } - - // Delay closing slightly to avoid timing bug on Linux. - window.close(); - return false; -} - -function createInstance(contractid, iidName) -{ - var iid = Components.interfaces[iidName]; - return Components.classes[contractid].createInstance(iid); } const nsIFilePicker = Components.interfaces.nsIFilePicker; --- xpfe/communicator/resources/content/openLocation.xul 2005-03-10 13:44:09.000000000 -0500 +++ xpfe/communicator/resources/content/openLocation.xul 2006-09-02 22:12:40.000000000 -0400 @@ -64,7 +64,6 @@