Bug 1235494 - Optimize nsStyleImageLayers::Layer::CalcDifference
MozReview-Commit-ID: K8lxA8S4EW2
--- a/layout/style/nsStyleStruct.cpp
+++ b/layout/style/nsStyleStruct.cpp
@@ -2649,21 +2649,45 @@ nsStyleImageLayers::Layer::operator==(co
}
nsChangeHint
nsStyleImageLayers::Layer::CalcDifference(const nsStyleImageLayers::Layer& aNewLayer,
nsChangeHint aPositionChangeHint) const
{
nsChangeHint hint = nsChangeHint(0);
if (!EqualURIs(mSourceURI, aNewLayer.mSourceURI)) {
- hint |= nsChangeHint_UpdateEffects |
- nsChangeHint_RepaintFrame;
- // Mask changes require that we update the PreEffectsBBoxProperty,
- // which is done during overflow computation.
- hint |= nsChangeHint_UpdateOverflow;
+ hint |= nsChangeHint_RepaintFrame;
+
+ // If Layer::mSourceURI links to a SVG mask, it has a fragment. Not vice
+ // versa. Here are examples of URI contains a fragment, two of them link
+ // to a SVG mask:
+ // mask:url(a.svg#maskID); // The fragment of this URI is an ID of a mask
+ // // element in a.svg.
+ // mask:url(#localMaskID); // The fragment of this URI is an ID of a mask
+ // // element in local document.
+ // mask:url(b.svg#viewBoxID); // The fragment of this URI is an ID of a
+ // // viewbox defined in b.svg.
+ // That is, if mSourceURI has a fragment, it may link to a SVG mask; If
+ // not, it "must" not link to a SVG mask.
+ bool maybeSVGMask = false;
+ if (mSourceURI) {
+ mSourceURI->GetHasRef(&maybeSVGMask);
+ }
+ if (!maybeSVGMask && aNewLayer.mSourceURI) {
+ aNewLayer.mSourceURI->GetHasRef(&maybeSVGMask);
+ }
+
+ // Return nsChangeHint_UpdateEffects and nsChangeHint_UpdateOverflow if
+ // either URI might link to an SVG mask.
+ if (maybeSVGMask) {
+ hint |= nsChangeHint_UpdateEffects;
+ // Mask changes require that we update the PreEffectsBBoxProperty,
+ // which is done during overflow computation.
+ hint |= nsChangeHint_UpdateOverflow;
+ }
} else if (mAttachment != aNewLayer.mAttachment ||
mClip != aNewLayer.mClip ||
mOrigin != aNewLayer.mOrigin ||
mRepeat != aNewLayer.mRepeat ||
mBlendMode != aNewLayer.mBlendMode ||
mSize != aNewLayer.mSize ||
mImage != aNewLayer.mImage ||
mMaskMode != aNewLayer.mMaskMode ||