tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 4eaf9717396aa173beadf74f12fed52acfd50592
parent 233c97df8abc6eef46716129e21da9c5343a2836
Author: Edgar Chen <echen@mozilla.com>
Date:   Wed, 31 Dec 2025 09:46:11 +0000

Bug 2007940 - Simplify RangeSerializer::SerializeNodePartiallyContainedInRange() a bit; r=masayuki

Differential Revision: https://phabricator.services.mozilla.com/D277617

Diffstat:
Mdom/serializers/nsDocumentEncoder.cpp | 39++++++++++++++++++---------------------
1 file changed, 18 insertions(+), 21 deletions(-)

diff --git a/dom/serializers/nsDocumentEncoder.cpp b/dom/serializers/nsDocumentEncoder.cpp @@ -479,11 +479,10 @@ class nsDocumentEncoder : public nsIDocumentEncoder { bool HasInvisibleParentAndShouldBeSkipped(nsINode& aNode) const; nsresult SerializeNodePartiallyContainedInRange( - nsINode& aNode, nsIContent& aContent, - const StartAndEndContent& aStartAndEndContent, const nsRange& aRange, - int32_t aDepth); + nsIContent& aContent, const StartAndEndContent& aStartAndEndContent, + const nsRange& aRange, int32_t aDepth); - nsresult SerializeTextNode(nsINode& aNode, const nsIContent& aContent, + nsresult SerializeTextNode(nsIContent& aContent, const StartAndEndContent& aStartAndEndContent, const nsRange& aRange) const; @@ -1095,8 +1094,7 @@ nsDocumentEncoder::RangeSerializer::GetStartAndEndContentForRecursionLevel( } nsresult nsDocumentEncoder::RangeSerializer::SerializeTextNode( - nsINode& aNode, const nsIContent& aContent, - const StartAndEndContent& aStartAndEndContent, + nsIContent& aContent, const StartAndEndContent& aStartAndEndContent, const nsRange& aRange) const { const int32_t startOffset = (aStartAndEndContent.mStart == &aContent) ? ShadowDOMSelectionHelpers::StartOffset( @@ -1106,7 +1104,7 @@ nsresult nsDocumentEncoder::RangeSerializer::SerializeTextNode( ? ShadowDOMSelectionHelpers::EndOffset( &aRange, mAllowCrossShadowBoundary) : -1; - return mNodeSerializer.SerializeTextNode(aNode, startOffset, endOffset); + return mNodeSerializer.SerializeTextNode(aContent, startOffset, endOffset); } nsresult nsDocumentEncoder::RangeSerializer::SerializeRangeNodes( @@ -1134,8 +1132,8 @@ nsresult nsDocumentEncoder::RangeSerializer::SerializeRangeNodes( aNode, NodeSerializer::SerializeRoot::eYes); NS_ENSURE_SUCCESS(rv, rv); } else { - rv = SerializeNodePartiallyContainedInRange( - *aNode, *content, startAndEndContent, *aRange, aDepth); + rv = SerializeNodePartiallyContainedInRange(*content, startAndEndContent, + *aRange, aDepth); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; } @@ -1145,19 +1143,18 @@ nsresult nsDocumentEncoder::RangeSerializer::SerializeRangeNodes( nsresult nsDocumentEncoder::RangeSerializer::SerializeNodePartiallyContainedInRange( - nsINode& aNode, nsIContent& aContent, - const StartAndEndContent& aStartAndEndContent, const nsRange& aRange, - const int32_t aDepth) { + nsIContent& aContent, const StartAndEndContent& aStartAndEndContent, + const nsRange& aRange, const int32_t aDepth) { // due to implementation it is impossible for text node to be both start and // end of range. We would have handled that case without getting here. // XXXsmaug What does this all mean? - if (IsTextNode(&aNode)) { - nsresult rv = - SerializeTextNode(aNode, aContent, aStartAndEndContent, aRange); + if (IsTextNode(&aContent)) { + nsresult rv = SerializeTextNode(aContent, aStartAndEndContent, aRange); NS_ENSURE_SUCCESS(rv, rv); } else { - if (&aNode != mClosestCommonInclusiveAncestorOfRange) { - if (mRangeContextSerializer.mRangeNodeContext.IncludeInContext(aNode)) { + if (&aContent != mClosestCommonInclusiveAncestorOfRange) { + if (mRangeContextSerializer.mRangeNodeContext.IncludeInContext( + aContent)) { // halt the incrementing of mContextInfoDepth. This // is so paste client will include this node in paste. mHaltRangeHint = true; @@ -1170,7 +1167,7 @@ nsDocumentEncoder::RangeSerializer::SerializeNodePartiallyContainedInRange( } // serialize the start of this node - nsresult rv = mNodeSerializer.SerializeNodeStart(aNode, 0, -1); + nsresult rv = mNodeSerializer.SerializeNodeStart(aContent, 0, -1); NS_ENSURE_SUCCESS(rv, rv); } @@ -1214,7 +1211,7 @@ nsDocumentEncoder::RangeSerializer::SerializeNodePartiallyContainedInRange( // to add one here in order to include it in the children we serialize. const nsINode* endContainer = ShadowDOMSelectionHelpers::GetEndContainer( &aRange, mAllowCrossShadowBoundary); - if (&aNode != endContainer) { + if (&aContent != endContainer) { MOZ_ASSERT(*endOffset != UINT32_MAX); endOffset.ref()++; } @@ -1226,8 +1223,8 @@ nsDocumentEncoder::RangeSerializer::SerializeNodePartiallyContainedInRange( NS_ENSURE_SUCCESS(rv, rv); // serialize the end of this node - if (&aNode != mClosestCommonInclusiveAncestorOfRange) { - nsresult rv = mNodeSerializer.SerializeNodeEnd(aNode); + if (&aContent != mClosestCommonInclusiveAncestorOfRange) { + nsresult rv = mNodeSerializer.SerializeNodeEnd(aContent); NS_ENSURE_SUCCESS(rv, rv); } }