Bug 1300401 - Part 2. Add more comments and assertions. draft
authorcku <cku@mozilla.com>
Mon, 05 Sep 2016 12:46:56 +0800
changeset 410255 633337ad151f2bc9ecd3365a3b93a9fce9c2c18b
parent 410254 5fe2fcf1213cc1fbba72a5f48f86ff4e8a4de95f
child 410257 856d900e5c76097640b56a43eb5d6fe8d17d849f
push id28697
push userbmo:cku@mozilla.com
push dateTue, 06 Sep 2016 13:43:54 +0000
bugs1300401
milestone51.0a1
Bug 1300401 - Part 2. Add more comments and assertions. MozReview-Commit-ID: HywA9IrGhk2
layout/generic/nsFrame.cpp
layout/svg/nsSVGIntegrationUtils.cpp
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -2437,17 +2437,18 @@ nsIFrame::BuildDisplayListForStackingCon
 
   /* If there are any SVG effects, wrap the list up in an SVG effects item
    * (which also handles CSS group opacity). Note that we create an SVG effects
    * item even if resultList is empty, since a filter can produce graphical
    * output even if the element being filtered wouldn't otherwise do so.
    */
   if (usingSVGEffects) {
     MOZ_ASSERT(StyleEffects()->HasFilters() ||
-               nsSVGIntegrationUtils::UsingMaskOrClipPathForFrame(this));
+               nsSVGIntegrationUtils::UsingMaskOrClipPathForFrame(this),
+               "Beside filter & mask/clip-path, what else effect do we have?");
 
     if (clipCapturedBy == ContainerItemType::eSVGEffects) {
       clipState.ExitStackingContextContents(&containerItemScrollClip);
     }
     // Revert to the post-filter dirty rect.
     buildingDisplayList.SetDirtyRect(dirtyRectOutsideSVGEffects);
 
     // Skip all filter effects while generating glyph mask.
--- a/layout/svg/nsSVGIntegrationUtils.cpp
+++ b/layout/svg/nsSVGIntegrationUtils.cpp
@@ -747,16 +747,20 @@ BlendToTarget(const nsSVGIntegrationUtil
   RefPtr<gfxPattern> pattern = new gfxPattern(targetSurf, Matrix::Translation(aTargetOffset.x, aTargetOffset.y));
   context.SetPattern(pattern);
   context.Paint();
 }
 
 DrawResult
 nsSVGIntegrationUtils::PaintMaskAndClipPath(const PaintFramesParams& aParams)
 {
+  MOZ_ASSERT(UsingMaskOrClipPathForFrame(aParams.frame),
+             "Should not use this method when no mask or clipPath effect"
+             "on this frame");
+
   /* SVG defines the following rendering model:
    *
    *  1. Render geometry
    *  2. Apply filter
    *  3. Apply clipping, masking, group opacity
    *
    * We handle #3 here and perform a couple of optimizations:
    *
@@ -915,17 +919,20 @@ nsSVGIntegrationUtils::PaintMaskAndClipP
   }
 
   return result;
 }
 
 DrawResult
 nsSVGIntegrationUtils::PaintFilter(const PaintFramesParams& aParams)
 {
-  MOZ_ASSERT(!aParams.builder->IsForGenerateGlyphMask());
+  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;
   }