Closed Bug 58028 Opened 24 years ago Closed 24 years ago

compareBoundaryPoints returns opposite value

Categories

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

defect

Tracking

()

VERIFIED FIXED
mozilla0.9

People

(Reporter: mail, Assigned: anthonyd)

Details

(Keywords: testcase, Whiteboard: FIX IN HAND)

Attachments

(5 files)

From Bugzilla Helper: BuildID: 2000100908 The comparison of boundary points in DOM Level 2 Range returns the opposite value as listed in the spec. -1 in place of 1 and vice versa. Reproducible: Always Steps to Reproduce: 1. Run testcase Actual Results: compareBoundaryPoints should have returned 1 for all four scenarios, but returnes -1 instead. I believe the reference is backwards. Expected Results: return 1 for all four cases Testcase to follow Spec statement: 2.5. Comparing Range Boundary-Points It is possible to compare two Ranges by comparing their boundary-points: short compareBoundaryPoints(in CompareHow how, in Range sourceRange) raises (RangeException); where CompareHow is one of four values: START_TO_START, START_TO_END, END_TO_END and END_TO_START. The return value is -1, 0 or 1 depending on whether the corresponding boundary-point of the Range is before, equal to, or after the corresponding boundary-point of sourceRange. I believe it is giving the sourceRange relative to the range, rather than the range relative tot eh sourceRange.
Priority: P3 → P5
Keywords: testcase
Confirming and reassigning, this needs to be fixed ASAP in mozilla, setting to milestone mozilla0.9.
Assignee: jst → anthonyd
Status: UNCONFIRMED → NEW
Ever confirmed: true
Keywords: correctness
OS: Windows 2000 → All
Priority: P5 → P3
Hardware: PC → All
Target Milestone: --- → mozilla0.9
setting to p1 anthonyd
Status: NEW → ASSIGNED
Priority: P3 → P1
attaching new test case. much conferring with kin. START_TO_END and END_TO_START are returning the opposite values. adding kin a jfrancis to cc list. anthonyd
Attached file new test case
Just to be clear, it seems that our interpretation of the constants START_TO_START, START_TO_END, END_TO_START, and END_TO_END was different from what the spec now says. For example, according to the spec, it says that START_TO_END refers to the start of the source range, and the end of the boundary range, but our implementation is actually comparing the start of the boundary range against the end of the source range. Fixing this is a simple matter of fixing the switch statement in nsRange::CompareBoundaryPoints(), but we also need to make sure the editor code that uses CompareBoundaryPoints() is also corrected.
By the way the definition of the *_TO_* constants http://www.w3.org/TR/2000/REC-DOM-Level-2-Traversal-Range-20001113/ranges.html seems backwards to me, especially if you were to think of them as saying: "Compare *_TO_*"
actually, after re-reading what kin and I talked about for this bug, the switch cases are all fine, just the return values were incorrect, and the looks like there was a small problem with that. I re-wrote the code to make it a bit more clear what should be happening, and I changed the corresponding code in htmlrules. I will attach a patch for kin and joe (and anyone else for that matter) to look at. anthonyd
need reviewers and approval. anthonyd
Whiteboard: FIX IN HAND
can i get some r= and a= please? anthonyd
r=jst
r,a=kin@netscape.com (a= assuming that the Editor group now owns range code?)
Status: ASSIGNED → RESOLVED
Closed: 24 years ago
Resolution: --- → FIXED
fix is checked in. anthonyd
Component: DOM Level 2 → DOM Traversal-Range
catching up on verifications
Status: RESOLVED → VERIFIED
Component: DOM: Traversal-Range → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: