mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-07 15:57:31 +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;
|
nsCOMPtr<nsIPrincipal> principal;
|
||||||
if (aSourceNode == this) {
|
if (aSourceNode == this) {
|
||||||
principal = mSrcsetTriggeringPrincipal;
|
principal = mSrcsetTriggeringPrincipal;
|
||||||
|
} else if (auto* source = HTMLSourceElement::FromContent(aSourceNode)) {
|
||||||
|
principal = source->GetSrcsetTriggeringPrincipal();
|
||||||
}
|
}
|
||||||
mResponsiveSelector->SetCandidatesFromSourceSet(aNewValue, principal);
|
mResponsiveSelector->SetCandidatesFromSourceSet(aNewValue, principal);
|
||||||
}
|
}
|
||||||
|
|
@ -1254,6 +1256,8 @@ HTMLImageElement::TryCreateResponsiveSelector(nsIContent *aSourceNode)
|
||||||
if (!SourceElementMatches(aSourceNode)) {
|
if (!SourceElementMatches(aSourceNode)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
auto* source = HTMLSourceElement::FromContent(aSourceNode);
|
||||||
|
principal = source->GetSrcsetTriggeringPrincipal();
|
||||||
} else if (aSourceNode->IsHTMLElement(nsGkAtoms::img)) {
|
} else if (aSourceNode->IsHTMLElement(nsGkAtoms::img)) {
|
||||||
// Otherwise this is the <img> tag itself
|
// Otherwise this is the <img> tag itself
|
||||||
MOZ_ASSERT(aSourceNode == this);
|
MOZ_ASSERT(aSourceNode == this);
|
||||||
|
|
|
||||||
|
|
@ -102,6 +102,11 @@ HTMLSourceElement::AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
|
||||||
nsIPrincipal* aMaybeScriptedPrincipal,
|
nsIPrincipal* aMaybeScriptedPrincipal,
|
||||||
bool aNotify)
|
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
|
// If we are associated with a <picture> with a valid <img>, notify it of
|
||||||
// responsive parameter changes
|
// responsive parameter changes
|
||||||
Element *parent = nsINode::GetParentElement();
|
Element *parent = nsINode::GetParentElement();
|
||||||
|
|
|
||||||
|
|
@ -69,6 +69,11 @@ public:
|
||||||
return mSrcTriggeringPrincipal;
|
return mSrcTriggeringPrincipal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nsIPrincipal* GetSrcsetTriggeringPrincipal() const
|
||||||
|
{
|
||||||
|
return mSrcsetTriggeringPrincipal;
|
||||||
|
}
|
||||||
|
|
||||||
void GetType(DOMString& aType)
|
void GetType(DOMString& aType)
|
||||||
{
|
{
|
||||||
GetHTMLAttr(nsGkAtoms::type, aType);
|
GetHTMLAttr(nsGkAtoms::type, aType);
|
||||||
|
|
@ -78,13 +83,13 @@ public:
|
||||||
SetHTMLAttr(nsGkAtoms::type, aType, rv);
|
SetHTMLAttr(nsGkAtoms::type, aType, rv);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GetSrcset(DOMString& aSrcset)
|
void GetSrcset(DOMString& aSrcset, nsIPrincipal&)
|
||||||
{
|
{
|
||||||
GetHTMLAttr(nsGkAtoms::srcset, aSrcset);
|
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)
|
void GetSizes(DOMString& aSizes)
|
||||||
|
|
@ -124,6 +129,9 @@ private:
|
||||||
// The triggering principal for the src attribute.
|
// The triggering principal for the src attribute.
|
||||||
nsCOMPtr<nsIPrincipal> mSrcTriggeringPrincipal;
|
nsCOMPtr<nsIPrincipal> mSrcTriggeringPrincipal;
|
||||||
|
|
||||||
|
// The triggering principal for the srcset attribute.
|
||||||
|
nsCOMPtr<nsIPrincipal> mSrcsetTriggeringPrincipal;
|
||||||
|
|
||||||
// Generates a new nsMediaList using the given input
|
// Generates a new nsMediaList using the given input
|
||||||
void UpdateMediaList(const nsAttrValue* aValue);
|
void UpdateMediaList(const nsAttrValue* aValue);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ interface HTMLSourceElement : HTMLElement {
|
||||||
};
|
};
|
||||||
|
|
||||||
partial interface HTMLSourceElement {
|
partial interface HTMLSourceElement {
|
||||||
[CEReactions, SetterThrows]
|
[CEReactions, NeedsSubjectPrincipal, SetterThrows]
|
||||||
attribute DOMString srcset;
|
attribute DOMString srcset;
|
||||||
[CEReactions, SetterThrows]
|
[CEReactions, SetterThrows]
|
||||||
attribute DOMString sizes;
|
attribute DOMString sizes;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue