Closed Bug 301357 Opened 21 years ago Closed 20 years ago

Simplify context menu selection code

Categories

(Firefox :: Menus, enhancement)

enhancement
Not set
normal

Tracking

()

VERIFIED FIXED
Firefox1.5

People

(Reporter: polidobj, Assigned: martijn.martijn)

Details

(Keywords: verified1.8)

Attachments

(1 file, 3 obsolete files)

User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8b4) Gecko/20050719 Firefox/1.0+ Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8b4) Gecko/20050719 Firefox/1.0+ This can be reproduced using the 'Vote for this bug' link. The bug seems to require text before the link. For example the 'Votes' link functions properly. Reproducible: Always Steps to Reproduce: 1.Select the text of a link using the mouse from the left edge of the link. 2.Right click on the selected text. Actual Results: No copy option is present on the context menu. Expected Results: A copy menu item should be present. This also occurs when selecting a link with caret browsing with the same requirements.
Keywords: regression
The regression time frame for this seems to be: 6/13 OK 6/14 broken From the build thread for 6/14: http://forums.mozillazine.org/viewtopic.php?t=279117 I'd point to this bug fix: bug 293758 [Firefox]-Context menu screw-up with data and javascript protocol images [All]
Ah! I get the same regression period, independantly. However, I think the fix for bug 280284 is more likely the cause of this bug.
Confirmed, Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8b4) Gecko/20050718 Firefox/1.0+
Status: UNCONFIRMED → NEW
Ever confirmed: true
Flags: blocking1.8b4?
Ok, this part of the patch in bug 280284 returns true: if (node.nodeType == node.TEXT_NODE && node.nodeValue.length == 0) { So when selecting from the left to the right directly before a link, you begin with an empty textnode. That doesn't seem logical in itself, but the code of that patch is also not good. Probably the collapsed property of a range object is best used here.
Attached patch patch (obsolete) — Splinter Review
Like this. This fixes it for me.
Attachment #189844 - Flags: review?(mconnor)
Is this possibly a dupe of bug 301466 which was just checked in? The patch is different but changes the same area.
You're right, Brian, it is the same bug. However, I think my patch is better (imho). I'll ask in that bug.
Yes, this patch is much simpler and works better than the kludge in the other patch. Martijn, do you want to update your patch now that the other one has been checked in?
Attached patch patch2, updated (obsolete) — Splinter Review
I've diffed this locally, and again tested the patch.
Attachment #189844 - Attachment is obsolete: true
Attachment #189844 - Flags: review?(mconnor)
Attached patch patch3 (obsolete) — Splinter Review
This is even a bit simpler (based on some sharp suggestions by Gavin). I've also tested this patch a bit, for not breaking anything (and fixing the issue).
Attachment #189940 - Attachment is obsolete: true
Attachment #189944 - Flags: review?(mconnor)
Flags: blocking1.8b4? → blocking1.8b4+
Changing summary to reflect new intent of bug.
Assignee: nobody → martijn.martijn
Severity: normal → enhancement
Keywords: regression
OS: Windows XP → All
Hardware: PC → All
Summary: Copy context menu item missing when selecting a link's text → Simplify context menu selection code
Target Milestone: --- → Firefox1.1
Version: unspecified → Trunk
+ return ((selection.rangeCount >= 1) && !selection.getRangeAt(0).collapsed) Shouldn't this be true if *any* range in the selection is uncollapsed?
Comment on attachment 189944 [details] [diff] [review] patch3 Yes, you're right. Probably I can use the isCollapsed property on the selection object to simplify this code even more: http://mozref.com/reference/objects/Selection#isCollapsed
Attachment #189944 - Flags: review?(mconnor)
Attached patch patch4Splinter Review
I've tested that this works correctly. There is a potential issue where you have multiple ranges and all of the instances of the ranges are collapsed, then you get the "View Selection Source", when you probably shouldn't, but I think that is a situation that virtually never happens.
Attachment #189944 - Attachment is obsolete: true
Attachment #191399 - Flags: review?(mconnor)
WFM Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8b4) Gecko/20050806 Firefox/1.0+ ID:2005080619 Context menu: Open Link in New Window Open Link in New Tab ---------------- Bookmark This Link... Save Link As... Send Link... Copy Link Location Copy ---------------- Search Web for "" View Selection Source Properties
Whiteboard: [ETA ?]
Whiteboard: [ETA ?] → [ETA ?][needs review mconnor]
Comment on attachment 191399 [details] [diff] [review] patch4 Please get this in on the trunk, and then request branch approval after a couple of days.
Attachment #191399 - Flags: review?(mconnor) → review+
Trunk: Checking in browser.js; /cvsroot/mozilla/browser/base/content/browser.js,v <-- browser.js new revision: 1.490; previous revision: 1.489 done
Status: NEW → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
Whiteboard: [ETA ?][needs review mconnor]
works well on Linux 2005-08-29-06-trunk
v.fixed with Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9a1) Gecko/20050829 Firefox/1.6a1. I see the same context menu as in comment #15. We should get this onto the branch.
Status: RESOLVED → VERIFIED
Attachment #191399 - Flags: approval1.8b4? → approval1.8b4+
1.8 Branch: Checking in browser.js; /cvsroot/mozilla/browser/base/content/browser.js,v <-- browser.js new revision: 1.479.2.20; previous revision: 1.479.2.19 done
Keywords: fixed1.8
verified on Firefox 1.4 -mozilla1.8 branch- Win, Lin and Mac : 2005-09-07
Keywords: fixed1.8verified1.8
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: