diff options
author | shanehandley <1322294+shanehandley@users.noreply.github.com> | 2024-12-22 21:31:27 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-12-22 10:31:27 +0000 |
commit | 41f27ae80b9519bde413b095a0131a76ae51319d (patch) | |
tree | 83796b5cf3c3be26ee7fa826de4e24b68645913f /components | |
parent | 09408ae10b2ffb8f2b6d78155ea970f670feb9ab (diff) | |
download | servo-41f27ae80b9519bde413b095a0131a76ae51319d.tar.gz servo-41f27ae80b9519bde413b095a0131a76ae51319d.zip |
Implement referrerpolicy attribute on remaining elements (#34736)
Fixes #11861
Signed-off-by: Shane Handley <shanehandley@fastmail.com>
Diffstat (limited to 'components')
-rw-r--r-- | components/script/dom/htmlanchorelement.rs | 10 | ||||
-rw-r--r-- | components/script/dom/htmlareaelement.rs | 10 | ||||
-rw-r--r-- | components/script/dom/htmlimageelement.rs | 10 | ||||
-rw-r--r-- | components/script/dom/webidls/HTMLAnchorElement.webidl | 2 | ||||
-rw-r--r-- | components/script/dom/webidls/HTMLAreaElement.webidl | 1 |
5 files changed, 25 insertions, 8 deletions
diff --git a/components/script/dom/htmlanchorelement.rs b/components/script/dom/htmlanchorelement.rs index afdfa7bb68d..4e6df0f5212 100644 --- a/components/script/dom/htmlanchorelement.rs +++ b/components/script/dom/htmlanchorelement.rs @@ -24,7 +24,7 @@ use crate::dom::bindings::root::{DomRoot, MutNullableDom}; use crate::dom::bindings::str::{DOMString, USVString}; use crate::dom::document::Document; use crate::dom::domtokenlist::DOMTokenList; -use crate::dom::element::{AttributeMutation, Element}; +use crate::dom::element::{reflect_referrer_policy_attribute, AttributeMutation, Element}; use crate::dom::event::Event; use crate::dom::eventtarget::EventTarget; use crate::dom::htmlelement::HTMLElement; @@ -582,6 +582,14 @@ impl HTMLAnchorElementMethods<crate::DomTypeHolder> for HTMLAnchorElement { // Step 5. self.update_href(url, can_gc); } + + // https://html.spec.whatwg.org/multipage/#dom-a-referrerpolicy + fn ReferrerPolicy(&self) -> DOMString { + reflect_referrer_policy_attribute(self.upcast::<Element>()) + } + + // https://html.spec.whatwg.org/multipage/#dom-script-referrerpolicy + make_setter!(SetReferrerPolicy, "referrerpolicy"); } impl Activatable for HTMLAnchorElement { diff --git a/components/script/dom/htmlareaelement.rs b/components/script/dom/htmlareaelement.rs index 0586b0875d7..1523ae285d8 100644 --- a/components/script/dom/htmlareaelement.rs +++ b/components/script/dom/htmlareaelement.rs @@ -22,7 +22,7 @@ use crate::dom::bindings::root::{DomRoot, MutNullableDom}; use crate::dom::bindings::str::DOMString; use crate::dom::document::Document; use crate::dom::domtokenlist::DOMTokenList; -use crate::dom::element::{AttributeMutation, Element}; +use crate::dom::element::{reflect_referrer_policy_attribute, AttributeMutation, Element}; use crate::dom::event::Event; use crate::dom::eventtarget::EventTarget; use crate::dom::htmlelement::HTMLElement; @@ -362,6 +362,14 @@ impl HTMLAreaElementMethods<crate::DomTypeHolder> for HTMLAreaElement { ) }) } + + /// <https://html.spec.whatwg.org/multipage/#attr-iframe-referrerpolicy> + fn ReferrerPolicy(&self) -> DOMString { + reflect_referrer_policy_attribute(self.upcast::<Element>()) + } + + // https://html.spec.whatwg.org/multipage/#attr-iframe-referrerpolicy + make_setter!(SetReferrerPolicy, "referrerpolicy"); } impl Activatable for HTMLAreaElement { diff --git a/components/script/dom/htmlimageelement.rs b/components/script/dom/htmlimageelement.rs index c23e02d5672..fe32f388e1d 100644 --- a/components/script/dom/htmlimageelement.rs +++ b/components/script/dom/htmlimageelement.rs @@ -69,8 +69,8 @@ use crate::dom::bindings::str::{DOMString, USVString}; use crate::dom::document::{determine_policy_for_token, Document}; use crate::dom::element::{ cors_setting_for_element, referrer_policy_for_element, reflect_cross_origin_attribute, - set_cross_origin_attribute, AttributeMutation, CustomElementCreationMode, Element, - ElementCreator, LayoutElementHelpers, + reflect_referrer_policy_attribute, set_cross_origin_attribute, AttributeMutation, + CustomElementCreationMode, Element, ElementCreator, LayoutElementHelpers, }; use crate::dom::event::Event; use crate::dom::eventtarget::EventTarget; @@ -1691,11 +1691,9 @@ impl HTMLImageElementMethods<crate::DomTypeHolder> for HTMLImageElement { } } - // https://html.spec.whatwg.org/multipage/#dom-img-referrerpolicy + /// <https://html.spec.whatwg.org/multipage/#dom-img-referrerpolicy> fn ReferrerPolicy(&self) -> DOMString { - let element = self.upcast::<Element>(); - let current_policy_value = element.get_string_attribute(&local_name!("referrerpolicy")); - get_correct_referrerpolicy_from_raw_token(¤t_policy_value) + reflect_referrer_policy_attribute(self.upcast::<Element>()) } // https://html.spec.whatwg.org/multipage/#dom-img-referrerpolicy diff --git a/components/script/dom/webidls/HTMLAnchorElement.webidl b/components/script/dom/webidls/HTMLAnchorElement.webidl index f6e48281102..ed867a6a9a2 100644 --- a/components/script/dom/webidls/HTMLAnchorElement.webidl +++ b/components/script/dom/webidls/HTMLAnchorElement.webidl @@ -32,6 +32,8 @@ interface HTMLAnchorElement : HTMLElement { [CEReactions, Pure] attribute DOMString text; + [CEReactions] attribute DOMString referrerPolicy; + // also has obsolete members }; HTMLAnchorElement includes HTMLHyperlinkElementUtils; diff --git a/components/script/dom/webidls/HTMLAreaElement.webidl b/components/script/dom/webidls/HTMLAreaElement.webidl index 74c281e93c5..222eef4962c 100644 --- a/components/script/dom/webidls/HTMLAreaElement.webidl +++ b/components/script/dom/webidls/HTMLAreaElement.webidl @@ -22,6 +22,7 @@ interface HTMLAreaElement : HTMLElement { [CEReactions] attribute DOMString rel; [SameObject, PutForwards=value] readonly attribute DOMTokenList relList; + [CEReactions] attribute DOMString referrerPolicy; // hreflang and type are not reflected }; //HTMLAreaElement includes HTMLHyperlinkElementUtils; |