DescriptionLet Selection.collapse remember a raw Position instead of a canonicalized one.
This patch fixes a long-standing editing bug that a Range object returned by
Selection.getRangeAt() may not be equivalent to the Range used to set selection
with Selection.collapse().
FrameSelection.setSelectedRange sets a Range without canonicalization:
https://src.chromium.org/viewvc/blink?revision=169100&view=revision
Hence this patch adopts it.
Following is the implementation detail.
DOMSelection.cpp:
- When selection.collapse(node, offset) is called, we create a caret Range corresponding to node and offset and pass it to FrameSelection.setSelectedRange.
FrameSelection.cpp:
- If new Selection is collapsed, use old isDirectional. This is following the current behavior.
LayoutTests:
editing/selection/no-range-canonicalization.html
- The main test added to current setRange test.
fast/css/counters/counter-before-content-not-incremented.html
- Some tests expect the collapse method to canonicalize Selection so we need to set a exact DOM position.
editing/editing.js
- Some tests expect the collapse method to canonicalize Selection at start so I canonicalize that as the old Blink collapse implementation.
editing/selection/DOMSelection-DocumentType.html
- The current HTML spec says that if Range is set DocumentType node, we should throw type exception.
editing/selection/selection-invalid-offset.html
- We should throw exception when the method is called with a offset larger than length of a node.
- Remove a redundant case.
BUG=346613
Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=175779
Patch Set 1 : Rebase #
Total comments: 8
Patch Set 2 : Update editing.js to canonicalize Position #Patch Set 3 : Fix setSelectedRange arguments #
Total comments: 4
Messages
Total messages: 37 (0 generated)
|