mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 03:37:45 +00:00
LibWeb: Add HTMLAnchorElement.referrerPolicy property
This commit is contained in:
parent
0c19d3aa58
commit
88d64fcb55
7 changed files with 87 additions and 0 deletions
|
@ -195,6 +195,7 @@ namespace AttributeNames {
|
|||
__ENUMERATE_HTML_ATTRIBUTE(poster) \
|
||||
__ENUMERATE_HTML_ATTRIBUTE(preload) \
|
||||
__ENUMERATE_HTML_ATTRIBUTE(readonly) \
|
||||
__ENUMERATE_HTML_ATTRIBUTE(referrerpolicy) \
|
||||
__ENUMERATE_HTML_ATTRIBUTE(rel) \
|
||||
__ENUMERATE_HTML_ATTRIBUTE(required) \
|
||||
__ENUMERATE_HTML_ATTRIBUTE(rev) \
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -26,6 +26,9 @@ public:
|
|||
DeprecatedString text() const;
|
||||
void set_text(DeprecatedString const&);
|
||||
|
||||
DeprecatedString referrer_policy() const;
|
||||
WebIDL::ExceptionOr<void> set_referrer_policy(DeprecatedString const&);
|
||||
|
||||
// ^EventTarget
|
||||
// https://html.spec.whatwg.org/multipage/interaction.html#the-tabindex-attribute:the-a-element
|
||||
virtual bool is_focusable() const override { return has_attribute(HTML::AttributeNames::href); }
|
||||
|
|
|
@ -17,6 +17,8 @@ interface HTMLAnchorElement : HTMLElement {
|
|||
|
||||
[CEReactions] attribute DOMString text;
|
||||
|
||||
[CEReactions] attribute DOMString referrerPolicy;
|
||||
|
||||
// Obsolete
|
||||
[CEReactions, Reflect] attribute DOMString coords;
|
||||
[CEReactions, Reflect] attribute DOMString charset;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue