aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/script/dom/htmllinkelement.rs38
-rw-r--r--components/script/stylesheet_loader.rs2
-rw-r--r--components/script_bindings/webidls/HTMLLinkElement.webidl11
-rw-r--r--tests/wpt/meta/css/cssom/HTMLLinkElement-disabled-003.html.ini4
-rw-r--r--tests/wpt/meta/css/cssom/HTMLLinkElement-disabled-004.html.ini4
-rw-r--r--tests/wpt/meta/css/cssom/HTMLLinkElement-disabled-007.html.ini4
-rw-r--r--tests/wpt/meta/css/cssom/HTMLLinkElement-disabled-alternate.html.ini2
-rw-r--r--tests/wpt/meta/html/dom/idlharness.https.html.ini6
-rw-r--r--tests/wpt/meta/subresource-integrity/subresource-integrity.html.ini3
9 files changed, 46 insertions, 28 deletions
diff --git a/components/script/dom/htmllinkelement.rs b/components/script/dom/htmllinkelement.rs
index 427153fefd9..ed1fcf1349d 100644
--- a/components/script/dom/htmllinkelement.rs
+++ b/components/script/dom/htmllinkelement.rs
@@ -114,6 +114,8 @@ pub(crate) struct HTMLLinkElement {
any_failed_load: Cell<bool>,
/// A monotonically increasing counter that keeps track of which stylesheet to apply.
request_generation_id: Cell<RequestGenerationId>,
+ /// <https://html.spec.whatwg.org/multipage/#explicitly-enabled>
+ is_explicitly_enabled: Cell<bool>,
}
impl HTMLLinkElement {
@@ -133,6 +135,7 @@ impl HTMLLinkElement {
pending_loads: Cell::new(0),
any_failed_load: Cell::new(false),
request_generation_id: Cell::new(RequestGenerationId(0)),
+ is_explicitly_enabled: Cell::new(false),
}
}
@@ -196,6 +199,12 @@ impl HTMLLinkElement {
self.relations.get().contains(LinkRelations::ALTERNATE)
}
+ pub(crate) fn is_effectively_disabled(&self) -> bool {
+ (self.is_alternate() && !self.is_explicitly_enabled.get()) ||
+ self.upcast::<Element>()
+ .has_attribute(&local_name!("disabled"))
+ }
+
fn clean_stylesheet_ownership(&self) {
if let Some(cssom_stylesheet) = self.cssom_stylesheet.get() {
cssom_stylesheet.set_owner(None);
@@ -221,11 +230,18 @@ impl VirtualMethods for HTMLLinkElement {
self.super_type()
.unwrap()
.attribute_mutated(attr, mutation, can_gc);
- if !self.upcast::<Node>().is_connected() || mutation.is_removal() {
+
+ let local_name = attr.local_name();
+ let is_removal = mutation.is_removal();
+ if *local_name == local_name!("disabled") {
+ self.handle_disabled_attribute_change(!is_removal);
return;
}
- match *attr.local_name() {
+ if !self.upcast::<Node>().is_connected() || is_removal {
+ return;
+ }
+ match *local_name {
local_name!("rel") | local_name!("rev") => {
self.relations
.set(LinkRelations::for_element(self.upcast()));
@@ -472,6 +488,18 @@ impl HTMLLinkElement {
);
}
+ /// <https://html.spec.whatwg.org/multipage/#attr-link-disabled>
+ fn handle_disabled_attribute_change(&self, disabled: bool) {
+ if !disabled {
+ self.is_explicitly_enabled.set(true);
+ }
+ if let Some(stylesheet) = self.get_stylesheet() {
+ if stylesheet.set_disabled(disabled) {
+ self.stylesheet_list_owner().invalidate_stylesheets();
+ }
+ }
+ }
+
fn handle_favicon_url(&self, href: &str, _sizes: &Option<String>) {
let document = self.owner_document();
match document.base_url().join(href) {
@@ -567,6 +595,12 @@ impl HTMLLinkElementMethods<crate::DomTypeHolder> for HTMLLinkElement {
// https://html.spec.whatwg.org/multipage/#dom-link-type
make_setter!(SetType, "type");
+ // https://html.spec.whatwg.org/multipage/#dom-link-disabled
+ make_bool_getter!(Disabled, "disabled");
+
+ // https://html.spec.whatwg.org/multipage/#dom-link-disabled
+ make_bool_setter!(SetDisabled, "disabled");
+
// https://html.spec.whatwg.org/multipage/#dom-link-rellist
fn RelList(&self) -> DomRoot<DOMTokenList> {
self.rel_list.or_init(|| {
diff --git a/components/script/stylesheet_loader.rs b/components/script/stylesheet_loader.rs
index 7c7f7f98a07..e88c0b8ed69 100644
--- a/components/script/stylesheet_loader.rs
+++ b/components/script/stylesheet_loader.rs
@@ -214,7 +214,7 @@ impl FetchResponseListener for StylesheetContext {
document.quirks_mode(),
));
- if link.is_alternate() {
+ if link.is_effectively_disabled() {
sheet.set_disabled(true);
}
diff --git a/components/script_bindings/webidls/HTMLLinkElement.webidl b/components/script_bindings/webidls/HTMLLinkElement.webidl
index 31590a8dc04..9182ef393f8 100644
--- a/components/script_bindings/webidls/HTMLLinkElement.webidl
+++ b/components/script_bindings/webidls/HTMLLinkElement.webidl
@@ -13,17 +13,24 @@ interface HTMLLinkElement : HTMLElement {
attribute DOMString? crossOrigin;
[CEReactions]
attribute DOMString rel;
+ // [CEReactions] attribute DOMString as;
[SameObject, PutForwards=value] readonly attribute DOMTokenList relList;
[CEReactions]
attribute DOMString media;
[CEReactions]
+ attribute DOMString integrity;
+ [CEReactions]
attribute DOMString hreflang;
[CEReactions]
attribute DOMString type;
- [CEReactions]
- attribute DOMString integrity;
+ // [SameObject, PutForwards=value] readonly attribute DOMTokenList sizes;
+ // [CEReactions] attribute USVString imageSrcset;
+ // [CEReactions] attribute DOMString imageSizes;
[CEReactions]
attribute DOMString referrerPolicy;
+ // [SameObject, PutForwards=value] readonly attribute DOMTokenList blocking;
+ [CEReactions] attribute boolean disabled;
+ // [CEReactions] attribute DOMString fetchPriority;
// also has obsolete members
};
diff --git a/tests/wpt/meta/css/cssom/HTMLLinkElement-disabled-003.html.ini b/tests/wpt/meta/css/cssom/HTMLLinkElement-disabled-003.html.ini
deleted file mode 100644
index a63c586fd67..00000000000
--- a/tests/wpt/meta/css/cssom/HTMLLinkElement-disabled-003.html.ini
+++ /dev/null
@@ -1,4 +0,0 @@
-[HTMLLinkElement-disabled-003.html]
- [HTMLLinkElement.disabled's explicitly enabled state persists when disconnected and connected again]
- expected: FAIL
-
diff --git a/tests/wpt/meta/css/cssom/HTMLLinkElement-disabled-004.html.ini b/tests/wpt/meta/css/cssom/HTMLLinkElement-disabled-004.html.ini
deleted file mode 100644
index 20462805942..00000000000
--- a/tests/wpt/meta/css/cssom/HTMLLinkElement-disabled-004.html.ini
+++ /dev/null
@@ -1,4 +0,0 @@
-[HTMLLinkElement-disabled-004.html]
- [HTMLLinkElement.disabled's explicitly enabled state doesn't persist on clones]
- expected: FAIL
-
diff --git a/tests/wpt/meta/css/cssom/HTMLLinkElement-disabled-007.html.ini b/tests/wpt/meta/css/cssom/HTMLLinkElement-disabled-007.html.ini
deleted file mode 100644
index 62ef580305f..00000000000
--- a/tests/wpt/meta/css/cssom/HTMLLinkElement-disabled-007.html.ini
+++ /dev/null
@@ -1,4 +0,0 @@
-[HTMLLinkElement-disabled-007.html]
- [HTMLLinkElement.disabled setter sets the explicitly enabled state if toggled back and forth.]
- expected: FAIL
-
diff --git a/tests/wpt/meta/css/cssom/HTMLLinkElement-disabled-alternate.html.ini b/tests/wpt/meta/css/cssom/HTMLLinkElement-disabled-alternate.html.ini
deleted file mode 100644
index eb0657d3a0a..00000000000
--- a/tests/wpt/meta/css/cssom/HTMLLinkElement-disabled-alternate.html.ini
+++ /dev/null
@@ -1,2 +0,0 @@
-[HTMLLinkElement-disabled-alternate.html]
- expected: FAIL
diff --git a/tests/wpt/meta/html/dom/idlharness.https.html.ini b/tests/wpt/meta/html/dom/idlharness.https.html.ini
index a7c7cec2568..6b41e3a07f9 100644
--- a/tests/wpt/meta/html/dom/idlharness.https.html.ini
+++ b/tests/wpt/meta/html/dom/idlharness.https.html.ini
@@ -6052,9 +6052,6 @@
[HTMLLinkElement interface: attribute blocking]
expected: FAIL
- [HTMLLinkElement interface: attribute disabled]
- expected: FAIL
-
[HTMLLinkElement interface: attribute fetchPriority]
expected: FAIL
@@ -6073,9 +6070,6 @@
[HTMLLinkElement interface: document.createElement("link") must inherit property "blocking" with the proper type]
expected: FAIL
- [HTMLLinkElement interface: document.createElement("link") must inherit property "disabled" with the proper type]
- expected: FAIL
-
[HTMLLinkElement interface: document.createElement("link") must inherit property "fetchPriority" with the proper type]
expected: FAIL
diff --git a/tests/wpt/meta/subresource-integrity/subresource-integrity.html.ini b/tests/wpt/meta/subresource-integrity/subresource-integrity.html.ini
index df363f2b546..564fb9c3c97 100644
--- a/tests/wpt/meta/subresource-integrity/subresource-integrity.html.ini
+++ b/tests/wpt/meta/subresource-integrity/subresource-integrity.html.ini
@@ -1,7 +1,4 @@
[subresource-integrity.html]
- [Style: Same-origin with correct sha256 and sha512 hash, rel='alternate stylesheet' enabled]
- expected: FAIL
-
[Script: Same-origin with non-Base64 hash.]
expected: FAIL