mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-08 16:58:38 +09:00
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:
parent
b1b5062dc4
commit
faf4f2c23f
4 changed files with 21 additions and 4 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -102,6 +102,11 @@ HTMLSourceElement::AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
|
|||
nsIPrincipal* aMaybeScriptedPrincipal,
|
||||
bool aNotify)
|
||||
{
|
||||
if (aNameSpaceID == kNameSpaceID_None && aName == nsGkAtoms::srcset) {
|
||||
mSrcsetTriggeringPrincipal = nsContentUtils::GetAttrTriggeringPrincipal(
|
||||
this, aValue ? aValue->GetStringValue() : EmptyString(),
|
||||
aMaybeScriptedPrincipal);
|
||||
}
|
||||
// If we are associated with a <picture> with a valid <img>, notify it of
|
||||
// responsive parameter changes
|
||||
Element *parent = nsINode::GetParentElement();
|
||||
|
|
|
|||
|
|
@ -69,6 +69,11 @@ public:
|
|||
return mSrcTriggeringPrincipal;
|
||||
}
|
||||
|
||||
nsIPrincipal* GetSrcsetTriggeringPrincipal() const
|
||||
{
|
||||
return mSrcsetTriggeringPrincipal;
|
||||
}
|
||||
|
||||
void GetType(DOMString& aType)
|
||||
{
|
||||
GetHTMLAttr(nsGkAtoms::type, aType);
|
||||
|
|
@ -78,13 +83,13 @@ public:
|
|||
SetHTMLAttr(nsGkAtoms::type, aType, rv);
|
||||
}
|
||||
|
||||
void GetSrcset(DOMString& aSrcset)
|
||||
void GetSrcset(DOMString& aSrcset, nsIPrincipal&)
|
||||
{
|
||||
GetHTMLAttr(nsGkAtoms::srcset, aSrcset);
|
||||
}
|
||||
void SetSrcset(const nsAString& aSrcset, mozilla::ErrorResult& rv)
|
||||
void SetSrcset(const nsAString& aSrcset, nsIPrincipal& aTriggeringPrincipal, mozilla::ErrorResult& rv)
|
||||
{
|
||||
SetHTMLAttr(nsGkAtoms::srcset, aSrcset, rv);
|
||||
SetHTMLAttr(nsGkAtoms::srcset, aSrcset, aTriggeringPrincipal, rv);
|
||||
}
|
||||
|
||||
void GetSizes(DOMString& aSizes)
|
||||
|
|
@ -124,6 +129,9 @@ private:
|
|||
// The triggering principal for the src attribute.
|
||||
nsCOMPtr<nsIPrincipal> mSrcTriggeringPrincipal;
|
||||
|
||||
// The triggering principal for the srcset attribute.
|
||||
nsCOMPtr<nsIPrincipal> mSrcsetTriggeringPrincipal;
|
||||
|
||||
// Generates a new nsMediaList using the given input
|
||||
void UpdateMediaList(const nsAttrValue* aValue);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ interface HTMLSourceElement : HTMLElement {
|
|||
};
|
||||
|
||||
partial interface HTMLSourceElement {
|
||||
[CEReactions, SetterThrows]
|
||||
[CEReactions, NeedsSubjectPrincipal, SetterThrows]
|
||||
attribute DOMString srcset;
|
||||
[CEReactions, SetterThrows]
|
||||
attribute DOMString sizes;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue