Bug 1831457. Call MaybeRestrictSVGContext in VectorImage::GetImageProvider. r=aosmond

The main part of MaybeRestrictSVGContext blocks context paint where is it not allowed. The css style that enables it is already restricted to chrome, see https://searchfox.org/mozilla-central/source/servo/components/style/properties/longhands/inherited_svg.mako.rs#208 so this isn't a big deal.

We've had a test that context paint isn't enabled in content for a long time

https://searchfox.org/mozilla-central/rev/85b4f7363292b272eb9b606e00de2c37a6be73f0/layout/reftests/svg/as-image/reftest.list#59

So this never regressed. So this just makes it consistent and blocks it further and executes the preserve aspect ratio code.

Differential Revision: https://phabricator.services.mozilla.com/D177216
This commit is contained in:
Timothy Nikkel 2023-07-06 11:59:34 +00:00
parent e5836c019d
commit dff579d30a

View File

@ -796,8 +796,11 @@ VectorImage::GetImageProvider(WindowRenderer* aRenderer,
mHaveAnimations ? PlaybackType::eAnimated : PlaybackType::eStatic;
auto surfaceFlags = ToSurfaceFlags(aFlags);
SurfaceKey surfaceKey =
VectorSurfaceKey(aSize, aRegion, aSVGContext, surfaceFlags, playbackType);
SVGImageContext newSVGContext = aSVGContext;
bool contextPaint = MaybeRestrictSVGContext(newSVGContext, aFlags);
SurfaceKey surfaceKey = VectorSurfaceKey(aSize, aRegion, newSVGContext,
surfaceFlags, playbackType);
if ((aFlags & FLAG_SYNC_DECODE) || !(aFlags & FLAG_HIGH_QUALITY_SCALING)) {
result = SurfaceCache::Lookup(ImageKey(this), surfaceKey,
/* aMarkUsed = */ true);
@ -870,10 +873,9 @@ VectorImage::GetImageProvider(WindowRenderer* aRenderer,
// we cannot cache.
SVGDrawingParameters params(
nullptr, rasterSize, aSize, ImageRegion::Create(rasterSize),
SamplingFilter::POINT, aSVGContext, animTime, aFlags, 1.0);
SamplingFilter::POINT, newSVGContext, animTime, aFlags, 1.0);
RefPtr<gfxDrawable> svgDrawable = CreateSVGDrawable(params);
bool contextPaint = aSVGContext.GetContextPaint();
AutoRestoreSVGState autoRestore(params, mSVGDocumentWrapper, contextPaint);
mSVGDocumentWrapper->UpdateViewportBounds(params.viewportSize);