Bug 43385

Summary: Range::create should not be calling deprecatedEditingOffset and node on start and end
Product: WebKit Reporter: Ryosuke Niwa <rniwa>
Component: HTML EditingAssignee: Ryosuke Niwa <rniwa>
Status: RESOLVED FIXED    
Severity: Normal CC: darin, enrica, eric, ojan, tony
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Attachments:
Description Flags
fixes the bug eric: review+

Description Ryosuke Niwa 2010-08-02 15:33:49 PDT
The version of Range::create that takes two positions calls deprecatedEditingOffset() and node() on start and end to create a range object.  Since these two methods are deprecated and have side-effects, we should be calling containerNode() and computeOffsetInContainerNode() instead.

A simple patch coming with the following change:

@@ -94,8 +94,7 @@
 
 PassRefPtr<Range> Range::create(PassRefPtr<Document> ownerDocument, const Position& start, const Position& end)
 {
-    // FIXME: we shouldn't be using deprecatedEditingOffset here
-    return adoptRef(new Range(ownerDocument, start.node(), start.deprecatedEditingOffset(), end.node(), end.deprecatedEditingOffset()));
+    return adoptRef(new Range(ownerDocument, start.containerNode(), start.computeOffsetInContainerNode(), end.containerNode(), end.computeOffsetInContainerNode()));
 }
Comment 1 Ryosuke Niwa 2010-08-02 15:40:50 PDT
Created attachment 63270 [details]
fixes the bug
Comment 2 Eric Seidel (no email) 2010-08-02 15:42:41 PDT
Comment on attachment 63270 [details]
fixes the bug

I wonder if this is tesable.  It's obviously wrong, but I wonder how we would trigger it.

This should make it so we don't need to call rangeCompliantPosition on positions before passing them to this function. :)  So we could remove that in a later patch.
Comment 3 Ryosuke Niwa 2010-08-02 18:00:11 PDT
Committed r64516: <http://trac.webkit.org/changeset/64516>