Bug 43385 - Range::create should not be calling deprecatedEditingOffset and node on start and end
Summary: Range::create should not be calling deprecatedEditingOffset and node on start...
Alias: None
Product: WebKit
Classification: Unclassified
Component: HTML Editing (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Ryosuke Niwa
Depends on:
Reported: 2010-08-02 15:33 PDT by Ryosuke Niwa
Modified: 2010-08-02 18:00 PDT (History)
5 users (show)

See Also:

fixes the bug (1.47 KB, patch)
2010-08-02 15:40 PDT, Ryosuke Niwa
eric: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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>