зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1245499 - Do not trigger a download request for CSS "mask-image" when it's set to a local-reference URI r=dholbert
MozReview-Commit-ID: DPtvKQ2UQof --HG-- extra : rebase_source : aec873dc8ee96d79f9cda37da2eb324fa14601f1
This commit is contained in:
Родитель
de6a18cca7
Коммит
c19f2ac4d8
|
@ -60,6 +60,23 @@ TryToStartImageLoadOnValue(const nsCSSValue& aValue, nsIDocument* aDocument,
|
|||
MOZ_ASSERT(aDocument);
|
||||
|
||||
if (aValue.GetUnit() == eCSSUnit_URL) {
|
||||
#ifdef MOZ_ENABLE_MASK_AS_SHORTHAND
|
||||
// The 'mask-image' property accepts local reference URIs.
|
||||
// For example,
|
||||
// mask-image: url(#mask_id); // refer to a SVG mask element, whose id is
|
||||
// // "mask_id", in the current document.
|
||||
// For such 'mask-image' values (pointing to an in-document element),
|
||||
// there is no need to trigger image download.
|
||||
if (aProperty == eCSSProperty_mask_image) {
|
||||
nsIURI* docURI = aDocument->GetDocumentURI();
|
||||
nsIURI* imageURI = aValue.GetURLValue();
|
||||
bool isEqualExceptRef = false;
|
||||
nsresult rv = imageURI->EqualsExceptRef(docURI, &isEqualExceptRef);
|
||||
if (NS_SUCCEEDED(rv) && isEqualExceptRef) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
aValue.StartImageLoad(aDocument);
|
||||
if (aForTokenStream && aContext) {
|
||||
CSSVariableImageTable::Add(aContext, aProperty,
|
||||
|
|
|
@ -1259,13 +1259,25 @@ static void SetStyleImage(nsStyleContext* aStyleContext,
|
|||
case eCSSUnit_Unset:
|
||||
case eCSSUnit_None:
|
||||
break;
|
||||
default:
|
||||
// We might have eCSSUnit_URL values for if-visited style
|
||||
// contexts, which we can safely treat like 'none'. Otherwise
|
||||
// this is an unexpected unit.
|
||||
NS_ASSERTION(aStyleContext->IsStyleIfVisited() &&
|
||||
aValue.GetUnit() == eCSSUnit_URL,
|
||||
case eCSSUnit_URL:
|
||||
{
|
||||
#ifdef DEBUG
|
||||
nsIDocument* currentDoc = aStyleContext->PresContext()->Document();
|
||||
nsIURI* docURI = currentDoc->GetDocumentURI();
|
||||
nsIURI* imageURI = aValue.GetURLValue();
|
||||
bool isEqualExceptRef = false;
|
||||
imageURI->EqualsExceptRef(docURI, &isEqualExceptRef);
|
||||
// Either we have eCSSUnit_URL values for if-visited style contexts,
|
||||
// which we can safely treat like 'none', or aValue refers to an
|
||||
// in-document resource. Otherwise this is an unexpected unit.
|
||||
NS_ASSERTION(aStyleContext->IsStyleIfVisited() || isEqualExceptRef,
|
||||
"unexpected unit; maybe nsCSSValue::Image::Image() failed?");
|
||||
#endif
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
MOZ_ASSERT_UNREACHABLE("Unexpected Unit type.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -6575,7 +6587,8 @@ struct BackgroundItemComputer<nsCSSValueList, nsCOMPtr<nsIURI> >
|
|||
nsCOMPtr<nsIURI>& aComputedValue,
|
||||
RuleNodeCacheConditions& aConditions)
|
||||
{
|
||||
if (eCSSUnit_Image == aSpecifiedValue->mValue.GetUnit()) {
|
||||
if (eCSSUnit_Image == aSpecifiedValue->mValue.GetUnit() ||
|
||||
eCSSUnit_URL == aSpecifiedValue->mValue.GetUnit()) {
|
||||
aComputedValue = aSpecifiedValue->mValue.GetURLValue();
|
||||
} else if (eCSSUnit_Null != aSpecifiedValue->mValue.GetUnit()) {
|
||||
aComputedValue = nullptr;
|
||||
|
|
Загрузка…
Ссылка в новой задаче