RESOLVED INVALID 73762
Selecting text by double-clicking a word gives incorrect start/end offsets to javascript
https://bugs.webkit.org/show_bug.cgi?id=73762
Summary Selecting text by double-clicking a word gives incorrect start/end offsets to...
Peter Kelly
Reported 2011-12-03 21:35:59 PST
Summary: Using javascript, it is possible to determine the current text selection on a page by calling window.getSelection(). This contains the fields baseNode, baseOffset, endNode, and endOffset representing the start and end of the selection. When text is selected by pressing the mouse button and dragging, these offsets are set correctly. When double-clicking a word, the start and end offset are incorrect - they are equal to the same value, which is part-way through the word. Steps to Reproduce: Open the attacked file in Safari. Double-click on the word "some", then click "Show selection" Expected Results: The dialog should show the following: baseNode = [object Text] baseOffset = 8 extentNode = [object Text] extentOffset = 12 Actual Results: The dialog shows the following: baseNode = [object Text] baseOffset = 11 extentNode = [object Text] extentOffset = 11 Regression: Notes: This problem occurs in both Safari 5.1.2 (7534.52.7) and Chrome 15.0.874.121. I am running Mac OS X 10.7.2.
Attachments
Alexey Proskuryakov
Comment 1 2011-12-04 20:58:12 PST
This is correct behavior - base and extent positions are the same when double clicking. The properties you are looking for are anchor{Node|Offset} and focus{Node|Offset}.
Note You need to log in before you can comment on or make changes to this bug.