Closed Bug 1810403 Opened 2 years ago Closed 2 years ago

Allow Ranges to be in multiple Selections

Categories

(Core :: DOM: Selection, task)

task

Tracking

()

RESOLVED FIXED
112 Branch
Tracking Status
firefox112 --- fixed

People

(Reporter: jjaschke, Assigned: jjaschke)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

Currently a nsRange can only be associated with one Selection instance. To support the custom highlight API, for which we use the Selection mechanism to display highlights, it must be possible for a Range to be part of multiple Selections.

This should be as simple as replacing nsRange::mSelection with a nsTArray<RefPtr<Selection>> and updating the RegisterSelection()/UnregisterSelection() methods.

Blocks: 1803355
Blocks: css-highlight-api-1
No longer blocks: 1803355

The Custom Highlight API allows a use case where a Range of a Highlight
is used as Selection. Due to the decision to use the Selection mechanism
to display Highlights, this results in the possibility of a Range
being part of several Selections. Since the Range has a pointer to
its associated Selection to notify about changes, this must be adapted
to allow several Selections.

For performance and memory reasons and acknowledging that
in the overwhelming majority of cases only one Selection will
be associated with a nsRange, the Selections are divided into
one single Selection (mSelection) and an array of additional
Selections (mAdditionalSelections).
When several Selections are present and the first one is removed,
one of the other Selections is moved out of the array,
guaranteeing that mSelection is not null.

Registering and unregistering of the closest common inclusive ancestor
of the Range happens when the first Selection is registered and
the last Selection is unregistered.

Attachment #9317287 - Attachment description: WIP: Bug 1810403: Allow `nsRange`s to be in multiple `Selection`s. r=masayuki → Bug 1810403: Allow `nsRange`s to be in multiple `Selection`s. r=masayuki
Pushed by jjaschke@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/389f129ba5e2 Allow `nsRange`s to be in multiple `Selection`s. r=masayuki
Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 112 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: