Bug 1575844: Allow for null/empty GradientStops in Moz2D recording code. r=jrmuizel

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Bob Owen 2019-08-30 17:14:22 +00:00
parent 44d14c3f29
commit 4ad6464c7c
3 changed files with 21 additions and 8 deletions

View File

@ -639,13 +639,17 @@ void DrawTargetRecording::EnsurePatternDependenciesStored(
// No dependencies here.
return;
case PatternType::LINEAR_GRADIENT: {
MOZ_ASSERT(mRecorder->HasStoredObject(
static_cast<const LinearGradientPattern*>(&aPattern)->mStops));
MOZ_ASSERT_IF(
static_cast<const LinearGradientPattern*>(&aPattern)->mStops,
mRecorder->HasStoredObject(
static_cast<const LinearGradientPattern*>(&aPattern)->mStops));
return;
}
case PatternType::RADIAL_GRADIENT: {
MOZ_ASSERT(mRecorder->HasStoredObject(
static_cast<const RadialGradientPattern*>(&aPattern)->mStops));
MOZ_ASSERT_IF(
static_cast<const LinearGradientPattern*>(&aPattern)->mStops,
mRecorder->HasStoredObject(
static_cast<const RadialGradientPattern*>(&aPattern)->mStops));
return;
}
case PatternType::SURFACE: {

View File

@ -64,8 +64,15 @@ class InlineTranslator : public Translator {
}
GradientStops* LookupGradientStops(ReferencePtr aRefPtr) final {
GradientStops* result = mGradientStops.GetWeak(aRefPtr);
MOZ_ASSERT(result);
DebugOnly<bool> found;
GradientStops* result = mGradientStops.GetWeak(aRefPtr
#if defined(DEBUG)
,
&found
#endif
);
// GradientStops can be null in some circumstances.
MOZ_ASSERT(found);
return result;
}

View File

@ -2093,7 +2093,8 @@ struct GenericPattern {
&mStorage->mStorage);
mPattern = new (mLinGradPat) LinearGradientPattern(
storage->mBegin, storage->mEnd,
mTranslator->LookupGradientStops(storage->mStops),
storage->mStops ? mTranslator->LookupGradientStops(storage->mStops)
: nullptr,
storage->mMatrix);
return mPattern;
}
@ -2104,7 +2105,8 @@ struct GenericPattern {
mPattern = new (mRadGradPat) RadialGradientPattern(
storage->mCenter1, storage->mCenter2, storage->mRadius1,
storage->mRadius2,
mTranslator->LookupGradientStops(storage->mStops),
storage->mStops ? mTranslator->LookupGradientStops(storage->mStops)
: nullptr,
storage->mMatrix);
return mPattern;
}