From da4c7e7ed675c3bf405668739c3012d140856109 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 15 May 2024 05:34:42 +0200 Subject: Adding upstream version 126.0. Signed-off-by: Daniel Baumann --- dom/serializers/nsDocumentEncoder.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'dom/serializers/nsDocumentEncoder.cpp') diff --git a/dom/serializers/nsDocumentEncoder.cpp b/dom/serializers/nsDocumentEncoder.cpp index 14120bae64..46ea15fecc 100644 --- a/dom/serializers/nsDocumentEncoder.cpp +++ b/dom/serializers/nsDocumentEncoder.cpp @@ -1270,8 +1270,14 @@ nsresult nsDocumentEncoder::RangeSerializer::SerializeRangeToString( const nsRange* aRange) { if (!aRange || aRange->Collapsed()) return NS_OK; + // Consider a case where the boundary of the selection is ShadowRoot (ie, the + // first child of ShadowRoot is selected, so ShadowRoot is the container hence + // the boundary), allowing GetClosestCommonInclusiveAncestor to cross the + // boundary can return the host element as the container. + // SerializeRangeContextStart doesn't support this case. mClosestCommonInclusiveAncestorOfRange = - aRange->GetClosestCommonInclusiveAncestor(); + aRange->GetClosestCommonInclusiveAncestor( + AllowRangeCrossShadowBoundary::No); if (!mClosestCommonInclusiveAncestorOfRange) { return NS_OK; -- cgit v1.2.3