Closed
Bug 415707
Opened 17 years ago
Closed 16 years ago
multiple text selection improvement doesn't work with double-click "word-by-word" or triple-click "paragraph" modes
Categories
(Core :: DOM: Selection, defect)
Core
DOM: Selection
Tracking
()
RESOLVED
FIXED
mozilla1.9.1b2
People
(Reporter: metaxis, Assigned: uriber)
References
(Depends on 2 open bugs)
Details
Attachments
(2 files, 3 obsolete files)
18.76 KB,
patch
|
roc
:
review+
roc
:
superreview+
|
Details | Diff | Splinter Review |
2.90 KB,
patch
|
Details | Diff | Splinter Review |
User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.4; en-US; rv:1.9b2) Gecko/2007121014 Firefox/3.0b2 Build Identifier: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.4; en-US; rv:1.9b2) Gecko/2007121014 Firefox/3.0b2 Trying text selection improvements in the 3.0b2 rel notes, it behaves as if CMD was not held and forgets the first selection with CMD-double-click or CMD-triple-click. It does not matter how the first selection was made. Reproducible: Always Steps to Reproduce: 1. Click & drag to create a selection. 2. Then CMD-double-click or CMD-triple-click, with or without dragging, to add a selection. Actual Results: first selection is forgotten, a new selection is made Expected Results: A word or paragraph delimited selection should be added to the first selection, as should further selections of any type (char, word, pargraph) made with Ctrl/Cmd held down.
Assignee | ||
Updated•16 years ago
|
Component: General → Selection
Product: Firefox → Core
Assignee | ||
Comment 1•16 years ago
|
||
Confirming.
Status: UNCONFIRMED → NEW
Ever confirmed: true
QA Contact: general → selection
Comment 4•16 years ago
|
||
(In reply to comment #3) Bug 423624 shows the same problem in Beta 4 on Windows XP.
Assignee | ||
Comment 5•16 years ago
|
||
(In reply to comment #4) > (In reply to comment #3) > > Bug 423624 shows the same problem in Beta 4 on Windows XP. > Yeah, this is cross-platform. Marking All/All.
OS: Mac OS X → All
Hardware: Macintosh → All
Assignee | ||
Comment 6•16 years ago
|
||
This would have fixed it, I think, if not for bug 392746.
Assignee | ||
Comment 7•16 years ago
|
||
Comment on attachment 311130 [details] [diff] [review] WIP (depends on bug 392746) I verified that with my proposed fix for bug 392746, this patch does in fact fix this bug.
Attachment #311130 -
Attachment description: attempted fix (doesn't work) → patch (depends on bug 392746)
Assignee | ||
Updated•16 years ago
|
Assignee: nobody → uriber
Assignee | ||
Updated•16 years ago
|
Status: NEW → ASSIGNED
Assignee | ||
Comment 8•16 years ago
|
||
Comment on attachment 311130 [details] [diff] [review] WIP (depends on bug 392746) Actually, this fixes double[triple]-click, but not double[triple]-click-drag. Will have to look further into that.
Assignee | ||
Comment 9•16 years ago
|
||
Notes: 1. nsFrameSelection::MaintainSelection() uses the range at position 0. Should probably use mAnchorFocusRange instead. 2. nsFrameSelection::AdjustForMaintainedSelection() uses Collapse(), which collapses the entire selection. We need something that collapses just the current range.
Blocks: 73373
Assignee | ||
Updated•16 years ago
|
Attachment #311130 -
Attachment description: patch (depends on bug 392746) → WIP (depends on bug 392746)
Assignee | ||
Comment 10•16 years ago
|
||
This adds the two items mentioned in comment #9, and also removes part of nsFrameSelection::AdjustForMaintainedSelection() that is not necessary now that bug 16203 is fixed. Unfortunately, replacing the calls to Collapse() by calls to CopyRangeToAnchorFocus() causes "selection turds" (areas that remain highlighted after they're de-selected, until the window is re-focused) in certain cases. I tried calling Repaint() but that doesn't help. I'd appreciate help on this.
Attachment #311130 -
Attachment is obsolete: true
Attachment #341773 -
Flags: review?(roc)
The patch looks good other than that last issue. nsTypedSelection::Collapse does selectFrames and NotifySelectionListeners, but CopyRangeToAnchorFocus does not (but its caller nsTypedSelection::Extend does). I think you need to do those yourself. Or maybe you could extend Collapse so that it can optionally just collapse the current range.
Assignee | ||
Comment 12•16 years ago
|
||
Comment on attachment 341773 [details] [diff] [review] patch v0.9 Thanks for the feedback. I'll have a closer look when I have some time. Removing the review request for now.
Attachment #341773 -
Flags: review?(roc)
Assignee | ||
Comment 13•16 years ago
|
||
This is based on v0.9, with the following changes: - Added nsTypedSelection::ReplaceAnchorFocusRange(), that de-selects the frames of the current anchor/focus range before replacing it (and selecting the frames of the new range). It turns out that the de-selecting was the part I was actually missing (for the problem in comment 10), and since it's difficult to access the current anchor/focus range from nsFrameSelection, I had to implement this in nsTypedSelection. - Changed the implementation of AdjustForMaintainedSelection() (again), and restored its original API (so to not rely on the fix for bug 16203). This implementation is the most simple and elegant I could come up with. - Added nsTypedSelection::RemoveCollapsedRanges() and called it when adding a range for multiple-selection. This is not strictly necessary. I originally did it because I thought it would fix what turned out to be bug 459599. It does, in fact, reduce the probability of hitting that bug when ctrl-doubleclick-dragging, and I also think it's a reasonable thing to do (having collapsed ranges lying around doesn't help anyone). But if it's considered unnecessary, I'll remove it. As a side note, I think the current structure of nsFrameSelection vs. nsTypedSelection is flawed. I have some ideas how to refactor those classes to make more sense. I'll probably lay them out in a separate bug.
Attachment #341773 -
Attachment is obsolete: true
Attachment #342819 -
Flags: review?(roc)
Comment on attachment 342819 [details] [diff] [review] patch v1.0 Looks good. Would it be possible to write a test for this? I think you could, by synthesizing mouse events.
Attachment #342819 -
Flags: superreview+
Attachment #342819 -
Flags: review?(roc)
Attachment #342819 -
Flags: review+
Assignee | ||
Comment 15•16 years ago
|
||
(In reply to comment #14) > Would it be possible to write a test for this? I think you could, by > synthesizing mouse events. I tried generating a double-click selection using repeated calls to nsIDOMWindowUtils::sendMouseEvent, but nothing was actually selected. Martijn - have you ever done this? Can you point me to an example?
Assignee | ||
Comment 16•16 years ago
|
||
http://hg.mozilla.org/mozilla-central/rev/3632fa9aad9b
Status: ASSIGNED → RESOLVED
Closed: 16 years ago
Flags: in-testsuite?
Resolution: --- → FIXED
Target Milestone: --- → mozilla1.9.1b2
Comment 17•16 years ago
|
||
(In reply to comment #15) > I tried generating a double-click selection using repeated calls to > nsIDOMWindowUtils::sendMouseEvent, but nothing was actually selected. To simulate a double click, you need to send a mousedown then mouseup with clickCount=2, like this: utils.sendMouseEvent("mousedown", x, y, 0, 2, 0); utils.sendMouseEvent("mouseup", x, y, 0, 2, 0); (To accurately simulate a double click, you should probably send a mousedown/mouseup with clickCount=1 first, but I don't think it makes a practical difference.) If you have access to EventUtils.js, you can instead use synthesizeMouse() and pass {clickCount: 2} as the aEvent parameter.
Assignee | ||
Comment 18•16 years ago
|
||
Thanks, Gavin. My problem turned out to be that I didn't delay the test running using setTimeout(), as I apparently should have. This test *should* work cross-platform, but I only tested it on Mac. Could someone please test it on Windows/Linux? Also, any other comments are welcome, as I'm still pretty new to Mochitests.
Assignee | ||
Comment 19•16 years ago
|
||
Comment on attachment 343978 [details] [diff] [review] mochitest >+ // It's cmd+click on mack, ctrl+click otherwise. >+ var keyMask = (osString == "Darwin") ? 8 : 2; Where by "mack" I mean "Mac".
Assignee | ||
Comment 20•16 years ago
|
||
Using EventUtils.js, and including a workaround for bug 426195.
Attachment #343978 -
Attachment is obsolete: true
Assignee | ||
Comment 21•16 years ago
|
||
I'm not going to check in the test until bug 426195 is fixed, since the workaround seems to be unreliable (and even causes trouble on Linux). See also bug 459921.
Depends on: 426195
Comment 22•15 years ago
|
||
So... This patch changed the signature of a virtual nsFrame method, but didn't update any of the classes that overrode it. When compiling layout/xul, I get: In file included from /Users/bzbarsky/mozilla/css-frameconst/mozilla/layout/xul/base/src/nsScrollbarFrame.cpp:46: /Users/bzbarsky/mozilla/css-frameconst/mozilla/layout/xul/base/src/../../../generic/nsFrame.h:348: warning: ‘virtual nsresult nsFrame::HandleMultiplePress(nsPresContext*, nsGUIEvent*, nsEventStatus*, PRBool)’ was hidden /Users/bzbarsky/mozilla/css-frameconst/mozilla/layout/xul/base/src/nsScrollbarFrame.h:77: warning: by ‘virtual nsresult nsScrollbarFrame::HandleMultiplePress(nsPresContext*, nsGUIEvent*, nsEventStatus*)’ In file included from /Users/bzbarsky/mozilla/css-frameconst/mozilla/layout/xul/base/src/nsScrollbarFrame.cpp:47: /Users/bzbarsky/mozilla/css-frameconst/mozilla/layout/xul/base/src/../../../generic/nsFrame.h:348: warning: ‘virtual nsresult nsFrame::HandleMultiplePress(nsPresContext*, nsGUIEvent*, nsEventStatus*, PRBool)’ was hidden /Users/bzbarsky/mozilla/css-frameconst/mozilla/layout/xul/base/src/nsScrollbarButtonFrame.h:79: warning: by ‘virtual nsresult nsScrollbarButtonFrame::HandleMultiplePress(nsPresContext*, nsGUIEvent*, nsEventStatus*)’ etc, etc.
You need to log in
before you can comment on or make changes to this bug.
Description
•