Bug 1348564 - Part 3. Fix assertion in nsSVGIntegrationUtils::GetSVGBBoxForNonSVGFrame. draft
authorcku <cku@mozilla.com>
Tue, 21 Mar 2017 20:24:51 +0800
changeset 502270 3f5f1ced0fbd84be67a980ead6e30356bddc98d3
parent 502269 0d29f60c6e744541bf61241bf263e8594d2fc8fc
child 550115 1e8cd0fcde0c86261d7c45d20c40e7d3736f2273
push id50234
push userbmo:cku@mozilla.com
push dateTue, 21 Mar 2017 15:07:45 +0000
bugs1348564, 1320036
milestone55.0a1
Bug 1348564 - Part 3. Fix assertion in nsSVGIntegrationUtils::GetSVGBBoxForNonSVGFrame. This issue exists even before we landed bug 1320036. nsSVGIntegrationUtils::GetSVGBBoxForNonSVGFrame is called under the following conditions: 1. (Before bug 1320036 landed) The target frame is not inherited from nsISVGChildFrame or is not an SVG frame. 2. (After bug 1320036 landed) The target frame is not inherited from nsISVGChildFrame or is not an SVG frame, except SVG-outer frame. So if you pass a nsGradientFrame object, which is not inherited from nsISVGChildFrame, to nsSVGUtils::GetBBox, this assertion always fails. MozReview-Commit-ID: IvQApquMPhp
layout/svg/nsSVGIntegrationUtils.cpp
--- a/layout/svg/nsSVGIntegrationUtils.cpp
+++ b/layout/svg/nsSVGIntegrationUtils.cpp
@@ -187,18 +187,24 @@ nsSVGIntegrationUtils::GetSVGCoordContex
   nsPresContext* presContext = firstFrame->PresContext();
   return gfx::Size(presContext->AppUnitsToFloatCSSPixels(r.width),
                    presContext->AppUnitsToFloatCSSPixels(r.height));
 }
 
 gfxRect
 nsSVGIntegrationUtils::GetSVGBBoxForNonSVGFrame(nsIFrame* aNonSVGFrame)
 {
-  NS_ASSERTION(!(aNonSVGFrame->GetStateBits() & NS_FRAME_SVG_LAYOUT),
-               "Frames with SVG layout should not get here");
+#ifdef DEBUG
+  const bool hasSVGLayout = aNonSVGFrame->GetStateBits() & NS_FRAME_SVG_LAYOUT;
+  nsISVGChildFrame* svg = do_QueryFrame(aNonSVGFrame);
+  NS_ASSERTION(!hasSVGLayout || !svg,
+               "Frames with SVG layout or inherited from nsISVGChildFrame"
+               "should not get here");
+#endif
+
   nsIFrame* firstFrame =
     nsLayoutUtils::FirstContinuationOrIBSplitSibling(aNonSVGFrame);
   // 'r' is in "user space":
   nsRect r = GetPreEffectsVisualOverflowUnion(firstFrame, nullptr, nsRect(),
                                               GetOffsetToBoundingBox(firstFrame));
   return nsLayoutUtils::RectToGfxRect(r,
            aNonSVGFrame->PresContext()->AppUnitsPerCSSPixel());
 }