Bug 1264830 - Part 2: Change nsStyleImageLayers::mLayers to use nsStyleAutoArray. r=bholley

nsStyleImageLayers::mLayers always has at least one element in it, so we
change it to use nsStyleAutoArray rather than nsTArray.
This commit is contained in:
Cameron McCormack 2016-04-19 09:51:16 +10:00
parent 25fd6bca14
commit e7ae67f825
3 changed files with 10 additions and 11 deletions

View File

@ -6725,8 +6725,8 @@ template <class ComputedValueItem>
static void
SetImageLayerList(nsStyleContext* aStyleContext,
const nsCSSValue& aValue,
AutoTArray< nsStyleImageLayers::Layer, 1> &aLayers,
const AutoTArray<nsStyleImageLayers::Layer, 1> &aParentLayers,
nsStyleAutoArray<nsStyleImageLayers::Layer>& aLayers,
const nsStyleAutoArray<nsStyleImageLayers::Layer>& aParentLayers,
ComputedValueItem nsStyleImageLayers::Layer::* aResultLocation,
ComputedValueItem aInitialValue,
uint32_t aParentItemCount,
@ -6790,9 +6790,8 @@ template <class ComputedValueItem>
static void
SetImageLayerPairList(nsStyleContext* aStyleContext,
const nsCSSValue& aValue,
AutoTArray< nsStyleImageLayers::Layer, 1> &aLayers,
const AutoTArray<nsStyleImageLayers::Layer, 1>
&aParentLayers,
nsStyleAutoArray<nsStyleImageLayers::Layer>& aLayers,
const nsStyleAutoArray<nsStyleImageLayers::Layer>& aParentLayers,
ComputedValueItem nsStyleImageLayers::Layer::*
aResultLocation,
ComputedValueItem aInitialValue,
@ -6857,7 +6856,8 @@ SetImageLayerPairList(nsStyleContext* aStyleContext,
template <class ComputedValueItem>
static void
FillBackgroundList(AutoTArray< nsStyleImageLayers::Layer, 1> &aLayers,
FillBackgroundList(
nsStyleAutoArray<nsStyleImageLayers::Layer>& aLayers,
ComputedValueItem nsStyleImageLayers::Layer::* aResultLocation,
uint32_t aItemCount, uint32_t aFillCount)
{
@ -6979,7 +6979,7 @@ nsRuleNode::ComputeBackgroundData(void* aStartStruct,
if (rebuild) {
// Delete any extra items. We need to keep layers in which any
// property was specified.
bg->mImage.mLayers.TruncateLength(maxItemCount);
bg->mImage.mLayers.TruncateLengthNonZero(maxItemCount);
uint32_t fillCount = bg->mImage.mImageCount;
FillBackgroundList(bg->mImage.mLayers,
@ -9794,7 +9794,7 @@ nsRuleNode::ComputeSVGResetData(void* aStartStruct,
if (rebuild) {
// Delete any extra items. We need to keep layers in which any
// property was specified.
svgReset->mMask.mLayers.TruncateLength(maxItemCount);
svgReset->mMask.mLayers.TruncateLengthNonZero(maxItemCount);
uint32_t fillCount = svgReset->mMask.mImageCount;

View File

@ -2324,10 +2324,9 @@ nsStyleImageLayers::nsStyleImageLayers()
, mMaskModeCount(1)
, mBlendModeCount(1)
, mCompositeCount(1)
, mLayers(nsStyleAutoArray<Layer>::WITH_SINGLE_INITIAL_ELEMENT)
{
MOZ_COUNT_CTOR(nsStyleImageLayers);
mLayers.AppendElement();
NS_ASSERTION(mLayers.Length() == 1, "auto array must have room for 1 element");
}
nsStyleImageLayers::nsStyleImageLayers(const nsStyleImageLayers &aSource)

View File

@ -752,7 +752,7 @@ struct nsStyleImageLayers {
// layer. In layers below the bottom layer, properties will be
// uninitialized unless their count, above, indicates that they are
// present.
AutoTArray<Layer, 1> mLayers;
nsStyleAutoArray<Layer> mLayers;
const Layer& BottomLayer() const { return mLayers[mImageCount - 1]; }