Closed Bug 1927549 Opened 1 year ago Closed 1 year ago

Refactor `nsFrameSelection::CreateRangeExtendedToSomewhere()` to remove dependency of `Selection`

Categories

(Core :: DOM: Selection, task)

task

Tracking

()

RESOLVED FIXED
134 Branch
Tracking Status
firefox134 --- fixed

People

(Reporter: jjaschke, Assigned: jjaschke)

References

(Blocks 3 open bugs)

Details

Attachments

(5 files, 1 obsolete file)

nsFrameSelection::CreateRangeExtendedToSomewhere() currently expects the range to be extended to be the first range of the normal Selection.
However, extending a range by a word comes in handy when implementing an algorithm to create a text fragment from a range (Bug 1876524), in which no Selection is present (instead only nsRanges), among other use cases.

This bug moves the logic to extend a range by an amount into SelectionMovementUtils and removes the dependency of Selection.

This new helper function can move a range boundary by aAmount without requiring to be in a selection.

Attachment #9433738 - Attachment is obsolete: true
Attachment #9433836 - Attachment description: WIP: Bug 1927549, part 1: Introduce enum `ExtendSelection` in `nsFrameSelection`. r=masayuki! → Bug 1927549, part 1: Introduce enum `ExtendSelection` in `nsFrameSelection`. r=masayuki!
Attachment #9433837 - Attachment description: WIP: Bug 1927549, part 2: Moved logic of `nsFrameSelection::PeekOffsetForCaretMove()` into helper methods. r=masayuki! → Bug 1927549, part 2: Moved logic of `nsFrameSelection::PeekOffsetForCaretMove()` into helper methods. r=masayuki!
Attachment #9433838 - Attachment description: WIP: Bug 1927549, part 3: Introduced `SelectionMovementUtils::MoveRangeBoundaryToSomewhere()`. r=masayuki! → Bug 1927549, part 3: Introduced `SelectionMovementUtils::MoveRangeBoundaryToSomewhere()`. r=masayuki!

The logic of this method was moved into helper methods in part 2 of this patchset.
Now, there was only one caller left.
So, we can easily move the code into the one call site and get rid of the method.

Pushed by jjaschke@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/ac1cca025807 part 1: Introduce enum `ExtendSelection` in `nsFrameSelection`. r=masayuki https://hg.mozilla.org/integration/autoland/rev/2f6e8e5ac5dd part 2: Moved logic of `nsFrameSelection::PeekOffsetForCaretMove()` into helper methods. r=masayuki https://hg.mozilla.org/integration/autoland/rev/f0ba0a69319a part 3: Introduced `SelectionMovementUtils::MoveRangeBoundaryToSomewhere()`. r=masayuki https://hg.mozilla.org/integration/autoland/rev/dc7e27f6058a part 4: Renamed `aContinueSelection` to `aExtendSelection` to align with the enum name. r=masayuki https://hg.mozilla.org/integration/autoland/rev/27cbe2030881 part 5: Moved content of `nsFrameSelection::PeekOffsetForCaretMove()` into `nsFrameSelection::MoveCaret()`. r=masayuki https://hg.mozilla.org/integration/autoland/rev/89ffb15c23a7 apply code formatting via Lando
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: