Commit Graph
111 Commits
Author SHA1 Message Date
Jan-Niklas Jaeschke 0b2d030087 Bug 2030660 - Remove dom.shadowdom.selection_across_boundary.enabled pref. r=masayuki,webidl
Differential Revision: https://phabricator.services.mozilla.com/D293086
2026-04-10 08:02:43 +00:00
Sylvestre Ledru 9eb1a31a98 Bug 2023419 - Remove Emacs/Vim modelines from dom/ r=emilio,media-playback-reviewers,webidl,padenot
replaced by .editorconfig
# ignore-this-changeset

Differential Revision: https://phabricator.services.mozilla.com/D287843
2026-03-16 21:02:32 +00:00
Norisz Fay a86d829321 Revert "Bug 2012637 - part 9: Add a Firefox Source Docs documentation page for TreeKind and notable issues r=smaug,dom-core" as requested by dev
This reverts commit 88008cd8ca.

Revert "Bug 2012637 - part 8: Make `nsContentUtils::ComparePoints` handle `TreeKind::Flat` and `TreeKind::FlatForSelection` correctly r=smaug,dom-core"

This reverts commit 73e6f6587b.

Revert "Bug 2012637 - part 7: Make `RangeUtils::CompareNodeToRangeBoundaries()` use `nsContentUtils::ComparePoints` with valid point in the tree r=smaug"

This reverts commit 6985d5e80f.

Revert "Bug 2012637 - part 6: Make `nsRange::CutContents()` convert the range boundaries to the ones in the DOM before comparing r=smaug"

This reverts commit 73b585af3d.

Revert "Bug 2012637 - part 5: Delete the default template parameter of `nsContentUtils::ComparePoints` and relatives r=smaug,dom-core"

This reverts commit 1a7f24e5b5.

Revert "Bug 2012637 - part 4: Make `nsContentUtils` use `nsIContent` for taking a child node as a parameter r=smaug"

This reverts commit a6ea8d6824.

Revert "Bug 2012637 - part 3: Add template `nsINode` API which can switch to call API from `TreeKind` r=smaug,dom-core,webidl"

This reverts commit a4211e9df0.

Revert "Bug 2012637 - part 2: Add `TreeKind::FlatForSelection` and change the template parameter of `ChildIteratorBase` to `TreeKind` r=smaug,dom-core"

This reverts commit 0241749ee7.

Revert "Bug 2012637 - part 1: Make `ChildIterBase` template class to re-implement `FlattenedChildIterator` for DOM, Flat and FlatForSelection TreeKind r=smaug,dom-core,layout-reviewers,emilio"

This reverts commit 9e71cb77fb.
2026-03-13 02:52:45 +00:00
Masayuki Nakano 1a7f24e5b5 Bug 2012637 - part 5: Delete the default template parameter of nsContentUtils::ComparePoints and relatives r=smaug,dom-core
They accept any kind of points even if it does not match with the
template parameter's `TreeKind` because the caller wants to check the
relation in different kind of tree.  Therefore, any callers need to
consider the `TreeKind` more carefully and clarify the `TreeKind` makes
developers easier to find a bug.

Differential Revision: https://phabricator.services.mozilla.com/D281308
2026-03-12 03:01:54 +00:00
Masayuki Nakano 0241749ee7 Bug 2012637 - part 2: Add TreeKind::FlatForSelection and change the template parameter of ChildIteratorBase to TreeKind r=smaug,dom-core
This add `TreeKind::FlatForSelection` which should ignore the UA shadow
trees which are created in `<details>`, `<video>`, SVG `<use>`, etc
because their children are not selectable or slotted and reordered by
the shadow tree so that `Selection` and `AbstractRange` need to work
with their children in the non-flattened tree.

This patch does not change the behavior. It'll be done by a following
patch.

Differential Revision: https://phabricator.services.mozilla.com/D281304
2026-03-12 03:01:48 +00:00
Jan-Niklas Jaeschke 25d7139059 Bug 1917991, part 1.1 - HighlightsFromPoint: Move GetClientRect into AbstractRange: MoveRangeSubtreeIterator into ContentIterator file. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D244189
2026-03-03 13:29:05 +00:00
Atila Butkovits 9075bc6e17 Revert "Bug 1917991, part 4 - HighlightsFromPoint: Add more test cases. r=emilio" for causing bustages at Highlight.cpp.
This reverts commit 53c20dba9c.

Revert "Bug 1917991, part 3 - HighlightsFromPoint: Implement `HighlightsFromPoint()`. r=emilio"

This reverts commit 6b88681d64.

Revert "Bug 1917991, part 2 - HighlightsFromPoint: Implement webidl interface. r=emilio,webidl,smaug"

This reverts commit be1f3a6f50.

Revert "Bug 1917991, part 1.2 - HighlightsFromPoint: Move GetClientRect() into AbstractRange. r=emilio"

This reverts commit 10c28cc410.

Revert "Bug 1917991, part 1.1 - HighlightsFromPoint: Move GetClientRect into AbstractRange: Move`RangeSubtreeIterator` into `ContentIterator` file. r=emilio"

This reverts commit 9c569a7957.
2026-03-03 12:06:10 +00:00
Jan-Niklas Jaeschke 9c569a7957 Bug 1917991, part 1.1 - HighlightsFromPoint: Move GetClientRect into AbstractRange: MoveRangeSubtreeIterator into ContentIterator file. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D244189
2026-03-03 07:06:49 +00:00
Masayuki Nakano f880cd0ef8 Bug 2010730 - Rewrite RangeBoundaryBase::AsRangeBoundaryInFlatTree() r=jjaschke,smaug,dom-core
Currently, the method may return unset boundary.  However, we need to
map a DOM tree point to a flat tree point.

The wrong point of current implementation is, the method respect the
container and offset. However, that may be wrong if the pointing child
node is moved into a `<slot>` or a `ShadowRoot`. Instead, this patch
computes proper parent from pointing child node if there is.

(I think there should be `nsINode::ComputeFlatTreeIndexOfForSelection`
or something, but I'd like to put off doing that later because it'd
affect to wider scope of our code.)

Differential Revision: https://phabricator.services.mozilla.com/D279308
2026-01-25 23:20:58 +00:00
Masayuki Nakano 4fa12d7518 Bug 2009323 - part 1: Make RangeBoundaryBase have some factory methods which take only a child node r=jjaschke,dom-core
`RangeBoundaryBase` allows to be initialized with invalid data for
allowing the users to use it as a validator.  However, this is bad,
and now it supports 2 tree kinds.  So, the users need to be familiar
with the relation of a child node and its parent and its offset when
they use `TreeKind::Flat`.  For making it easier to use, this patch
adds some new factory methods which automatically computes proper
parent/offset for a node with the `TreeKind`.

Differential Revision: https://phabricator.services.mozilla.com/D279306
2026-01-25 23:20:51 +00:00
agoloman 83e701e107 Revert "Bug 2009323 - part 2: Make RangeBoundaryBase disallow invalid DOM point at creation when pointing to a child node r=jjaschke,dom-core" for causing conflicts when backing out Bug 2009323.
This reverts commit 5728aae19d.

Revert "Bug 2009323 - part 1: Make `RangeBoundaryBase` have some factory methods which take only a child node r=jjaschke,dom-core"

This reverts commit 41c5bea4d5.
2026-01-23 14:51:12 +00:00
agoloman 96800d940e Revert "Bug 2010730 - Rewrite RangeBoundaryBase::AsRangeBoundaryInFlatTree() r=jjaschke,smaug,dom-core" for causing wpt failures @setBaseAndExtent-start-or-end-in-anonymous-shadow-container.html.
This reverts commit 34e2538a71.
2026-01-23 06:51:38 +00:00
Masayuki Nakano 34e2538a71 Bug 2010730 - Rewrite RangeBoundaryBase::AsRangeBoundaryInFlatTree() r=jjaschke,smaug,dom-core
Currently, the method may return unset boundary.  However, we need to
map a DOM tree point to a flat tree point.

The wrong point of current implementation is, the method respect the
container and offset. However, that may be wrong if the pointing child
node is moved into a `<slot>` or a `ShadowRoot`. Instead, this patch
computes proper parent from pointing child node if there is.

(I think there should be `nsINode::ComputeFlatTreeIndexOfForSelection`
or something, but I'd like to put off doing that later because it'd
affect to wider scope of our code.)

Differential Revision: https://phabricator.services.mozilla.com/D279308
2026-01-23 05:21:05 +00:00
Masayuki Nakano 41c5bea4d5 Bug 2009323 - part 1: Make RangeBoundaryBase have some factory methods which take only a child node r=jjaschke,dom-core
`RangeBoundaryBase` allows to be initialized with invalid data for
allowing the users to use it as a validator.  However, this is bad,
and now it supports 2 tree kinds.  So, the users need to be familiar
with the relation of a child node and its parent and its offset when
they use `TreeKind::Flat`.  For making it easier to use, this patch
adds some new factory methods which automatically computes proper
parent/offset for a node with the `TreeKind`.

