1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-12 10:40:39 +09:00

LibWeb: Add HTMLAnchorElement.referrerPolicy property

This commit is contained in:
Sam Atkins 2023-03-29 12:46:50 +01:00 committed by Linus Groh
parent 0c19d3aa58
commit 88d64fcb55
Notes: sideshowbarker 2024-07-17 02:38:39 +09:00
7 changed files with 87 additions and 0 deletions

View file

@ -7,6 +7,7 @@
#include <LibWeb/ARIA/Roles.h>
#include <LibWeb/HTML/HTMLAnchorElement.h>
#include <LibWeb/HTML/Window.h>
#include <LibWeb/ReferrerPolicy/ReferrerPolicy.h>
namespace Web::HTML {
@ -114,4 +115,22 @@ void HTMLAnchorElement::set_text(DeprecatedString const& text)
string_replace_all(text);
}
// https://html.spec.whatwg.org/multipage/text-level-semantics.html#dom-a-referrerpolicy
DeprecatedString HTMLAnchorElement::referrer_policy() const
{
// The IDL attribute referrerPolicy must reflect the referrerpolicy content attribute, limited to only known values.
auto policy_string = attribute(HTML::AttributeNames::referrerpolicy);
auto maybe_policy = ReferrerPolicy::from_string(policy_string);
if (maybe_policy.has_value())
return ReferrerPolicy::to_string(maybe_policy.value());
return "";
}
// https://html.spec.whatwg.org/multipage/text-level-semantics.html#dom-a-referrerpolicy
WebIDL::ExceptionOr<void> HTMLAnchorElement::set_referrer_policy(DeprecatedString const& referrer_policy)
{
// The IDL attribute referrerPolicy must reflect the referrerpolicy content attribute, limited to only known values.
return set_attribute(HTML::AttributeNames::referrerpolicy, referrer_policy);
}
}