diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:35:37 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:35:37 +0000 |
commit | a90a5cba08fdf6c0ceb95101c275108a152a3aed (patch) | |
tree | 532507288f3defd7f4dcf1af49698bcb76034855 /dom/base/Selection.h | |
parent | Adding debian version 126.0.1-1. (diff) | |
download | firefox-a90a5cba08fdf6c0ceb95101c275108a152a3aed.tar.xz firefox-a90a5cba08fdf6c0ceb95101c275108a152a3aed.zip |
Merging upstream version 127.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/base/Selection.h')
-rw-r--r-- | dom/base/Selection.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/dom/base/Selection.h b/dom/base/Selection.h index 08563993ac..101bada49f 100644 --- a/dom/base/Selection.h +++ b/dom/base/Selection.h @@ -386,6 +386,30 @@ class Selection final : public nsSupportsWeakReference, return mStyledRanges.mRanges[0].mRange->Collapsed(); } + // Returns whether both normal range and cross-shadow-boundary + // range are collapsed. + // + // If StaticPrefs::dom_shadowdom_selection_across_boundary_enabled is + // disabled, this method always returns result as nsRange::IsCollapsed. + bool AreNormalAndCrossShadowBoundaryRangesCollapsed() const { + if (!IsCollapsed()) { + return false; + } + + size_t cnt = mStyledRanges.Length(); + if (cnt == 0) { + return true; + } + + AbstractRange* range = mStyledRanges.mRanges[0].mRange; + MOZ_ASSERT_IF( + range->MayCrossShadowBoundary(), + !range->AsDynamicRange()->CrossShadowBoundaryRangeCollapsed()); + // Returns false if nsRange::mCrossBoundaryRange exists, + // true otherwise. + return !range->MayCrossShadowBoundary(); + } + // *JS() methods are mapped to Selection.*(). // They may move focus only when the range represents normal selection. // These methods shouldn't be used by non-JS callers. |