Closed Bug 190382 Opened 22 years ago Closed 22 years ago

selectionEnd off by one when user selects text via CMD/CTRL-A

Categories

(Core :: DOM: Core & HTML, defect, P3)

defect

Tracking

()

RESOLVED FIXED
mozilla1.3beta

People

(Reporter: chris, Assigned: kinmoz)

References

()

Details

Attachments

(1 file)

Text copied from my comment in Bug 88049. Please switch Platform/OS:ALL if
you're seeing this elsewhere.

Just trying to hack together some quick editor buttons (similar to that of
blogger and movable type) at hit some strange behavior (that is available in the
current testcase). It seems that when a user highlights all the text with the
mouse selectionEnd == length, however when selecting all text with CMD/CTRL-A
selectionEnd == length + 1. While inserting text at this higher value seems to
work properly, it screws with resetting focus in the following example:

http://placenamehere.com/Mozilla/js_textareas.html

You'll notice that if you select all the text in the textarea via CMD-A and then
hit one of the editor buttons it throws off my calculation for the new
selectionEnd and grabs the first character in the newly inserted tag.

My Build:
Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en-US; rv:1.3b) Gecko/20030122


While I can easily test that the selection isn't longer the then length in my
script to get it to work, should I have to? Is there a reason for this behavior?
Status: NEW → ASSIGNED
OS: MacOS X → All
Priority: -- → P3
Hardware: Macintosh → All
Summary: selectionEnd off by one when user selects text via CMD/CTRL-A → selectionEnd off by one when user selects text via CMD/CTRL-A
Target Milestone: --- → mozilla1.3final
Attached patch Patch Rev 1Splinter Review
Here's the patch that fixes the problem. We shouldn't be counting the last BR
under the root node as a character. I also fixed 3 warnings related to signed
comparisons.
Attachment #112463 - Flags: superreview?(sfraser)
Attachment #112463 - Flags: review?(jkeiser)
Attachment #112463 - Flags: superreview?(sfraser) → superreview+
Attachment #112463 - Flags: review?(jkeiser) → review+
Flags: blocking1.3b?
Comment on attachment 112463 [details] [diff] [review]
Patch Rev 1

a=asa (on behalf of drivers) for checkin to 1.3beta.
Attachment #112463 - Flags: approval1.3b+
Flags: blocking1.3b?
Keywords: nsbeta1+
Fix checked into TRUNK:

  mozilla/layout/html/forms/src/nsTextControlFrame.cpp  rev 3.114

Fix should appear in 8am trunk daily builds and the Mozilla 1.3 beta.
Status: ASSIGNED → RESOLVED
Closed: 22 years ago
Resolution: --- → FIXED
Target Milestone: mozilla1.3final → mozilla1.3beta
Confirming Fix on OS X/MachO Nightly:
Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.3b) Gecko/20030201

thx for the fast turnaround
Component: DOM: HTML → DOM: Core & HTML
QA Contact: stummala → general
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: