--- a/layout/style/nsCSSValue.h
+++ b/layout/style/nsCSSValue.h
@@ -133,16 +133,18 @@ public:
// Smae as DefinitelyEqualURIs but additionally compares the nsIPrincipal
// pointers of the two URLValueData objects.
bool DefinitelyEqualURIsAndPrincipal(const URLValueData& aOther) const;
nsIURI* GetURI() const;
bool IsLocalRef() const { return mIsLocalRef; }
+ bool HasRef() const;
+
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(URLValueData)
// When matching a url with mIsLocalRef set, resolve it against aURI;
// Otherwise, ignore aURL and return mURL directly.
already_AddRefed<nsIURI> ResolveLocalRef(nsIURI* aURI) const;
already_AddRefed<nsIURI> ResolveLocalRef(nsIContent* aContent) const;
// Serializes mURI as a computed URI value, taking into account mIsLocalRef
--- a/layout/style/nsRuleNode.cpp
+++ b/layout/style/nsRuleNode.cpp
@@ -7129,17 +7129,18 @@ SetImageLayerList(nsStyleContext* aStyle
nsStyleAutoArray<nsStyleImageLayers::Layer>& aLayers,
const nsStyleAutoArray<nsStyleImageLayers::Layer>& aParentLayers,
ComputedValueItem nsStyleImageLayers::Layer::* aResultLocation,
ComputedValueItem aInitialValue,
uint32_t aParentItemCount,
uint32_t& aItemCount,
uint32_t& aMaxItemCount,
bool& aRebuild,
- RuleNodeCacheConditions& aConditions)
+ RuleNodeCacheConditions& aConditions,
+ std::function<void(ComputedValueItem&)> aCallback = std::function<void(ComputedValueItem&)>())
{
switch (aValue.GetUnit()) {
case eCSSUnit_Null:
break;
case eCSSUnit_Inherit:
aRebuild = true;
aConditions.SetUncacheable();
@@ -7169,16 +7170,19 @@ SetImageLayerList(nsStyleContext* aStyle
item->mValue.GetUnit() != eCSSUnit_Unset,
"unexpected unit");
++aItemCount;
aLayers.EnsureLengthAtLeast(aItemCount);
BackgroundItemComputer<nsCSSValueList, ComputedValueItem>
::ComputeValue(aStyleContext, item,
aLayers[aItemCount-1].*aResultLocation,
aConditions);
+ if (aCallback) {
+ aCallback(aLayers[aItemCount-1].*aResultLocation);
+ }
item = item->mNext;
} while (item);
break;
}
default:
MOZ_ASSERT(false, "unexpected unit");
}
@@ -7265,17 +7269,18 @@ SetImageLayerPairList(nsStyleContext* aS
const nsStyleAutoArray<nsStyleImageLayers::Layer>& aParentLayers,
ComputedValueItem nsStyleImageLayers::Layer::*
aResultLocation,
ComputedValueItem aInitialValue,
uint32_t aParentItemCount,
uint32_t& aItemCount,
uint32_t& aMaxItemCount,
bool& aRebuild,
- RuleNodeCacheConditions& aConditions)
+ RuleNodeCacheConditions& aConditions,
+ std::function<void(ComputedValueItem&)> aCallback = std::function<void(ComputedValueItem&)>())
{
switch (aValue.GetUnit()) {
case eCSSUnit_Null:
break;
case eCSSUnit_Inherit:
aRebuild = true;
aConditions.SetUncacheable();
@@ -7307,16 +7312,19 @@ SetImageLayerPairList(nsStyleContext* aS
item->mYValue.GetUnit() != eCSSUnit_Unset,
"unexpected unit");
++aItemCount;
aLayers.EnsureLengthAtLeast(aItemCount);
BackgroundItemComputer<nsCSSValuePairList, ComputedValueItem>
::ComputeValue(aStyleContext, item,
aLayers[aItemCount-1].*aResultLocation,
aConditions);
+ if (aCallback) {
+ aCallback(aLayers[aItemCount-1].*aResultLocation);
+ }
item = item->mNext;
} while (item);
break;
}
default:
MOZ_ASSERT(false, "unexpected unit");
}
@@ -10064,17 +10072,30 @@ nsRuleNode::ComputeSVGResetData(void* aS
maxItemCount, rebuild, conditions);
SetImageLayerList(aContext, *aRuleData->ValueForMaskImage(),
svgReset->mMask.mLayers,
parentSVGReset->mMask.mLayers,
&nsStyleImageLayers::Layer::mSourceURI,
RefPtr<css::URLValueData>(),
parentSVGReset->mMask.mImageCount,
svgReset->mMask.mImageCount,
- maxItemCount, rebuild, conditions);
+ maxItemCount, rebuild, conditions,
+ std::function<void(RefPtr<css::URLValueData>&)>(
+ [](RefPtr<css::URLValueData>& aComputedValue) {
+ // mSourceURI can be used to address an SVG mask only
+ // if it contains a fragment, not vice versa. If not,
+ // we can just clean it out now, to prevent resouce
+ // lookup in rendering process.
+ if (aComputedValue) {
+ if (!aComputedValue->HasRef()) {
+ aComputedValue = nullptr;
+ }
+ }
+ })
+ );
// mask-repeat: enum, inherit, initial [pair list]
nsStyleImageLayers::Repeat initialRepeat;
initialRepeat.SetInitialValues();
SetImageLayerPairList(aContext, *aRuleData->ValueForMaskRepeat(),
svgReset->mMask.mLayers,
parentSVGReset->mMask.mLayers,
&nsStyleImageLayers::Layer::mRepeat,