Closed
Bug 490225
Opened 14 years ago
Closed 11 years ago
CMD-T opens a new window instead of a new tab when Downloads window is in focus
Categories
(Firefox :: General, defect)
Tracking
()
RESOLVED
FIXED
Firefox 11
People
(Reporter: tchung, Assigned: reuben)
Details
(Whiteboard: [good first bug])
Attachments
(1 file, 7 obsolete files)
1.69 KB,
patch
|
reuben
:
review+
|
Details | Diff | Splinter Review |
User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1b4) Gecko/20090423 Firefox/3.5b4 Build Identifier: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1b4) Gecko/20090423 Firefox/3.5b4 When the downloads window is in focus, opening a new tab (CMD-T on mac), is opening a new browser window instead of a new tab. It should open a new tab instead of a new window Reproducible: Always Steps to Reproduce: 1. launch beta 4 2. open tools > Download window, and bring to focus 3. hit keyboard shortcut to open a new tab (CMD-T on mac, CTRL-T on win) 4. Verify a new browser window is opened, instead of a new tab Actual Results: New window opened Expected Results: New Tab opened
Comment 1•14 years ago
|
||
We could use nsIBrowserGlue::getMostRecentBrowserWindow instead of a gBrowser check, I suppose. http://mxr.mozilla.org/mozilla-central/source/browser/base/content/browser.js#1781
Whiteboard: [good first bug]
This seems like the reporter is expecting results that he should not expect. Is there a way to mark this "working as designed"? Does it even make sense to add a tab to the Downloads window? Cmd-T with no windows open should generate a new window. Ditto for Cmd-T with the Downloads window open, right?
![]() |
||
Comment 3•13 years ago
|
||
(In reply to comment #2) The expected behaviour is to open a new tab in the active window (if one exists). Currently, Fx always opens a new window, even if there already is an existing window.
Comment 4•13 years ago
|
||
So to be crystal clear, the way to fix this would be to change BrowserOpenTab() to call getMostRecentBrowserWindow() and open a new tab in that window if it exists, before it falls back to opening a new window.
![]() |
||
Comment 5•13 years ago
|
||
(In reply to comment #4) > So to be crystal clear, the way to fix this would be to change BrowserOpenTab() > to call getMostRecentBrowserWindow() and open a new tab in that window if it > exists, before it falls back to opening a new window. Yes. That is how Camino and Safari behave.
Comment 6•12 years ago
|
||
Attachment #512442 -
Flags: review?(gavin.sharp)
Comment 7•12 years ago
|
||
Same patch, but after pull/update.
Attachment #512442 -
Attachment is obsolete: true
Attachment #512445 -
Flags: review?(gavin.sharp)
Attachment #512442 -
Flags: review?(gavin.sharp)
Comment 8•12 years ago
|
||
Can you just call openUILinkIn("about:blank", "tab");?
Component: Keyboard Navigation → General
QA Contact: keyboard.navigation → general
Comment 9•12 years ago
|
||
Comment on attachment 512445 [details] [diff] [review] Fix it Seems like dao's suggestion should work, and is much simpler.
Attachment #512445 -
Flags: review?(gavin.sharp)
Comment 10•12 years ago
|
||
Using openUILinkIn is really easy. Also I've changed focusAndSelectUrlBar to accept unnecessary parameter aWindow (to focus urlbar in given window). I'm not sure that it's right way, but I don't know how to handle situation when we should focus urlbar from another window (such as Downloads or Error Console window). I've added Dão to 'feedback' field. May be he knows right way to do it.
Attachment #512445 -
Attachment is obsolete: true
Attachment #521467 -
Flags: review?(gavin.sharp)
Attachment #521467 -
Flags: feedback?
Updated•12 years ago
|
Attachment #521467 -
Flags: feedback? → review?(dao)
Comment 11•12 years ago
|
||
(In reply to comment #10) > I'm not sure that it's right way, but I > don't know how to handle situation when we should focus urlbar from another > window (such as Downloads or Error Console window). How about calling focusAndSelectUrlBar in BrowserStartup when loading about:blank?
Comment 12•12 years ago
|
||
(In reply to comment #11) > (In reply to comment #10) > > I'm not sure that it's right way, but I > > don't know how to handle situation when we should focus urlbar from another > > window (such as Downloads or Error Console window). > > How about calling focusAndSelectUrlBar in BrowserStartup when loading > about:blank? BrowserStartup called only when new window initializing. This bug about reusing existing window, so BrowserStartup is not suitable in this case.
Comment 13•12 years ago
|
||
A new window will be opened if no other is around. For the other case, the openLinkIn function in utilityOverlay.js could focus the url bar.
Comment 14•12 years ago
|
||
> For the other case, the openLinkIn function in utilityOverlay.js could focus
> the url bar.
... either automatically for about:blank or depending on a parameter.
Comment 15•12 years ago
|
||
Comment on attachment 521467 [details] [diff] [review] BrowserOpenTab, focusAndSelectUrlBar refactoring per previous comments. Please let me know if something is unclear.
Attachment #521467 -
Flags: review?(gavin.sharp)
Attachment #521467 -
Flags: review?(dao)
Attachment #521467 -
Flags: review-
This is still not right in the 8.x Beta channel, as of today at least. FWIW, "Page Info" and some of the other modal windows also trigger this behaviour. Tabby chrome windows like "Tools > Add-ons" do not.
Assignee | ||
Comment 17•12 years ago
|
||
I'm taking this as this bug has been bugging me for a while ;-) dao, calling focusAndSelectUrlBar() in BrowserStartup solves the case where a new window is created, but calling it in openUILinkIn does not work for the other case, since the previous is still the one in the global context. Any tips on how to proceed?
Assignee | ||
Comment 18•12 years ago
|
||
Actually, I missed content.focus() being called after my code. This patch fixes it for real.
Attachment #521467 -
Attachment is obsolete: true
Attachment #579192 -
Attachment is obsolete: true
Attachment #579196 -
Flags: review?(dao)
Attachment #579192 -
Flags: feedback?(dao)
Comment 19•12 years ago
|
||
Comment on attachment 579196 [details] [diff] [review] Fix. Looks pretty good overall, just a few refinements: > function BrowserOpenTab() > { >- if (!gBrowser) { >- // If there are no open browser windows, open a new one >- window.openDialog("chrome://browser/content/", "_blank", >- "chrome,all,dialog=no", "about:blank"); >- return; >- } >- gBrowser.loadOneTab("about:blank", {inBackground: false}); >+ openUILinkIn("about:blank", "tab"); > focusAndSelectUrlBar(); > } Looks like you can now remove focusAndSelectUrlBar here. Note that your openUILinkIn call can open a background tab, depending on browser.tabs.loadBookmarksInBackground. I intent to fix this in bug 707672. >@@ -298,16 +298,21 @@ function openLinkIn(url, where, params) > // content but don't raise the window, since the URI we just loaded may have > // resulted in a new frontmost window (e.g. "javascript:window.open('');"). > var fm = Components.classes["@mozilla.org/focus-manager;1"]. > getService(Components.interfaces.nsIFocusManager); > if (window == fm.activeWindow) > w.content.focus(); > else > w.gBrowser.selectedBrowser.focus(); >+ >+ if (url == "about:blank") { >+ w.gURLBar.focus(); >+ w.gURLBar.select(); >+ } You should use focusAndSelectUrlBar here. However, you shouldn't do this in case a background tab was opened.
Attachment #579196 -
Flags: review?(dao) → review-
Assignee | ||
Comment 20•12 years ago
|
||
(In reply to Dão Gottwald [:dao] from comment #19) > >@@ -298,16 +298,21 @@ function openLinkIn(url, where, params) > > // content but don't raise the window, since the URI we just loaded may have > > // resulted in a new frontmost window (e.g. "javascript:window.open('');"). > > var fm = Components.classes["@mozilla.org/focus-manager;1"]. > > getService(Components.interfaces.nsIFocusManager); > > if (window == fm.activeWindow) > > w.content.focus(); > > else > > w.gBrowser.selectedBrowser.focus(); > >+ > >+ if (url == "about:blank") { > >+ w.gURLBar.focus(); > >+ w.gURLBar.select(); > >+ } > > You should use focusAndSelectUrlBar here. However, you shouldn't do this in > case a background tab was opened. focusAndSelectUrlBar operates on the global gURLBar object, which at that time is not the same as w.gURLBar. When this happens from a different window, are we running on a different browser context?
Comment 21•12 years ago
|
||
You should be able to use w.focusAndSelectUrlBar().
Assignee | ||
Comment 22•12 years ago
|
||
(In reply to Gavin Sharp (use gavin@gavinsharp.com for email) from comment #21) > You should be able to use w.focusAndSelectUrlBar(). Oh, silly me, everything makes much more sense now. Thanks :)
Attachment #579196 -
Attachment is obsolete: true
Attachment #579753 -
Flags: review?(dao)
Comment 23•12 years ago
|
||
Comment on attachment 579753 [details] [diff] [review] Patch. >--- a/browser/base/content/browser.js >+++ b/browser/base/content/browser.js >@@ -1248,16 +1248,19 @@ function BrowserStartup() { > window.arguments[4] || false); > content.focus(); > } > // Note: loadOneOrMoreURIs *must not* be called if window.arguments.length >= 3. > // Such callers expect that window.arguments[0] is handled as a single URI. > else > loadOneOrMoreURIs(uriToLoad); > } >+ else { >+ focusAndSelectUrlBar(); >+ } Turns out, this isn't needed, delayedStartup already takes care of this. >--- a/browser/base/content/utilityOverlay.js >+++ b/browser/base/content/utilityOverlay.js >@@ -298,16 +298,20 @@ function openLinkIn(url, where, params) > // content but don't raise the window, since the URI we just loaded may have > // resulted in a new frontmost window (e.g. "javascript:window.open('');"). > var fm = Components.classes["@mozilla.org/focus-manager;1"]. > getService(Components.interfaces.nsIFocusManager); > if (window == fm.activeWindow) > w.content.focus(); > else > w.gBrowser.selectedBrowser.focus(); >+ >+ if (!loadInBackground && url == "about:blank") { >+ w.focusAndSelectUrlBar(); >+ } > } You need to take where=="current" into account, where we don't care about loadInbackground.
Attachment #579753 -
Flags: review?(dao) → review-
Comment 24•11 years ago
|
||
Reuben, are you going to update your patch? It's really close, addressing my previous comment shouldn't be hard.
Assignee | ||
Comment 25•11 years ago
|
||
(In reply to Dão Gottwald [:dao] from comment #24) > Reuben, are you going to update your patch? It's really close, addressing my > previous comment shouldn't be hard. Yes! Very busy, etc etc.
Attachment #579753 -
Attachment is obsolete: true
Attachment #583110 -
Flags: review?(dao)
Comment 26•11 years ago
|
||
Comment on attachment 583110 [details] [diff] [review] Patch v3 thanks!
Attachment #583110 -
Flags: review?(dao) → review+
Assignee | ||
Comment 27•11 years ago
|
||
Patch for check-in, carrying r=dao.
Attachment #583110 -
Attachment is obsolete: true
Attachment #583117 -
Flags: review+
Assignee | ||
Updated•11 years ago
|
Keywords: checkin-needed
Comment 28•11 years ago
|
||
http://hg.mozilla.org/mozilla-central/rev/f7a00571c87f
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Keywords: checkin-needed
Resolution: --- → FIXED
Target Milestone: --- → Firefox 11
Comment 29•11 years ago
|
||
Would it be possible to add a pref for this?
You need to log in
before you can comment on or make changes to this bug.
Description
•