summaryrefslogtreecommitdiffstats
path: root/dom/base/RangeBoundary.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:35:49 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:35:49 +0000
commitd8bbc7858622b6d9c278469aab701ca0b609cddf (patch)
treeeff41dc61d9f714852212739e6b3738b82a2af87 /dom/base/RangeBoundary.h
parentReleasing progress-linux version 125.0.3-1~progress7.99u1. (diff)
downloadfirefox-d8bbc7858622b6d9c278469aab701ca0b609cddf.tar.xz
firefox-d8bbc7858622b6d9c278469aab701ca0b609cddf.zip
Merging upstream version 126.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/base/RangeBoundary.h')
-rw-r--r--dom/base/RangeBoundary.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/dom/base/RangeBoundary.h b/dom/base/RangeBoundary.h
index 2e4ab42397..4c5a70fb6a 100644
--- a/dom/base/RangeBoundary.h
+++ b/dom/base/RangeBoundary.h
@@ -9,6 +9,7 @@
#include "nsCOMPtr.h"
#include "nsIContent.h"
+#include "mozilla/dom/ShadowRoot.h"
#include "mozilla/Assertions.h"
#include "mozilla/Maybe.h"
@@ -351,6 +352,34 @@ class RangeBoundaryBase {
}
public:
+ void NotifyParentBecomesShadowHost() {
+ MOZ_ASSERT(mParent);
+ MOZ_ASSERT(mParent->IsContainerNode(),
+ "Range is positioned on a text node!");
+ if (!StaticPrefs::dom_shadowdom_selection_across_boundary_enabled()) {
+ return;
+ }
+
+ if (!mIsMutationObserved) {
+ // RangeBoundaries that are not used in the context of a
+ // `MutationObserver` use the offset as main source of truth to compute
+ // `mRef`. Therefore, it must not be updated or invalidated.
+ return;
+ }
+
+ if (!mRef) {
+ MOZ_ASSERT(mOffset.isSome() && mOffset.value() == 0,
+ "Invalidating offset of invalid RangeBoundary?");
+ return;
+ }
+
+ if (dom::ShadowRoot* shadowRoot = mParent->GetShadowRootForSelection()) {
+ mParent = shadowRoot;
+ }
+
+ mOffset = Some(0);
+ }
+
bool IsSet() const { return mParent && (mRef || mOffset.isSome()); }
bool IsSetAndValid() const {