Bug 1839315: part 2) Add fetchPriority attribute to HTMLLinkElement's DOM interface. r=necko-reviewers,webidl,saschanaz,valentin

Setting the internal priority depending on the `fetchPriority` will be
implemented in a following part.

Differential Revision: https://phabricator.services.mozilla.com/D189936
This commit is contained in:
Mirko Brodesser 2023-10-23 08:14:50 +00:00
parent 5ccc34b836
commit 06401bfd3f
4 changed files with 15 additions and 16 deletions

View File

@ -49,7 +49,7 @@ namespace mozilla::dom {
HTMLLinkElement::HTMLLinkElement(
already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
: nsGenericHTMLElement(std::move(aNodeInfo)) {}
: nsGenericHTMLElementWithFetchPriorityAttribute(std::move(aNodeInfo)) {}
HTMLLinkElement::~HTMLLinkElement() { SupportsDNSPrefetch::Destroyed(*this); }
@ -165,8 +165,8 @@ bool HTMLLinkElement::ParseAttribute(int32_t aNamespaceID, nsAtom* aAttribute,
}
}
return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
aMaybeScriptedPrincipal, aResult);
return nsGenericHTMLElementWithFetchPriorityAttribute::ParseAttribute(
aNamespaceID, aAttribute, aValue, aMaybeScriptedPrincipal, aResult);
}
void HTMLLinkElement::CreateAndDispatchEvent(const nsAString& aEventName) {

View File

@ -8,11 +8,11 @@
#define mozilla_dom_HTMLLinkElement_h
#include "mozilla/Attributes.h"
#include "mozilla/nsGenericHTMLElementWithFetchPriorityAttribute.h"
#include "mozilla/dom/HTMLDNSPrefetch.h"
#include "mozilla/dom/LinkStyle.h"
#include "mozilla/dom/Link.h"
#include "mozilla/WeakPtr.h"
#include "nsGenericHTMLElement.h"
#include "nsDOMTokenList.h"
namespace mozilla {
@ -22,9 +22,10 @@ class PreloaderBase;
namespace dom {
class HTMLLinkElement final : public nsGenericHTMLElement,
public LinkStyle,
public SupportsDNSPrefetch {
class HTMLLinkElement final
: public nsGenericHTMLElementWithFetchPriorityAttribute,
public LinkStyle,
public SupportsDNSPrefetch {
public:
explicit HTMLLinkElement(
already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);

View File

@ -11,7 +11,7 @@
* and create derivative works of this document.
*/
// http://www.whatwg.org/specs/web-apps/current-work/#the-link-element
// https://html.spec.whatwg.org/multipage/semantics.html#the-link-element
[Exposed=Window]
interface HTMLLinkElement : HTMLElement {
[HTMLConstructor] constructor();
@ -39,10 +39,12 @@ interface HTMLLinkElement : HTMLElement {
attribute USVString imageSrcset;
[CEReactions, SetterThrows, Pure]
attribute USVString imageSizes;
[Pref="network.fetchpriority.enabled", CEReactions]
attribute DOMString fetchPriority;
};
HTMLLinkElement includes LinkStyle;
// http://www.whatwg.org/specs/web-apps/current-work/#other-elements,-attributes-and-apis
// https://html.spec.whatwg.org/multipage/obsolete.html#other-elements%2C-attributes-and-apis
partial interface HTMLLinkElement {
[CEReactions, SetterThrows, Pure]
attribute DOMString charset;
@ -52,13 +54,13 @@ partial interface HTMLLinkElement {
attribute DOMString target;
};
// https://w3c.github.io/webappsec/specs/subresourceintegrity/#htmllinkelement-1
// https://html.spec.whatwg.org/multipage/semantics.html#the-link-element
partial interface HTMLLinkElement {
[CEReactions, SetterThrows]
attribute DOMString integrity;
};
//https://w3c.github.io/preload/
// https://html.spec.whatwg.org/multipage/links.html#link-type-preload
partial interface HTMLLinkElement {
[SetterThrows, Pure]
attribute DOMString as;

View File

@ -1,6 +1,2 @@
[attr-link-fetchpriority.html]
[fetchpriority attribute on <link> elements should reflect valid IDL values]
expected: FAIL
[default fetchpriority attribute on <link> elements should be 'auto']
expected: FAIL
prefs: [network.fetchpriority.enabled:true]