Bug 1311244 Part 5 - Convert FloatInfo's copy constructor into a move constructor. r=dbaron

Use move constructor for two reasons. 1) The copy constructor is needed only
when appending FloatInfo to mFloats, so using move constructor will likely
be more efficient if some of the member variables support move constructor.
2) Part 6 will added a UniquePtr member to FloatInfo, so using move
constructor becomes necessary.

Also change the return value of AddFloat() to void to simplify the code,
since all the other callers do not check the return value, and
BlockReflowInput::FloatAndPlaceFloat() only asserts in debug mode. I assume
it's safe to omit the OOM check.

MozReview-Commit-ID: GVbbsdBjr7b

--HG--
extra : rebase_source : e0f647e029278a5033bb9d6d780e73e32de460d3
This commit is contained in:
Ting-Yu Lin 2017-01-06 16:36:19 +08:00
Родитель 8b267972a6
Коммит ea61e604fa
3 изменённых файлов: 14 добавлений и 18 удалений

Просмотреть файл

@ -988,9 +988,8 @@ BlockReflowInput::FlowAndPlaceFloat(nsIFrame* aFloat)
region.BSize(wm) = std::max(region.BSize(wm),
ContentBSize() - floatPos.B(wm));
}
DebugOnly<nsresult> rv = mFloatManager->AddFloat(aFloat, region, wm,
ContainerSize());
MOZ_ASSERT(NS_SUCCEEDED(rv), "bad float placement");
mFloatManager->AddFloat(aFloat, region, wm, ContainerSize());
// store region
nsFloatManager::StoreRegionFor(wm, aFloat, region, ContainerSize());

Просмотреть файл

@ -261,7 +261,7 @@ nsFloatManager::GetFlowArea(WritingMode aWM, nscoord aBCoord, nscoord aBSize,
lineRight - lineLeft, blockSize, haveFloats);
}
nsresult
void
nsFloatManager::AddFloat(nsIFrame* aFloatFrame, const LogicalRect& aMarginRect,
WritingMode aWM, const nsSize& aContainerSize)
{
@ -290,10 +290,7 @@ nsFloatManager::AddFloat(nsIFrame* aFloatFrame, const LogicalRect& aMarginRect,
if (thisBEnd > sideBEnd)
sideBEnd = thisBEnd;
if (!mFloats.AppendElement(info))
return NS_ERROR_OUT_OF_MEMORY;
return NS_OK;
mFloats.AppendElement(Move(info));
}
// static
@ -577,12 +574,12 @@ nsFloatManager::FloatInfo::FloatInfo(nsIFrame* aFrame,
}
#ifdef NS_BUILD_REFCNT_LOGGING
nsFloatManager::FloatInfo::FloatInfo(const FloatInfo& aOther)
: mFrame(aOther.mFrame)
, mLeftBEnd(aOther.mLeftBEnd)
, mRightBEnd(aOther.mRightBEnd)
, mRect(aOther.mRect)
, mShapeBoxRect(aOther.mShapeBoxRect)
nsFloatManager::FloatInfo::FloatInfo(FloatInfo&& aOther)
: mFrame(Move(aOther.mFrame))
, mLeftBEnd(Move(aOther.mLeftBEnd))
, mRightBEnd(Move(aOther.mRightBEnd))
, mRect(Move(aOther.mRect))
, mShapeBoxRect(Move(aOther.mShapeBoxRect))
{
MOZ_COUNT_CTOR(nsFloatManager::FloatInfo);
}

Просмотреть файл

@ -201,9 +201,9 @@ public:
* aMarginRect is relative to the current translation. The caller
* must ensure aMarginRect.height >= 0 and aMarginRect.width >= 0.
*/
nsresult AddFloat(nsIFrame* aFloatFrame,
const mozilla::LogicalRect& aMarginRect,
mozilla::WritingMode aWM, const nsSize& aContainerSize);
void AddFloat(nsIFrame* aFloatFrame,
const mozilla::LogicalRect& aMarginRect,
mozilla::WritingMode aWM, const nsSize& aContainerSize);
/**
* Notify that we tried to place a float that could not fit at all and
@ -387,7 +387,7 @@ private:
const nscoord aRadiusY);
#ifdef NS_BUILD_REFCNT_LOGGING
FloatInfo(const FloatInfo& aOther);
FloatInfo(FloatInfo&& aOther);
~FloatInfo();
#endif