-
- Downloads
Bug 1810403: Allow `nsRange`s to be in multiple `Selection`s. r=masayuki
The Custom Highlight API allows a use case where a `Range` of a `Highlight` is also used as `Selection`. Due to the decision to use the `Selection` mechanism to display `Highlight`s, a `Range` can be part of several `Selection`s. Since the `Range` has a pointer to its associated `Selection` to notify about changes, this must be adapted to allow several `Selections`. As a tradeoff of performance and memory usage, the `Selection`s are stored as `mozilla::LinkedList`. A helper class `mozilla::SelectionListWrapper` was implemented to allow `Selection`s to be in multiple of these lists and without having to be derived from `LinkedListElement<T>`. To simplify usage of the list, the use case "does this range belong to Selection x?" is wrapped into the convenience method`IsInSelection(Selection&)`; The method previously named like this was renamed to `IsInAnySelection()` to be named more precisely. Registering and unregistering of the closest common inclusive ancestor of the `Range` is done when the first `Selection` is registered and the last `Selection` is unregistered. Differential Revision: https://phabricator.services.mozilla.com/D169597
Showing
- dom/base/Selection.cpp 19 additions, 25 deletionsdom/base/Selection.cpp
- dom/base/Selection.h 6 additions, 3 deletionsdom/base/Selection.h
- dom/base/nsINode.cpp 5 additions, 8 deletionsdom/base/nsINode.cpp
- dom/base/nsRange.cpp 95 additions, 38 deletionsdom/base/nsRange.cpp
- dom/base/nsRange.h 38 additions, 9 deletionsdom/base/nsRange.h
- editor/libeditor/AutoRangeArray.cpp 2 additions, 2 deletionseditor/libeditor/AutoRangeArray.cpp
- editor/libeditor/WSRunObject.cpp 1 addition, 1 deletioneditor/libeditor/WSRunObject.cpp
- extensions/spellcheck/src/mozInlineSpellChecker.cpp 6 additions, 5 deletionsextensions/spellcheck/src/mozInlineSpellChecker.cpp
- layout/generic/nsFrameSelection.cpp 1 addition, 1 deletionlayout/generic/nsFrameSelection.cpp
- testing/web-platform/mozilla/meta/dom/range-in-two-selections.html.ini 1 addition, 0 deletions...latform/mozilla/meta/dom/range-in-two-selections.html.ini
- testing/web-platform/mozilla/tests/dom/range-in-two-selections.html 34 additions, 0 deletions...b-platform/mozilla/tests/dom/range-in-two-selections.html
Loading
Please register or sign in to comment