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
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>());