Issue #2736 - Part 10: Re-work <source> srcset attribute.

Use subject principal as triggering principal in <source> "srcset"
attribute for <picture>.
This commit is contained in:
Moonchild 2025-05-04 14:39:03 +02:00 committed by roytam1
commit faf4f2c23f
4 changed files with 21 additions and 4 deletions

View file

@ -1060,6 +1060,8 @@ HTMLImageElement::PictureSourceSrcsetChanged(nsIContent *aSourceNode,
nsCOMPtr<nsIPrincipal> principal;
if (aSourceNode == this) {
principal = mSrcsetTriggeringPrincipal;
} else if (auto* source = HTMLSourceElement::FromContent(aSourceNode)) {
principal = source->GetSrcsetTriggeringPrincipal();
}
mResponsiveSelector->SetCandidatesFromSourceSet(aNewValue, principal);
}
@ -1254,6 +1256,8 @@ HTMLImageElement::TryCreateResponsiveSelector(nsIContent *aSourceNode)
if (!SourceElementMatches(aSourceNode)) {
return false;
}
auto* source = HTMLSourceElement::FromContent(aSourceNode);
principal = source->GetSrcsetTriggeringPrincipal();
} else if (aSourceNode->IsHTMLElement(nsGkAtoms::img)) {
// Otherwise this is the <img> tag itself
MOZ_ASSERT(aSourceNode == this);