Bug 1448535 part 1 - Make nsMathMLmtdInnerFrame use UniquePtr for its StyleText. r?dholbert
MozReview-Commit-ID: 6tuA3JC1FDV
--- a/layout/mathml/nsMathMLmtableFrame.cpp
+++ b/layout/mathml/nsMathMLmtableFrame.cpp
@@ -1264,24 +1264,19 @@ NS_NewMathMLmtdInnerFrame(nsIPresShell*
{
return new (aPresShell) nsMathMLmtdInnerFrame(aStyle);
}
NS_IMPL_FRAMEARENA_HELPERS(nsMathMLmtdInnerFrame)
nsMathMLmtdInnerFrame::nsMathMLmtdInnerFrame(ComputedStyle* aStyle)
: nsBlockFrame(aStyle, kClassID)
+ // Make a copy of the parent nsStyleText for later modification.
+ , mUniqueStyleText(MakeUnique<nsStyleText>(*StyleText()))
{
- // Make a copy of the parent nsStyleText for later modification.
- mUniqueStyleText = new (PresContext()) nsStyleText(*StyleText());
-}
-
-nsMathMLmtdInnerFrame::~nsMathMLmtdInnerFrame()
-{
- mUniqueStyleText->Destroy(PresContext());
}
void
nsMathMLmtdInnerFrame::Reflow(nsPresContext* aPresContext,
ReflowOutput& aDesiredSize,
const ReflowInput& aReflowInput,
nsReflowStatus& aStatus)
{
@@ -1309,18 +1304,17 @@ nsStyleText* nsMathMLmtdInnerFrame::Styl
// values, we simply repeat the last value.
if (columnIndex < alignmentList->Length())
alignment = alignmentList->ElementAt(columnIndex);
else
alignment = alignmentList->ElementAt(alignmentList->Length() - 1);
}
mUniqueStyleText->mTextAlign = alignment;
- return mUniqueStyleText;
+ return mUniqueStyleText.get();
}
/* virtual */ void
nsMathMLmtdInnerFrame::DidSetComputedStyle(ComputedStyle* aOldComputedStyle)
{
nsBlockFrame::DidSetComputedStyle(aOldComputedStyle);
- mUniqueStyleText->Destroy(PresContext());
- mUniqueStyleText = new (PresContext()) nsStyleText(*StyleText());
+ mUniqueStyleText = MakeUnique<nsStyleText>(*StyleText());
}
--- a/layout/mathml/nsMathMLmtableFrame.h
+++ b/layout/mathml/nsMathMLmtableFrame.h
@@ -3,16 +3,17 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef nsMathMLmtableFrame_h___
#define nsMathMLmtableFrame_h___
#include "mozilla/Attributes.h"
+#include "mozilla/UniquePtr.h"
#include "nsMathMLContainerFrame.h"
#include "nsBlockFrame.h"
#include "nsTableWrapperFrame.h"
#include "nsTableRowFrame.h"
#include "nsTableCellFrame.h"
//
// <mtable> -- table or matrix
@@ -332,15 +333,15 @@ public:
{
return mFrames.FirstChild() !=
mFrames.LastChild() ||
!mFrames.FirstChild();
}
protected:
explicit nsMathMLmtdInnerFrame(ComputedStyle* aStyle);
- virtual ~nsMathMLmtdInnerFrame();
+ virtual ~nsMathMLmtdInnerFrame() {}
- nsStyleText* mUniqueStyleText;
+ mozilla::UniquePtr<nsStyleText> mUniqueStyleText;
}; // class nsMathMLmtdInnerFrame
#endif /* nsMathMLmtableFrame_h___ */