Differential Revision: https://phabricator.services.mozilla.com/D279306
2026-01-23 05:14:49 +00:00
Emilio Cobos Álvarez 2a3733e687 Bug 2006613 - Optimize front-removal of various tree-ordered-arrays. r=smaug
The previous approach wasn't quite sound, because it makes the frame
constructor receive the WillBeRemoved after the flat tree has already
changed.

Instead, what do you think about something like this? This creates a
very simple wrapper over an array, but special-cases removals from the
front, and uses it for TreeOrderedArray and also AssignedNodes...

It could be polished (in particular there are a few places where an
Span::IndexOf operator could be beneficial and so).

Differential Revision: https://phabricator.services.mozilla.com/D277301
2025-12-22 21:03:58 +00:00
Norisz Fay ac500ea570 Revert "Bug 2006613 - Optimize front-removal of various tree-ordered-arrays. r=smaug" for causing multiple failures and bustages
This reverts commit 4d02f992d0.
2025-12-22 19:45:18 +00:00
Emilio Cobos Álvarez 4d02f992d0 Bug 2006613 - Optimize front-removal of various tree-ordered-arrays. r=smaug
The previous approach wasn't quite sound, because it makes the frame
constructor receive the WillBeRemoved after the flat tree has already
changed.

Instead, what do you think about something like this? This creates a
very simple wrapper over an array, but special-cases removals from the
front, and uses it for TreeOrderedArray and also AssignedNodes...

It could be polished (in particular there are a few places where an
Span::IndexOf operator could be beneficial and so).

Differential Revision: https://phabricator.services.mozilla.com/D277301
2025-12-22 18:35:29 +00:00
Emilio Cobos Álvarez 791917d8af Bug 1976665 - Sort headers in dom/. r=dom-core,media-playback-reviewers,webrtc-reviewers,dom-storage-reviewers,padenot,janv,smaug,jesup,jib
Most changes are automated. Relevant bit is dom/.clang-format. I had to
manually disable clang-format in a few places where importing external
files and so on that aren't self-contained, and fix a couple includes /
forward declarations.

Differential Revision: https://phabricator.services.mozilla.com/D256800
2025-08-05 11:47:34 +00:00
Sean Feng 8b9e726102 Bug 1975990 - Fix the parent assertion in RangeBoundary when it's for flat tree r=smaug
When parent is a shadow host and the boundary is for flat tree, it
should use the corresponding shadow root to get the children, it
shouldn't use the light DOM children.

Differential Revision: https://phabricator.services.mozilla.com/D256670
2025-07-11 02:48:25 +00:00
Sean Feng 81b802d1df Bug 1968960 - Make ContentSubtreeIterator iterates slot element normally if it doesn't have assigned nodes r=jjaschke,dom-core
Differential Revision: https://phabricator.services.mozilla.com/D252884
2025-06-09 13:37:45 +00:00
Sean Feng e6a6045ffb Bug 1965664 - Fix some crashes in ContentSubtreeIterator r=jjaschke,dom-core
by skipping the shadow hosts that ShadowDOM selection doesn't
support at the moment.

Differential Revision: https://phabricator.services.mozilla.com/D248917
2025-05-13 00:23:43 +00:00
Sean Feng 8bf705cca5 Bug 1965634 - Fix perma assertion failure in RangeUtils.cpp r=dom-core,jjaschke
Differential Revision: https://phabricator.services.mozilla.com/D248694
2025-05-10 16:14:31 +00:00
Sean Feng 63dc851a46 Bug 1932150 - ContentSubtreeIterator #3: Fix a bug in ContentSubtreeIterator where the end container is in the light DOM of a shadow host r=jjaschke
When the end container is in light DOM of a shadow host, we stop the
iteration after we have finished iterating the shadow root of it.

Differential Revision: https://phabricator.services.mozilla.com/D246953
2025-05-09 18:19:15 +00:00
Sean Feng 2e03bcf894 Bug 1932150 - ContentSubtreeIterator #2: Allow ContentSubtreeIterator to iterate nodes in flattened tree r=jjaschke
Differential Revision: https://phabricator.services.mozilla.com/D246952
2025-05-09 18:19:11 +00:00
Sean Feng 6f630ad3ce Bug 1932150 - ContentSubtreeIterator #1: Make the end container related logic in ContentSubtreeIterator more robust r=jjaschke,smaug,dom-core
This is more like a fix to the current logic. The end container could
be in a shadow tree of a shadow host, or in the light DOM of a shadow
host.

