From 4ec81aed903ee28fddf8cedf413941a0539cbd04 Mon Sep 17 00:00:00 2001 From: Mirko Brodesser Date: Fri, 12 Jun 2020 08:53:54 +0000 Subject: [PATCH] Bug 1643721: part 3) Factor initializing `mRangeSerializer`'s members out to `RangeSerializer::Initialize`. r=masayuki Differential Revision: https://phabricator.services.mozilla.com/D79112 --- dom/base/nsDocumentEncoder.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/dom/base/nsDocumentEncoder.cpp b/dom/base/nsDocumentEncoder.cpp index 8d1680e98dee..5970b3556bb9 100644 --- a/dom/base/nsDocumentEncoder.cpp +++ b/dom/base/nsDocumentEncoder.cpp @@ -408,6 +408,8 @@ class nsDocumentEncoder : public nsIDocumentEncoder { mFlags{aFlags}, mNodeSerializer{aNodeSerializer} {} + void Initialize(); + RangeBoundariesInclusiveAncestorsAndOffsets mRangeBoundariesInclusiveAncestorsAndOffsets; /** @@ -431,6 +433,15 @@ class nsDocumentEncoder : public nsIDocumentEncoder { RangeSerializer mRangeSerializer; }; +void nsDocumentEncoder::RangeSerializer::Initialize() { + mContextInfoDepth = {}; + mStartRootIndex = 0; + mEndRootIndex = 0; + mHaltRangeHint = false; + mClosestCommonInclusiveAncestorOfRange = nullptr; + mRangeBoundariesInclusiveAncestorsAndOffsets = {}; +} + NS_IMPL_CYCLE_COLLECTING_ADDREF(nsDocumentEncoder) NS_IMPL_CYCLE_COLLECTING_RELEASE_WITH_LAST_RELEASE( nsDocumentEncoder, ReleaseDocumentReferenceAndInitialize(true)) @@ -466,16 +477,11 @@ nsDocumentEncoder::nsDocumentEncoder() void nsDocumentEncoder::Initialize(bool aClearCachedSerializer) { mFlags = 0; mWrapColumn = 72; - mRangeSerializer.mContextInfoDepth = {}; - mRangeSerializer.mStartRootIndex = 0; - mRangeSerializer.mEndRootIndex = 0; + mRangeSerializer.Initialize(); mNeedsPreformatScanning = false; - mRangeSerializer.mHaltRangeHint = false; mDisableContextSerialize = false; mEncodingScope = {}; - mRangeSerializer.mClosestCommonInclusiveAncestorOfRange = nullptr; mNodeFixup = nullptr; - mRangeSerializer.mRangeBoundariesInclusiveAncestorsAndOffsets = {}; if (aClearCachedSerializer) { mSerializer = nullptr; }