Bug 1313570 - Change the parameter of ValidateSVGFrame.
MozReview-Commit-ID: Brym9cbGRw8
--- a/layout/svg/nsSVGIntegrationUtils.cpp
+++ b/layout/svg/nsSVGIntegrationUtils.cpp
@@ -561,38 +561,36 @@ ComputeOpacity(const PaintFramesParams&
(nsSVGUtils::CanOptimizeOpacity(frame) || !aParams.handleOpacity)) {
return 1.0f;
}
return opacity;
}
static bool
-ValidateSVGFrame(const PaintFramesParams& aParams, bool aHasSVGLayout,
- DrawResult* aResult)
+ValidateSVGFrame(nsIFrame* aFrame)
{
#ifdef DEBUG
- NS_ASSERTION(!(aParams.frame->GetStateBits() & NS_FRAME_SVG_LAYOUT) ||
+ NS_ASSERTION(!(aFrame->GetStateBits() & NS_FRAME_SVG_LAYOUT) ||
(NS_SVGDisplayListPaintingEnabled() &&
- !(aParams.frame->GetStateBits() & NS_FRAME_IS_NONDISPLAY)),
+ !(aFrame->GetStateBits() & NS_FRAME_IS_NONDISPLAY)),
"Should not use nsSVGIntegrationUtils on this SVG frame");
#endif
- nsIFrame* frame = aParams.frame;
- const nsIContent* content = frame->GetContent();
- if (aHasSVGLayout) {
- nsISVGChildFrame *svgChildFrame = do_QueryFrame(frame);
- if (!svgChildFrame || !frame->GetContent()->IsSVGElement()) {
- NS_ASSERTION(false, "why?");
- *aResult = DrawResult::BAD_ARGS;
- return false;
- }
+ bool hasSVGLayout = (aFrame->GetStateBits() & NS_FRAME_SVG_LAYOUT);
+ if (hasSVGLayout) {
+#ifdef DEBUG
+ nsISVGChildFrame *svgChildFrame = do_QueryFrame(aFrame);
+ MOZ_ASSERT(svgChildFrame && aFrame->GetContent()->IsSVGElement(),
+ "A non-SVG frame carries NS_FRAME_SVG_LAYOUT flag?");
+#endif
+
+ const nsIContent* content = aFrame->GetContent();
if (!static_cast<const nsSVGElement*>(content)->HasValidDimensions()) {
// The SVG spec says not to draw _anything_
- *aResult = DrawResult::SUCCESS;
return false;
}
}
return true;
}
/**
@@ -680,18 +678,17 @@ nsSVGIntegrationUtils::PaintMaskAndClipP
*
* + Use cairo's clipPath when representable natively (single object
* clip region).
*
* + Merge opacity and masking if both used together.
*/
nsIFrame* frame = aParams.frame;
DrawResult result = DrawResult::SUCCESS;
- bool hasSVGLayout = (frame->GetStateBits() & NS_FRAME_SVG_LAYOUT);
- if (!ValidateSVGFrame(aParams, hasSVGLayout, &result)) {
+ if (!ValidateSVGFrame(frame)) {
return result;
}
float opacity = ComputeOpacity(aParams);
if (opacity == 0.0f) {
return DrawResult::SUCCESS;
}
@@ -718,16 +715,17 @@ nsSVGIntegrationUtils::PaintMaskAndClipP
// For a HTML doc:
// According to css-masking spec, always create a mask surface when we
// have any item in maskFrame even if all of those items are
// non-resolvable <mask-sources> or <images>, we still need to create a
// transparent black mask layer under this condition.
// For a SVG doc:
// SVG 1.1 say that if we fail to resolve a mask, we should draw the
// object unmasked.
+ bool hasSVGLayout = (frame->GetStateBits() & NS_FRAME_SVG_LAYOUT);
bool shouldGenerateMaskLayer = hasSVGLayout
? maskFrames.Length() == 1 && maskFrames[0]
: maskFrames.Length() > 0;
#else
// Since we do not support image mask so far, we should treat any
// unresolvable mask as no mask. Otherwise, any object with a valid image
// mask, e.g. url("xxx.png"), will become invisible just because we can not
// handle image mask correctly. (See bug 1294171)
@@ -855,20 +853,18 @@ DrawResult
nsSVGIntegrationUtils::PaintFilter(const PaintFramesParams& aParams)
{
MOZ_ASSERT(!aParams.builder->IsForGenerateGlyphMask(),
"Filter effect is discarded while generating glyph mask.");
MOZ_ASSERT(aParams.frame->StyleEffects()->HasFilters(),
"Should not use this method when no filter effect on this frame");
nsIFrame* frame = aParams.frame;
- DrawResult result = DrawResult::SUCCESS;
- bool hasSVGLayout = (frame->GetStateBits() & NS_FRAME_SVG_LAYOUT);
- if (!ValidateSVGFrame(aParams, hasSVGLayout, &result)) {
- return result;
+ if (!ValidateSVGFrame(frame)) {
+ return DrawResult::SUCCESS;
}
float opacity = ComputeOpacity(aParams);
if (opacity == 0.0f) {
return DrawResult::SUCCESS;
}
/* Properties are added lazily and may have been removed by a restyle,
@@ -902,17 +898,17 @@ nsSVGIntegrationUtils::PaintFilter(const
gfxMatrix tm = nsSVGIntegrationUtils::GetCSSPxToDevPxMatrix(frame);
nsFilterInstance::PaintFilteredFrame(frame, context.GetDrawTarget(),
tm, &callback, &dirtyRegion);
if (opacity != 1.0f) {
context.PopGroupAndBlend();
}
- return result;
+ return DrawResult::SUCCESS;
}
gfxMatrix
nsSVGIntegrationUtils::GetCSSPxToDevPxMatrix(nsIFrame* aNonSVGFrame)
{
int32_t appUnitsPerDevPixel = aNonSVGFrame->PresContext()->AppUnitsPerDevPixel();
float devPxPerCSSPx =
1 / nsPresContext::AppUnitsToFloatCSSPixels(appUnitsPerDevPixel);