When ContentSubtreeIterator reaches to an ancestor of the end container,
it should decide whether dive to the shadow tree or not based on
the true info, not depends on a guess.

Differential Revision: https://phabricator.services.mozilla.com/D246951
2025-05-09 18:19:08 +00:00
Sean Feng 322a5282b6 Bug 1932150 - Fix some inconsistency about indicating whether the selection is allowed to cross the shadow boundary r=jjaschke,dom-core
Differential Revision: https://phabricator.services.mozilla.com/D246949
2025-05-09 18:18:57 +00:00
Serban Stanca 5290701da0 Revert "Bug 1932150 - Fix some inconsistency about indicating whether the selection is allowed to cross the shadow boundary r=jjaschke,dom-core"
This reverts commit f0836d70a7.
2025-05-08 20:00:35 +00:00
Serban Stanca f0fe413ca6 Revert "Bug 1932150 - ContentSubtreeIterator #1: Make the end container related logic in ContentSubtreeIterator more robust r=jjaschke,smaug,dom-core"
This reverts commit e2fc06c5c6.
2025-05-08 20:00:24 +00:00
Serban Stanca a3337cbf2a Revert "Bug 1932150 - ContentSubtreeIterator #2: Allow ContentSubtreeIterator to iterate nodes in flattened tree r=jjaschke"
This reverts commit 65bfc49c52.
2025-05-08 20:00:20 +00:00
Serban Stanca 69a21cb95c Revert "Bug 1932150 - ContentSubtreeIterator #3: Fix a bug in ContentSubtreeIterator where the end container is in the light DOM of a shadow host r=jjaschke"
This reverts commit 9e81625107.
2025-05-08 20:00:17 +00:00
Sean Feng 9e81625107 Bug 1932150 - ContentSubtreeIterator #3: Fix a bug in ContentSubtreeIterator where the end container is in the light DOM of a shadow host r=jjaschke
When the end container is in light DOM of a shadow host, we stop the
iteration after we have finished iterating the shadow root of it.

Differential Revision: https://phabricator.services.mozilla.com/D246953
2025-05-08 13:40:15 +00:00
Sean Feng 65bfc49c52 Bug 1932150 - ContentSubtreeIterator #2: Allow ContentSubtreeIterator to iterate nodes in flattened tree r=jjaschke
Differential Revision: https://phabricator.services.mozilla.com/D246952
2025-05-08 13:40:11 +00:00
Sean Feng e2fc06c5c6 Bug 1932150 - ContentSubtreeIterator #1: Make the end container related logic in ContentSubtreeIterator more robust r=jjaschke,smaug,dom-core
This is more like a fix to the current logic. The end container could
be in a shadow tree of a shadow host, or in the light DOM of a shadow
host.

When ContentSubtreeIterator reaches to an ancestor of the end container,
it should decide whether dive to the shadow tree or not based on
the true info, not depends on a guess.

Differential Revision: https://phabricator.services.mozilla.com/D246951
2025-05-08 13:40:08 +00:00
Sean Feng f0836d70a7 Bug 1932150 - Fix some inconsistency about indicating whether the selection is allowed to cross the shadow boundary r=jjaschke,dom-core
Differential Revision: https://phabricator.services.mozilla.com/D246949
2025-05-08 13:39:57 +00:00
Atila Butkovits da71eedf0a Revert "Bug 1932150 - Fix build bustage" for causing build bustages.
This reverts commit 0681b181d6.

Revert "Bug 1932150 - Fix lint failure" for causing Build bustage.

This reverts commit 60cc0878d3.

Revert "Bug 1932150 - Add new test cases for selection in flat tree r=smaug"

This reverts commit 3dbe5fc183.

Revert "Bug 1932150 - Make selection code to correctly iterate flattened tree r=smaug"

This reverts commit 6f7a1e4886.

Revert "Bug 1932150 - ContentSubtreeIterator #3: Fix a bug in ContentSubtreeIterator where the end container is in the light DOM of a shadow host r=jjaschke"

This reverts commit 19ce2c5806.

Revert "Bug 1932150 - ContentSubtreeIterator #2: Allow ContentSubtreeIterator to iterate nodes in flattened tree r=jjaschke"

