Bug 1291280 - Part 2. Declare nsStyleImageLayers::Layer::mSourceURI as FragmentOrURI r=heycam

MozReview-Commit-ID: 6KFb7MjlLqj

--HG--
extra : rebase_source : 24ac046807f12e3bea6717baab962de94d8fafc5
This commit is contained in:
cku 2016-08-06 06:38:44 +08:00
Родитель 6fc952395d
Коммит e39570c057
6 изменённых файлов: 44 добавлений и 23 удалений

Просмотреть файл

@ -2145,12 +2145,10 @@ nsComputedDOMStyle::DoGetImageLayerImage(const nsStyleImageLayers& aLayers)
// Instead, we store the local URI in one place -- on Layer::mSourceURI.
// Hence, we must serialize using mSourceURI (instead of
// SetValueToStyleImage()/mImage) in this case.
bool isLocalURI = image.GetType() == eStyleImageType_Null &&
aLayers.mLayers[i].mSourceURI;
if (isLocalURI) {
if (aLayers.mLayers[i].mSourceURI.IsLocalRef()) {
// This is how we represent a 'mask-image' reference for a local URI,
// such as 'mask-image:url(#mymask)' or 'mask:url(#mymask)'
val->SetURI(aLayers.mLayers[i].mSourceURI);
val->SetURI(aLayers.mLayers[i].mSourceURI.GetSourceURL());
} else {
SetValueToStyleImage(image, val);
}
@ -6147,8 +6145,8 @@ nsComputedDOMStyle::DoGetMask()
RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;
if (firstLayer.mSourceURI) {
val->SetURI(firstLayer.mSourceURI);
if (firstLayer.mSourceURI.GetSourceURL()) {
val->SetURI(firstLayer.mSourceURI.GetSourceURL());
} else {
val->SetIdent(eCSSKeyword_none);
}

Просмотреть файл

@ -6657,18 +6657,18 @@ struct BackgroundItemComputer<nsCSSValueList, nsStyleImage>
};
template <>
struct BackgroundItemComputer<nsCSSValueList, nsCOMPtr<nsIURI> >
struct BackgroundItemComputer<nsCSSValueList, FragmentOrURL>
{
static void ComputeValue(nsStyleContext* aStyleContext,
const nsCSSValueList* aSpecifiedValue,
nsCOMPtr<nsIURI>& aComputedValue,
FragmentOrURL& aComputedValue,
RuleNodeCacheConditions& aConditions)
{
if (eCSSUnit_Image == aSpecifiedValue->mValue.GetUnit() ||
eCSSUnit_URL == aSpecifiedValue->mValue.GetUnit()) {
aComputedValue = aSpecifiedValue->mValue.GetURLValue();
aComputedValue.SetValue(&aSpecifiedValue->mValue);
} else if (eCSSUnit_Null != aSpecifiedValue->mValue.GetUnit()) {
aComputedValue = nullptr;
aComputedValue.SetNull();
}
}
};
@ -10082,11 +10082,11 @@ nsRuleNode::ComputeSVGResetData(void* aStartStruct,
// mask: none | <url>
const nsCSSValue* maskValue = aRuleData->ValueForMask();
if (eCSSUnit_URL == maskValue->GetUnit()) {
svgReset->mMask.mLayers[0].mSourceURI = maskValue->GetURLValue();
svgReset->mMask.mLayers[0].mSourceURI.SetValue(maskValue);
} else if (eCSSUnit_None == maskValue->GetUnit() ||
eCSSUnit_Initial == maskValue->GetUnit() ||
eCSSUnit_Unset == maskValue->GetUnit()) {
svgReset->mMask.mLayers[0].mSourceURI = nullptr;
svgReset->mMask.mLayers[0].mSourceURI.SetNull();
} else if (eCSSUnit_Inherit == maskValue->GetUnit()) {
conditions.SetUncacheable();
svgReset->mMask.mLayers[0].mSourceURI =

Просмотреть файл

@ -2607,7 +2607,7 @@ nsStyleImageLayers::HasLayerWithImage() const
// mLayers[i].mImage can be empty if mask-image prop value is a reference
// to SVG mask element.
// So we need to test both mSourceURI and mImage.
if (mLayers[i].mSourceURI || !mLayers[i].mImage.IsEmpty()) {
if (mLayers[i].mSourceURI.GetSourceURL() || !mLayers[i].mImage.IsEmpty()) {
return true;
}
}
@ -2834,7 +2834,7 @@ nsStyleImageLayers::Layer::operator==(const Layer& aOther) const
mImage == aOther.mImage &&
mMaskMode == aOther.mMaskMode &&
mComposite == aOther.mComposite &&
EqualURIs(mSourceURI, aOther.mSourceURI);
mSourceURI == aOther.mSourceURI;
}
nsChangeHint
@ -2842,7 +2842,7 @@ nsStyleImageLayers::Layer::CalcDifference(const nsStyleImageLayers::Layer& aNewL
nsChangeHint aPositionChangeHint) const
{
nsChangeHint hint = nsChangeHint(0);
if (!EqualURIs(mSourceURI, aNewLayer.mSourceURI)) {
if (mSourceURI != aNewLayer.mSourceURI) {
hint |= nsChangeHint_RepaintFrame;
// If Layer::mSourceURI links to a SVG mask, it has a fragment. Not vice
@ -2857,11 +2857,18 @@ nsStyleImageLayers::Layer::CalcDifference(const nsStyleImageLayers::Layer& aNewL
// 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 (mSourceURI.IsLocalRef()) {
maybeSVGMask = true;
} else if (mSourceURI.GetSourceURL()) {
mSourceURI.GetSourceURL()->GetHasRef(&maybeSVGMask);
}
if (!maybeSVGMask) {
if (aNewLayer.mSourceURI.IsLocalRef()) {
maybeSVGMask = true;
} else if (aNewLayer.mSourceURI.GetSourceURL()) {
aNewLayer.mSourceURI.GetSourceURL()->GetHasRef(&maybeSVGMask);
}
if (!maybeSVGMask && aNewLayer.mSourceURI) {
aNewLayer.mSourceURI->GetHasRef(&maybeSVGMask);
}
// Return nsChangeHint_UpdateEffects and nsChangeHint_UpdateOverflow if

Просмотреть файл

@ -685,7 +685,7 @@ struct nsStyleImageLayers {
friend struct Layer;
struct Layer {
nsStyleImage mImage; // [reset]
nsCOMPtr<nsIURI> mSourceURI; // [reset]
FragmentOrURL mSourceURI; // [reset]
// mask-only property
// This property is used for mask layer only.
// For a background layer, it should always

Просмотреть файл

@ -395,8 +395,8 @@ nsSVGMaskProperty::nsSVGMaskProperty(nsIFrame* aFrame)
const nsStyleSVGReset *svgReset = aFrame->StyleSVGReset();
for (uint32_t i = 0; i < svgReset->mMask.mImageCount; i++) {
nsSVGPaintingProperty* prop =
new nsSVGPaintingProperty(svgReset->mMask.mLayers[i].mSourceURI, aFrame,
nsCOMPtr<nsIURI> maskUri = nsSVGEffects::GetMaskURI(aFrame, i);
nsSVGPaintingProperty* prop = new nsSVGPaintingProperty(maskUri, aFrame,
false);
mProperties.AppendElement(prop);
}
@ -964,3 +964,13 @@ nsSVGEffects::GetPaintURI(nsIFrame* aFrame,
return ResolveFragmentOrURL(aFrame, (svgStyle->*aPaint).mPaint.mPaintServer);
}
already_AddRefed<nsIURI>
nsSVGEffects::GetMaskURI(nsIFrame* aFrame, uint32_t aIndex)
{
const nsStyleSVGReset* svgReset = aFrame->StyleSVGReset();
MOZ_ASSERT(svgReset->mMask.mLayers.Length() > aIndex);
return ResolveFragmentOrURL(aFrame,
&svgReset->mMask.mLayers[aIndex].mSourceURI);
}

Просмотреть файл

@ -624,6 +624,12 @@ public:
*/
static already_AddRefed<nsIURI>
GetPaintURI(nsIFrame* aFrame, nsStyleSVGPaint nsStyleSVG::* aPaint);
/**
* A helper function to resolve SVG mask URL.
*/
static already_AddRefed<nsIURI>
GetMaskURI(nsIFrame* aFrame, uint32_t aIndex);
};
#endif /*NSSVGEFFECTS_H_*/