From 40a355a42d4a9444dc753c04c6608dade2f06a23 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 03:13:27 +0200 Subject: Adding upstream version 125.0.1. Signed-off-by: Daniel Baumann --- dom/base/nsINode.cpp | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'dom/base/nsINode.cpp') diff --git a/dom/base/nsINode.cpp b/dom/base/nsINode.cpp index 3a9fe23899..d5455e5596 100644 --- a/dom/base/nsINode.cpp +++ b/dom/base/nsINode.cpp @@ -16,6 +16,7 @@ #include "js/JSON.h" // JS_ParseJSON #include "mozAutoDocUpdate.h" #include "mozilla/AsyncEventDispatcher.h" +#include "mozilla/ClearOnShutdown.h" #include "mozilla/CORSMode.h" #include "mozilla/EventDispatcher.h" #include "mozilla/EventListenerManager.h" @@ -304,7 +305,7 @@ class IsItemInRangeComparator { // @param aStartOffset has to be less or equal to aEndOffset. IsItemInRangeComparator(const nsINode& aNode, const uint32_t aStartOffset, const uint32_t aEndOffset, - nsContentUtils::ComparePointsCache* aCache) + nsContentUtils::NodeIndexCache* aCache) : mNode(aNode), mStartOffset(aStartOffset), mEndOffset(aEndOffset), @@ -332,7 +333,7 @@ class IsItemInRangeComparator { const nsINode& mNode; const uint32_t mStartOffset; const uint32_t mEndOffset; - nsContentUtils::ComparePointsCache* mCache; + nsContentUtils::NodeIndexCache* mCache; }; bool nsINode::IsSelected(const uint32_t aStartOffset, @@ -367,7 +368,7 @@ bool nsINode::IsSelected(const uint32_t aStartOffset, } } - nsContentUtils::ComparePointsCache cache; + nsContentUtils::NodeIndexCache cache; IsItemInRangeComparator comparator{*this, aStartOffset, aEndOffset, &cache}; for (Selection* selection : ancestorSelections) { // Binary search the sorted ranges in this selection. @@ -1810,6 +1811,10 @@ Maybe nsINode::ComputeIndexOf(const nsINode* aPossibleChild) const { return Nothing(); } + if (aPossibleChild == GetFirstChild()) { + return Some(0); + } + if (aPossibleChild == GetLastChild()) { MOZ_ASSERT(GetChildCount()); return Some(GetChildCount() - 1); @@ -3672,15 +3677,13 @@ already_AddRefed nsINode::CloneAndAdopt( } newShadowRoot->SetIsDeclarative(originalShadowRoot->IsDeclarative()); - if (aDeep) { - for (nsIContent* origChild = originalShadowRoot->GetFirstChild(); - origChild; origChild = origChild->GetNextSibling()) { - nsCOMPtr child = - CloneAndAdopt(origChild, aClone, aDeep, nodeInfoManager, - aReparentScope, newShadowRoot, aError); - if (NS_WARN_IF(aError.Failed())) { - return nullptr; - } + for (nsIContent* origChild = originalShadowRoot->GetFirstChild(); + origChild; origChild = origChild->GetNextSibling()) { + nsCOMPtr child = + CloneAndAdopt(origChild, aClone, true, nodeInfoManager, + aReparentScope, newShadowRoot, aError); + if (NS_WARN_IF(aError.Failed())) { + return nullptr; } } } -- cgit v1.2.3