Bug 1322330 - Part 3. Implement EffectProperties::HasInvalidMask. draft
authorcku <cku@mozilla.com>
Wed, 07 Dec 2016 00:11:06 -1000
changeset 448945 aaf29758141832059ca5aa747d987253ce434b80
parent 448944 5ad31d8db3e57fc92efa44177b428f55a9756548
child 448957 846dd3fa2099294b2a6f0f8671f5bf9f5a385d84
child 448959 a8dc2353d2e5ad5902cb6f903e29840ed3273080
push id38492
push userbmo:cku@mozilla.com
push dateTue, 13 Dec 2016 09:30:56 +0000
bugs1322330
milestone53.0a1
Bug 1322330 - Part 3. Implement EffectProperties::HasInvalidMask. MozReview-Commit-ID: 7bEheewinTl
layout/painting/nsDisplayList.cpp
layout/svg/nsSVGEffects.cpp
layout/svg/nsSVGEffects.h
--- a/layout/painting/nsDisplayList.cpp
+++ b/layout/painting/nsDisplayList.cpp
@@ -7270,17 +7270,18 @@ nsDisplayMask::BuildLayer(nsDisplayListB
     return nullptr;
   }
 
   nsIFrame* firstFrame =
     nsLayoutUtils::FirstContinuationOrIBSplitSibling(mFrame);
   nsSVGEffects::EffectProperties effectProperties =
     nsSVGEffects::GetEffectProperties(firstFrame);
 
-  if (effectProperties.HasInvalidClipPath()) {
+  if (effectProperties.HasInvalidClipPath() ||
+      effectProperties.HasInvalidMask()) {
     return nullptr;
   }
 
   RefPtr<ContainerLayer> container = aManager->GetLayerBuilder()->
     BuildContainerLayerFor(aBuilder, aManager, mFrame, this, &mList,
                            aContainerParameters, nullptr);
 
   return container.forget();
--- a/layout/svg/nsSVGEffects.cpp
+++ b/layout/svg/nsSVGEffects.cpp
@@ -664,32 +664,18 @@ nsSVGEffects::EffectProperties::GetMaskF
   }
 
   return result;
 }
 
 bool
 nsSVGEffects::EffectProperties::HasNoOrValidEffects()
 {
-  if (HasInvalidClipPath()) {
-    return false;
-  }
-
-  if (mMask) {
-    bool ok = true;
-    const nsTArray<RefPtr<nsSVGPaintingProperty>>& props = mMask->GetProps();
-    for (size_t i = 0; i < props.Length(); i++) {
-      props[i]->GetReferencedFrame(nsGkAtoms::svgMaskFrame, &ok);
-      if (!ok) {
-        return false;
-      }
-    }
-  }
-
-  return HasNoFilterOrHasValidFilter();
+  return HasNoOrValidClipPath() && HasNoOrValidMask() &&
+         HasNoFilterOrHasValidFilter();
 }
 
 bool
 nsSVGEffects::EffectProperties::MightHaveNoneSVGMask() const
 {
   if (!mMask) {
     return false;
   }
@@ -715,16 +701,33 @@ nsSVGEffects::EffectProperties::HasNoOrV
     if (!ok || (frame && !frame->IsValid())) {
       return false;
     }
   }
 
   return true;
 }
 
+bool
+nsSVGEffects::EffectProperties::HasNoOrValidMask()
+{
+  if (mMask) {
+    bool ok = true;
+    const nsTArray<RefPtr<nsSVGPaintingProperty>>& props = mMask->GetProps();
+    for (size_t i = 0; i < props.Length(); i++) {
+      props[i]->GetReferencedFrame(nsGkAtoms::svgMaskFrame, &ok);
+      if (!ok) {
+        return false;
+      }
+    }
+  }
+
+  return true;
+}
+
 void
 nsSVGEffects::UpdateEffects(nsIFrame* aFrame)
 {
   NS_ASSERTION(aFrame->GetContent()->IsElement(),
                "aFrame's content should be an element");
 
   FrameProperties props = aFrame->Properties();
   props.Delete(FilterProperty());
--- a/layout/svg/nsSVGEffects.h
+++ b/layout/svg/nsSVGEffects.h
@@ -506,16 +506,29 @@ public:
 
     /*
      * @return true if we have an invalid clip-path.
      */
     bool HasInvalidClipPath() {
       return !HasNoOrValidClipPath();
     }
 
+    /*
+     * @return true if we either do not have mask or all masks we have
+     * are valid.
+     */
+    bool HasNoOrValidMask();
+
+    /*
+     * @return true if we have an invalid mask.
+     */
+    bool HasInvalidMask() {
+      return !HasNoOrValidMask();
+    }
+
     bool HasValidFilter() {
       return mFilter && mFilter->ReferencesValidResources();
     }
 
     bool HasNoFilterOrHasValidFilter() {
       return !mFilter || mFilter->ReferencesValidResources();
     }
   };