Closed
Bug 454518
Opened 15 years ago
Closed 14 years ago
allow opening URLs that are not linked from the context menu (if selected)
Categories
(Firefox :: Menus, enhancement, P3)
Firefox
Menus
Tracking
()
VERIFIED
FIXED
Firefox 3.7a1
People
(Reporter: mconnor, Assigned: mconnor)
References
(Depends on 1 open bug, Blocks 2 open bugs)
Details
Attachments
(2 files, 2 obsolete files)
131 bytes,
text/plain
|
Details | |
5.05 KB,
patch
|
Details | Diff | Splinter Review |
Ultimately, we don't want to go down the path of auto-linkifying every URI we encounter, especially in text/plain docs and the like, since we don't really want to modify content intentionally served as text/plain. However, it is trivial and desirable to make it easier to visit these URLs, by detecting that a URL is selected and offering the normal link context options, as well as the option to open in the current tab.
Attachment #337798 -
Flags: ui-review?(beltzner)
Attachment #337798 -
Flags: review?(gavin.sharp)
Updated•15 years ago
|
Attachment #337798 -
Flags: review?(gavin.sharp)
Comment 1•15 years ago
|
||
Comment on attachment 337798 [details] [diff] [review] open selected URLs via context menu v1 >diff --git a/browser/base/content/nsContextMenu.js b/browser/base/content/nsContextMenu.js >+ var focusedWindow = document.commandDispatcher.focusedWindow; >+ if (focusedWindow == window) >+ focusedWindow = content; >+ var someText = focusedWindow.getSelection().toString(); Why is this needed? Is there really a way to trigger the context menu for a given window without it being focused? If so, the check probably belongs in getBrowserSelection() anyways (so that we never even set isTextSelected if the window isn't focused). Would be good to use getBrowserSelection here too, or otherwise limit the selection length (getBrowserSelection might be unsuitable because of the "important chars" thing - not sure). >+ var onPlainTextLink = false; >+ if (uri && uri.host) { GetHost will throw for nsSimpleURIs (e.g. data/javascript), and I don't think it will return null/empty for an nsStandardURL, so the host check seems superfluous. QI to nsIStandardURL is probably better, but even that isn't really the right way of filtering out "abnormal links". Perhaps an explicit check for "https?/ftp" would be best? Otherwise this looks OK, but there are a couple of tabs in this that should be removed.
Assignee | ||
Comment 2•15 years ago
|
||
I swiped the selection stuff from the view partial source bits, but this seems to work fine, not sure quite why it was necessary, it seems rather solid in testing locally. I made the check more robust, you can get an http URI without a host, which is why I added the check in the first place.
Attachment #337798 -
Attachment is obsolete: true
Attachment #339858 -
Flags: review?(gavin.sharp)
Attachment #337798 -
Flags: ui-review?(beltzner)
Comment 3•15 years ago
|
||
(In reply to comment #2) > I made the check more robust, you can get an http URI without a host How, out of curiosity?
Assignee | ||
Comment 4•15 years ago
|
||
Assignee | ||
Comment 5•15 years ago
|
||
Gavin, it seems to work like that if you just pass in http://, for example. var ioService = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService); var uri = ioService.newURI("http://", null, null); uri; evaluates to an nsIURI maybe that shouldn't be the case, but, meh, I can file a followup
Updated•15 years ago
|
Attachment #339858 -
Flags: review?(gavin.sharp) → review+
Comment 6•15 years ago
|
||
Comment on attachment 339858 [details] [diff] [review] v2 >diff --git a/browser/base/content/nsContextMenu.js b/browser/base/content/nsContextMenu.js >+ var ioService = Cc["@mozilla.org/network/io-service;1"]. >+ getService(Ci.nsIIOService); >+ try { >+ var uri = ioService.newURI(someText, null, null); >+ } >+ catch (ex) { } Could use makeURI here (and in getLinkURI for that matter). Still need the try/catch though. >+ if (uri && /^(https?|ftp)/i.test(uri.scheme) && uri.host) { >+ this.linkURI = uri; >+ this.linkURL = this.linkURI.spec; nit: still tabs here! :) >+ // open URL in current tab >+ openLinkInCurrent: function() { >+ openUILink(this.linkURL, null, null, null, null, null, >+ this.target.ownerDocument.documentURIObject); and here! Would be clearer to just call openUILinkIn() directly with "current", I think.
Assignee | ||
Comment 9•15 years ago
|
||
Comment on attachment 339858 [details] [diff] [review] v2 Mrgh, guess this makes 3.2 Beltzner, ui-r?
Attachment #339858 -
Flags: ui-review?(beltzner)
Assignee | ||
Updated•15 years ago
|
Priority: -- → P3
Target Milestone: --- → Firefox 3.2a1
Assignee | ||
Updated•14 years ago
|
Status: NEW → ASSIGNED
Whiteboard: [has patch][needs ui-review beltzner]
Updated•14 years ago
|
Flags: wanted-firefox3.6?
Flags: blocking-firefox3.6?
Comment 10•14 years ago
|
||
Half a year later, still waiting for ui-review on the "Open Link" string in the context menu, shown only when selecting URL which is not linkified.
Updated•14 years ago
|
Attachment #339858 -
Flags: ui-review?(beltzner) → ui-review?(faaborg)
Updated•14 years ago
|
Attachment #339858 -
Flags: ui-review?(faaborg) → ui-review+
Comment 11•14 years ago
|
||
Comment on attachment 339858 [details] [diff] [review] v2 It'd be even nicer if you didn't need to select the entire URL, and just needed to right-click on a string which was a URL. Anyway, yes, this is fine. Clever, even.
Comment 12•14 years ago
|
||
Not going to block; we should get it on mozilla-central then ask for 1.9.2 approval.
Flags: wanted-firefox3.6?
Flags: wanted-firefox3.6+
Flags: blocking-firefox3.6?
Flags: blocking-firefox3.6-
Assignee | ||
Comment 13•14 years ago
|
||
rebuilding to test in the AM, will commit to trunk then and request approval as appropriate. I don't remember now why I decided to just have it be for selected links for ease of implementation, though I'll file a followup on making this smarter in the future.
Attachment #339858 -
Attachment is obsolete: true
Comment 14•14 years ago
|
||
Ugh, links without http:// in front of them don't get this behavior, filed bug 515512
Comment 15•14 years ago
|
||
I was able to load the middle 3 as links in a new tab using Vista.
Comment 16•14 years ago
|
||
http://hg.mozilla.org/mozilla-central/rev/921c0a30c2f3 http://hg.mozilla.org/mozilla-central/rev/7ed220eb3a9f
Status: ASSIGNED → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
Whiteboard: [has patch][needs ui-review beltzner]
Target Milestone: Firefox 3.6a1 → Firefox 3.7a1
Comment 17•14 years ago
|
||
This sends an HTTP referrer. For example, when following a link from http://www.squarefree.com/bug454518/a.txt, that URL is sent as the referrer. This may or may not be a problem.
Comment 18•14 years ago
|
||
(In reply to comment #14) > Ugh, links without http:// in front of them don't get this behavior, filed bug > 515512 What about https:// (with "s")?
Comment 19•14 years ago
|
||
can this mechanism help with Bug 475045?
Comment 20•14 years ago
|
||
(In reply to comment #17) > This sends an HTTP referrer. For example, when following a link from > http://www.squarefree.com/bug454518/a.txt, that URL is sent as the referrer. > This may or may not be a problem. I think it's a problem. People sometimes intentionally don't linkify URLs in pages to prevent the Referer header from being sent. It's also inconsistent with legacy mechanisms for visiting unlinked URLs (e.g. copying the URL and pasting into the Location bar or selecting the URL and dragging to the tab bar), which don't send Referer headers.
Comment 21•14 years ago
|
||
Did bug 515932 fix this to not send a referrer?
Comment 22•14 years ago
|
||
nope
Comment 23•14 years ago
|
||
k, filed bug 517316 for that.
Comment 24•14 years ago
|
||
why do we just add the context menu items for opening the link, but not the whole link context menu (bookmark, save, send, etc.)? this also means that add-on actions on links such as "open in ie tab" will not be available.
Comment 25•14 years ago
|
||
submitted Bug 518005 per comment #11 submitted Bug 518006 per comment #24
Comment 26•14 years ago
|
||
Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.3a1pre) Gecko/20090930 Minefield/3.7a1pre ID:20090930030840 Verified on all platforms that non-linkyfied url's with a leading protocol will have the context menu items. Would be nice to have some automated tests for this feature.
Status: RESOLVED → VERIFIED
Flags: in-testsuite?
Comment 27•14 years ago
|
||
Tests for this bug are included in the tests for bug 515512.
Updated•14 years ago
|
Flags: in-testsuite? → in-testsuite+
Comment 29•12 years ago
|
||
Was it the intention to have this feature work only for valid URLs? Because as it is now, it offers "Open Link" pretty much randomly. It's irritating when I select plain text, and due to muscle memory I click the first option in the context menu. I expect it to be "Copy", but instead of copying to the clipboard, I end up with a confusing "Firefox can't find the server" error. Examples: firstname.lastname@example.com ^ The above opens http://example.com/, which may be a valid address, but hardly desirable or expected. 12.ian.2007 Video.1080p.mkv Quarterly_report.docx usermanual.pdf I've tested in safe mode with the nightly dated March 7th 2011.
You need to log in
before you can comment on or make changes to this bug.
Description
•