summaryrefslogtreecommitdiffstats
path: root/dom/base/Selection.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:35:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:35:29 +0000
commit59203c63bb777a3bacec32fb8830fba33540e809 (patch)
tree58298e711c0ff0575818c30485b44a2f21bf28a0 /dom/base/Selection.h
parentAdding upstream version 126.0.1. (diff)
downloadfirefox-59203c63bb777a3bacec32fb8830fba33540e809.tar.xz
firefox-59203c63bb777a3bacec32fb8830fba33540e809.zip
Adding upstream version 127.0.upstream/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.h24
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.