Bug 1365189, part 1 - Prevent SVG elements that are neither displayable nor paint servers from painting. r=dholbert

MozReview-Commit-ID: 97Q9PN4eUBw
This commit is contained in:
Jonathan Watt 2017-06-06 17:04:37 +01:00
Родитель ce27fee74e
Коммит 4dbb614775
2 изменённых файлов: 16 добавлений и 2 удалений

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

@ -19,6 +19,7 @@
#include "nsCSSRenderingGradients.h"
#include "nsIFrame.h"
#include "nsStyleStructInlines.h"
#include "nsSVGDisplayableFrame.h"
#include "nsSVGEffects.h"
#include "nsSVGIntegrationUtils.h"
@ -192,11 +193,17 @@ nsImageRenderer::PrepareImage()
mImageElementSurface =
nsLayoutUtils::SurfaceFromElement(property->GetReferencedElement());
if (!mImageElementSurface.GetSourceSurface()) {
mPaintServerFrame = property->GetReferencedFrame();
if (!mPaintServerFrame) {
nsIFrame* paintServerFrame = property->GetReferencedFrame();
// If there's no referenced frame, or the referenced frame is
// non-displayable SVG, then we have nothing valid to paint.
if (!paintServerFrame ||
(paintServerFrame->IsFrameOfType(nsIFrame::eSVG) &&
!paintServerFrame->IsFrameOfType(nsIFrame::eSVGPaintServer) &&
!static_cast<nsSVGDisplayableFrame*>(do_QueryFrame(paintServerFrame)))) {
mPrepareResult = DrawResult::BAD_IMAGE;
return false;
}
mPaintServerFrame = paintServerFrame;
}
mPrepareResult = DrawResult::SUCCESS;

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

@ -1242,6 +1242,13 @@ nsSVGIntegrationUtils::DrawableFromPaintServer(nsIFrame* aFrame,
return drawable.forget();
}
if (aFrame->IsFrameOfType(nsIFrame::eSVG) &&
!static_cast<nsSVGDisplayableFrame*>(do_QueryFrame(aFrame))) {
MOZ_ASSERT_UNREACHABLE("We should prevent painting of unpaintable SVG "
"before we get here");
return nullptr;
}
// We don't want to paint into a surface as long as we don't need to, so we
// set up a drawing callback.
RefPtr<gfxDrawingCallback> cb =