Bug 73762
Summary: | Selecting text by double-clicking a word gives incorrect start/end offsets to javascript | ||
---|---|---|---|
Product: | WebKit | Reporter: | Peter Kelly <kellypmk> |
Component: | DOM | Assignee: | Nobody <webkit-unassigned> |
Status: | RESOLVED INVALID | ||
Severity: | Normal | CC: | ap |
Priority: | P2 | ||
Version: | 528+ (Nightly build) | ||
Hardware: | Mac | ||
OS: | OS X 10.7 |
Peter Kelly
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 | ||
---|---|---|
Add attachment proposed patch, testcase, etc. |
Alexey Proskuryakov
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}.