Closed Bug 643671 Opened 13 years ago Closed 13 years ago

some of the range and selection API's are behaving differently than specified in standards.

Categories

(Core :: General, defect)

x86
Windows 7
defect
Not set
normal

Tracking

()

VERIFIED FIXED

People

(Reporter: tgvrs_santhosh, Unassigned)

Details

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.151 Safari/534.16
Build Identifier: 4.0 RC2 (Built from http://hg.mozilla.org/releases/mozilla-2.0/rev/6be9e31d01b4)

when i select the content from right to left, range.startOffset is greater than range.endOffset.

when i select the content from right to left, selection.collapseToStart is causing anchor node to move to the focus node rather than the reverse order.

Reproducible: Always

Steps to Reproduce:
Range Defect:

1. I understood from Document Object Model Range that the start position of the range is gauranteed to never be after the end position.


 "The start position of a Range is guaranteed to never be after the end position. To enforce this restriction, if the start is set to be at a position after the end, the Range is collapsed to that position. Similarly, if the end is set to be at a position before the start, the Range is collapsed to that position."


2. But, in a case, when i select the text from right to left whose boundary points have the common parent i.e startNode and endNode are same, there the startOffset is greater than the endOffset. 

3. Is it not violating the above rule? here start position is greater than the end position.

Selection Defect:

1. I understood from mozilla development center that, selection.collpaseToEnd should collapse the selection such that the focus node remain at the same position but anchor node will move.

similarly, for selection.collapseToStart, anchor Node will remain in the same position but focus Node will move.

2. But if i do reverse selection i.e from right to left, and if i call collapseToStart(), it is behaving in opposite way. i.e moving anchor to the focus rather from focus to anchor.

similarly for collapseToEnd()
Actual Results:  
range.startOffset is greater than range.endOffset (when startcontainer and endcontainer are same)

collapseToStart is causing anchor node to move to focus node. vice versa for collapseToEnd

Expected Results:  
range.endOffset always should be greater than range.startOffset (when startcontainer and endcontainer are same)

collapseToStart should move focus node to anchor node. vice versa for collapseToEnd
> Steps to Reproduce:

You sort of need this part.  I just tried selecting some text from right to left on this page.  The result of window.getSelection().getRangeAt(0).endOffset was 1136.  The startOffset was 1120.  So as far as I can tell, I can't reproduce your issue #2.  Explicit steps that describe what you're doing to reproduce it are needed.

> I understood from mozilla development center

That documentation was just wrong.  Thank you for pointing that out.  I've fixed it.
Hi Boris,

I mistaken rangeObj.startContainer with selectionObj.anchorNode. Yes, first issue is not valid and as you fixed second issue (documentation issue), you can close the defect.
Status: UNCONFIRMED → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
As per Comment 2 setting resolution to Verified Fixed.
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.