This reverts commit d9d192bc3a.

Revert "Bug 1932150 - ContentSubtreeIterator #1: Make the end container related logic in ContentSubtreeIterator more robust r=jjaschke,smaug,dom-core"

This reverts commit 2fbde5b84d.

Revert "Bug 1932150 - Update ranges to correctly set and update nodes for flattened selection r=jjaschke,smaug,dom-core"

This reverts commit 116d26c37f.

Revert "Bug 1932150 - Allow using flat tree order for point comparing in selection r=jjaschke,smaug,dom-core"

This reverts commit 2ba73e1639.

Revert "Bug 1932150 - Fix some inconsistency about indicating whether the selection is allowed to cross the shadow boundary r=jjaschke,dom-core"

This reverts commit 793c2453f1.
2025-05-07 18:30:42 +00:00
Sean Feng 19ce2c5806 Bug 1932150 - ContentSubtreeIterator #3: Fix a bug in ContentSubtreeIterator where the end container is in the light DOM of a shadow host r=jjaschke
When the end container is in light DOM of a shadow host, we stop the
iteration after we have finished iterating the shadow root of it.

Differential Revision: https://phabricator.services.mozilla.com/D246953
2025-05-07 15:08:49 +00:00
Sean Feng d9d192bc3a Bug 1932150 - ContentSubtreeIterator #2: Allow ContentSubtreeIterator to iterate nodes in flattened tree r=jjaschke
Differential Revision: https://phabricator.services.mozilla.com/D246952
2025-05-07 15:08:45 +00:00
Sean Feng 2fbde5b84d Bug 1932150 - ContentSubtreeIterator #1: Make the end container related logic in ContentSubtreeIterator more robust r=jjaschke,smaug,dom-core
This is more like a fix to the current logic. The end container could
be in a shadow tree of a shadow host, or in the light DOM of a shadow
host.

When ContentSubtreeIterator reaches to an ancestor of the end container,
it should decide whether dive to the shadow tree or not based on
the true info, not depends on a guess.

Differential Revision: https://phabricator.services.mozilla.com/D246951
2025-05-07 15:08:42 +00:00
Sean Feng 793c2453f1 Bug 1932150 - Fix some inconsistency about indicating whether the selection is allowed to cross the shadow boundary r=jjaschke,dom-core
Differential Revision: https://phabricator.services.mozilla.com/D246949
2025-05-07 15:08:30 +00:00
Masayuki Nakano a5637890c7 Bug 1946001 - Fix some points which may cross independent selection boundary r=emilio,jjaschke
This patch fixes multiple points which may cross independent selection
boundaries which is element boundary of the native anonymous `<div>` for
editable content in text controls.  The reason why I don't split this patch is,
fixing one of them leads another assertion failure.  So, I couldn't pass all
tests with separated patches.

1. `nsFrameTraversal` should take `Element` instead of `nsIFrame` for the
limiter because e.g., inline editing host like `<span contenteditable>` may
have multiple frames if it's wrapped.  Therefore, we should make it take
an element as the ancestor limiter, and check it when getting parent frame
or after getting previous or next frame.
2. `nsIFrame::PeekBackwardAndForward` may cross the boundary because it does not
take the anonymous `<div>` element as ancestor limiter of the selection.  It's
currently used only for extending selection.  Therefore, I rename it to make
it clearer.
3. `SelectionMovementUtils::GetPrevNextBidiLevel` to take the ancestor limiter
for calling `nsIFrame::GetFrameFromDirection()`.
4. `nsINode` should have a method to return the `nsFrameSelection` instance
which manages the selection in the node.  This makes the check simpler, and
this is not expensive.  Then, for making it clearer, I rename
`TextControlElement::GetConstFrameSelection()` to
`GetIndependentFrameSelection()`.
5. `nsINode::GetSelectionRootContent()` should have an option to return
independent selection root when the node is its host for
`nsFrameSelection::ConstrainFrameAndPointToAnchorSubtree()`
6. `nsFrameSelection::ConstrainFrameAndPointToAnchorSubtree()` should not
retrieve independent selection root when the given frame is a text control
frame.
7. `RangeUtils` should get parent with checking the independent selection
boundaries.
8. `Selection::Extend` should assert if the destination is managed by its
frame selection to detect a bug.

