Bug 1314536 - Part 3. Correct comment and add a test case for it. draft
authorcku <cku@mozilla.com>
Fri, 18 Nov 2016 22:06:51 +0800
changeset 441642 0be04c368dcae5894a6127300131a504a3fbad44
parent 441641 eac0bb481c365faf9bdf563d195b115fa0511284
child 537601 b3cfdc9d58ec79172d9c0a337cbb5bcf62670b64
push id36479
push userbmo:cku@mozilla.com
push dateSun, 20 Nov 2016 14:56:54 +0000
bugs1314536
milestone53.0a1
Bug 1314536 - Part 3. Correct comment and add a test case for it. At the caller side of nsSVGMaskFrame::GetMaskForMaskedFrame(nsSVGIntegrationUtils & nsSVGUtils), we do skip masked frame painting when this function return value other then DrawResult::SUCCESS. So there is no need to return an empty surface anymore. And add a test case to verify it. MozReview-Commit-ID: DHl6krJ1ABF
layout/reftests/svg/mask-empty-size.svg
layout/reftests/svg/reftest.list
layout/svg/nsSVGMaskFrame.cpp
new file mode 100644
--- /dev/null
+++ b/layout/reftests/svg/mask-empty-size.svg
@@ -0,0 +1,8 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="200" height="200">
+  <title>Testcase for mask with empty size</title>
+  <mask id="m1" width="1" height="0">
+    <rect x="0" y="0" width="100" height="100" style="stroke:none; fill: #ffffff"/>
+  </mask>
+  <!-- Since the size of m1 is empty, the following rect should be invisible. -->
+  <rect width="100" height="100" fill="blue" mask="url(#m1)"/>
+</svg>
--- a/layout/reftests/svg/reftest.list
+++ b/layout/reftests/svg/reftest.list
@@ -454,9 +454,10 @@ fuzzy(1,32400) == clipPath-on-outflowEle
 default-preferences
 
 == mask-on-outflowElement-01a.html clipPath-on-outflowElement-01-ref.html
 == mask-on-outflowElement-01b.html clipPath-on-outflowElement-01-ref.html
 
 == clipPath-and-mask-on-outflowElement-01a.html clipPath-on-outflowElement-01-ref.html
 == clipPath-and-mask-on-outflowElement-01b.html clipPath-on-outflowElement-01-ref.html
 
-!= nested-mask-mode.svg about:blank
\ No newline at end of file
+!= nested-mask-mode.svg about:blank
+== mask-empty-size.svg about:blank
--- a/layout/svg/nsSVGMaskFrame.cpp
+++ b/layout/svg/nsSVGMaskFrame.cpp
@@ -224,18 +224,18 @@ nsSVGMaskFrame::GetMaskForMaskedFrame(Ma
   maskSurfaceRect.RoundOut();
   context->Restore();
 
   bool resultOverflows;
   IntSize maskSurfaceSize =
     nsSVGUtils::ConvertToSurfaceSize(maskSurfaceRect.Size(), &resultOverflows);
 
   if (resultOverflows || maskSurfaceSize.IsEmpty()) {
-    // XXXjwatt we should return an empty surface so we don't paint
-    // aParams.maskedFrame!
+    // Return value other then DrawResult::SUCCESS, so the caller can skip
+    // painting the masked frame(aParams.maskedFrame).
     return MakePair(DrawResult::TEMPORARY_ERROR, RefPtr<SourceSurface>());
   }
 
   RefPtr<DrawTarget> maskDT =
     Factory::CreateDrawTarget(BackendType::CAIRO, maskSurfaceSize,
                               SurfaceFormat::B8G8R8A8);
   if (!maskDT || !maskDT->IsValid()) {
     return MakePair(DrawResult::TEMPORARY_ERROR, RefPtr<SourceSurface>());