Bug 1361180 - Part 1. Return error DrawResult to the caller when the mask url can not be resolved. draft
authorcku <cku@mozilla.com>
Wed, 03 May 2017 10:39:05 +0800
changeset 571653 e21069fcc26b4efb680e9378ca15f320d77c1b6a
parent 571272 48c0fd9c9ec5d68061ea7b59358874ae8da72572
child 571654 b98d5679e6a6f25702d48b0ab94611650d963d02
push id56877
push userbmo:cku@mozilla.com
push dateWed, 03 May 2017 03:35:40 +0000
bugs1361180
milestone55.0a1
Bug 1361180 - Part 1. Return error DrawResult to the caller when the mask url can not be resolved. Precondition: In an SVG doc, giving an invalid local-ref mask, e.g. mask="url"#foo"", and clipState.mDirtyRectInDevPx be empty. e.g. apply mask onto a path object which the size of area is zero(Please refers to the reftest in Part 2) 1. PaintStyleImageLayerWithSC early continue at [1], and the value of result is still the initial value, DrawResult::SUCCESS. 2. The caller is not aware of that the mask image was left unresolved since it get DrawResult::SUCCESS from #1. This patch fixed this problem by calling PrepareImageLayer before early return for updating correct drawing result. [1] https://hg.mozilla.org/mozilla-central/file/ebf68ba9b098/layout/painting/nsCSSRendering.cpp#l2682 MozReview-Commit-ID: DjJ0Nni1gDl
layout/painting/nsCSSRendering.cpp
--- a/layout/painting/nsCSSRendering.cpp
+++ b/layout/painting/nsCSSRendering.cpp
@@ -2670,28 +2670,32 @@ nsCSSRendering::PaintStyleImageLayerWith
           autoSR.EnsureSaved(ctx);
           ctx->NewPath();
           ctx->SnappedRectangle(clip);
           ctx->Clip();
         }
       }
     }
 
-    // Skip the following layer painting code if we found the dirty region is
-    // empty or the current layer is not selected for drawing.
-    if (clipState.mDirtyRectInDevPx.IsEmpty() ||
-        (aParams.layer >= 0 && i != (uint32_t)aParams.layer)) {
+    // Skip the following layer preparing and painting code if the current
+    // layer is not selected for drawing.
+    if (aParams.layer >= 0 && i != (uint32_t)aParams.layer) {
       continue;
     }
-
     nsBackgroundLayerState state =
       PrepareImageLayer(&aParams.presCtx, aParams.frame,
                         aParams.paintFlags, paintBorderArea,
                         clipState.mBGClipArea, layer, nullptr);
     result &= state.mImageRenderer.PrepareResult();
+
+    // Skip the layer painting code if we found the dirty region is empty.
+    if (clipState.mDirtyRectInDevPx.IsEmpty()) {
+      continue;
+    }
+
     if (!state.mFillArea.IsEmpty()) {
       CompositionOp co = DetermineCompositionOp(aParams, layers, i);
       if (co != CompositionOp::OP_OVER) {
         NS_ASSERTION(ctx->CurrentOp() == CompositionOp::OP_OVER,
                      "It is assumed the initial op is OP_OVER, when it is "
                      "restored later");
         ctx->SetOp(co);
       }