Differential Revision: https://phabricator.services.mozilla.com/D241587
2025-03-17 12:49:57 +00:00
Jan-Niklas Jaeschke e8f2074681 Bug 1942080, part 3 - Text Fragments: Use an initializer for ContentIterator which does not validate the boundary points. r=farre,dom-core
`TextDirectiveUtil::NormalizedRangeBoundariesAreEqual()`
uses an `UnsafePreContentIterator` to iterate the nodes
between the two input range boundaries.
In order to do so, these boundaries must be ordered correctly,
which requires a call to `nsContentUtils::ComparePoints()`.
The initializer method for content iterators does another
call to `ComparePoints()`, to ensure the points are in correct order.

To improve this, a new `InitWithoutValidatingPoints()` method
is implemented, which moves the `ComparePoints()` check into
a `MOZ_ASSERT`.

Differential Revision: https://phabricator.services.mozilla.com/D235556
2025-02-22 19:46:43 +00:00
Masayuki Nakano da4abce2d9 Bug 1945714 - Rename RangeBoundaryBase::Container() to GetContainer() r=jjaschke,dom-core
Usually, we name methods as `GetFoo()` if they may return `nullptr`, on the
other hand, we name methods as `Foo()` if they won't return `nullptr`.

`RangeBoundaryBase::Container()` may return `nullptr`.  So, this name may cause
misleading of some developers.  Let's rename it as `GetContainer()`.

This does not change anything for avoiding merge conflict with the other
landings.

Differential Revision: https://phabricator.services.mozilla.com/D236796
2025-02-10 01:29:40 +00:00
Sean Feng 927127a6d0 Bug 1907228 - Fix a crash about when Element::FromNode is used for textnode r=jjaschke,dom-core
Differential Revision: https://phabricator.services.mozilla.com/D216742
2024-07-17 17:47:13 +00:00
Tamas Szentpeteri d6e930bc2f Backed out changeset 525316d699c5 (bug 1907228) for causing reftest fails on 1907228.html 2024-07-17 01:53:45 +03:00
Sean Feng cb81353d15 Bug 1907228 - Fix a crash about when Element::FromNode is used for textnode r=jjaschke,dom-core
Differential Revision: https://phabricator.services.mozilla.com/D216742
2024-07-16 21:14:28 +00:00
Sean Feng c9765020e2 Bug 1881095 - Separate IteratorHelpers out for reuse r=jjaschke,dom-core
Differential Revision: https://phabricator.services.mozilla.com/D211576
2024-06-10 18:59:49 +00:00
Sean Feng 0f3c30f79c Bug 1891783 - Ensure a consistent behaviour for slotted contents r=smaug
This patch ensures we always use the Shadow-including order for
selecting nodes.

Differential Revision: https://phabricator.services.mozilla.com/D208370
2024-05-13 20:24:04 +00:00
Mike Hommey 57a8fd7899 Bug 1890902 - Remove unused assignment. r=sefeng
Differential Revision: https://phabricator.services.mozilla.com/D207228
2024-04-16 01:04:39 +00:00
Sean Feng 53d71314a6 Bug 1889477 - Make ContentSubtreeIterator to always go into the shadow tree (if there's one) for getting the deepest child r=smaug
This patch should only impact how `ContentSubtreeIterator` uses `ContentIteratorBase<NodeType>::GetDeepFirstChild`
because `IteratorHelpers::GetShadowRoot` can only return non-null with
ContentSubtreeIterator. Secondly, `ContentSubtreeIterator` only uses this
method with
`ContentSubtreeIterator::DetermineCandidateForFirstContent`, so we are
talking about getting the deepest first child for the first content candidate.

If the first content candidate is a shadow host with web exposed shadow
root, we should always use the first child of this shadow root rather than the
child of this content in light DOM.

Differential Revision: https://phabricator.services.mozilla.com/D206552
2024-04-04 14:32:04 +00:00
Sean Feng 14802f4025 Bug 1887974 - Allow nextNode to be null in ContentSubtreeIterator::Next r=jjaschke,smaug,dom-core
This is actually reverting the assertion to the version before we
add the initial ShadowDOM selection support.

The issue is that nsRange::CutContents allows scripts to run
while iterating the nodes, and scripts can possibly changes DOM
tree. So the mStart and mEnd of ContentSubtreeIterator may stop
making sense, hence nextNode becomes null.

This is an old bug, not related to ShadowDOM selection, so I am
just revering the assertion.

Differential Revision: https://phabricator.services.mozilla.com/D205903
2024-04-02 19:25:52 +00:00